const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PostcardManager-CHQqNc7Q.js","assets/usePostcardZones-BX60GUY8.js","assets/DirectMail-OdpdHHPI.js","assets/EmailCampaignComposer-yjR7sV-W.js","assets/EditorModeSelector-DwHSiIw9.js","assets/SharedCampaignTemplates-DiEVx-5l.js","assets/TemplateEditorDialog-CCB1V0uq.js","assets/AgentTemplates-_zZV4xns.js"])))=>i.map(i=>d[i]); var mmt=Object.defineProperty;var mTe=t=>{throw TypeError(t)};var pmt=(t,s,r)=>s in t?mmt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var Mn=(t,s,r)=>pmt(t,typeof s!="symbol"?s+"":s,r),_fe=(t,s,r)=>s.has(t)||mTe("Cannot "+r);var is=(t,s,r)=>(_fe(t,s,"read from private field"),r?r.call(t):s.get(t)),Xa=(t,s,r)=>s.has(t)?mTe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),Yn=(t,s,r,n)=>(_fe(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),Qi=(t,s,r)=>(_fe(t,s,"access private method"),r);var x7=(t,s,r,n)=>({set _(a){Yn(t,s,a,r)},get _(){return is(t,s,n)}});function fmt(t,s){for(var r=0;rn[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&n(l)}).observe(document,{childList:!0,subtree:!0});function r(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(a){if(a.ep)return;a.ep=!0;const o=r(a);fetch(a.href,o)}})();var Hv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Po(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function y9e(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 v9e={exports:{}},nde={},b9e={exports:{}},go={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var dO=Symbol.for("react.element"),xmt=Symbol.for("react.portal"),gmt=Symbol.for("react.fragment"),ymt=Symbol.for("react.strict_mode"),vmt=Symbol.for("react.profiler"),bmt=Symbol.for("react.provider"),_mt=Symbol.for("react.context"),wmt=Symbol.for("react.forward_ref"),jmt=Symbol.for("react.suspense"),Nmt=Symbol.for("react.memo"),kmt=Symbol.for("react.lazy"),pTe=Symbol.iterator;function Smt(t){return t===null||typeof t!="object"?null:(t=pTe&&t[pTe]||t["@@iterator"],typeof t=="function"?t:null)}var _9e={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w9e=Object.assign,j9e={};function LA(t,s,r){this.props=t,this.context=s,this.refs=j9e,this.updater=r||_9e}LA.prototype.isReactComponent={};LA.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")};LA.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function N9e(){}N9e.prototype=LA.prototype;function fwe(t,s,r){this.props=t,this.context=s,this.refs=j9e,this.updater=r||_9e}var xwe=fwe.prototype=new N9e;xwe.constructor=fwe;w9e(xwe,LA.prototype);xwe.isPureReactComponent=!0;var fTe=Array.isArray,k9e=Object.prototype.hasOwnProperty,gwe={current:null},S9e={key:!0,ref:!0,__self:!0,__source:!0};function C9e(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)k9e.call(s,n)&&!S9e.hasOwnProperty(n)&&(a[n]=s[n]);var i=arguments.length-2;if(i===1)a.children=r;else if(1>>1,pe=ce[ue];if(0>>1;uea(Ne,ge))Pea(Oe,Ne)?(ce[ue]=Oe,ce[Pe]=ge,ue=Pe):(ce[ue]=Ne,ce[Me]=ge,ue=Me);else if(Pea(Oe,ge))ce[ue]=Oe,ce[Pe]=ge,ue=Pe;else break e}}return xe}function a(ce,xe){var ge=ce.sortIndex-xe.sortIndex;return ge!==0?ge:ce.id-xe.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var l=Date,i=l.now();t.unstable_now=function(){return l.now()-i}}var c=[],u=[],p=1,f=null,g=3,b=!1,_=!1,j=!1,w=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function M(ce){for(var xe=r(u);xe!==null;){if(xe.callback===null)n(u);else if(xe.startTime<=ce)n(u),xe.sortIndex=xe.expirationTime,s(c,xe);else break;xe=r(u)}}function L(ce){if(j=!1,M(ce),!_)if(r(c)!==null)_=!0,re(I);else{var xe=r(u);xe!==null&&oe(L,xe.startTime-ce)}}function I(ce,xe){_=!1,j&&(j=!1,k(U),U=-1),b=!0;var ge=g;try{for(M(xe),f=r(c);f!==null&&(!(f.expirationTime>xe)||ce&&!Z());){var ue=f.callback;if(typeof ue=="function"){f.callback=null,g=f.priorityLevel;var pe=ue(f.expirationTime<=xe);xe=t.unstable_now(),typeof pe=="function"?f.callback=pe:f===r(c)&&n(c),M(xe)}else n(c);f=r(c)}if(f!==null)var be=!0;else{var Me=r(u);Me!==null&&oe(L,Me.startTime-xe),be=!1}return be}finally{f=null,g=ge,b=!1}}var O=!1,q=null,U=-1,B=5,V=-1;function Z(){return!(t.unstable_now()-Vce||125ue?(ce.sortIndex=ge,s(u,ce),r(c)===null&&ce===r(u)&&(j?(k(U),U=-1):j=!0,oe(L,ge-ue))):(ce.sortIndex=pe,s(c,ce),_||b||(_=!0,re(I))),ce},t.unstable_shouldYield=Z,t.unstable_wrapCallback=function(ce){var xe=g;return function(){var ge=g;g=xe;try{return ce.apply(this,arguments)}finally{g=ge}}}})(P9e);E9e.exports=P9e;var Rmt=E9e.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 Fmt=N,Sf=Rmt;function Qr(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"),Fye=Object.prototype.hasOwnProperty,zmt=/^[: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]*$/,gTe={},yTe={};function Bmt(t){return Fye.call(yTe,t)?!0:Fye.call(gTe,t)?!1:zmt.test(t)?yTe[t]=!0:(gTe[t]=!0,!1)}function $mt(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 qmt(t,s,r,n){if(s===null||typeof s>"u"||$mt(t,s,r,n))return!0;if(n)return!1;if(r!==null)switch(r.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function Hm(t,s,r,n,a,o,l){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=n,this.attributeNamespace=a,this.mustUseProperty=r,this.propertyName=t,this.type=s,this.sanitizeURL=o,this.removeEmptyString=l}var Ph={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Ph[t]=new Hm(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];Ph[s]=new Hm(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Ph[t]=new Hm(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Ph[t]=new Hm(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Ph[t]=new Hm(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Ph[t]=new Hm(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Ph[t]=new Hm(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Ph[t]=new Hm(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Ph[t]=new Hm(t,5,!1,t.toLowerCase(),null,!1,!1)});var bwe=/[\-:]([a-z])/g;function _we(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(bwe,_we);Ph[s]=new Hm(s,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var s=t.replace(bwe,_we);Ph[s]=new Hm(s,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var s=t.replace(bwe,_we);Ph[s]=new Hm(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Ph[t]=new Hm(t,1,!1,t.toLowerCase(),null,!1,!1)});Ph.xlinkHref=new Hm("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Ph[t]=new Hm(t,1,!1,t.toLowerCase(),null,!0,!0)});function wwe(t,s,r,n){var a=Ph.hasOwnProperty(s)?Ph[s]:null;(a!==null?a.type!==0:n||!(2i||a[l]!==o[i]){var c=` `+a[l].replace(" at new "," at ");return t.displayName&&c.includes("")&&(c=c.replace("",t.displayName)),c}while(1<=l&&0<=i);break}}}finally{Nfe=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?mI(t):""}function Umt(t){switch(t.tag){case 5:return mI(t.type);case 16:return mI("Lazy");case 13:return mI("Suspense");case 19:return mI("SuspenseList");case 0:case 2:case 15:return t=kfe(t.type,!1),t;case 11:return t=kfe(t.type.render,!1),t;case 1:return t=kfe(t.type,!0),t;default:return""}}function qye(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 K5:return"Fragment";case G5:return"Portal";case zye:return"Profiler";case jwe:return"StrictMode";case Bye:return"Suspense";case $ye:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case D9e:return(t.displayName||"Context")+".Consumer";case L9e:return(t._context.displayName||"Context")+".Provider";case Nwe:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case kwe:return s=t.displayName||null,s!==null?s:qye(t.type)||"Memo";case Vb:s=t._payload,t=t._init;try{return qye(t(s))}catch{}}return null}function Vmt(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 qye(s);case 8:return s===jwe?"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 aw(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function R9e(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function Hmt(t){var s=R9e(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 v7(t){t._valueTracker||(t._valueTracker=Hmt(t))}function F9e(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return t&&(n=R9e(t)?t.checked?"true":"false":t.value),t=n,t!==r?(s.setValue(t),!0):!1}function Oie(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 Uye(t,s){var r=s.checked;return nd({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function bTe(t,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.checked!=null?s.checked:s.defaultChecked;r=aw(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 z9e(t,s){s=s.checked,s!=null&&wwe(t,"checked",s,!1)}function Vye(t,s){z9e(t,s);var r=aw(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")?Hye(t,s.type,r):s.hasOwnProperty("defaultValue")&&Hye(t,s.type,aw(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function _Te(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 Hye(t,s,r){(s!=="number"||Oie(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var pI=Array.isArray;function yM(t,s,r,n){if(t=t.options,s){s={};for(var a=0;a"+s.valueOf().toString()+"",s=b7.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function j8(t,s){if(s){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=s;return}}t.textContent=s}var II={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},Wmt=["Webkit","ms","Moz","O"];Object.keys(II).forEach(function(t){Wmt.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),II[s]=II[t]})});function U9e(t,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||II.hasOwnProperty(t)&&II[t]?(""+s).trim():s+"px"}function V9e(t,s){t=t.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=U9e(r,s[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,a):t[r]=a}}var Gmt=nd({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 Kye(t,s){if(s){if(Gmt[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Qr(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Qr(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Qr(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Qr(62))}}function Zye(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 Yye=null;function Swe(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Xye=null,vM=null,bM=null;function NTe(t){if(t=mO(t)){if(typeof Xye!="function")throw Error(Qr(280));var s=t.stateNode;s&&(s=cde(s),Xye(t.stateNode,t.type,s))}}function H9e(t){vM?bM?bM.push(t):bM=[t]:vM=t}function W9e(){if(vM){var t=vM,s=bM;if(bM=vM=null,NTe(t),s)for(t=0;t>>=0,t===0?32:31-(npt(t)/apt|0)|0}var _7=64,w7=4194304;function fI(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 Bie(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=fI(i):(o&=l,o!==0&&(n=fI(o)))}else l=r&~a,l!==0?n=fI(l):o!==0&&(n=fI(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 uO(t,s,r){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-Kg(s),t[s]=r}function cpt(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=DI),ITe=" ",LTe=!1;function hBe(t,s){switch(t){case"keyup":return Rpt.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function mBe(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Z5=!1;function zpt(t,s){switch(t){case"compositionend":return mBe(s);case"keypress":return s.which!==32?null:(LTe=!0,ITe);case"textInput":return t=s.data,t===ITe&<e?null:t;default:return null}}function Bpt(t,s){if(Z5)return t==="compositionend"||!Lwe&&hBe(t,s)?(t=dBe(),l9=Ewe=v_=null,Z5=!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=FTe(r)}}function gBe(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?gBe(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function yBe(){for(var t=window,s=Oie();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=Oie(t.document)}return s}function Dwe(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 Zpt(t){var s=yBe(),r=t.focusedElem,n=t.selectionRange;if(s!==r&&r&&r.ownerDocument&&gBe(r.ownerDocument.documentElement,r)){if(n!==null&&Dwe(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=zTe(r,o);var l=zTe(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,Y5=null,r0e=null,RI=null,n0e=!1;function BTe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;n0e||Y5==null||Y5!==Oie(n)||(n=Y5,"selectionStart"in n&&Dwe(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}),RI&&T8(RI,n)||(RI=n,n=Uie(r0e,"onSelect"),0J5||(t.current=d0e[J5],d0e[J5]=null,J5--)}function Zl(t,s){J5++,d0e[J5]=t.current,t.current=s}var iw={},Yh=ww(iw),wp=ww(!1),ES=iw;function NT(t,s){var r=t.type.contextTypes;if(!r)return iw;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===s)return n.__reactInternalMemoizedMaskedChildContext;var a={},o;for(o in r)a[o]=s[o];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=a),a}function jp(t){return t=t.childContextTypes,t!=null}function Hie(){jc(wp),jc(Yh)}function GTe(t,s,r){if(Yh.current!==iw)throw Error(Qr(168));Zl(Yh,s),Zl(wp,r)}function CBe(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(Qr(108,Vmt(t)||"Unknown",a));return nd({},r,n)}function Wie(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||iw,ES=Yh.current,Zl(Yh,t),Zl(wp,wp.current),!0}function KTe(t,s,r){var n=t.stateNode;if(!n)throw Error(Qr(169));r?(t=CBe(t,s,ES),n.__reactInternalMemoizedMergedChildContext=t,jc(wp),jc(Yh),Zl(Yh,t)):jc(wp),Zl(wp,r)}var Lv=null,dde=!1,zfe=!1;function MBe(t){Lv===null?Lv=[t]:Lv.push(t)}function oft(t){dde=!0,MBe(t)}function jw(){if(!zfe&&Lv!==null){zfe=!0;var t=0,s=vl;try{var r=Lv;for(vl=1;t>=l,a-=l,Wv=1<<32-Kg(s)+a|r<U?(B=q,q=null):B=q.sibling;var V=g(k,q,M[U],L);if(V===null){q===null&&(q=B);break}t&&q&&V.alternate===null&&s(k,q),S=o(V,S,U),O===null?I=V:O.sibling=V,O=V,q=B}if(U===M.length)return r(k,q),zc&&V2(k,U),I;if(q===null){for(;UU?(B=q,q=null):B=q.sibling;var Z=g(k,q,V.value,L);if(Z===null){q===null&&(q=B);break}t&&q&&Z.alternate===null&&s(k,q),S=o(Z,S,U),O===null?I=Z:O.sibling=Z,O=Z,q=B}if(V.done)return r(k,q),zc&&V2(k,U),I;if(q===null){for(;!V.done;U++,V=M.next())V=f(k,V.value,L),V!==null&&(S=o(V,S,U),O===null?I=V:O.sibling=V,O=V);return zc&&V2(k,U),I}for(q=n(k,q);!V.done;U++,V=M.next())V=b(q,k,U,V.value,L),V!==null&&(t&&V.alternate!==null&&q.delete(V.key===null?U:V.key),S=o(V,S,U),O===null?I=V:O.sibling=V,O=V);return t&&q.forEach(function(X){return s(k,X)}),zc&&V2(k,U),I}function w(k,S,M,L){if(typeof M=="object"&&M!==null&&M.type===K5&&M.key===null&&(M=M.props.children),typeof M=="object"&&M!==null){switch(M.$$typeof){case y7:e:{for(var I=M.key,O=S;O!==null;){if(O.key===I){if(I=M.type,I===K5){if(O.tag===7){r(k,O.sibling),S=a(O,M.props.children),S.return=k,k=S;break e}}else if(O.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===Vb&&XTe(I)===O.type){r(k,O.sibling),S=a(O,M.props),S.ref=IP(k,O,M),S.return=k,k=S;break e}r(k,O);break}else s(k,O);O=O.sibling}M.type===K5?(S=V4(M.props.children,k.mode,L,M.key),S.return=k,k=S):(L=x9(M.type,M.key,M.props,null,k.mode,L),L.ref=IP(k,S,M),L.return=k,k=L)}return l(k);case G5:e:{for(O=M.key;S!==null;){if(S.key===O)if(S.tag===4&&S.stateNode.containerInfo===M.containerInfo&&S.stateNode.implementation===M.implementation){r(k,S.sibling),S=a(S,M.children||[]),S.return=k,k=S;break e}else{r(k,S);break}else s(k,S);S=S.sibling}S=Gfe(M,k.mode,L),S.return=k,k=S}return l(k);case Vb:return O=M._init,w(k,S,O(M._payload),L)}if(pI(M))return _(k,S,M,L);if(MP(M))return j(k,S,M,L);T7(k,M)}return typeof M=="string"&&M!==""||typeof M=="number"?(M=""+M,S!==null&&S.tag===6?(r(k,S.sibling),S=a(S,M),S.return=k,k=S):(r(k,S),S=Wfe(M,k.mode,L),S.return=k,k=S),l(k)):r(k,S)}return w}var ST=PBe(!0),IBe=PBe(!1),Zie=ww(null),Yie=null,sM=null,zwe=null;function Bwe(){zwe=sM=Yie=null}function $we(t){var s=Zie.current;jc(Zie),t._currentValue=s}function m0e(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 wM(t,s){Yie=t,zwe=sM=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(gp=!0),t.firstContext=null)}function Px(t){var s=t._currentValue;if(zwe!==t)if(t={context:t,memoizedValue:s,next:null},sM===null){if(Yie===null)throw Error(Qr(308));sM=t,Yie.dependencies={lanes:0,firstContext:t}}else sM=sM.next=t;return s}var p4=null;function qwe(t){p4===null?p4=[t]:p4.push(t)}function LBe(t,s,r,n){var a=s.interleaved;return a===null?(r.next=r,qwe(s)):(r.next=a.next,a.next=r),s.interleaved=r,N1(t,n)}function N1(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 Hb=!1;function Uwe(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function DBe(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 Jv(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function P_(t,s,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,zo&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,N1(t,r)}return a=n.interleaved,a===null?(s.next=s,qwe(n)):(s.next=a.next,a.next=s),n.interleaved=s,N1(t,r)}function d9(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,Mwe(t,r)}}function QTe(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 Xie(t,s,r,n){var a=t.updateQueue;Hb=!1;var o=a.firstBaseUpdate,l=a.lastBaseUpdate,i=a.shared.pending;if(i!==null){a.shared.pending=null;var c=i,u=c.next;c.next=null,l===null?o=u:l.next=u,l=c;var p=t.alternate;p!==null&&(p=p.updateQueue,i=p.lastBaseUpdate,i!==l&&(i===null?p.firstBaseUpdate=u:i.next=u,p.lastBaseUpdate=c))}if(o!==null){var f=a.baseState;l=0,p=u=c=null,i=o;do{var g=i.lane,b=i.eventTime;if((n&g)===g){p!==null&&(p=p.next={eventTime:b,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var _=t,j=i;switch(g=s,b=r,j.tag){case 1:if(_=j.payload,typeof _=="function"){f=_.call(b,f,g);break e}f=_;break e;case 3:_.flags=_.flags&-65537|128;case 0:if(_=j.payload,g=typeof _=="function"?_.call(b,f,g):_,g==null)break e;f=nd({},f,g);break e;case 2:Hb=!0}}i.callback!==null&&i.lane!==0&&(t.flags|=64,g=a.effects,g===null?a.effects=[i]:g.push(i))}else b={eventTime:b,lane:g,tag:i.tag,payload:i.payload,callback:i.callback,next:null},p===null?(u=p=b,c=f):p=p.next=b,l|=g;if(i=i.next,i===null){if(i=a.shared.pending,i===null)break;g=i,i=g.next,g.next=null,a.lastBaseUpdate=g,a.shared.pending=null}}while(!0);if(p===null&&(c=f),a.baseState=c,a.firstBaseUpdate=u,a.lastBaseUpdate=p,s=a.shared.interleaved,s!==null){a=s;do l|=a.lane,a=a.next;while(a!==s)}else o===null&&(a.shared.lanes=0);LS|=l,t.lanes=l,t.memoizedState=f}}function JTe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=$fe.transition;$fe.transition={};try{t(!1),s()}finally{vl=r,$fe.transition=n}}function QBe(){return Ix().memoizedState}function uft(t,s,r){var n=L_(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},JBe(t))e$e(s,r);else if(r=LBe(t,s,r,n),r!==null){var a=Pm();Zg(r,t,n,a),t$e(r,s,n)}}function hft(t,s,r){var n=L_(t),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(JBe(t))e$e(s,a);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=s.lastRenderedReducer,o!==null))try{var l=s.lastRenderedState,i=o(l,r);if(a.hasEagerState=!0,a.eagerState=i,ny(i,l)){var c=s.interleaved;c===null?(a.next=a,qwe(s)):(a.next=c.next,c.next=a),s.interleaved=a;return}}catch{}finally{}r=LBe(t,s,a,n),r!==null&&(a=Pm(),Zg(r,t,n,a),t$e(r,s,n))}}function JBe(t){var s=t.alternate;return t===sd||s!==null&&s===sd}function e$e(t,s){FI=Jie=!0;var r=t.pending;r===null?s.next=s:(s.next=r.next,r.next=s),t.pending=s}function t$e(t,s,r){if(r&4194240){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,Mwe(t,r)}}var eoe={readContext:Px,useCallback:Rh,useContext:Rh,useEffect:Rh,useImperativeHandle:Rh,useInsertionEffect:Rh,useLayoutEffect:Rh,useMemo:Rh,useReducer:Rh,useRef:Rh,useState:Rh,useDebugValue:Rh,useDeferredValue:Rh,useTransition:Rh,useMutableSource:Rh,useSyncExternalStore:Rh,useId:Rh,unstable_isNewReconciler:!1},mft={readContext:Px,useCallback:function(t,s){return Vy().memoizedState=[t,s===void 0?null:s],t},useContext:Px,useEffect:tAe,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,h9(4194308,4,GBe.bind(null,s,t),r)},useLayoutEffect:function(t,s){return h9(4194308,4,t,s)},useInsertionEffect:function(t,s){return h9(4,2,t,s)},useMemo:function(t,s){var r=Vy();return s=s===void 0?null:s,t=t(),r.memoizedState=[t,s],t},useReducer:function(t,s,r){var n=Vy();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=uft.bind(null,sd,t),[n.memoizedState,t]},useRef:function(t){var s=Vy();return t={current:t},s.memoizedState=t},useState:eAe,useDebugValue:Xwe,useDeferredValue:function(t){return Vy().memoizedState=t},useTransition:function(){var t=eAe(!1),s=t[0];return t=dft.bind(null,t[1]),Vy().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,r){var n=sd,a=Vy();if(zc){if(r===void 0)throw Error(Qr(407));r=r()}else{if(r=s(),Qu===null)throw Error(Qr(349));IS&30||zBe(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,tAe($Be.bind(null,n,o,t),[t]),n.flags|=2048,R8(9,BBe.bind(null,n,o,r,s),void 0,null),r},useId:function(){var t=Vy(),s=Qu.identifierPrefix;if(zc){var r=Gv,n=Wv;r=(n&~(1<<32-Kg(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=D8++,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[t0]=s,t[P8]=n,u$e(t,s,!1,!1),s.stateNode=t;e:{switch(l=Zye(r,n),r){case"dialog":pc("cancel",t),pc("close",t),a=n;break;case"iframe":case"object":case"embed":pc("load",t),a=n;break;case"video":case"audio":for(a=0;aTT&&(s.flags|=128,n=!0,LP(o,!1),s.lanes=4194304)}else{if(!n)if(t=Qie(l),t!==null){if(s.flags|=128,n=!0,r=t.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),LP(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!zc)return Fh(s),null}else 2*Pd()-o.renderingStartTime>TT&&r!==1073741824&&(s.flags|=128,n=!0,LP(o,!1),s.lanes=4194304);o.isBackwards?(l.sibling=s.child,s.child=l):(r=o.last,r!==null?r.sibling=l:s.child=l,o.last=l)}return o.tail!==null?(s=o.tail,o.rendering=s,o.tail=s.sibling,o.renderingStartTime=Pd(),s.sibling=null,r=Qc.current,Zl(Qc,n?r&1|2:r&1),s):(Fh(s),null);case 22:case 23:return r2e(),n=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?ef&1073741824&&(Fh(s),s.subtreeFlags&6&&(s.flags|=8192)):Fh(s),null;case 24:return null;case 25:return null}throw Error(Qr(156,s.tag))}function _ft(t,s){switch(Rwe(s),s.tag){case 1:return jp(s.type)&&Hie(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return CT(),jc(wp),jc(Yh),Wwe(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return Hwe(s),null;case 13:if(jc(Qc),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Qr(340));kT()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return jc(Qc),null;case 4:return CT(),null;case 10:return $we(s.type._context),null;case 22:case 23:return r2e(),null;case 24:return null;default:return null}}var E7=!1,Uh=!1,wft=typeof WeakSet=="function"?WeakSet:Set,na=null;function rM(t,s){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){md(t,s,n)}else r.current=null}function w0e(t,s,r){try{r()}catch(n){md(t,s,n)}}var hAe=!1;function jft(t,s){if(a0e=$ie,t=yBe(),Dwe(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var a=n.anchorOffset,o=n.focusNode;n=n.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break e}var l=0,i=-1,c=-1,u=0,p=0,f=t,g=null;t:for(;;){for(var b;f!==r||a!==0&&f.nodeType!==3||(i=l+a),f!==o||n!==0&&f.nodeType!==3||(c=l+n),f.nodeType===3&&(l+=f.nodeValue.length),(b=f.firstChild)!==null;)g=f,f=b;for(;;){if(f===t)break t;if(g===r&&++u===a&&(i=l),g===o&&++p===n&&(c=l),(b=f.nextSibling)!==null)break;f=g,g=f.parentNode}f=b}r=i===-1||c===-1?null:{start:i,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(i0e={focusedElem:t,selectionRange:r},$ie=!1,na=s;na!==null;)if(s=na,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,na=t;else for(;na!==null;){s=na;try{var _=s.alternate;if(s.flags&1024)switch(s.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var j=_.memoizedProps,w=_.memoizedState,k=s.stateNode,S=k.getSnapshotBeforeUpdate(s.elementType===s.type?j:Eg(s.type,j),w);k.__reactInternalSnapshotBeforeUpdate=S}break;case 3:var M=s.stateNode.containerInfo;M.nodeType===1?M.textContent="":M.nodeType===9&&M.documentElement&&M.removeChild(M.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Qr(163))}}catch(L){md(s,s.return,L)}if(t=s.sibling,t!==null){t.return=s.return,na=t;break}na=s.return}return _=hAe,hAe=!1,_}function zI(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&&w0e(s,r,o)}a=a.next}while(a!==n)}}function mde(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 j0e(t){var s=t.ref;if(s!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof s=="function"?s(t):s.current=t}}function p$e(t){var s=t.alternate;s!==null&&(t.alternate=null,p$e(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[t0],delete s[P8],delete s[c0e],delete s[aft],delete s[ift])),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 f$e(t){return t.tag===5||t.tag===3||t.tag===4}function mAe(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||f$e(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function N0e(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=Vie));else if(n!==4&&(t=t.child,t!==null))for(N0e(t,s,r),t=t.sibling;t!==null;)N0e(t,s,r),t=t.sibling}function k0e(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(k0e(t,s,r),t=t.sibling;t!==null;)k0e(t,s,r),t=t.sibling}var gh=null,Dg=!1;function Mb(t,s,r){for(r=r.child;r!==null;)x$e(t,s,r),r=r.sibling}function x$e(t,s,r){if(d0&&typeof d0.onCommitFiberUnmount=="function")try{d0.onCommitFiberUnmount(ade,r)}catch{}switch(r.tag){case 5:Uh||rM(r,s);case 6:var n=gh,a=Dg;gh=null,Mb(t,s,r),gh=n,Dg=a,gh!==null&&(Dg?(t=gh,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):gh.removeChild(r.stateNode));break;case 18:gh!==null&&(Dg?(t=gh,r=r.stateNode,t.nodeType===8?Ffe(t.parentNode,r):t.nodeType===1&&Ffe(t,r),C8(t)):Ffe(gh,r.stateNode));break;case 4:n=gh,a=Dg,gh=r.stateNode.containerInfo,Dg=!0,Mb(t,s,r),gh=n,Dg=a;break;case 0:case 11:case 14:case 15:if(!Uh&&(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)&&w0e(r,s,l),a=a.next}while(a!==n)}Mb(t,s,r);break;case 1:if(!Uh&&(rM(r,s),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(i){md(r,s,i)}Mb(t,s,r);break;case 21:Mb(t,s,r);break;case 22:r.mode&1?(Uh=(n=Uh)||r.memoizedState!==null,Mb(t,s,r),Uh=n):Mb(t,s,r);break;default:Mb(t,s,r)}}function pAe(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new wft),s.forEach(function(n){var a=Pft.bind(null,t,n);r.has(n)||(r.add(n),n.then(a,a))})}}function wg(t,s){var r=s.deletions;if(r!==null)for(var n=0;na&&(a=l),n&=~o}if(n=a,n=Pd()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*kft(n/1960))-n,10t?16:t,b_===null)var n=!1;else{if(t=b_,b_=null,roe=0,zo&6)throw Error(Qr(331));var a=zo;for(zo|=4,na=t.current;na!==null;){var o=na,l=o.child;if(na.flags&16){var i=o.deletions;if(i!==null){for(var c=0;cPd()-t2e?U4(t,0):e2e|=r),Np(t,s)}function N$e(t,s){s===0&&(t.mode&1?(s=w7,w7<<=1,!(w7&130023424)&&(w7=4194304)):s=1);var r=Pm();t=N1(t,s),t!==null&&(uO(t,s,r),Np(t,r))}function Eft(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),N$e(t,r)}function Pft(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(Qr(314))}n!==null&&n.delete(s),N$e(t,r)}var k$e;k$e=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||wp.current)gp=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return gp=!1,vft(t,s,r);gp=!!(t.flags&131072)}else gp=!1,zc&&s.flags&1048576&&TBe(s,Kie,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;m9(t,s),t=s.pendingProps;var a=NT(s,Yh.current);wM(s,r),a=Kwe(null,s,n,t,a,r);var o=Zwe();return s.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,jp(n)?(o=!0,Wie(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Uwe(s),a.updater=hde,s.stateNode=a,a._reactInternals=s,f0e(s,n,t,r),s=y0e(null,s,n,!0,o,r)):(s.tag=0,zc&&o&&Owe(s),bm(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(m9(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=Lft(n),t=Eg(n,t),a){case 0:s=g0e(null,s,n,t,r);break e;case 1:s=cAe(null,s,n,t,r);break e;case 11:s=oAe(null,s,n,t,r);break e;case 14:s=lAe(null,s,n,Eg(n.type,t),r);break e}throw Error(Qr(306,n,""))}return s;case 0:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Eg(n,a),g0e(t,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Eg(n,a),cAe(t,s,n,a,r);case 3:e:{if(l$e(s),t===null)throw Error(Qr(387));n=s.pendingProps,o=s.memoizedState,a=o.element,DBe(t,s),Xie(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=MT(Error(Qr(423)),s),s=dAe(t,s,n,r,a);break e}else if(n!==a){a=MT(Error(Qr(424)),s),s=dAe(t,s,n,r,a);break e}else for(uf=E_(s.stateNode.containerInfo.firstChild),mf=s,zc=!0,Bg=null,r=IBe(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(kT(),n===a){s=k1(t,s,r);break e}bm(t,s,n,r)}s=s.child}return s;case 5:return OBe(s),t===null&&h0e(s),n=s.type,a=s.pendingProps,o=t!==null?t.memoizedProps:null,l=a.children,o0e(n,a)?l=null:o!==null&&o0e(n,o)&&(s.flags|=32),o$e(t,s),bm(t,s,l,r),s.child;case 6:return t===null&&h0e(s),null;case 13:return c$e(t,s,r);case 4:return Vwe(s,s.stateNode.containerInfo),n=s.pendingProps,t===null?s.child=ST(s,null,n,r):bm(t,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Eg(n,a),oAe(t,s,n,a,r);case 7:return bm(t,s,s.pendingProps,r),s.child;case 8:return bm(t,s,s.pendingProps.children,r),s.child;case 12:return bm(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,Zl(Zie,n._currentValue),n._currentValue=l,o!==null)if(ny(o.value,l)){if(o.children===a.children&&!wp.current){s=k1(t,s,r);break e}}else for(o=s.child,o!==null&&(o.return=s);o!==null;){var i=o.dependencies;if(i!==null){l=o.child;for(var c=i.firstContext;c!==null;){if(c.context===n){if(o.tag===1){c=Jv(-1,r&-r),c.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?c.next=c:(c.next=p.next,p.next=c),u.pending=c}}o.lanes|=r,c=o.alternate,c!==null&&(c.lanes|=r),m0e(o.return,r,s),i.lanes|=r;break}c=c.next}}else if(o.tag===10)l=o.type===s.type?null:o.child;else if(o.tag===18){if(l=o.return,l===null)throw Error(Qr(341));l.lanes|=r,i=l.alternate,i!==null&&(i.lanes|=r),m0e(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}bm(t,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,wM(s,r),a=Px(a),n=n(a),s.flags|=1,bm(t,s,n,r),s.child;case 14:return n=s.type,a=Eg(n,s.pendingProps),a=Eg(n.type,a),lAe(t,s,n,a,r);case 15:return a$e(t,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Eg(n,a),m9(t,s),s.tag=1,jp(n)?(t=!0,Wie(s)):t=!1,wM(s,r),s$e(s,n,a),f0e(s,n,a,r),y0e(null,s,n,!0,t,r);case 19:return d$e(t,s,r);case 22:return i$e(t,s,r)}throw Error(Qr(156,s.tag))};function S$e(t,s){return J9e(t,s)}function Ift(t,s,r,n){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vx(t,s,r,n){return new Ift(t,s,r,n)}function a2e(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Lft(t){if(typeof t=="function")return a2e(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Nwe)return 11;if(t===kwe)return 14}return 2}function D_(t,s){var r=t.alternate;return r===null?(r=vx(t.tag,s,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=s,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&14680064,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,s=t.dependencies,r.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r}function x9(t,s,r,n,a,o){var l=2;if(n=t,typeof t=="function")a2e(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case K5:return V4(r.children,a,o,s);case jwe:l=8,a|=8;break;case zye:return t=vx(12,r,s,a|2),t.elementType=zye,t.lanes=o,t;case Bye:return t=vx(13,r,s,a),t.elementType=Bye,t.lanes=o,t;case $ye:return t=vx(19,r,s,a),t.elementType=$ye,t.lanes=o,t;case O9e:return fde(r,a,o,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case L9e:l=10;break e;case D9e:l=9;break e;case Nwe:l=11;break e;case kwe:l=14;break e;case Vb:l=16,n=null;break e}throw Error(Qr(130,t==null?t:typeof t,""))}return s=vx(l,r,s,a),s.elementType=t,s.type=n,s.lanes=o,s}function V4(t,s,r,n){return t=vx(7,t,n,s),t.lanes=r,t}function fde(t,s,r,n){return t=vx(22,t,n,s),t.elementType=O9e,t.lanes=r,t.stateNode={isHidden:!1},t}function Wfe(t,s,r){return t=vx(6,t,null,s),t.lanes=r,t}function Gfe(t,s,r){return s=vx(4,t.children!==null?t.children:[],t.key,s),s.lanes=r,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function Dft(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=Cfe(0),this.expirationTimes=Cfe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Cfe(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function i2e(t,s,r,n,a,o,l,i,c){return t=new Dft(t,s,r,i,c),s===1?(s=1,o===!0&&(s|=8)):s=0,o=vx(3,null,null,s),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},Uwe(o),t}function Oft(t,s,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(A$e)}catch(t){console.error(t)}}A$e(),A9e.exports=Ef;var yp=A9e.exports;const d2e=Po(yp);var E$e,wAe=yp;E$e=wAe.createRoot,wAe.hydrateRoot;const $ft="modulepreload",qft=function(t){return"/"+t},jAe={},oc=function(s,r,n){let a=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),i=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));a=Promise.allSettled(r.map(c=>{if(c=qft(c),c in jAe)return;jAe[c]=!0;const u=c.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${p}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":$ft,u||(f.as="script"),f.crossOrigin="",f.href=c,i&&f.setAttribute("nonce",i),document.head.appendChild(f),u)return new Promise((g,b)=>{f.addEventListener("load",g),f.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return a.then(l=>{for(const i of l||[])i.status==="rejected"&&o(i.reason);return s().catch(o)})},Uft=1,Vft=1e6;let Kfe=0;function Hft(){return Kfe=(Kfe+1)%Number.MAX_SAFE_INTEGER,Kfe.toString()}const Zfe=new Map,NAe=t=>{if(Zfe.has(t))return;const s=setTimeout(()=>{Zfe.delete(t),qI({type:"REMOVE_TOAST",toastId:t})},Vft);Zfe.set(t,s)},Wft=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,Uft)};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?NAe(r):t.toasts.forEach(n=>{NAe(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)}}},g9=[];let y9={toasts:[]};function qI(t){y9=Wft(y9,t),g9.forEach(s=>{s(y9)})}function wn({...t}){const s=Hft(),r=a=>qI({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>qI({type:"DISMISS_TOAST",toastId:s});return qI({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function Ua(){const[t,s]=N.useState(y9);return N.useEffect(()=>(g9.push(s),()=>{const r=g9.indexOf(s);r>-1&&g9.splice(r,1)}),[t]),{...t,toast:wn,dismiss:r=>qI({type:"DISMISS_TOAST",toastId:r})}}function Ir(t,s,{checkForDefaultPrevented:r=!0}={}){return function(a){if(t==null||t(a),r===!1||!a.defaultPrevented)return s==null?void 0:s(a)}}function kAe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function S1(...t){return s=>{let r=!1;const n=t.map(a=>{const o=kAe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{children:l,...i}=o,c=N.useMemo(()=>i,Object.values(i));return e.jsx(r.Provider,{value:c,children:l})};n.displayName=t+"Provider";function a(o){const l=N.useContext(r);if(l)return l;if(s!==void 0)return s;throw new Error(`\`${o}\` must be used within \`${t}\``)}return[n,a]}function ad(t,s=[]){let r=[];function n(o,l){const i=N.createContext(l),c=r.length;r=[...r,l];const u=f=>{var k;const{scope:g,children:b,..._}=f,j=((k=g==null?void 0:g[t])==null?void 0:k[c])||i,w=N.useMemo(()=>_,Object.values(_));return e.jsx(j.Provider,{value:w,children:b})};u.displayName=o+"Provider";function p(f,g){var j;const b=((j=g==null?void 0:g[t])==null?void 0:j[c])||i,_=N.useContext(b);if(_)return _;if(l!==void 0)return l;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[u,p]}const a=()=>{const o=r.map(l=>N.createContext(l));return function(i){const c=(i==null?void 0:i[t])||o;return N.useMemo(()=>({[`__scope${t}`]:{...i,[t]:c}}),[i,c])}};return a.scopeName=t,[n,Kft(a,...s)]}function Kft(...t){const s=t[0];if(t.length===1)return s;const r=()=>{const n=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const l=n.reduce((i,{useScope:c,scopeName:u})=>{const f=c(o)[`__scope${u}`];return{...i,...f}},{});return N.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}function ow(t){const s=Zft(t),r=N.forwardRef((n,a)=>{const{children:o,...l}=n,i=N.Children.toArray(o),c=i.find(Yft);if(c){const u=c.props.children,p=i.map(f=>f===c?N.Children.count(u)>1?N.Children.only(null):N.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:N.isValidElement(u)?N.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}var u2e=ow("Slot");function Zft(t){const s=N.forwardRef((r,n)=>{const{children:a,...o}=r;if(N.isValidElement(a)){const l=Qft(a),i=Xft(o,a.props);return a.type!==N.Fragment&&(i.ref=n?S1(n,l):l),N.cloneElement(a,i)}return N.Children.count(a)>1?N.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var P$e=Symbol("radix.slottable");function I$e(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=P$e,s}function Yft(t){return N.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===P$e}function Xft(t,s){const r={...s};for(const n in s){const a=t[n],o=s[n];/^on[A-Z]/.test(n)?a&&o?r[n]=(...i)=>{const c=o(...i);return a(...i),c}:a&&(r[n]=a):n==="style"?r[n]={...a,...o}:n==="className"&&(r[n]=[a,o].filter(Boolean).join(" "))}return{...t,...r}}function Qft(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 fO(t){const s=t+"CollectionProvider",[r,n]=ad(s),[a,o]=r(s,{collectionRef:{current:null},itemMap:new Map}),l=j=>{const{scope:w,children:k}=j,S=ht.useRef(null),M=ht.useRef(new Map).current;return e.jsx(a,{scope:w,itemMap:M,collectionRef:S,children:k})};l.displayName=s;const i=t+"CollectionSlot",c=ow(i),u=ht.forwardRef((j,w)=>{const{scope:k,children:S}=j,M=o(i,k),L=qa(w,M.collectionRef);return e.jsx(c,{ref:L,children:S})});u.displayName=i;const p=t+"CollectionItemSlot",f="data-radix-collection-item",g=ow(p),b=ht.forwardRef((j,w)=>{const{scope:k,children:S,...M}=j,L=ht.useRef(null),I=qa(w,L),O=o(p,k);return ht.useEffect(()=>(O.itemMap.set(L,{ref:L,...M}),()=>void O.itemMap.delete(L))),e.jsx(g,{[f]:"",ref:I,children:S})});b.displayName=p;function _(j){const w=o(t+"CollectionConsumer",j);return ht.useCallback(()=>{const S=w.collectionRef.current;if(!S)return[];const M=Array.from(S.querySelectorAll(`[${f}]`));return Array.from(w.itemMap.values()).sort((O,q)=>M.indexOf(O.ref.current)-M.indexOf(q.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:l,Slot:u,ItemSlot:b},_,n]}var Jft=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],nn=Jft.reduce((t,s)=>{const r=ow(`Primitive.${s}`),n=N.forwardRef((a,o)=>{const{asChild:l,...i}=a,c=l?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(c,{...i,ref:o})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{});function h2e(t,s){t&&yp.flushSync(()=>t.dispatchEvent(s))}function yd(t){const s=N.useRef(t);return N.useEffect(()=>{s.current=t}),N.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}function ext(t,s=globalThis==null?void 0:globalThis.document){const r=yd(t);N.useEffect(()=>{const n=a=>{a.key==="Escape"&&r(a)};return s.addEventListener("keydown",n,{capture:!0}),()=>s.removeEventListener("keydown",n,{capture:!0})},[r,s])}var txt="DismissableLayer",A0e="dismissableLayer.update",sxt="dismissableLayer.pointerDownOutside",rxt="dismissableLayer.focusOutside",SAe,L$e=N.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Nw=N.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...c}=t,u=N.useContext(L$e),[p,f]=N.useState(null),g=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=N.useState({}),_=qa(s,q=>f(q)),j=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),k=j.indexOf(w),S=p?j.indexOf(p):-1,M=u.layersWithOutsidePointerEventsDisabled.size>0,L=S>=k,I=axt(q=>{const U=q.target,B=[...u.branches].some(V=>V.contains(U));!L||B||(a==null||a(q),l==null||l(q),q.defaultPrevented||i==null||i())},g),O=ixt(q=>{const U=q.target;[...u.branches].some(V=>V.contains(U))||(o==null||o(q),l==null||l(q),q.defaultPrevented||i==null||i())},g);return ext(q=>{S===u.layers.size-1&&(n==null||n(q),!q.defaultPrevented&&i&&(q.preventDefault(),i()))},g),N.useEffect(()=>{if(p)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(SAe=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),CAe(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=SAe)}},[p,g,r,u]),N.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),CAe())},[p,u]),N.useEffect(()=>{const q=()=>b({});return document.addEventListener(A0e,q),()=>document.removeEventListener(A0e,q)},[]),e.jsx(nn.div,{...c,ref:_,style:{pointerEvents:M?L?"auto":"none":void 0,...t.style},onFocusCapture:Ir(t.onFocusCapture,O.onFocusCapture),onBlurCapture:Ir(t.onBlurCapture,O.onBlurCapture),onPointerDownCapture:Ir(t.onPointerDownCapture,I.onPointerDownCapture)})});Nw.displayName=txt;var nxt="DismissableLayerBranch",D$e=N.forwardRef((t,s)=>{const r=N.useContext(L$e),n=N.useRef(null),a=qa(s,n);return N.useEffect(()=>{const o=n.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),e.jsx(nn.div,{...t,ref:a})});D$e.displayName=nxt;function axt(t,s=globalThis==null?void 0:globalThis.document){const r=yd(t),n=N.useRef(!1),a=N.useRef(()=>{});return N.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let c=function(){O$e(sxt,r,u,{discrete:!0})};const u={originalEvent:i};i.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=c,s.addEventListener("click",a.current,{once:!0})):c()}else s.removeEventListener("click",a.current);n.current=!1},l=window.setTimeout(()=>{s.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(l),s.removeEventListener("pointerdown",o),s.removeEventListener("click",a.current)}},[s,r]),{onPointerDownCapture:()=>n.current=!0}}function ixt(t,s=globalThis==null?void 0:globalThis.document){const r=yd(t),n=N.useRef(!1);return N.useEffect(()=>{const a=o=>{o.target&&!n.current&&O$e(rxt,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 CAe(){const t=new CustomEvent(A0e);document.dispatchEvent(t)}function O$e(t,s,r,{discrete:n}){const a=r.originalEvent.target,o=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:r});s&&a.addEventListener(t,s,{once:!0}),n?h2e(a,o):a.dispatchEvent(o)}var oxt=Nw,lxt=D$e,wd=globalThis!=null&&globalThis.document?N.useLayoutEffect:()=>{},cxt="Portal",RA=N.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=N.useState(!1);wd(()=>o(!0),[]);const l=r||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?d2e.createPortal(e.jsx(nn.div,{...n,ref:s}),l):null});RA.displayName=cxt;function dxt(t,s){return N.useReducer((r,n)=>s[r][n]??r,t)}var Fd=t=>{const{present:s,children:r}=t,n=uxt(s),a=typeof r=="function"?r({present:n.isPresent}):N.Children.only(r),o=qa(n.ref,hxt(a));return typeof r=="function"||n.isPresent?N.cloneElement(a,{ref:o}):null};Fd.displayName="Presence";function uxt(t){const[s,r]=N.useState(),n=N.useRef(null),a=N.useRef(t),o=N.useRef("none"),l=t?"mounted":"unmounted",[i,c]=dxt(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return N.useEffect(()=>{const u=L7(n.current);o.current=i==="mounted"?u:"none"},[i]),wd(()=>{const u=n.current,p=a.current;if(p!==t){const g=o.current,b=L7(u);t?c("MOUNT"):b==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(p&&g!==b?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,c]),wd(()=>{if(s){let u;const p=s.ownerDocument.defaultView??window,f=b=>{const j=L7(n.current).includes(b.animationName);if(b.target===s&&j&&(c("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",u=p.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},g=b=>{b.target===s&&(o.current=L7(n.current))};return s.addEventListener("animationstart",g),s.addEventListener("animationcancel",f),s.addEventListener("animationend",f),()=>{p.clearTimeout(u),s.removeEventListener("animationstart",g),s.removeEventListener("animationcancel",f),s.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[s,c]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:N.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function L7(t){return(t==null?void 0:t.animationName)||"none"}function hxt(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 mxt=vwe[" useInsertionEffect ".trim().toString()]||wd;function ah({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=pxt({defaultProp:s,onChange:r}),i=t!==void 0,c=i?t:a;{const p=N.useRef(t!==void 0);N.useEffect(()=>{const f=p.current;f!==i&&console.warn(`${n} is changing from ${f?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=i},[i,n])}const u=N.useCallback(p=>{var f;if(i){const g=fxt(p)?p(t):p;g!==t&&((f=l.current)==null||f.call(l,g))}else o(p)},[i,t,o,l]);return[c,u]}function pxt({defaultProp:t,onChange:s}){const[r,n]=N.useState(t),a=N.useRef(r),o=N.useRef(s);return mxt(()=>{o.current=s},[s]),N.useEffect(()=>{var l;a.current!==r&&((l=o.current)==null||l.call(o,r),a.current=r)},[r,a]),[r,n,o]}function fxt(t){return typeof t=="function"}var R$e=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),xxt="VisuallyHidden",bde=N.forwardRef((t,s)=>e.jsx(nn.span,{...t,ref:s,style:{...R$e,...t.style}}));bde.displayName=xxt;var gxt=bde,m2e="ToastProvider",[p2e,yxt,vxt]=fO("Toast"),[F$e]=ad("Toast",[vxt]),[bxt,_de]=F$e(m2e),z$e=t=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=t,[i,c]=N.useState(null),[u,p]=N.useState(0),f=N.useRef(!1),g=N.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${m2e}\`. Expected non-empty \`string\`.`),e.jsx(p2e.Provider,{scope:s,children:e.jsx(bxt,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:i,onViewportChange:c,onToastAdd:N.useCallback(()=>p(b=>b+1),[]),onToastRemove:N.useCallback(()=>p(b=>b-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:g,children:l})})};z$e.displayName=m2e;var B$e="ToastViewport",_xt=["F8"],E0e="toast.viewportPause",P0e="toast.viewportResume",$$e=N.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=_xt,label:a="Notifications ({hotkey})",...o}=t,l=_de(B$e,r),i=yxt(r),c=N.useRef(null),u=N.useRef(null),p=N.useRef(null),f=N.useRef(null),g=qa(s,f,l.onViewportChange),b=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),_=l.toastCount>0;N.useEffect(()=>{const w=k=>{var M;n.length!==0&&n.every(L=>k[L]||k.code===L)&&((M=f.current)==null||M.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[n]),N.useEffect(()=>{const w=c.current,k=f.current;if(_&&w&&k){const S=()=>{if(!l.isClosePausedRef.current){const O=new CustomEvent(E0e);k.dispatchEvent(O),l.isClosePausedRef.current=!0}},M=()=>{if(l.isClosePausedRef.current){const O=new CustomEvent(P0e);k.dispatchEvent(O),l.isClosePausedRef.current=!1}},L=O=>{!w.contains(O.relatedTarget)&&M()},I=()=>{w.contains(document.activeElement)||M()};return w.addEventListener("focusin",S),w.addEventListener("focusout",L),w.addEventListener("pointermove",S),w.addEventListener("pointerleave",I),window.addEventListener("blur",S),window.addEventListener("focus",M),()=>{w.removeEventListener("focusin",S),w.removeEventListener("focusout",L),w.removeEventListener("pointermove",S),w.removeEventListener("pointerleave",I),window.removeEventListener("blur",S),window.removeEventListener("focus",M)}}},[_,l.isClosePausedRef]);const j=N.useCallback(({tabbingDirection:w})=>{const S=i().map(M=>{const L=M.ref.current,I=[L,...Lxt(L)];return w==="forwards"?I:I.reverse()});return(w==="forwards"?S.reverse():S).flat()},[i]);return N.useEffect(()=>{const w=f.current;if(w){const k=S=>{var I,O,q;const M=S.altKey||S.ctrlKey||S.metaKey;if(S.key==="Tab"&&!M){const U=document.activeElement,B=S.shiftKey;if(S.target===w&&B){(I=u.current)==null||I.focus();return}const X=j({tabbingDirection:B?"backwards":"forwards"}),ee=X.findIndex(Q=>Q===U);Yfe(X.slice(ee+1))?S.preventDefault():B?(O=u.current)==null||O.focus():(q=p.current)==null||q.focus()}};return w.addEventListener("keydown",k),()=>w.removeEventListener("keydown",k)}},[i,j]),e.jsxs(lxt,{ref:c,role:"region","aria-label":a.replace("{hotkey}",b),tabIndex:-1,style:{pointerEvents:_?void 0:"none"},children:[_&&e.jsx(I0e,{ref:u,onFocusFromOutsideViewport:()=>{const w=j({tabbingDirection:"forwards"});Yfe(w)}}),e.jsx(p2e.Slot,{scope:r,children:e.jsx(nn.ol,{tabIndex:-1,...o,ref:g})}),_&&e.jsx(I0e,{ref:p,onFocusFromOutsideViewport:()=>{const w=j({tabbingDirection:"backwards"});Yfe(w)}})]})});$$e.displayName=B$e;var q$e="ToastFocusProxy",I0e=N.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=_de(q$e,r);return e.jsx(bde,{"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()}})});I0e.displayName=q$e;var xO="Toast",wxt="toast.swipeStart",jxt="toast.swipeMove",Nxt="toast.swipeCancel",kxt="toast.swipeEnd",U$e=N.forwardRef((t,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...l}=t,[i,c]=ah({prop:n,defaultProp:a??!0,onChange:o,caller:xO});return e.jsx(Fd,{present:r||i,children:e.jsx(Mxt,{open:i,...l,ref:s,onClose:()=>c(!1),onPause:yd(t.onPause),onResume:yd(t.onResume),onSwipeStart:Ir(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Ir(t.onSwipeMove,u=>{const{x:p,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${p}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:Ir(t.onSwipeCancel,u=>{u.currentTarget.setAttribute("data-swipe","cancel"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Ir(t.onSwipeEnd,u=>{const{x:p,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${p}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),c(!1)})})})});U$e.displayName=xO;var[Sxt,Cxt]=F$e(xO,{onClose(){}}),Mxt=N.forwardRef((t,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:o,onClose:l,onEscapeKeyDown:i,onPause:c,onResume:u,onSwipeStart:p,onSwipeMove:f,onSwipeCancel:g,onSwipeEnd:b,..._}=t,j=_de(xO,r),[w,k]=N.useState(null),S=qa(s,Q=>k(Q)),M=N.useRef(null),L=N.useRef(null),I=a||j.duration,O=N.useRef(0),q=N.useRef(I),U=N.useRef(0),{onToastAdd:B,onToastRemove:V}=j,Z=yd(()=>{var ie;(w==null?void 0:w.contains(document.activeElement))&&((ie=j.viewport)==null||ie.focus()),l()}),X=N.useCallback(Q=>{!Q||Q===1/0||(window.clearTimeout(U.current),O.current=new Date().getTime(),U.current=window.setTimeout(Z,Q))},[Z]);N.useEffect(()=>{const Q=j.viewport;if(Q){const ie=()=>{X(q.current),u==null||u()},re=()=>{const oe=new Date().getTime()-O.current;q.current=q.current-oe,window.clearTimeout(U.current),c==null||c()};return Q.addEventListener(E0e,re),Q.addEventListener(P0e,ie),()=>{Q.removeEventListener(E0e,re),Q.removeEventListener(P0e,ie)}}},[j.viewport,I,c,u,X]),N.useEffect(()=>{o&&!j.isClosePausedRef.current&&X(I)},[o,I,j.isClosePausedRef,X]),N.useEffect(()=>(B(),()=>V()),[B,V]);const ee=N.useMemo(()=>w?Y$e(w):null,[w]);return j.viewport?e.jsxs(e.Fragment,{children:[ee&&e.jsx(Txt,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:ee}),e.jsx(Sxt,{scope:r,onClose:Z,children:yp.createPortal(e.jsx(p2e.ItemSlot,{scope:r,children:e.jsx(oxt,{asChild:!0,onEscapeKeyDown:Ir(i,()=>{j.isFocusedToastEscapeKeyDownRef.current||Z(),j.isFocusedToastEscapeKeyDownRef.current=!1}),children:e.jsx(nn.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":j.swipeDirection,..._,ref:S,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Ir(t.onKeyDown,Q=>{Q.key==="Escape"&&(i==null||i(Q.nativeEvent),Q.nativeEvent.defaultPrevented||(j.isFocusedToastEscapeKeyDownRef.current=!0,Z()))}),onPointerDown:Ir(t.onPointerDown,Q=>{Q.button===0&&(M.current={x:Q.clientX,y:Q.clientY})}),onPointerMove:Ir(t.onPointerMove,Q=>{if(!M.current)return;const ie=Q.clientX-M.current.x,re=Q.clientY-M.current.y,oe=!!L.current,ce=["left","right"].includes(j.swipeDirection),xe=["left","up"].includes(j.swipeDirection)?Math.min:Math.max,ge=ce?xe(0,ie):0,ue=ce?0:xe(0,re),pe=Q.pointerType==="touch"?10:2,be={x:ge,y:ue},Me={originalEvent:Q,delta:be};oe?(L.current=be,D7(jxt,f,Me,{discrete:!1})):MAe(be,j.swipeDirection,pe)?(L.current=be,D7(wxt,p,Me,{discrete:!1}),Q.target.setPointerCapture(Q.pointerId)):(Math.abs(ie)>pe||Math.abs(re)>pe)&&(M.current=null)}),onPointerUp:Ir(t.onPointerUp,Q=>{const ie=L.current,re=Q.target;if(re.hasPointerCapture(Q.pointerId)&&re.releasePointerCapture(Q.pointerId),L.current=null,M.current=null,ie){const oe=Q.currentTarget,ce={originalEvent:Q,delta:ie};MAe(ie,j.swipeDirection,j.swipeThreshold)?D7(kxt,b,ce,{discrete:!0}):D7(Nxt,g,ce,{discrete:!0}),oe.addEventListener("click",xe=>xe.preventDefault(),{once:!0})}})})})}),j.viewport)})]}):null}),Txt=t=>{const{__scopeToast:s,children:r,...n}=t,a=_de(xO,s),[o,l]=N.useState(!1),[i,c]=N.useState(!1);return Pxt(()=>l(!0)),N.useEffect(()=>{const u=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(u)},[]),i?null:e.jsx(RA,{asChild:!0,children:e.jsx(bde,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},Axt="ToastTitle",V$e=N.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(nn.div,{...n,ref:s})});V$e.displayName=Axt;var Ext="ToastDescription",H$e=N.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(nn.div,{...n,ref:s})});H$e.displayName=Ext;var W$e="ToastAction",G$e=N.forwardRef((t,s)=>{const{altText:r,...n}=t;return r.trim()?e.jsx(Z$e,{altText:r,asChild:!0,children:e.jsx(f2e,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${W$e}\`. Expected non-empty \`string\`.`),null)});G$e.displayName=W$e;var K$e="ToastClose",f2e=N.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=Cxt(K$e,r);return e.jsx(Z$e,{asChild:!0,children:e.jsx(nn.button,{type:"button",...n,ref:s,onClick:Ir(t.onClick,a.onClose)})})});f2e.displayName=K$e;var Z$e=N.forwardRef((t,s)=>{const{__scopeToast:r,altText:n,...a}=t;return e.jsx(nn.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:s})});function Y$e(t){const s=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),Ixt(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(...Y$e(n))}}),s}function D7(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?h2e(a,o):a.dispatchEvent(o)}var MAe=(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 Pxt(t=()=>{}){const s=yd(t);wd(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function Ixt(t){return t.nodeType===t.ELEMENT_NODE}function Lxt(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 Yfe(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var Dxt=z$e,X$e=$$e,Q$e=U$e,J$e=V$e,eqe=H$e,tqe=G$e,sqe=f2e;function rqe(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,AAe=Vi,mC=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return AAe(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:a,defaultVariants:o}=s,l=Object.keys(a).map(u=>{const p=r==null?void 0:r[u],f=o==null?void 0:o[u];if(p===null)return null;const g=TAe(p)||TAe(f);return a[u][g]}),i=r&&Object.entries(r).reduce((u,p)=>{let[f,g]=p;return g===void 0||(u[f]=g),u},{}),c=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((u,p)=>{let{class:f,className:g,...b}=p;return Object.entries(b).every(_=>{let[j,w]=_;return Array.isArray(w)?w.includes({...o,...i}[j]):{...o,...i}[j]===w})?[...u,f,g]:u},[]);return AAe(t,l,c,r==null?void 0:r.class,r==null?void 0:r.className)};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oxt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),nqe=(...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 Rxt={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 aqe=N.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},c)=>N.createElement("svg",{ref:c,...Rxt,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:nqe("lucide",a),...i},[...l.map(([u,p])=>N.createElement(u,p)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y=(t,s)=>{const r=N.forwardRef(({className:n,...a},o)=>N.createElement(aqe,{ref:o,iconNode:s,className:nqe(`lucide-${Oxt(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 v9=Y("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 b9=Y("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 _9=Y("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 w9=Y("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 kh=Y("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 j9=Y("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 N9=Y("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 W2=Y("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 G2=Y("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 k9=Y("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 K2=Y("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 S9=Y("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 C9=Y("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 M9=Y("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 T9=Y("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 A9=Y("AlignCenterVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4",key:"14d6g8"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4",key:"1e2lrw"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1",key:"1fkdwx"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1",key:"1euafb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H4=Y("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 E9=Y("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 P9=Y("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 I9=Y("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 L9=Y("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 D9=Y("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 O9=Y("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 R9=Y("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 F9=Y("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 z9=Y("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 B9=Y("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 $9=Y("AlignJustify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W4=Y("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G4=Y("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 q9=Y("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 U9=Y("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 V9=Y("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 H9=Y("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 W9=Y("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 G9=Y("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 K9=Y("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 Z9=Y("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 Y9=Y("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 X9=Y("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 Q9=Y("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 J9=Y("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 eB=Y("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 tB=Y("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 sB=Y("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 rB=Y("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 nB=Y("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 aB=Y("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 iB=Y("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 oB=Y("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 lB=Y("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 UI=Y("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 cB=Y("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 VI=Y("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 dB=Y("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 NM=Y("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 uB=Y("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 hB=Y("ArrowBigDownDash",[["path",{d:"M15 5H9",key:"1tp3ed"}],["path",{d:"M15 9v3h4l-7 7-7-7h4V9z",key:"ncdc4b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mB=Y("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 pB=Y("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 fB=Y("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 xB=Y("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 gB=Y("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 yB=Y("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 vB=Y("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 bB=Y("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 _B=Y("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 Z2=Y("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 wB=Y("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 jB=Y("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 NB=Y("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 HI=Y("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 kB=Y("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 SB=Y("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 CB=Y("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 Y2=Y("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 X2=Y("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 Wh=Y("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 MB=Y("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 TB=Y("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 AB=Y("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 Ja=Y("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 EB=Y("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 e1=Y("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 PB=Y("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 Qa=Y("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 IB=Y("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 LB=Y("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 Q2=Y("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 vd=Y("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 DB=Y("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 OB=Y("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 RB=Y("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 J2=Y("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 WI=Y("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 FB=Y("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 zB=Y("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 ej=Y("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 ku=Y("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 BB=Y("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 $B=Y("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 qB=Y("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 UB=Y("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 VB=Y("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 HB=Y("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 Nc=Y("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 WB=Y("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 tj=Y("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 GB=Y("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 KB=Y("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 ZB=Y("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 YB=Y("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 sj=Y("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 XB=Y("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 QB=Y("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 JB=Y("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 e$=Y("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 t$=Y("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 s$=Y("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 r$=Y("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 n$=Y("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 a$=Y("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 i$=Y("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 o$=Y("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 l$=Y("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 c$=Y("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 d$=Y("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 u$=Y("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 GI=Y("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 h$=Y("Banana",[["path",{d:"M4 13c3.5-2 8-2 10 2a5.5 5.5 0 0 1 8 5",key:"1cscit"}],["path",{d:"M5.15 17.89c5.52-1.52 8.65-6.89 7-12C11.55 4 11.5 2 13 2c3.22 0 5 5.5 5 8 0 6.5-4.2 12-10.49 12C5.11 22 2 22 2 20c0-1.5 1.14-1.55 3.15-2.11Z",key:"1y1nbv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m$=Y("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 p$=Y("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 f$=Y("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 x$=Y("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 Ju=Y("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 g$=Y("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 y$=Y("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 v$=Y("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 b$=Y("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 _$=Y("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 w$=Y("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 j$=Y("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 N$=Y("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 k$=Y("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 K4=Y("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 S$=Y("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 Im=Y("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 C$=Y("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 M$=Y("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 T$=Y("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 A$=Y("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 E$=Y("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 P$=Y("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 t1=Y("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 I$=Y("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 L$=Y("BellRing",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lm=Y("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 rj=Y("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 nj=Y("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 D$=Y("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 O$=Y("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 R$=Y("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 F$=Y("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 z$=Y("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 B$=Y("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 $$=Y("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 q$=Y("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 U$=Y("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 V$=Y("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 H$=Y("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 W$=Y("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 G$=Y("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 K$=Y("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 Z$=Y("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 Y$=Y("Bluetooth",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z4=Y("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 X$=Y("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 Q$=Y("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 J$=Y("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 eq=Y("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 tq=Y("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 sq=Y("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 rq=Y("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 aj=Y("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 nq=Y("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 aq=Y("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 iq=Y("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 oq=Y("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 lq=Y("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 cq=Y("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 dq=Y("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 uq=Y("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 hq=Y("BookOpenCheck",[["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m16 12 2 2 4-4",key:"mdajum"}],["path",{d:"M22 6V4a1 1 0 0 0-1-1h-5a4 4 0 0 0-4 4 4 4 0 0 0-4-4H3a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h6a3 3 0 0 1 3 3 3 3 0 0 1 3-3h6a1 1 0 0 0 1-1v-1.3",key:"8arnkb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mq=Y("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 Sh=Y("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 pq=Y("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 fq=Y("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 xq=Y("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 gq=Y("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 yq=Y("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 vq=Y("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 bq=Y("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 _q=Y("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 wq=Y("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 jq=Y("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 KI=Y("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 Nq=Y("BookmarkX",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nx=Y("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 kq=Y("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 Sq=Y("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 Cq=Y("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 kM=Y("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 Mq=Y("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 Tq=Y("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 ij=Y("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 Aq=Y("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 Eq=Y("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 Pq=Y("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 ZI=Y("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 Iq=Y("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 Lq=Y("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 Dq=Y("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 Oq=Y("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 Gh=Y("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 Rq=Y("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 Fq=Y("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 zq=Y("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 Bq=Y("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 $q=Y("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 ka=Y("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 Y4=Y("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 qq=Y("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 Uq=Y("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 Vq=Y("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 Hq=Y("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 Wq=Y("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 Ch=Y("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 YI=Y("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 Gq=Y("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 Kq=Y("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 Zq=Y("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 Yq=Y("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 XI=Y("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 QI=Y("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 Xq=Y("CalendarCog",[["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"M21 10.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"11kmuh"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dd=Y("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 Qq=Y("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 Jq=Y("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 eU=Y("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 tU=Y("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 JI=Y("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 sU=Y("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 O_=Y("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 rU=Y("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 nU=Y("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 aU=Y("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 iU=Y("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 oU=Y("CalendarX",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m14 14-4 4",key:"rymu2i"}],["path",{d:"m10 14 4 4",key:"3sz06r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hn=Y("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 lU=Y("CameraOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16",key:"qmtpty"}],["path",{d:"M9.5 4h5L17 7h3a2 2 0 0 1 2 2v7.5",key:"1ufyfc"}],["path",{d:"M14.121 15.121A3 3 0 1 1 9.88 10.88",key:"11zox6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kx=Y("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 cU=Y("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 dU=Y("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 uU=Y("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 hU=Y("Cannabis",[["path",{d:"M12 22v-4",key:"1utk9m"}],["path",{d:"M7 12c-1.5 0-4.5 1.5-5 3 3.5 1.5 6 1 6 1-1.5 1.5-2 3.5-2 5 2.5 0 4.5-1.5 6-3 1.5 1.5 3.5 3 6 3 0-1.5-.5-3.5-2-5 0 0 2.5.5 6-1-.5-1.5-3.5-3-5-3 1.5-1 4-4 4-6-2.5 0-5.5 1.5-7 3 0-2.5-.5-5-2-7-1.5 2-2 4.5-2 7-1.5-1.5-4.5-3-7-3 0 2 2.5 5 4 6",key:"1mezod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mU=Y("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 oj=Y("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 pU=Y("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 fU=Y("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 SM=Y("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 xU=Y("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 gU=Y("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 yU=Y("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 vU=Y("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 bU=Y("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 _U=Y("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 wU=Y("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 jU=Y("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 NU=Y("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 kU=Y("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 lj=Y("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 cj=Y("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 SU=Y("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 CU=Y("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 MU=Y("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 dj=Y("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 uj=Y("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 hj=Y("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 TU=Y("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 mj=Y("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 AU=Y("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 No=Y("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 EU=Y("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 pj=Y("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 PU=Y("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 IU=Y("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 fj=Y("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 xj=Y("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 LU=Y("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 gj=Y("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 yj=Y("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 vj=Y("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 DU=Y("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 OU=Y("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 va=Y("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 RU=Y("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 FU=Y("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 Eo=Y("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 zU=Y("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 BU=Y("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 cl=Y("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 da=Y("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pf=Y("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 $U=Y("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 qU=Y("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 UU=Y("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 VU=Y("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 HU=Y("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 WU=Y("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 GU=Y("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sx=Y("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 KU=Y("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 ZU=Y("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 YU=Y("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 XU=Y("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 QU=Y("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 kl=Y("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 bj=Y("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 _j=Y("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 wj=Y("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 jj=Y("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 Nj=Y("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 kj=Y("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 Sj=Y("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 Cj=Y("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xi=Y("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sa=Y("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 Mj=Y("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 Tj=Y("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 Aj=Y("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 Ej=Y("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 JU=Y("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 Pj=Y("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 eV=Y("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 tV=Y("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 sV=Y("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 rV=Y("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 nV=Y("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 aV=Y("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 iV=Y("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 Ij=Y("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 Dv=Y("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 Lj=Y("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 oV=Y("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 Dj=Y("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 Oj=Y("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 Rj=Y("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 Fj=Y("CirclePercent",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pp=Y("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 zj=Y("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 Bj=Y("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 $j=Y("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 lV=Y("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 qj=Y("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 Uj=Y("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 Vj=Y("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 vc=Y("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 bd=Y("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 cV=Y("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 dV=Y("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 uV=Y("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 CM=Y("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 hV=Y("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 R_=Y("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 mV=Y("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 pV=Y("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 Hj=Y("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 Wj=Y("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 fV=Y("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 xV=Y("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 gV=Y("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 yV=Y("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 vV=Y("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 bV=Y("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 _V=Y("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 wV=Y("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 jV=Y("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 NV=Y("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 kV=Y("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 SV=Y("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 CV=Y("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 MV=Y("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 TV=Y("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 AV=Y("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 EV=Y("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 PV=Y("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 IV=Y("ClockArrowUp",[["path",{d:"M13.228 21.925A10 10 0 1 1 21.994 12.338",key:"1fzlyi"}],["path",{d:"M12 6v6l1.562.781",key:"1ujuk9"}],["path",{d:"m14 18 4-4 4 4",key:"ftkppy"}],["path",{d:"M18 22v-8",key:"su0gjh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const un=Y("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 LV=Y("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 DV=Y("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 Gj=Y("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 OV=Y("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 RV=Y("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 FV=Y("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 zV=Y("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 BV=Y("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 $V=Y("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 qV=Y("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 UV=Y("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 VV=Y("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 HV=Y("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 WV=Y("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 GV=Y("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 Kj=Y("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 KV=Y("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 ZV=Y("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 Kv=Y("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 YV=Y("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 Zj=Y("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 X4=Y("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 XV=Y("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 QV=Y("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 Q4=Y("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 JV=Y("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 eL=Y("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 Yj=Y("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 Xj=Y("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 eH=Y("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 tH=Y("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 sH=Y("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 rH=Y("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 nH=Y("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 aH=Y("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 iH=Y("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 oH=Y("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 lH=Y("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 Qj=Y("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 J4=Y("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 cH=Y("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 dH=Y("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 uH=Y("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 hH=Y("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 mH=Y("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 pH=Y("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 fH=Y("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 xH=Y("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 gH=Y("CopyX",[["line",{x1:"12",x2:"18",y1:"12",y2:"18",key:"1rg63v"}],["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gi=Y("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 yH=Y("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 vH=Y("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 bH=Y("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 _H=Y("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 wH=Y("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 jH=Y("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 NH=Y("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 kH=Y("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 SH=Y("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 CH=Y("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 MH=Y("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 TH=Y("CreativeCommons",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M10 9.3a2.8 2.8 0 0 0-3.5 1 3.1 3.1 0 0 0 0 3.4 2.7 2.7 0 0 0 3.5 1",key:"1ss3eq"}],["path",{d:"M17 9.3a2.8 2.8 0 0 0-3.5 1 3.1 3.1 0 0 0 0 3.4 2.7 2.7 0 0 0 3.5 1",key:"1od56t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cx=Y("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 AH=Y("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 EH=Y("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 PH=Y("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 IH=Y("Crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dm=Y("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 LH=Y("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 DH=Y("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 OH=Y("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 RH=Y("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 FH=Y("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 zH=Y("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 BH=Y("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 tL=Y("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 $H=Y("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 qH=Y("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 UH=Y("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 VH=Y("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 Jj=Y("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 HH=Y("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 WH=Y("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 GH=Y("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 KH=Y("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 ZH=Y("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 YH=Y("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 XH=Y("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 QH=Y("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 JH=Y("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 eW=Y("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 tW=Y("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 sW=Y("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 rW=Y("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 nW=Y("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 aW=Y("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 iW=Y("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 oW=Y("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 lW=Y("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 cW=Y("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 nc=Y("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 dW=Y("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 uW=Y("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 s1=Y("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 hW=Y("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 yi=Y("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 mW=Y("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 pW=Y("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 fW=Y("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 xW=Y("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 gW=Y("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 Yg=Y("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 yW=Y("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 vW=Y("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 bW=Y("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 _W=Y("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 wW=Y("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 jW=Y("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 eN=Y("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 NW=Y("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 kW=Y("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 SW=Y("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 MM=Y("Egg",[["path",{d:"M12 22c6.23-.05 7.87-5.57 7.5-10-.36-4.34-3.95-9.96-7.5-10-3.55.04-7.14 5.66-7.5 10-.37 4.43 1.27 9.95 7.5 10z",key:"1c39pg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mx=Y("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const px=Y("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 CW=Y("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 MW=Y("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 TW=Y("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 AW=Y("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 EW=Y("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 PW=Y("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 sL=Y("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 tn=Y("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 IW=Y("EyeClosed",[["path",{d:"m15 18-.722-3.25",key:"1j64jw"}],["path",{d:"M2 8a10.645 10.645 0 0 0 20 0",key:"1e7gxb"}],["path",{d:"m20 15-1.726-2.05",key:"1cnuld"}],["path",{d:"m4 15 1.726-2.05",key:"1dsqqd"}],["path",{d:"m9 18 .722-3.25",key:"ypw2yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kp=Y("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 On=Y("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 Su=Y("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 LW=Y("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 DW=Y("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 OW=Y("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 RW=Y("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 FW=Y("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 zW=Y("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 BW=Y("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 $W=Y("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 qW=Y("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 UW=Y("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 tN=Y("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 VW=Y("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 HW=Y("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 WW=Y("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 sN=Y("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 rN=Y("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 nN=Y("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 aN=Y("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 GW=Y("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 KW=Y("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 ZW=Y("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 YW=Y("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 XW=Y("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 iN=Y("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 QW=Y("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 JW=Y("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 eG=Y("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 tG=Y("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 F_=Y("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 sG=Y("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 rG=Y("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 nG=Y("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 aG=Y("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 iG=Y("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 oG=Y("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 lG=Y("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 cG=Y("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 dG=Y("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 uG=Y("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 hG=Y("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 oN=Y("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 lN=Y("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 mG=Y("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 pG=Y("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 fG=Y("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 xG=Y("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 gG=Y("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 yG=Y("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 vG=Y("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 r1=Y("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 rL=Y("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 bG=Y("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 _G=Y("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 Sn=Y("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 wG=Y("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 jG=Y("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 NG=Y("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 kG=Y("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 SG=Y("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 CG=Y("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 MG=Y("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 TG=Y("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 AG=Y("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 EG=Y("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 PG=Y("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 TM=Y("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 IG=Y("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 gu=Y("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 LG=Y("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 Xg=Y("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 DG=Y("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 OG=Y("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 RG=Y("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 FG=Y("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 zG=Y("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 BG=Y("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 $G=Y("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 qG=Y("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 n1=Y("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 UG=Y("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 eh=Y("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 VG=Y("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 HG=Y("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 WG=Y("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 z_=Y("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 GG=Y("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 KG=Y("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 nL=Y("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 ZG=Y("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 YG=Y("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 Hg=Y("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 XG=Y("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 QG=Y("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 JG=Y("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 eK=Y("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 tK=Y("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 sK=Y("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 rK=Y("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 nK=Y("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 aK=Y("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 cN=Y("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 iK=Y("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 oK=Y("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 lK=Y("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 cK=Y("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 dK=Y("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 uK=Y("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 hK=Y("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 mK=Y("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 pK=Y("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 fK=Y("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 xK=Y("FolderOpenDot",[["path",{d:"m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2",key:"1nmvlm"}],["circle",{cx:"14",cy:"15",r:"1",key:"1gm4qj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Om=Y("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 gK=Y("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 dN=Y("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 yK=Y("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 vK=Y("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 bK=Y("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 _K=Y("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 wK=Y("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 jK=Y("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 NK=Y("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 kK=Y("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 SK=Y("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 CK=Y("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 MK=Y("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 TK=Y("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 AK=Y("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 EK=Y("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 PK=Y("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 IK=Y("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 LK=Y("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 DK=Y("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 OK=Y("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 RK=Y("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 FK=Y("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 zK=Y("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 BK=Y("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 $K=Y("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 qK=Y("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 UK=Y("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 VK=Y("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 HK=Y("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 WK=Y("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 eS=Y("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 ko=Y("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 GK=Y("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 KK=Y("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 uN=Y("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 ZK=Y("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 YK=Y("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 XK=Y("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 QK=Y("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 JK=Y("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 eZ=Y("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 tZ=Y("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 sZ=Y("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 rZ=Y("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 nZ=Y("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 aZ=Y("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 iZ=Y("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 oZ=Y("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 lZ=Y("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 cZ=Y("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 dZ=Y("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 uZ=Y("GlobeLock",[["path",{d:"M15.686 15A14.5 14.5 0 0 1 12 22a14.5 14.5 0 0 1 0-20 10 10 0 1 0 9.542 13",key:"qkt0x6"}],["path",{d:"M2 12h8.5",key:"ovaggd"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const su=Y("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 hZ=Y("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 mZ=Y("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 Kh=Y("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 pZ=Y("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 fZ=Y("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 hN=Y("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 xZ=Y("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 mN=Y("Grid2x2",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nx=Y("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 gZ=Y("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 Cu=Y("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 yZ=Y("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 vZ=Y("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 bZ=Y("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 _Z=Y("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 wZ=Y("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 jZ=Y("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 NZ=Y("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 pN=Y("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 kZ=Y("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 SZ=Y("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 aL=Y("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 iL=Y("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 CZ=Y("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 MZ=Y("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 oL=Y("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 TZ=Y("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 B_=Y("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 AZ=Y("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 EZ=Y("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 AM=Y("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 EM=Y("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 lL=Y("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 PZ=Y("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 IZ=Y("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 LZ=Y("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 DZ=Y("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 OZ=Y("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 RZ=Y("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 FZ=Y("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 zZ=Y("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 BZ=Y("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 $Z=Y("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 qZ=Y("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 ni=Y("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 UZ=Y("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 VZ=Y("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 HZ=Y("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 PM=Y("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 WZ=Y("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 GZ=Y("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 KZ=Y("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 ZZ=Y("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 YZ=Y("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 XZ=Y("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 QZ=Y("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 bn=Y("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 fN=Y("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 xN=Y("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 JZ=Y("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 eY=Y("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 tY=Y("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 sY=Y("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 rY=Y("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 a1=Y("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 nY=Y("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 aY=Y("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 gl=Y("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 iY=Y("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 oY=Y("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 lY=Y("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 gN=Y("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 yN=Y("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 cY=Y("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 dY=Y("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 cL=Y("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 uY=Y("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 Mu=Y("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 tS=Y("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 hY=Y("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 mY=Y("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 pY=Y("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 fY=Y("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 h0=Y("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 sS=Y("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 xY=Y("KeySquare",[["path",{d:"M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z",key:"165ttr"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814",key:"1ubxi2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sp=Y("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 gY=Y("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 yY=Y("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 vY=Y("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 bY=Y("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 _Y=Y("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 wY=Y("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 jY=Y("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 NY=Y("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 kY=Y("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 SY=Y("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 CY=Y("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 MY=Y("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 TY=Y("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 vN=Y("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 AY=Y("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 EY=Y("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 PY=Y("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 IY=Y("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 LY=Y("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 DY=Y("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 IM=Y("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 rS=Y("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cp=Y("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 OY=Y("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 RY=Y("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 FY=Y("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 nS=Y("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 zY=Y("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 BY=Y("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 $Y=Y("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 qY=Y("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 UY=Y("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 LM=Y("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 DM=Y("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 VY=Y("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 HY=Y("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 $_=Y("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 WY=Y("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 dl=Y("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bo=Y("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mp=Y("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 GY=Y("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 KY=Y("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 ZY=Y("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 YY=Y("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 XY=Y("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 QY=Y("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 JY=Y("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 m0=Y("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 eX=Y("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 tX=Y("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 sX=Y("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 rX=Y("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 nX=Y("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 aX=Y("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 iX=Y("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 Mh=Y("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ws=Y("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 oX=Y("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 lX=Y("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 cX=Y("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 dX=Y("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 uX=Y("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 bN=Y("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 hX=Y("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 _N=Y("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 Th=Y("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 aS=Y("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 iS=Y("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 mX=Y("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 pX=Y("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 fX=Y("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 xX=Y("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 gX=Y("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 yX=Y("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 vX=Y("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 dL=Y("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 bX=Y("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 _X=Y("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 wX=Y("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 uL=Y("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 cr=Y("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 jX=Y("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 NX=Y("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 kX=Y("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 SX=Y("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 CX=Y("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 MX=Y("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 TX=Y("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 AX=Y("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 EX=Y("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 PX=Y("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 IX=Y("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 LX=Y("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 ma=Y("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 DX=Y("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 i1=Y("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 OX=Y("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 RX=Y("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 oS=Y("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 o1=Y("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 FX=Y("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 Ah=Y("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 zX=Y("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 BX=Y("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 OM=Y("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 $X=Y("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 qX=Y("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 UX=Y("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 RM=Y("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 VX=Y("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 HX=Y("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 WX=Y("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 hL=Y("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 GX=Y("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 KX=Y("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 ZX=Y("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 $c=Y("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 YX=Y("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 XX=Y("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 QX=Y("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 JX=Y("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 eQ=Y("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 tQ=Y("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 mL=Y("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 sQ=Y("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 FM=Y("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 pL=Y("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 rQ=Y("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 nQ=Y("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 aQ=Y("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 iQ=Y("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 oQ=Y("MessageSquareX",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const so=Y("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 lQ=Y("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 cQ=Y("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 wN=Y("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 fL=Y("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 dQ=Y("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 uQ=Y("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 hQ=Y("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 mQ=Y("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 pQ=Y("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 fQ=Y("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 xQ=Y("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 gQ=Y("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=Y("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 yQ=Y("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 vQ=Y("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 bQ=Y("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 _Q=Y("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 wQ=Y("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 jQ=Y("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 NQ=Y("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 kQ=Y("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 SQ=Y("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 CQ=Y("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 lS=Y("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 MQ=Y("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 cS=Y("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 TQ=Y("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 AQ=Y("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 EQ=Y("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 PQ=Y("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 IQ=Y("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 LQ=Y("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 DQ=Y("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 Qg=Y("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 wh=Y("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 OQ=Y("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 jN=Y("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 RQ=Y("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 FQ=Y("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 zQ=Y("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 BQ=Y("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 $Q=Y("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 qQ=Y("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 UQ=Y("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 VQ=Y("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 HQ=Y("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 WQ=Y("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 GQ=Y("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 KQ=Y("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 ZQ=Y("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 YQ=Y("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 XQ=Y("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 QQ=Y("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 JQ=Y("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 eJ=Y("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 tJ=Y("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 sJ=Y("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 rJ=Y("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 nJ=Y("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 l1=Y("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 aJ=Y("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 iJ=Y("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 oJ=Y("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 lJ=Y("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 cJ=Y("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 dJ=Y("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 uJ=Y("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 hJ=Y("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 mJ=Y("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 Ov=Y("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 pJ=Y("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 NN=Y("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 kN=Y("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 fJ=Y("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 xJ=Y("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 gJ=Y("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 yJ=Y("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 vJ=Y("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 bJ=Y("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 _J=Y("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 wJ=Y("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 jJ=Y("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 NJ=Y("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 kJ=Y("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 SJ=Y("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 Ml=Y("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 CJ=Y("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 MJ=Y("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 SN=Y("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 TJ=Y("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 ac=Y("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 AJ=Y("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 CN=Y("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 EJ=Y("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 PJ=Y("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 MN=Y("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 TN=Y("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 AN=Y("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 EN=Y("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 IJ=Y("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 PN=Y("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 LJ=Y("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 DJ=Y("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 OJ=Y("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 IN=Y("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 RJ=Y("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 FJ=Y("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 zJ=Y("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 BJ=Y("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 Rv=Y("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 dS=Y("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 $J=Y("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 qJ=Y("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 ru=Y("PartyPopper",[["path",{d:"M5.8 11.3 2 22l10.7-3.79",key:"gwxi1d"}],["path",{d:"M4 3h.01",key:"1vcuye"}],["path",{d:"M22 8h.01",key:"1mrtc2"}],["path",{d:"M15 2h.01",key:"1cjtqr"}],["path",{d:"M22 20h.01",key:"1mrys2"}],["path",{d:"m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10",key:"hbicv8"}],["path",{d:"m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17",key:"1i94pl"}],["path",{d:"m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7",key:"1cofks"}],["path",{d:"M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z",key:"4kbmks"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rm=Y("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 UJ=Y("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 VJ=Y("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 Fv=Y("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 HJ=Y("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 q_=Y("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 Jy=Y("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 WJ=Y("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 GJ=Y("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 KJ=Y("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=Y("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 ZJ=Y("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 uS=Y("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 YJ=Y("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 XJ=Y("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 QJ=Y("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 JJ=Y("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 eee=Y("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 tee=Y("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 see=Y("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 ree=Y("PhoneOutgoing",[["polyline",{points:"22 8 22 2 16 2",key:"1g204g"}],["line",{x1:"16",x2:"22",y1:"8",y2:"2",key:"1ggias"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Un=Y("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 nee=Y("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 aee=Y("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 iee=Y("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 oee=Y("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 lee=Y("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 cee=Y("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 dee=Y("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 uee=Y("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 hee=Y("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 mee=Y("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 pee=Y("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 xL=Y("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 U_=Y("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 fee=Y("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 xee=Y("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 gee=Y("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 yee=Y("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 vee=Y("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 nl=Y("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 bee=Y("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 LN=Y("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 gL=Y("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 $s=Y("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 _ee=Y("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 wee=Y("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 jee=Y("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 Nee=Y("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 kee=Y("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 See=Y("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 Cee=Y("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 Mee=Y("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 Tee=Y("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 yL=Y("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 Jg=Y("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 Aee=Y("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 vL=Y("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 Eee=Y("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 Pee=Y("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 Iee=Y("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 Lee=Y("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 c1=Y("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 V_=Y("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 Dee=Y("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 Oee=Y("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 Ree=Y("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 Fee=Y("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 zee=Y("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 Bee=Y("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 d1=Y("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 $ee=Y("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 qee=Y("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 Uee=Y("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 Vee=Y("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 Hee=Y("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 Wee=Y("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 Gee=Y("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 Kee=Y("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 Zee=Y("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 Yee=Y("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 Xee=Y("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 Qee=Y("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 Jee=Y("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 ete=Y("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 DN=Y("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 tte=Y("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 ste=Y("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 rte=Y("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 nte=Y("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 ate=Y("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 hS=Y("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 ite=Y("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 zM=Y("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 ote=Y("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 Go=Y("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 lte=Y("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 cte=Y("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 dte=Y("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 ute=Y("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 hte=Y("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 bL=Y("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 mte=Y("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 pte=Y("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 fte=Y("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 _L=Y("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 xte=Y("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 gte=Y("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 f0=Y("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 yte=Y("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 vte=Y("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 ON=Y("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 bte=Y("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 u1=Y("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 _te=Y("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 wL=Y("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 wte=Y("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 jte=Y("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 Nte=Y("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 RN=Y("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 FN=Y("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 kte=Y("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 Ste=Y("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 x0=Y("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 Cte=Y("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 Mte=Y("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 Tte=Y("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 Ate=Y("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 Ete=Y("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 Pte=Y("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 Ite=Y("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 Lte=Y("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 qc=Y("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 zN=Y("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 jL=Y("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 Dte=Y("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 Ote=Y("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 Rte=Y("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 Fte=Y("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 zte=Y("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 Bte=Y("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 $te=Y("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 qte=Y("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 Ute=Y("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 Vte=Y("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 Hte=Y("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 Wte=Y("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 Gte=Y("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 Kte=Y("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 Zte=Y("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 Yte=Y("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 Xte=Y("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 Qte=Y("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 Jte=Y("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 NL=Y("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 cn=Y("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 ese=Y("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 BN=Y("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 tse=Y("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 Bn=Y("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 sse=Y("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 rse=Y("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 nse=Y("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 ase=Y("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 ise=Y("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 ose=Y("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 kL=Y("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 Xo=Y("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 lse=Y("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 _d=Y("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 SL=Y("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 cse=Y("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 dse=Y("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 use=Y("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 hse=Y("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 CL=Y("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 mse=Y("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 pse=Y("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 fse=Y("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 xse=Y("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 gse=Y("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 yse=Y("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 $N=Y("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const th=Y("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 vse=Y("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 bse=Y("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 _se=Y("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 g0=Y("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 wse=Y("ShoppingBasket",[["path",{d:"m15 11-1 9",key:"5wnq3a"}],["path",{d:"m19 11-4-7",key:"cnml18"}],["path",{d:"M2 11h20",key:"3eubbj"}],["path",{d:"m3.5 11 1.6 7.4a2 2 0 0 0 2 1.6h9.8a2 2 0 0 0 2-1.6l1.7-7.4",key:"yiazzp"}],["path",{d:"M4.5 15.5h15",key:"13mye1"}],["path",{d:"m5 11 4-7",key:"116ra9"}],["path",{d:"m9 11 1 9",key:"1ojof7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vp=Y("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 jse=Y("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 Nse=Y("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 kse=Y("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 Sse=Y("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 mS=Y("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 Cse=Y("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 Mse=Y("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 Tse=Y("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 Ase=Y("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 Ese=Y("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 Pse=Y("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 Ise=Y("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 Lse=Y("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 Dse=Y("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 Ose=Y("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 Rse=Y("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 Fse=Y("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 zse=Y("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 Bse=Y("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 $se=Y("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 qse=Y("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 H_=Y("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 qN=Y("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 Use=Y("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 Vse=Y("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 h1=Y("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 Hse=Y("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 Wse=Y("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 Gse=Y("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 n0=Y("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 Kse=Y("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 Zse=Y("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 Yse=Y("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 Xse=Y("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 Qse=Y("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 pn=Y("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 Jse=Y("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 ere=Y("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 tre=Y("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 sre=Y("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 rre=Y("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 nre=Y("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 are=Y("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 ire=Y("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 UN=Y("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 VN=Y("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 HN=Y("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 WN=Y("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 GN=Y("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 KN=Y("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 ZN=Y("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 YN=Y("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 XN=Y("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 QN=Y("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 JN=Y("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 ek=Y("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 tk=Y("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 sk=Y("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 rk=Y("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 Uy=Y("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 zv=Y("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 nk=Y("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 ak=Y("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 ik=Y("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 ok=Y("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 lk=Y("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 ck=Y("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 ore=Y("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 lre=Y("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 dk=Y("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 uk=Y("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 hk=Y("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 mk=Y("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 pk=Y("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 fk=Y("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 xk=Y("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 gk=Y("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 yk=Y("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 vk=Y("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 bk=Y("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 _k=Y("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 wk=Y("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 jk=Y("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 Nk=Y("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 ud=Y("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 kk=Y("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 Sk=Y("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 Ck=Y("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 Mk=Y("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 Tk=Y("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 Ak=Y("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 cre=Y("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 Ek=Y("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 Pk=Y("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 Ik=Y("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 Lk=Y("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 Dk=Y("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 dre=Y("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 ure=Y("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 Ok=Y("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 Rk=Y("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 Fk=Y("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 zk=Y("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 y0=Y("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 hre=Y("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 mre=Y("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 pre=Y("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 fre=Y("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 xre=Y("StarOff",[["path",{d:"M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43",key:"16m0ql"}],["path",{d:"M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91",key:"1vt8nq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jn=Y("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 gre=Y("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 yre=Y("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 vre=Y("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 bre=Y("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 _re=Y("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 BM=Y("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 wre=Y("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 jre=Y("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 ML=Y("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 Nre=Y("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 kre=Y("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 Sre=Y("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 Cre=Y("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 Mre=Y("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 m1=Y("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 Tre=Y("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 Are=Y("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 Ere=Y("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 Pre=Y("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 Ire=Y("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 Lre=Y("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 Dre=Y("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 Ore=Y("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 Rre=Y("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 $M=Y("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 Fre=Y("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 zre=Y("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 Bre=Y("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 $re=Y("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 qre=Y("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 Ure=Y("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 qM=Y("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 Vre=Y("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 Hre=Y("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 Wre=Y("Tablets",[["circle",{cx:"7",cy:"7",r:"5",key:"x29byf"}],["circle",{cx:"17",cy:"17",r:"5",key:"1op1d2"}],["path",{d:"M12 17h10",key:"ls21zv"}],["path",{d:"m3.46 10.54 7.08-7.08",key:"1rehiu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fm=Y("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 Gre=Y("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 Kre=Y("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 Zre=Y("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 Yre=Y("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 Xre=Y("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 Qre=Y("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 Jre=Y("Tangent",[["circle",{cx:"17",cy:"4",r:"2",key:"y5j2s2"}],["path",{d:"M15.59 5.41 5.41 15.59",key:"l0vprr"}],["circle",{cx:"4",cy:"17",r:"2",key:"9p4efm"}],["path",{d:"M12 22s-4-9-1.5-11.5S22 12 22 12",key:"1twk4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zm=Y("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 ene=Y("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 tne=Y("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 sne=Y("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 rne=Y("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 Bk=Y("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 nne=Y("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 ane=Y("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 ine=Y("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 one=Y("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 lne=Y("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 cne=Y("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 $k=Y("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 dne=Y("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 une=Y("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 hne=Y("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 mne=Y("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 TL=Y("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 AL=Y("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 sh=Y("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 pne=Y("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 fne=Y("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 xne=Y("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 gne=Y("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 yne=Y("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 vne=Y("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 EL=Y("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 bne=Y("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 _ne=Y("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 wne=Y("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 jne=Y("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 Nne=Y("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 kne=Y("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 Sne=Y("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 Cne=Y("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 Mne=Y("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 Tne=Y("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 Ane=Y("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 Ene=Y("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 Pne=Y("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 Ine=Y("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 Lne=Y("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 Dne=Y("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 One=Y("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 Rne=Y("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 Fne=Y("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 qk=Y("TramFront",[["rect",{width:"16",height:"16",x:"4",y:"3",rx:"2",key:"1wxw4b"}],["path",{d:"M4 11h16",key:"mpoxn0"}],["path",{d:"M12 3v8",key:"1h2ygw"}],["path",{d:"m8 19-2 3",key:"13i0xs"}],["path",{d:"m18 22-2-3",key:"1p0ohu"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M16 15h.01",key:"rnfrdf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nr=Y("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 zne=Y("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 Bne=Y("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 Uk=Y("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 p1=Y("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 $ne=Y("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 qne=Y("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 pS=Y("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 Une=Y("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 ul=Y("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 Ku=Y("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 Vne=Y("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 Hne=Y("Triangle",[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xo=Y("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 PL=Y("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 Wne=Y("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 Gne=Y("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 Vk=Y("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 Kne=Y("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 Zne=Y("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 Yne=Y("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 Xne=Y("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 Qne=Y("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 Jne=Y("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 eae=Y("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 IL=Y("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 tae=Y("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 sae=Y("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 fS=Y("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 rae=Y("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 nae=Y("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 aae=Y("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 Hk=Y("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 iae=Y("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 xS=Y("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 oae=Y("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 li=Y("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 lae=Y("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 W_=Y("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 LL=Y("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 DL=Y("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 cae=Y("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 Tl=Y("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 Wk=Y("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 Gk=Y("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 Kk=Y("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 dae=Y("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 Zk=Y("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 uae=Y("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 Yk=Y("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 Xk=Y("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 hae=Y("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 mae=Y("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const to=Y("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 Qk=Y("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 pr=Y("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 Jk=Y("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 e4=Y("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 pae=Y("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 UM=Y("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 fae=Y("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 xae=Y("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 gae=Y("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 yae=Y("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 vae=Y("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 bae=Y("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 An=Y("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 _ae=Y("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 wae=Y("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 jae=Y("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 Nae=Y("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 kae=Y("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 Sae=Y("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 Cae=Y("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 Mae=Y("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 Tae=Y("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 Aae=Y("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 Eae=Y("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 t4=Y("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 OL=Y("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 Pae=Y("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 Bv=Y("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 Iae=Y("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 Lae=Y("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 Dae=Y("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 Oae=Y("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 RL=Y("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 Rae=Y("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 Fae=Y("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 zae=Y("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 Bae=Y("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 $ae=Y("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 qae=Y("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 Uae=Y("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 Vae=Y("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 Hae=Y("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 Wae=Y("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 Gae=Y("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 Kae=Y("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 Zae=Y("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 Yae=Y("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 Xae=Y("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 Qae=Y("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 Jae=Y("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 eie=Y("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 tie=Y("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 sie=Y("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 ey=Y("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 Rr=Y("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 rie=Y("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 nie=Y("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 Zh=Y("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 G_=Y("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 VM=Y("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 Fxt=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:v9,AArrowUp:b9,ALargeSmall:_9,Accessibility:w9,Activity:kh,AirVent:j9,Airplay:N9,AlarmClock:S9,AlarmClockCheck:W2,AlarmClockMinus:G2,AlarmClockOff:k9,AlarmClockPlus:K2,AlarmSmoke:C9,Album:M9,AlignCenter:H4,AlignCenterHorizontal:T9,AlignCenterVertical:A9,AlignEndHorizontal:E9,AlignEndVertical:P9,AlignHorizontalDistributeCenter:I9,AlignHorizontalDistributeEnd:L9,AlignHorizontalDistributeStart:D9,AlignHorizontalJustifyCenter:O9,AlignHorizontalJustifyEnd:R9,AlignHorizontalJustifyStart:F9,AlignHorizontalSpaceAround:z9,AlignHorizontalSpaceBetween:B9,AlignJustify:$9,AlignLeft:W4,AlignRight:G4,AlignStartHorizontal:q9,AlignStartVertical:U9,AlignVerticalDistributeCenter:V9,AlignVerticalDistributeEnd:H9,AlignVerticalDistributeStart:W9,AlignVerticalJustifyCenter:G9,AlignVerticalJustifyEnd:K9,AlignVerticalJustifyStart:Z9,AlignVerticalSpaceAround:Y9,AlignVerticalSpaceBetween:X9,Ambulance:Q9,Ampersand:J9,Ampersands:eB,Amphora:tB,Anchor:sB,Angry:rB,Annoyed:nB,Antenna:aB,Anvil:iB,Aperture:oB,AppWindow:UI,AppWindowMac:lB,Apple:cB,Archive:NM,ArchiveRestore:VI,ArchiveX:dB,Armchair:uB,ArrowBigDown:mB,ArrowBigDownDash:hB,ArrowBigLeft:fB,ArrowBigLeftDash:pB,ArrowBigRight:gB,ArrowBigRightDash:xB,ArrowBigUp:vB,ArrowBigUpDash:yB,ArrowDown:Wh,ArrowDown01:bB,ArrowDown10:_B,ArrowDownAZ:Z2,ArrowDownFromLine:wB,ArrowDownLeft:jB,ArrowDownNarrowWide:NB,ArrowDownRight:HI,ArrowDownToDot:kB,ArrowDownToLine:SB,ArrowDownUp:CB,ArrowDownWideNarrow:Y2,ArrowDownZA:X2,ArrowLeft:Ja,ArrowLeftFromLine:MB,ArrowLeftRight:TB,ArrowLeftToLine:AB,ArrowRight:Qa,ArrowRightFromLine:EB,ArrowRightLeft:e1,ArrowRightToLine:PB,ArrowUp:ku,ArrowUp01:IB,ArrowUp10:LB,ArrowUpAZ:Q2,ArrowUpDown:vd,ArrowUpFromDot:DB,ArrowUpFromLine:OB,ArrowUpLeft:RB,ArrowUpNarrowWide:J2,ArrowUpRight:WI,ArrowUpToLine:FB,ArrowUpWideNarrow:zB,ArrowUpZA:ej,ArrowsUpFromLine:BB,Asterisk:$B,AtSign:qB,Atom:UB,AudioLines:VB,AudioWaveform:HB,Award:Nc,Axe:WB,Axis3d:tj,Baby:GB,Backpack:KB,Badge:d$,BadgeAlert:ZB,BadgeCent:YB,BadgeCheck:sj,BadgeDollarSign:XB,BadgeEuro:QB,BadgeHelp:JB,BadgeIndianRupee:e$,BadgeInfo:t$,BadgeJapaneseYen:s$,BadgeMinus:r$,BadgePercent:n$,BadgePlus:a$,BadgePoundSterling:i$,BadgeRussianRuble:o$,BadgeSwissFranc:l$,BadgeX:c$,BaggageClaim:u$,Ban:GI,Banana:h$,Bandage:m$,Banknote:p$,Barcode:f$,Baseline:x$,Bath:Ju,Battery:w$,BatteryCharging:g$,BatteryFull:y$,BatteryLow:v$,BatteryMedium:b$,BatteryWarning:_$,Beaker:j$,Bean:k$,BeanOff:N$,Bed:Im,BedDouble:K4,BedSingle:S$,Beef:C$,Beer:T$,BeerOff:M$,Bell:Lm,BellDot:A$,BellElectric:E$,BellMinus:P$,BellOff:t1,BellPlus:I$,BellRing:L$,BetweenHorizontalEnd:rj,BetweenHorizontalStart:nj,BetweenVerticalEnd:D$,BetweenVerticalStart:O$,BicepsFlexed:R$,Bike:F$,Binary:z$,Binoculars:B$,Biohazard:$$,Bird:q$,Bitcoin:U$,Blend:V$,Blinds:H$,Blocks:W$,Bluetooth:Y$,BluetoothConnected:G$,BluetoothOff:K$,BluetoothSearching:Z$,Bold:Z4,Bolt:X$,Bomb:Q$,Bone:J$,Book:_q,BookA:eq,BookAudio:tq,BookCheck:sq,BookCopy:rq,BookDashed:aj,BookDown:nq,BookHeadphones:aq,BookHeart:iq,BookImage:oq,BookKey:lq,BookLock:cq,BookMarked:dq,BookMinus:uq,BookOpen:Sh,BookOpenCheck:hq,BookOpenText:mq,BookPlus:pq,BookText:fq,BookType:xq,BookUp:yq,BookUp2:gq,BookUser:vq,BookX:bq,Bookmark:Nx,BookmarkCheck:wq,BookmarkMinus:jq,BookmarkPlus:KI,BookmarkX:Nq,BoomBox:kq,Bot:kM,BotMessageSquare:Sq,BotOff:Cq,Box:Mq,Boxes:Tq,Braces:ij,Brackets:Aq,Brain:ZI,BrainCircuit:Eq,BrainCog:Pq,BrickWall:Iq,Briefcase:Gh,BriefcaseBusiness:Lq,BriefcaseConveyorBelt:Dq,BriefcaseMedical:Oq,BringToFront:Rq,Brush:Fq,Bug:$q,BugOff:zq,BugPlay:Bq,Building:Y4,Building2:ka,Bus:Uq,BusFront:qq,Cable:Hq,CableCar:Vq,Cake:Ch,CakeSlice:Wq,Calculator:YI,Calendar:hn,Calendar1:Gq,CalendarArrowDown:Kq,CalendarArrowUp:Zq,CalendarCheck:XI,CalendarCheck2:Yq,CalendarClock:QI,CalendarCog:Xq,CalendarDays:Dd,CalendarFold:Qq,CalendarHeart:Jq,CalendarMinus:tU,CalendarMinus2:eU,CalendarOff:JI,CalendarPlus:O_,CalendarPlus2:sU,CalendarRange:rU,CalendarSearch:nU,CalendarSync:aU,CalendarX:oU,CalendarX2:iU,Camera:kx,CameraOff:lU,Candy:uU,CandyCane:cU,CandyOff:dU,Cannabis:hU,Captions:oj,CaptionsOff:mU,Car:SM,CarFront:pU,CarTaxiFront:fU,Caravan:xU,Carrot:gU,CaseLower:yU,CaseSensitive:vU,CaseUpper:bU,CassetteTape:_U,Cast:wU,Castle:jU,Cat:NU,Cctv:kU,ChartArea:lj,ChartBar:dj,ChartBarBig:cj,ChartBarDecreasing:SU,ChartBarIncreasing:CU,ChartBarStacked:MU,ChartCandlestick:uj,ChartColumn:No,ChartColumnBig:hj,ChartColumnDecreasing:TU,ChartColumnIncreasing:mj,ChartColumnStacked:AU,ChartGantt:EU,ChartLine:pj,ChartNetwork:PU,ChartNoAxesColumn:xj,ChartNoAxesColumnDecreasing:IU,ChartNoAxesColumnIncreasing:fj,ChartNoAxesCombined:LU,ChartNoAxesGantt:gj,ChartPie:yj,ChartScatter:vj,ChartSpline:DU,Check:va,CheckCheck:OU,ChefHat:RU,Cherry:FU,ChevronDown:Eo,ChevronFirst:zU,ChevronLast:BU,ChevronLeft:cl,ChevronRight:da,ChevronUp:pf,ChevronsDown:qU,ChevronsDownUp:$U,ChevronsLeft:HU,ChevronsLeftRight:VU,ChevronsLeftRightEllipsis:UU,ChevronsRight:GU,ChevronsRightLeft:WU,ChevronsUp:KU,ChevronsUpDown:Sx,Chrome:ZU,Church:YU,Cigarette:QU,CigaretteOff:XU,Circle:bd,CircleAlert:kl,CircleArrowDown:bj,CircleArrowLeft:_j,CircleArrowOutDownLeft:wj,CircleArrowOutDownRight:jj,CircleArrowOutUpLeft:Nj,CircleArrowOutUpRight:kj,CircleArrowRight:Sj,CircleArrowUp:Cj,CircleCheck:sa,CircleCheckBig:xi,CircleChevronDown:Mj,CircleChevronLeft:Tj,CircleChevronRight:Aj,CircleChevronUp:Ej,CircleDashed:JU,CircleDivide:Pj,CircleDollarSign:eV,CircleDot:sV,CircleDotDashed:tV,CircleEllipsis:rV,CircleEqual:nV,CircleFadingArrowUp:aV,CircleFadingPlus:iV,CircleGauge:Ij,CircleHelp:Dv,CircleMinus:Lj,CircleOff:oV,CircleParking:Oj,CircleParkingOff:Dj,CirclePause:Rj,CirclePercent:Fj,CirclePlay:pp,CirclePlus:zj,CirclePower:Bj,CircleSlash:lV,CircleSlash2:$j,CircleStop:qj,CircleUser:Vj,CircleUserRound:Uj,CircleX:vc,CircuitBoard:cV,Citrus:dV,Clapperboard:uV,Clipboard:yV,ClipboardCheck:CM,ClipboardCopy:hV,ClipboardList:R_,ClipboardMinus:mV,ClipboardPaste:pV,ClipboardPen:Wj,ClipboardPenLine:Hj,ClipboardPlus:fV,ClipboardType:xV,ClipboardX:gV,Clock:un,Clock1:vV,Clock10:bV,Clock11:_V,Clock12:wV,Clock2:jV,Clock3:NV,Clock4:kV,Clock5:SV,Clock6:CV,Clock7:MV,Clock8:TV,Clock9:AV,ClockAlert:EV,ClockArrowDown:PV,ClockArrowUp:IV,Cloud:KV,CloudAlert:LV,CloudCog:DV,CloudDownload:Gj,CloudDrizzle:OV,CloudFog:RV,CloudHail:FV,CloudLightning:zV,CloudMoon:$V,CloudMoonRain:BV,CloudOff:qV,CloudRain:VV,CloudRainWind:UV,CloudSnow:HV,CloudSun:GV,CloudSunRain:WV,CloudUpload:Kj,Cloudy:ZV,Clover:Kv,Club:YV,Code:X4,CodeXml:Zj,Codepen:XV,Codesandbox:QV,Coffee:Q4,Cog:JV,Coins:eL,Columns2:Yj,Columns3:Xj,Columns4:eH,Combine:tH,Command:sH,Compass:rH,Component:nH,Computer:aH,ConciergeBell:iH,Cone:oH,Construction:lH,Contact:J4,ContactRound:Qj,Container:cH,Contrast:dH,Cookie:uH,CookingPot:hH,Copy:gi,CopyCheck:mH,CopyMinus:pH,CopyPlus:fH,CopySlash:xH,CopyX:gH,Copyleft:yH,Copyright:vH,CornerDownLeft:bH,CornerDownRight:_H,CornerLeftDown:wH,CornerLeftUp:jH,CornerRightDown:NH,CornerRightUp:kH,CornerUpLeft:SH,CornerUpRight:CH,Cpu:MH,CreativeCommons:TH,CreditCard:Cx,Croissant:AH,Crop:EH,Cross:PH,Crosshair:IH,Crown:Dm,Cuboid:LH,CupSoda:DH,Currency:OH,Cylinder:RH,Dam:FH,Database:tL,DatabaseBackup:zH,DatabaseZap:BH,Delete:$H,Dessert:qH,Diameter:UH,Diamond:WH,DiamondMinus:VH,DiamondPercent:Jj,DiamondPlus:HH,Dice1:GH,Dice2:KH,Dice3:ZH,Dice4:YH,Dice5:XH,Dice6:QH,Dices:JH,Diff:eW,Disc:nW,Disc2:tW,Disc3:sW,DiscAlbum:rW,Divide:aW,Dna:oW,DnaOff:iW,Dock:lW,Dog:cW,DollarSign:nc,Donut:dW,DoorClosed:uW,DoorOpen:s1,Dot:hW,Download:yi,DraftingCompass:mW,Drama:pW,Dribbble:fW,Drill:xW,Droplet:gW,Droplets:Yg,Drum:yW,Drumstick:vW,Dumbbell:bW,Ear:wW,EarOff:_W,Earth:eN,EarthLock:jW,Eclipse:NW,Egg:MM,EggFried:kW,EggOff:SW,Ellipsis:px,EllipsisVertical:mx,Equal:TW,EqualApproximately:CW,EqualNot:MW,Eraser:AW,EthernetPort:EW,Euro:PW,Expand:sL,ExternalLink:tn,Eye:On,EyeClosed:IW,EyeOff:kp,Facebook:Su,Factory:LW,Fan:DW,FastForward:OW,Feather:RW,Fence:FW,FerrisWheel:zW,Figma:BW,File:TM,FileArchive:$W,FileAudio:UW,FileAudio2:qW,FileAxis3d:tN,FileBadge:HW,FileBadge2:VW,FileBox:WW,FileChartColumn:rN,FileChartColumnIncreasing:sN,FileChartLine:nN,FileChartPie:aN,FileCheck:KW,FileCheck2:GW,FileClock:ZW,FileCode:XW,FileCode2:YW,FileCog:iN,FileDiff:QW,FileDigit:JW,FileDown:eG,FileHeart:tG,FileImage:F_,FileInput:sG,FileJson:nG,FileJson2:rG,FileKey:iG,FileKey2:aG,FileLock:lG,FileLock2:oG,FileMinus:dG,FileMinus2:cG,FileMusic:uG,FileOutput:hG,FilePen:lN,FilePenLine:oN,FilePlus:pG,FilePlus2:mG,FileQuestion:fG,FileScan:xG,FileSearch:yG,FileSearch2:gG,FileSliders:vG,FileSpreadsheet:r1,FileStack:rL,FileSymlink:bG,FileTerminal:_G,FileText:Sn,FileType:jG,FileType2:wG,FileUp:NG,FileUser:kG,FileVideo:CG,FileVideo2:SG,FileVolume:TG,FileVolume2:MG,FileWarning:AG,FileX:PG,FileX2:EG,Files:IG,Film:gu,Filter:Xg,FilterX:LG,Fingerprint:DG,FireExtinguisher:OG,Fish:zG,FishOff:RG,FishSymbol:FG,Flag:n1,FlagOff:BG,FlagTriangleLeft:$G,FlagTriangleRight:qG,Flame:eh,FlameKindling:UG,Flashlight:HG,FlashlightOff:VG,FlaskConical:z_,FlaskConicalOff:WG,FlaskRound:GG,FlipHorizontal:nL,FlipHorizontal2:KG,FlipVertical:YG,FlipVertical2:ZG,Flower:XG,Flower2:Hg,Focus:QG,FoldHorizontal:JG,FoldVertical:eK,Folder:CK,FolderArchive:tK,FolderCheck:sK,FolderClock:rK,FolderClosed:nK,FolderCode:aK,FolderCog:cN,FolderDot:iK,FolderDown:oK,FolderGit:cK,FolderGit2:lK,FolderHeart:dK,FolderInput:uK,FolderKanban:hK,FolderKey:mK,FolderLock:pK,FolderMinus:fK,FolderOpen:Om,FolderOpenDot:xK,FolderOutput:gK,FolderPen:dN,FolderPlus:yK,FolderRoot:vK,FolderSearch:_K,FolderSearch2:bK,FolderSymlink:wK,FolderSync:jK,FolderTree:NK,FolderUp:kK,FolderX:SK,Folders:MK,Footprints:TK,Forklift:AK,Forward:EK,Frame:PK,Framer:IK,Frown:LK,Fuel:DK,Fullscreen:OK,GalleryHorizontal:FK,GalleryHorizontalEnd:RK,GalleryThumbnails:zK,GalleryVertical:$K,GalleryVerticalEnd:BK,Gamepad:UK,Gamepad2:qK,Gauge:VK,Gavel:HK,Gem:WK,Ghost:eS,Gift:ko,GitBranch:KK,GitBranchPlus:GK,GitCommitHorizontal:uN,GitCommitVertical:ZK,GitCompare:XK,GitCompareArrows:YK,GitFork:QK,GitGraph:JK,GitMerge:eZ,GitPullRequest:iZ,GitPullRequestArrow:tZ,GitPullRequestClosed:sZ,GitPullRequestCreate:nZ,GitPullRequestCreateArrow:rZ,GitPullRequestDraft:aZ,Github:oZ,Gitlab:lZ,GlassWater:cZ,Glasses:dZ,Globe:su,GlobeLock:uZ,Goal:hZ,Grab:mZ,GraduationCap:Kh,Grape:pZ,Grid2x2:mN,Grid2x2Check:fZ,Grid2x2Plus:hN,Grid2x2X:xZ,Grid3x3:nx,Grip:yZ,GripHorizontal:gZ,GripVertical:Cu,Group:vZ,Guitar:bZ,Ham:_Z,Hammer:wZ,Hand:aL,HandCoins:jZ,HandHeart:NZ,HandHelping:pN,HandMetal:kZ,HandPlatter:SZ,Handshake:iL,HardDrive:oL,HardDriveDownload:CZ,HardDriveUpload:MZ,HardHat:TZ,Hash:B_,Haze:AZ,HdmiPort:EZ,Heading:DZ,Heading1:AM,Heading2:EM,Heading3:lL,Heading4:PZ,Heading5:IZ,Heading6:LZ,HeadphoneOff:OZ,Headphones:RZ,Headset:FZ,Heart:ni,HeartCrack:zZ,HeartHandshake:BZ,HeartOff:$Z,HeartPulse:qZ,Heater:UZ,Hexagon:VZ,Highlighter:HZ,History:PM,Hop:GZ,HopOff:WZ,Hospital:KZ,Hotel:ZZ,Hourglass:YZ,House:bn,HousePlug:XZ,HousePlus:QZ,IceCreamBowl:fN,IceCreamCone:xN,IdCard:JZ,Image:gl,ImageDown:eY,ImageMinus:tY,ImageOff:sY,ImagePlay:rY,ImagePlus:a1,ImageUp:nY,ImageUpscale:aY,Images:iY,Import:oY,Inbox:lY,IndentDecrease:gN,IndentIncrease:yN,IndianRupee:cY,Infinity:dY,Info:cL,InspectionPanel:uY,Instagram:Mu,Italic:tS,IterationCcw:hY,IterationCw:mY,JapaneseYen:pY,Joystick:fY,Kanban:h0,Key:Sp,KeyRound:sS,KeySquare:xY,Keyboard:vY,KeyboardMusic:gY,KeyboardOff:yY,Lamp:kY,LampCeiling:bY,LampDesk:_Y,LampFloor:wY,LampWallDown:jY,LampWallUp:NY,LandPlot:SY,Landmark:CY,Languages:MY,Laptop:AY,LaptopMinimal:vN,LaptopMinimalCheck:TY,Lasso:PY,LassoSelect:EY,Laugh:IY,Layers:IM,Layers2:LY,Layers3:DY,LayoutDashboard:rS,LayoutGrid:Cp,LayoutList:OY,LayoutPanelLeft:RY,LayoutPanelTop:FY,LayoutTemplate:nS,Leaf:zY,LeafyGreen:BY,Lectern:$Y,LetterText:qY,Library:LM,LibraryBig:UY,LifeBuoy:DM,Ligature:VY,Lightbulb:$_,LightbulbOff:HY,Link:Bo,Link2:dl,Link2Off:WY,Linkedin:Mp,List:Mh,ListCheck:GY,ListChecks:KY,ListCollapse:ZY,ListEnd:YY,ListFilter:XY,ListMinus:QY,ListMusic:JY,ListOrdered:m0,ListPlus:eX,ListRestart:tX,ListStart:sX,ListTodo:rX,ListTree:nX,ListVideo:aX,ListX:iX,Loader:lX,LoaderCircle:ws,LoaderPinwheel:oX,Locate:uX,LocateFixed:cX,LocateOff:dX,Lock:Th,LockKeyhole:hX,LockKeyholeOpen:bN,LockOpen:_N,LogIn:aS,LogOut:iS,Logs:mX,Lollipop:pX,Luggage:fX,Magnet:xX,Mail:cr,MailCheck:gX,MailMinus:yX,MailOpen:vX,MailPlus:dL,MailQuestion:bX,MailSearch:_X,MailWarning:wX,MailX:uL,Mailbox:jX,Mails:NX,Map:i1,MapPin:ma,MapPinCheck:SX,MapPinCheckInside:kX,MapPinHouse:CX,MapPinMinus:TX,MapPinMinusInside:MX,MapPinOff:AX,MapPinPlus:PX,MapPinPlusInside:EX,MapPinX:LX,MapPinXInside:IX,MapPinned:DX,Martini:OX,Maximize:oS,Maximize2:RX,Medal:o1,Megaphone:Ah,MegaphoneOff:FX,Meh:zX,MemoryStick:BX,Menu:OM,Merge:$X,MessageCircle:$c,MessageCircleCode:qX,MessageCircleDashed:UX,MessageCircleHeart:RM,MessageCircleMore:VX,MessageCircleOff:HX,MessageCirclePlus:WX,MessageCircleQuestion:hL,MessageCircleReply:GX,MessageCircleWarning:KX,MessageCircleX:ZX,MessageSquare:so,MessageSquareCode:YX,MessageSquareDashed:XX,MessageSquareDiff:QX,MessageSquareDot:JX,MessageSquareHeart:eQ,MessageSquareLock:tQ,MessageSquareMore:mL,MessageSquareOff:sQ,MessageSquarePlus:FM,MessageSquareQuote:pL,MessageSquareReply:rQ,MessageSquareShare:nQ,MessageSquareText:aQ,MessageSquareWarning:iQ,MessageSquareX:oQ,MessagesSquare:lQ,Mic:fL,MicOff:cQ,MicVocal:wN,Microchip:dQ,Microscope:uQ,Microwave:hQ,Milestone:mQ,Milk:fQ,MilkOff:pQ,Minimize:gQ,Minimize2:xQ,Minus:p0,Monitor:cS,MonitorCheck:yQ,MonitorCog:vQ,MonitorDot:bQ,MonitorDown:_Q,MonitorOff:wQ,MonitorPause:jQ,MonitorPlay:NQ,MonitorSmartphone:kQ,MonitorSpeaker:SQ,MonitorStop:CQ,MonitorUp:lS,MonitorX:MQ,Moon:AQ,MoonStar:TQ,Mountain:PQ,MountainSnow:EQ,Mouse:OQ,MouseOff:IQ,MousePointer:wh,MousePointer2:LQ,MousePointerBan:DQ,MousePointerClick:Qg,Move:ZQ,Move3d:jN,MoveDiagonal:FQ,MoveDiagonal2:RQ,MoveDown:$Q,MoveDownLeft:zQ,MoveDownRight:BQ,MoveHorizontal:qQ,MoveLeft:UQ,MoveRight:VQ,MoveUp:GQ,MoveUpLeft:HQ,MoveUpRight:WQ,MoveVertical:KQ,Music:JQ,Music2:YQ,Music3:XQ,Music4:QQ,Navigation:rJ,Navigation2:tJ,Navigation2Off:eJ,NavigationOff:sJ,Network:nJ,Newspaper:l1,Nfc:aJ,Notebook:cJ,NotebookPen:iJ,NotebookTabs:oJ,NotebookText:lJ,NotepadText:uJ,NotepadTextDashed:dJ,Nut:mJ,NutOff:hJ,Octagon:fJ,OctagonAlert:Ov,OctagonMinus:pJ,OctagonPause:NN,OctagonX:kN,Omega:xJ,Option:gJ,Orbit:yJ,Origami:vJ,Package:Ml,Package2:bJ,PackageCheck:_J,PackageMinus:wJ,PackageOpen:jJ,PackagePlus:NJ,PackageSearch:kJ,PackageX:SJ,PaintBucket:CJ,PaintRoller:MJ,Paintbrush:TJ,PaintbrushVertical:SN,Palette:ac,PanelBottom:PJ,PanelBottomClose:AJ,PanelBottomDashed:CN,PanelBottomOpen:EJ,PanelLeft:EN,PanelLeftClose:MN,PanelLeftDashed:TN,PanelLeftOpen:AN,PanelRight:DJ,PanelRightClose:IJ,PanelRightDashed:PN,PanelRightOpen:LJ,PanelTop:FJ,PanelTopClose:OJ,PanelTopDashed:IN,PanelTopOpen:RJ,PanelsLeftBottom:zJ,PanelsRightBottom:BJ,PanelsTopLeft:Rv,Paperclip:dS,Parentheses:$J,ParkingMeter:qJ,PartyPopper:ru,Pause:Rm,PawPrint:UJ,PcCase:VJ,Pen:Jy,PenLine:Fv,PenOff:HJ,PenTool:q_,Pencil:Ra,PencilLine:WJ,PencilOff:GJ,PencilRuler:KJ,Pentagon:ZJ,Percent:uS,PersonStanding:YJ,PhilippinePeso:XJ,Phone:Un,PhoneCall:QJ,PhoneForwarded:JJ,PhoneIncoming:eee,PhoneMissed:tee,PhoneOff:see,PhoneOutgoing:ree,Pi:nee,Piano:aee,Pickaxe:iee,PictureInPicture:lee,PictureInPicture2:oee,PiggyBank:cee,Pilcrow:hee,PilcrowLeft:dee,PilcrowRight:uee,Pill:pee,PillBottle:mee,Pin:U_,PinOff:xL,Pipette:fee,Pizza:xee,Plane:vee,PlaneLanding:gee,PlaneTakeoff:yee,Play:nl,Plug:gL,Plug2:bee,PlugZap:LN,Plus:$s,Pocket:wee,PocketKnife:_ee,Podcast:jee,Pointer:kee,PointerOff:Nee,Popcorn:See,Popsicle:Cee,PoundSterling:Mee,Power:yL,PowerOff:Tee,Presentation:Jg,Printer:vL,PrinterCheck:Aee,Projector:Eee,Proportions:Pee,Puzzle:Iee,Pyramid:Lee,QrCode:c1,Quote:V_,Rabbit:Dee,Radar:Oee,Radiation:Ree,Radical:Fee,Radio:d1,RadioReceiver:zee,RadioTower:Bee,Radius:$ee,RailSymbol:qee,Rainbow:Uee,Rat:Vee,Ratio:Hee,Receipt:ete,ReceiptCent:Wee,ReceiptEuro:Gee,ReceiptIndianRupee:Kee,ReceiptJapaneseYen:Zee,ReceiptPoundSterling:Yee,ReceiptRussianRuble:Xee,ReceiptSwissFranc:Qee,ReceiptText:Jee,RectangleEllipsis:DN,RectangleHorizontal:tte,RectangleVertical:ste,Recycle:rte,Redo:hS,Redo2:nte,RedoDot:ate,RefreshCcw:zM,RefreshCcwDot:ite,RefreshCw:Go,RefreshCwOff:ote,Refrigerator:lte,Regex:cte,RemoveFormatting:dte,Repeat:bL,Repeat1:ute,Repeat2:hte,Replace:pte,ReplaceAll:mte,Reply:_L,ReplyAll:fte,Rewind:xte,Ribbon:gte,Rocket:f0,RockingChair:yte,RollerCoaster:vte,Rotate3d:ON,RotateCcw:u1,RotateCcwSquare:bte,RotateCw:wL,RotateCwSquare:_te,Route:jte,RouteOff:wte,Router:Nte,Rows2:RN,Rows3:FN,Rows4:kte,Rss:Ste,Ruler:x0,RussianRuble:Cte,Sailboat:Mte,Salad:Tte,Sandwich:Ate,Satellite:Pte,SatelliteDish:Ete,Save:qc,SaveAll:Ite,SaveOff:Lte,Scale:jL,Scale3d:zN,Scaling:Dte,Scan:Ute,ScanBarcode:Ote,ScanEye:Rte,ScanFace:Fte,ScanLine:zte,ScanQrCode:Bte,ScanSearch:$te,ScanText:qte,School:Vte,Scissors:Wte,ScissorsLineDashed:Hte,ScreenShare:Kte,ScreenShareOff:Gte,Scroll:Yte,ScrollText:Zte,Search:cn,SearchCheck:Xte,SearchCode:Qte,SearchSlash:Jte,SearchX:NL,Section:ese,Send:Bn,SendHorizontal:BN,SendToBack:tse,SeparatorHorizontal:sse,SeparatorVertical:rse,Server:ose,ServerCog:nse,ServerCrash:ase,ServerOff:ise,Settings:Xo,Settings2:kL,Shapes:lse,Share:SL,Share2:_d,Sheet:cse,Shell:dse,Shield:th,ShieldAlert:use,ShieldBan:hse,ShieldCheck:CL,ShieldEllipsis:mse,ShieldHalf:pse,ShieldMinus:fse,ShieldOff:xse,ShieldPlus:gse,ShieldQuestion:yse,ShieldX:$N,Ship:bse,ShipWheel:vse,Shirt:_se,ShoppingBag:g0,ShoppingBasket:wse,ShoppingCart:vp,Shovel:jse,ShowerHead:Nse,Shrink:kse,Shrub:Sse,Shuffle:mS,Sigma:Cse,Signal:Pse,SignalHigh:Mse,SignalLow:Tse,SignalMedium:Ase,SignalZero:Ese,Signature:Ise,Signpost:Dse,SignpostBig:Lse,Siren:Ose,SkipBack:Rse,SkipForward:Fse,Skull:zse,Slack:Bse,Slash:$se,Slice:qse,SlidersHorizontal:H_,SlidersVertical:qN,Smartphone:h1,SmartphoneCharging:Use,SmartphoneNfc:Vse,Smile:Wse,SmilePlus:Hse,Snail:Gse,Snowflake:n0,Sofa:Kse,Soup:Zse,Space:Yse,Spade:Xse,Sparkle:Qse,Sparkles:pn,Speaker:Jse,Speech:ere,SpellCheck:sre,SpellCheck2:tre,Spline:rre,Split:nre,SprayCan:are,Sprout:ire,Square:y0,SquareActivity:UN,SquareArrowDown:WN,SquareArrowDownLeft:VN,SquareArrowDownRight:HN,SquareArrowLeft:GN,SquareArrowOutDownLeft:KN,SquareArrowOutDownRight:ZN,SquareArrowOutUpLeft:YN,SquareArrowOutUpRight:XN,SquareArrowRight:QN,SquareArrowUp:tk,SquareArrowUpLeft:JN,SquareArrowUpRight:ek,SquareAsterisk:sk,SquareBottomDashedScissors:rk,SquareChartGantt:Uy,SquareCheck:nk,SquareCheckBig:zv,SquareChevronDown:ak,SquareChevronLeft:ik,SquareChevronRight:ok,SquareChevronUp:lk,SquareCode:ck,SquareDashed:hk,SquareDashedBottom:lre,SquareDashedBottomCode:ore,SquareDashedKanban:dk,SquareDashedMousePointer:uk,SquareDivide:mk,SquareDot:pk,SquareEqual:fk,SquareFunction:xk,SquareKanban:gk,SquareLibrary:yk,SquareM:vk,SquareMenu:bk,SquareMinus:_k,SquareMousePointer:wk,SquareParking:Nk,SquareParkingOff:jk,SquarePen:ud,SquarePercent:kk,SquarePi:Sk,SquarePilcrow:Ck,SquarePlay:Mk,SquarePlus:Tk,SquarePower:Ak,SquareRadical:cre,SquareScissors:Ek,SquareSigma:Pk,SquareSlash:Ik,SquareSplitHorizontal:Lk,SquareSplitVertical:Dk,SquareSquare:dre,SquareStack:ure,SquareTerminal:Ok,SquareUser:Fk,SquareUserRound:Rk,SquareX:zk,Squircle:hre,Squirrel:mre,Stamp:pre,Star:Jn,StarHalf:fre,StarOff:xre,StepBack:gre,StepForward:yre,Stethoscope:vre,Sticker:bre,StickyNote:_re,Store:BM,StretchHorizontal:wre,StretchVertical:jre,Strikethrough:ML,Subscript:Nre,Sun:m1,SunDim:kre,SunMedium:Sre,SunMoon:Cre,SunSnow:Mre,Sunrise:Tre,Sunset:Are,Superscript:Ere,SwatchBook:Pre,SwissFranc:Ire,SwitchCamera:Lre,Sword:Dre,Swords:Ore,Syringe:Rre,Table:qM,Table2:$M,TableCellsMerge:Fre,TableCellsSplit:zre,TableColumnsSplit:Bre,TableOfContents:$re,TableProperties:qre,TableRowsSplit:Ure,Tablet:Hre,TabletSmartphone:Vre,Tablets:Wre,Tag:Fm,Tags:Gre,Tally1:Kre,Tally2:Zre,Tally3:Yre,Tally4:Xre,Tally5:Qre,Tangent:Jre,Target:zm,Telescope:ene,Tent:sne,TentTree:tne,Terminal:rne,TestTube:nne,TestTubeDiagonal:Bk,TestTubes:ane,Text:dne,TextCursor:one,TextCursorInput:ine,TextQuote:lne,TextSearch:cne,TextSelect:$k,Theater:une,Thermometer:TL,ThermometerSnowflake:hne,ThermometerSun:mne,ThumbsDown:AL,ThumbsUp:sh,Ticket:EL,TicketCheck:pne,TicketMinus:fne,TicketPercent:xne,TicketPlus:gne,TicketSlash:yne,TicketX:vne,Tickets:_ne,TicketsPlane:bne,Timer:Nne,TimerOff:wne,TimerReset:jne,ToggleLeft:kne,ToggleRight:Sne,Toilet:Cne,Tornado:Mne,Torus:Tne,Touchpad:Ene,TouchpadOff:Ane,TowerControl:Pne,ToyBrick:Ine,Tractor:Lne,TrafficCone:Dne,TrainFront:Rne,TrainFrontTunnel:One,TrainTrack:Fne,TramFront:qk,Trash:zne,Trash2:Nr,TreeDeciduous:Bne,TreePalm:Uk,TreePine:p1,Trees:$ne,Trello:qne,TrendingDown:pS,TrendingUp:ul,TrendingUpDown:Une,Triangle:Hne,TriangleAlert:Ku,TriangleRight:Vne,Trophy:xo,Truck:PL,Turtle:Wne,Tv:Kne,TvMinimal:Vk,TvMinimalPlay:Gne,Twitch:Zne,Twitter:Yne,Type:Qne,TypeOutline:Xne,Umbrella:eae,UmbrellaOff:Jne,Underline:IL,Undo:fS,Undo2:tae,UndoDot:sae,UnfoldHorizontal:rae,UnfoldVertical:nae,Ungroup:aae,University:Hk,Unlink:xS,Unlink2:iae,Unplug:oae,Upload:li,Usb:lae,User:to,UserCheck:W_,UserCog:LL,UserMinus:DL,UserPen:cae,UserPlus:Tl,UserRound:Xk,UserRoundCheck:Wk,UserRoundCog:Gk,UserRoundMinus:Kk,UserRoundPen:dae,UserRoundPlus:Zk,UserRoundSearch:uae,UserRoundX:Yk,UserSearch:hae,UserX:mae,Users:pr,UsersRound:Qk,Utensils:e4,UtensilsCrossed:Jk,UtilityPole:pae,Variable:UM,Vault:fae,Vegan:xae,VenetianMask:gae,Vibrate:vae,VibrateOff:yae,Video:An,VideoOff:bae,Videotape:_ae,View:wae,Voicemail:jae,Volleyball:Nae,Volume:Tae,Volume1:kae,Volume2:Sae,VolumeOff:Cae,VolumeX:Mae,Vote:Aae,Wallet:OL,WalletCards:Eae,WalletMinimal:t4,Wallpaper:Pae,Wand:Iae,WandSparkles:Bv,Warehouse:Lae,WashingMachine:Dae,Watch:Oae,Waves:RL,Waypoints:Rae,Webcam:Fae,Webhook:Bae,WebhookOff:zae,Weight:$ae,Wheat:Uae,WheatOff:qae,WholeWord:Vae,Wifi:Zae,WifiHigh:Hae,WifiLow:Wae,WifiOff:Gae,WifiZero:Kae,Wind:Xae,WindArrowDown:Yae,Wine:Jae,WineOff:Qae,Workflow:eie,Worm:tie,WrapText:sie,Wrench:ey,X:Rr,Youtube:rie,Zap:Zh,ZapOff:nie,ZoomIn:G_,ZoomOut:VM},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 x2e=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:v9,AArrowDownIcon:v9,AArrowUp:b9,AArrowUpIcon:b9,ALargeSmall:_9,ALargeSmallIcon:_9,Accessibility:w9,AccessibilityIcon:w9,Activity:kh,ActivityIcon:kh,ActivitySquare:UN,ActivitySquareIcon:UN,AirVent:j9,AirVentIcon:j9,Airplay:N9,AirplayIcon:N9,AlarmCheck:W2,AlarmCheckIcon:W2,AlarmClock:S9,AlarmClockCheck:W2,AlarmClockCheckIcon:W2,AlarmClockIcon:S9,AlarmClockMinus:G2,AlarmClockMinusIcon:G2,AlarmClockOff:k9,AlarmClockOffIcon:k9,AlarmClockPlus:K2,AlarmClockPlusIcon:K2,AlarmMinus:G2,AlarmMinusIcon:G2,AlarmPlus:K2,AlarmPlusIcon:K2,AlarmSmoke:C9,AlarmSmokeIcon:C9,Album:M9,AlbumIcon:M9,AlertCircle:kl,AlertCircleIcon:kl,AlertOctagon:Ov,AlertOctagonIcon:Ov,AlertTriangle:Ku,AlertTriangleIcon:Ku,AlignCenter:H4,AlignCenterHorizontal:T9,AlignCenterHorizontalIcon:T9,AlignCenterIcon:H4,AlignCenterVertical:A9,AlignCenterVerticalIcon:A9,AlignEndHorizontal:E9,AlignEndHorizontalIcon:E9,AlignEndVertical:P9,AlignEndVerticalIcon:P9,AlignHorizontalDistributeCenter:I9,AlignHorizontalDistributeCenterIcon:I9,AlignHorizontalDistributeEnd:L9,AlignHorizontalDistributeEndIcon:L9,AlignHorizontalDistributeStart:D9,AlignHorizontalDistributeStartIcon:D9,AlignHorizontalJustifyCenter:O9,AlignHorizontalJustifyCenterIcon:O9,AlignHorizontalJustifyEnd:R9,AlignHorizontalJustifyEndIcon:R9,AlignHorizontalJustifyStart:F9,AlignHorizontalJustifyStartIcon:F9,AlignHorizontalSpaceAround:z9,AlignHorizontalSpaceAroundIcon:z9,AlignHorizontalSpaceBetween:B9,AlignHorizontalSpaceBetweenIcon:B9,AlignJustify:$9,AlignJustifyIcon:$9,AlignLeft:W4,AlignLeftIcon:W4,AlignRight:G4,AlignRightIcon:G4,AlignStartHorizontal:q9,AlignStartHorizontalIcon:q9,AlignStartVertical:U9,AlignStartVerticalIcon:U9,AlignVerticalDistributeCenter:V9,AlignVerticalDistributeCenterIcon:V9,AlignVerticalDistributeEnd:H9,AlignVerticalDistributeEndIcon:H9,AlignVerticalDistributeStart:W9,AlignVerticalDistributeStartIcon:W9,AlignVerticalJustifyCenter:G9,AlignVerticalJustifyCenterIcon:G9,AlignVerticalJustifyEnd:K9,AlignVerticalJustifyEndIcon:K9,AlignVerticalJustifyStart:Z9,AlignVerticalJustifyStartIcon:Z9,AlignVerticalSpaceAround:Y9,AlignVerticalSpaceAroundIcon:Y9,AlignVerticalSpaceBetween:X9,AlignVerticalSpaceBetweenIcon:X9,Ambulance:Q9,AmbulanceIcon:Q9,Ampersand:J9,AmpersandIcon:J9,Ampersands:eB,AmpersandsIcon:eB,Amphora:tB,AmphoraIcon:tB,Anchor:sB,AnchorIcon:sB,Angry:rB,AngryIcon:rB,Annoyed:nB,AnnoyedIcon:nB,Antenna:aB,AntennaIcon:aB,Anvil:iB,AnvilIcon:iB,Aperture:oB,ApertureIcon:oB,AppWindow:UI,AppWindowIcon:UI,AppWindowMac:lB,AppWindowMacIcon:lB,Apple:cB,AppleIcon:cB,Archive:NM,ArchiveIcon:NM,ArchiveRestore:VI,ArchiveRestoreIcon:VI,ArchiveX:dB,ArchiveXIcon:dB,AreaChart:lj,AreaChartIcon:lj,Armchair:uB,ArmchairIcon:uB,ArrowBigDown:mB,ArrowBigDownDash:hB,ArrowBigDownDashIcon:hB,ArrowBigDownIcon:mB,ArrowBigLeft:fB,ArrowBigLeftDash:pB,ArrowBigLeftDashIcon:pB,ArrowBigLeftIcon:fB,ArrowBigRight:gB,ArrowBigRightDash:xB,ArrowBigRightDashIcon:xB,ArrowBigRightIcon:gB,ArrowBigUp:vB,ArrowBigUpDash:yB,ArrowBigUpDashIcon:yB,ArrowBigUpIcon:vB,ArrowDown:Wh,ArrowDown01:bB,ArrowDown01Icon:bB,ArrowDown10:_B,ArrowDown10Icon:_B,ArrowDownAZ:Z2,ArrowDownAZIcon:Z2,ArrowDownAz:Z2,ArrowDownAzIcon:Z2,ArrowDownCircle:bj,ArrowDownCircleIcon:bj,ArrowDownFromLine:wB,ArrowDownFromLineIcon:wB,ArrowDownIcon:Wh,ArrowDownLeft:jB,ArrowDownLeftFromCircle:wj,ArrowDownLeftFromCircleIcon:wj,ArrowDownLeftFromSquare:KN,ArrowDownLeftFromSquareIcon:KN,ArrowDownLeftIcon:jB,ArrowDownLeftSquare:VN,ArrowDownLeftSquareIcon:VN,ArrowDownNarrowWide:NB,ArrowDownNarrowWideIcon:NB,ArrowDownRight:HI,ArrowDownRightFromCircle:jj,ArrowDownRightFromCircleIcon:jj,ArrowDownRightFromSquare:ZN,ArrowDownRightFromSquareIcon:ZN,ArrowDownRightIcon:HI,ArrowDownRightSquare:HN,ArrowDownRightSquareIcon:HN,ArrowDownSquare:WN,ArrowDownSquareIcon:WN,ArrowDownToDot:kB,ArrowDownToDotIcon:kB,ArrowDownToLine:SB,ArrowDownToLineIcon:SB,ArrowDownUp:CB,ArrowDownUpIcon:CB,ArrowDownWideNarrow:Y2,ArrowDownWideNarrowIcon:Y2,ArrowDownZA:X2,ArrowDownZAIcon:X2,ArrowDownZa:X2,ArrowDownZaIcon:X2,ArrowLeft:Ja,ArrowLeftCircle:_j,ArrowLeftCircleIcon:_j,ArrowLeftFromLine:MB,ArrowLeftFromLineIcon:MB,ArrowLeftIcon:Ja,ArrowLeftRight:TB,ArrowLeftRightIcon:TB,ArrowLeftSquare:GN,ArrowLeftSquareIcon:GN,ArrowLeftToLine:AB,ArrowLeftToLineIcon:AB,ArrowRight:Qa,ArrowRightCircle:Sj,ArrowRightCircleIcon:Sj,ArrowRightFromLine:EB,ArrowRightFromLineIcon:EB,ArrowRightIcon:Qa,ArrowRightLeft:e1,ArrowRightLeftIcon:e1,ArrowRightSquare:QN,ArrowRightSquareIcon:QN,ArrowRightToLine:PB,ArrowRightToLineIcon:PB,ArrowUp:ku,ArrowUp01:IB,ArrowUp01Icon:IB,ArrowUp10:LB,ArrowUp10Icon:LB,ArrowUpAZ:Q2,ArrowUpAZIcon:Q2,ArrowUpAz:Q2,ArrowUpAzIcon:Q2,ArrowUpCircle:Cj,ArrowUpCircleIcon:Cj,ArrowUpDown:vd,ArrowUpDownIcon:vd,ArrowUpFromDot:DB,ArrowUpFromDotIcon:DB,ArrowUpFromLine:OB,ArrowUpFromLineIcon:OB,ArrowUpIcon:ku,ArrowUpLeft:RB,ArrowUpLeftFromCircle:Nj,ArrowUpLeftFromCircleIcon:Nj,ArrowUpLeftFromSquare:YN,ArrowUpLeftFromSquareIcon:YN,ArrowUpLeftIcon:RB,ArrowUpLeftSquare:JN,ArrowUpLeftSquareIcon:JN,ArrowUpNarrowWide:J2,ArrowUpNarrowWideIcon:J2,ArrowUpRight:WI,ArrowUpRightFromCircle:kj,ArrowUpRightFromCircleIcon:kj,ArrowUpRightFromSquare:XN,ArrowUpRightFromSquareIcon:XN,ArrowUpRightIcon:WI,ArrowUpRightSquare:ek,ArrowUpRightSquareIcon:ek,ArrowUpSquare:tk,ArrowUpSquareIcon:tk,ArrowUpToLine:FB,ArrowUpToLineIcon:FB,ArrowUpWideNarrow:zB,ArrowUpWideNarrowIcon:zB,ArrowUpZA:ej,ArrowUpZAIcon:ej,ArrowUpZa:ej,ArrowUpZaIcon:ej,ArrowsUpFromLine:BB,ArrowsUpFromLineIcon:BB,Asterisk:$B,AsteriskIcon:$B,AsteriskSquare:sk,AsteriskSquareIcon:sk,AtSign:qB,AtSignIcon:qB,Atom:UB,AtomIcon:UB,AudioLines:VB,AudioLinesIcon:VB,AudioWaveform:HB,AudioWaveformIcon:HB,Award:Nc,AwardIcon:Nc,Axe:WB,AxeIcon:WB,Axis3D:tj,Axis3DIcon:tj,Axis3d:tj,Axis3dIcon:tj,Baby:GB,BabyIcon:GB,Backpack:KB,BackpackIcon:KB,Badge:d$,BadgeAlert:ZB,BadgeAlertIcon:ZB,BadgeCent:YB,BadgeCentIcon:YB,BadgeCheck:sj,BadgeCheckIcon:sj,BadgeDollarSign:XB,BadgeDollarSignIcon:XB,BadgeEuro:QB,BadgeEuroIcon:QB,BadgeHelp:JB,BadgeHelpIcon:JB,BadgeIcon:d$,BadgeIndianRupee:e$,BadgeIndianRupeeIcon:e$,BadgeInfo:t$,BadgeInfoIcon:t$,BadgeJapaneseYen:s$,BadgeJapaneseYenIcon:s$,BadgeMinus:r$,BadgeMinusIcon:r$,BadgePercent:n$,BadgePercentIcon:n$,BadgePlus:a$,BadgePlusIcon:a$,BadgePoundSterling:i$,BadgePoundSterlingIcon:i$,BadgeRussianRuble:o$,BadgeRussianRubleIcon:o$,BadgeSwissFranc:l$,BadgeSwissFrancIcon:l$,BadgeX:c$,BadgeXIcon:c$,BaggageClaim:u$,BaggageClaimIcon:u$,Ban:GI,BanIcon:GI,Banana:h$,BananaIcon:h$,Bandage:m$,BandageIcon:m$,Banknote:p$,BanknoteIcon:p$,BarChart:fj,BarChart2:xj,BarChart2Icon:xj,BarChart3:No,BarChart3Icon:No,BarChart4:mj,BarChart4Icon:mj,BarChartBig:hj,BarChartBigIcon:hj,BarChartHorizontal:dj,BarChartHorizontalBig:cj,BarChartHorizontalBigIcon:cj,BarChartHorizontalIcon:dj,BarChartIcon:fj,Barcode:f$,BarcodeIcon:f$,Baseline:x$,BaselineIcon:x$,Bath:Ju,BathIcon:Ju,Battery:w$,BatteryCharging:g$,BatteryChargingIcon:g$,BatteryFull:y$,BatteryFullIcon:y$,BatteryIcon:w$,BatteryLow:v$,BatteryLowIcon:v$,BatteryMedium:b$,BatteryMediumIcon:b$,BatteryWarning:_$,BatteryWarningIcon:_$,Beaker:j$,BeakerIcon:j$,Bean:k$,BeanIcon:k$,BeanOff:N$,BeanOffIcon:N$,Bed:Im,BedDouble:K4,BedDoubleIcon:K4,BedIcon:Im,BedSingle:S$,BedSingleIcon:S$,Beef:C$,BeefIcon:C$,Beer:T$,BeerIcon:T$,BeerOff:M$,BeerOffIcon:M$,Bell:Lm,BellDot:A$,BellDotIcon:A$,BellElectric:E$,BellElectricIcon:E$,BellIcon:Lm,BellMinus:P$,BellMinusIcon:P$,BellOff:t1,BellOffIcon:t1,BellPlus:I$,BellPlusIcon:I$,BellRing:L$,BellRingIcon:L$,BetweenHorizonalEnd:rj,BetweenHorizonalEndIcon:rj,BetweenHorizonalStart:nj,BetweenHorizonalStartIcon:nj,BetweenHorizontalEnd:rj,BetweenHorizontalEndIcon:rj,BetweenHorizontalStart:nj,BetweenHorizontalStartIcon:nj,BetweenVerticalEnd:D$,BetweenVerticalEndIcon:D$,BetweenVerticalStart:O$,BetweenVerticalStartIcon:O$,BicepsFlexed:R$,BicepsFlexedIcon:R$,Bike:F$,BikeIcon:F$,Binary:z$,BinaryIcon:z$,Binoculars:B$,BinocularsIcon:B$,Biohazard:$$,BiohazardIcon:$$,Bird:q$,BirdIcon:q$,Bitcoin:U$,BitcoinIcon:U$,Blend:V$,BlendIcon:V$,Blinds:H$,BlindsIcon:H$,Blocks:W$,BlocksIcon:W$,Bluetooth:Y$,BluetoothConnected:G$,BluetoothConnectedIcon:G$,BluetoothIcon:Y$,BluetoothOff:K$,BluetoothOffIcon:K$,BluetoothSearching:Z$,BluetoothSearchingIcon:Z$,Bold:Z4,BoldIcon:Z4,Bolt:X$,BoltIcon:X$,Bomb:Q$,BombIcon:Q$,Bone:J$,BoneIcon:J$,Book:_q,BookA:eq,BookAIcon:eq,BookAudio:tq,BookAudioIcon:tq,BookCheck:sq,BookCheckIcon:sq,BookCopy:rq,BookCopyIcon:rq,BookDashed:aj,BookDashedIcon:aj,BookDown:nq,BookDownIcon:nq,BookHeadphones:aq,BookHeadphonesIcon:aq,BookHeart:iq,BookHeartIcon:iq,BookIcon:_q,BookImage:oq,BookImageIcon:oq,BookKey:lq,BookKeyIcon:lq,BookLock:cq,BookLockIcon:cq,BookMarked:dq,BookMarkedIcon:dq,BookMinus:uq,BookMinusIcon:uq,BookOpen:Sh,BookOpenCheck:hq,BookOpenCheckIcon:hq,BookOpenIcon:Sh,BookOpenText:mq,BookOpenTextIcon:mq,BookPlus:pq,BookPlusIcon:pq,BookTemplate:aj,BookTemplateIcon:aj,BookText:fq,BookTextIcon:fq,BookType:xq,BookTypeIcon:xq,BookUp:yq,BookUp2:gq,BookUp2Icon:gq,BookUpIcon:yq,BookUser:vq,BookUserIcon:vq,BookX:bq,BookXIcon:bq,Bookmark:Nx,BookmarkCheck:wq,BookmarkCheckIcon:wq,BookmarkIcon:Nx,BookmarkMinus:jq,BookmarkMinusIcon:jq,BookmarkPlus:KI,BookmarkPlusIcon:KI,BookmarkX:Nq,BookmarkXIcon:Nq,BoomBox:kq,BoomBoxIcon:kq,Bot:kM,BotIcon:kM,BotMessageSquare:Sq,BotMessageSquareIcon:Sq,BotOff:Cq,BotOffIcon:Cq,Box:Mq,BoxIcon:Mq,BoxSelect:hk,BoxSelectIcon:hk,Boxes:Tq,BoxesIcon:Tq,Braces:ij,BracesIcon:ij,Brackets:Aq,BracketsIcon:Aq,Brain:ZI,BrainCircuit:Eq,BrainCircuitIcon:Eq,BrainCog:Pq,BrainCogIcon:Pq,BrainIcon:ZI,BrickWall:Iq,BrickWallIcon:Iq,Briefcase:Gh,BriefcaseBusiness:Lq,BriefcaseBusinessIcon:Lq,BriefcaseConveyorBelt:Dq,BriefcaseConveyorBeltIcon:Dq,BriefcaseIcon:Gh,BriefcaseMedical:Oq,BriefcaseMedicalIcon:Oq,BringToFront:Rq,BringToFrontIcon:Rq,Brush:Fq,BrushIcon:Fq,Bug:$q,BugIcon:$q,BugOff:zq,BugOffIcon:zq,BugPlay:Bq,BugPlayIcon:Bq,Building:Y4,Building2:ka,Building2Icon:ka,BuildingIcon:Y4,Bus:Uq,BusFront:qq,BusFrontIcon:qq,BusIcon:Uq,Cable:Hq,CableCar:Vq,CableCarIcon:Vq,CableIcon:Hq,Cake:Ch,CakeIcon:Ch,CakeSlice:Wq,CakeSliceIcon:Wq,Calculator:YI,CalculatorIcon:YI,Calendar:hn,Calendar1:Gq,Calendar1Icon:Gq,CalendarArrowDown:Kq,CalendarArrowDownIcon:Kq,CalendarArrowUp:Zq,CalendarArrowUpIcon:Zq,CalendarCheck:XI,CalendarCheck2:Yq,CalendarCheck2Icon:Yq,CalendarCheckIcon:XI,CalendarClock:QI,CalendarClockIcon:QI,CalendarCog:Xq,CalendarCogIcon:Xq,CalendarDays:Dd,CalendarDaysIcon:Dd,CalendarFold:Qq,CalendarFoldIcon:Qq,CalendarHeart:Jq,CalendarHeartIcon:Jq,CalendarIcon:hn,CalendarMinus:tU,CalendarMinus2:eU,CalendarMinus2Icon:eU,CalendarMinusIcon:tU,CalendarOff:JI,CalendarOffIcon:JI,CalendarPlus:O_,CalendarPlus2:sU,CalendarPlus2Icon:sU,CalendarPlusIcon:O_,CalendarRange:rU,CalendarRangeIcon:rU,CalendarSearch:nU,CalendarSearchIcon:nU,CalendarSync:aU,CalendarSyncIcon:aU,CalendarX:oU,CalendarX2:iU,CalendarX2Icon:iU,CalendarXIcon:oU,Camera:kx,CameraIcon:kx,CameraOff:lU,CameraOffIcon:lU,CandlestickChart:uj,CandlestickChartIcon:uj,Candy:uU,CandyCane:cU,CandyCaneIcon:cU,CandyIcon:uU,CandyOff:dU,CandyOffIcon:dU,Cannabis:hU,CannabisIcon:hU,Captions:oj,CaptionsIcon:oj,CaptionsOff:mU,CaptionsOffIcon:mU,Car:SM,CarFront:pU,CarFrontIcon:pU,CarIcon:SM,CarTaxiFront:fU,CarTaxiFrontIcon:fU,Caravan:xU,CaravanIcon:xU,Carrot:gU,CarrotIcon:gU,CaseLower:yU,CaseLowerIcon:yU,CaseSensitive:vU,CaseSensitiveIcon:vU,CaseUpper:bU,CaseUpperIcon:bU,CassetteTape:_U,CassetteTapeIcon:_U,Cast:wU,CastIcon:wU,Castle:jU,CastleIcon:jU,Cat:NU,CatIcon:NU,Cctv:kU,CctvIcon:kU,ChartArea:lj,ChartAreaIcon:lj,ChartBar:dj,ChartBarBig:cj,ChartBarBigIcon:cj,ChartBarDecreasing:SU,ChartBarDecreasingIcon:SU,ChartBarIcon:dj,ChartBarIncreasing:CU,ChartBarIncreasingIcon:CU,ChartBarStacked:MU,ChartBarStackedIcon:MU,ChartCandlestick:uj,ChartCandlestickIcon:uj,ChartColumn:No,ChartColumnBig:hj,ChartColumnBigIcon:hj,ChartColumnDecreasing:TU,ChartColumnDecreasingIcon:TU,ChartColumnIcon:No,ChartColumnIncreasing:mj,ChartColumnIncreasingIcon:mj,ChartColumnStacked:AU,ChartColumnStackedIcon:AU,ChartGantt:EU,ChartGanttIcon:EU,ChartLine:pj,ChartLineIcon:pj,ChartNetwork:PU,ChartNetworkIcon:PU,ChartNoAxesColumn:xj,ChartNoAxesColumnDecreasing:IU,ChartNoAxesColumnDecreasingIcon:IU,ChartNoAxesColumnIcon:xj,ChartNoAxesColumnIncreasing:fj,ChartNoAxesColumnIncreasingIcon:fj,ChartNoAxesCombined:LU,ChartNoAxesCombinedIcon:LU,ChartNoAxesGantt:gj,ChartNoAxesGanttIcon:gj,ChartPie:yj,ChartPieIcon:yj,ChartScatter:vj,ChartScatterIcon:vj,ChartSpline:DU,ChartSplineIcon:DU,Check:va,CheckCheck:OU,CheckCheckIcon:OU,CheckCircle:xi,CheckCircle2:sa,CheckCircle2Icon:sa,CheckCircleIcon:xi,CheckIcon:va,CheckSquare:zv,CheckSquare2:nk,CheckSquare2Icon:nk,CheckSquareIcon:zv,ChefHat:RU,ChefHatIcon:RU,Cherry:FU,CherryIcon:FU,ChevronDown:Eo,ChevronDownCircle:Mj,ChevronDownCircleIcon:Mj,ChevronDownIcon:Eo,ChevronDownSquare:ak,ChevronDownSquareIcon:ak,ChevronFirst:zU,ChevronFirstIcon:zU,ChevronLast:BU,ChevronLastIcon:BU,ChevronLeft:cl,ChevronLeftCircle:Tj,ChevronLeftCircleIcon:Tj,ChevronLeftIcon:cl,ChevronLeftSquare:ik,ChevronLeftSquareIcon:ik,ChevronRight:da,ChevronRightCircle:Aj,ChevronRightCircleIcon:Aj,ChevronRightIcon:da,ChevronRightSquare:ok,ChevronRightSquareIcon:ok,ChevronUp:pf,ChevronUpCircle:Ej,ChevronUpCircleIcon:Ej,ChevronUpIcon:pf,ChevronUpSquare:lk,ChevronUpSquareIcon:lk,ChevronsDown:qU,ChevronsDownIcon:qU,ChevronsDownUp:$U,ChevronsDownUpIcon:$U,ChevronsLeft:HU,ChevronsLeftIcon:HU,ChevronsLeftRight:VU,ChevronsLeftRightEllipsis:UU,ChevronsLeftRightEllipsisIcon:UU,ChevronsLeftRightIcon:VU,ChevronsRight:GU,ChevronsRightIcon:GU,ChevronsRightLeft:WU,ChevronsRightLeftIcon:WU,ChevronsUp:KU,ChevronsUpDown:Sx,ChevronsUpDownIcon:Sx,ChevronsUpIcon:KU,Chrome:ZU,ChromeIcon:ZU,Church:YU,ChurchIcon:YU,Cigarette:QU,CigaretteIcon:QU,CigaretteOff:XU,CigaretteOffIcon:XU,Circle:bd,CircleAlert:kl,CircleAlertIcon:kl,CircleArrowDown:bj,CircleArrowDownIcon:bj,CircleArrowLeft:_j,CircleArrowLeftIcon:_j,CircleArrowOutDownLeft:wj,CircleArrowOutDownLeftIcon:wj,CircleArrowOutDownRight:jj,CircleArrowOutDownRightIcon:jj,CircleArrowOutUpLeft:Nj,CircleArrowOutUpLeftIcon:Nj,CircleArrowOutUpRight:kj,CircleArrowOutUpRightIcon:kj,CircleArrowRight:Sj,CircleArrowRightIcon:Sj,CircleArrowUp:Cj,CircleArrowUpIcon:Cj,CircleCheck:sa,CircleCheckBig:xi,CircleCheckBigIcon:xi,CircleCheckIcon:sa,CircleChevronDown:Mj,CircleChevronDownIcon:Mj,CircleChevronLeft:Tj,CircleChevronLeftIcon:Tj,CircleChevronRight:Aj,CircleChevronRightIcon:Aj,CircleChevronUp:Ej,CircleChevronUpIcon:Ej,CircleDashed:JU,CircleDashedIcon:JU,CircleDivide:Pj,CircleDivideIcon:Pj,CircleDollarSign:eV,CircleDollarSignIcon:eV,CircleDot:sV,CircleDotDashed:tV,CircleDotDashedIcon:tV,CircleDotIcon:sV,CircleEllipsis:rV,CircleEllipsisIcon:rV,CircleEqual:nV,CircleEqualIcon:nV,CircleFadingArrowUp:aV,CircleFadingArrowUpIcon:aV,CircleFadingPlus:iV,CircleFadingPlusIcon:iV,CircleGauge:Ij,CircleGaugeIcon:Ij,CircleHelp:Dv,CircleHelpIcon:Dv,CircleIcon:bd,CircleMinus:Lj,CircleMinusIcon:Lj,CircleOff:oV,CircleOffIcon:oV,CircleParking:Oj,CircleParkingIcon:Oj,CircleParkingOff:Dj,CircleParkingOffIcon:Dj,CirclePause:Rj,CirclePauseIcon:Rj,CirclePercent:Fj,CirclePercentIcon:Fj,CirclePlay:pp,CirclePlayIcon:pp,CirclePlus:zj,CirclePlusIcon:zj,CirclePower:Bj,CirclePowerIcon:Bj,CircleSlash:lV,CircleSlash2:$j,CircleSlash2Icon:$j,CircleSlashIcon:lV,CircleSlashed:$j,CircleSlashedIcon:$j,CircleStop:qj,CircleStopIcon:qj,CircleUser:Vj,CircleUserIcon:Vj,CircleUserRound:Uj,CircleUserRoundIcon:Uj,CircleX:vc,CircleXIcon:vc,CircuitBoard:cV,CircuitBoardIcon:cV,Citrus:dV,CitrusIcon:dV,Clapperboard:uV,ClapperboardIcon:uV,Clipboard:yV,ClipboardCheck:CM,ClipboardCheckIcon:CM,ClipboardCopy:hV,ClipboardCopyIcon:hV,ClipboardEdit:Wj,ClipboardEditIcon:Wj,ClipboardIcon:yV,ClipboardList:R_,ClipboardListIcon:R_,ClipboardMinus:mV,ClipboardMinusIcon:mV,ClipboardPaste:pV,ClipboardPasteIcon:pV,ClipboardPen:Wj,ClipboardPenIcon:Wj,ClipboardPenLine:Hj,ClipboardPenLineIcon:Hj,ClipboardPlus:fV,ClipboardPlusIcon:fV,ClipboardSignature:Hj,ClipboardSignatureIcon:Hj,ClipboardType:xV,ClipboardTypeIcon:xV,ClipboardX:gV,ClipboardXIcon:gV,Clock:un,Clock1:vV,Clock10:bV,Clock10Icon:bV,Clock11:_V,Clock11Icon:_V,Clock12:wV,Clock12Icon:wV,Clock1Icon:vV,Clock2:jV,Clock2Icon:jV,Clock3:NV,Clock3Icon:NV,Clock4:kV,Clock4Icon:kV,Clock5:SV,Clock5Icon:SV,Clock6:CV,Clock6Icon:CV,Clock7:MV,Clock7Icon:MV,Clock8:TV,Clock8Icon:TV,Clock9:AV,Clock9Icon:AV,ClockAlert:EV,ClockAlertIcon:EV,ClockArrowDown:PV,ClockArrowDownIcon:PV,ClockArrowUp:IV,ClockArrowUpIcon:IV,ClockIcon:un,Cloud:KV,CloudAlert:LV,CloudAlertIcon:LV,CloudCog:DV,CloudCogIcon:DV,CloudDownload:Gj,CloudDownloadIcon:Gj,CloudDrizzle:OV,CloudDrizzleIcon:OV,CloudFog:RV,CloudFogIcon:RV,CloudHail:FV,CloudHailIcon:FV,CloudIcon:KV,CloudLightning:zV,CloudLightningIcon:zV,CloudMoon:$V,CloudMoonIcon:$V,CloudMoonRain:BV,CloudMoonRainIcon:BV,CloudOff:qV,CloudOffIcon:qV,CloudRain:VV,CloudRainIcon:VV,CloudRainWind:UV,CloudRainWindIcon:UV,CloudSnow:HV,CloudSnowIcon:HV,CloudSun:GV,CloudSunIcon:GV,CloudSunRain:WV,CloudSunRainIcon:WV,CloudUpload:Kj,CloudUploadIcon:Kj,Cloudy:ZV,CloudyIcon:ZV,Clover:Kv,CloverIcon:Kv,Club:YV,ClubIcon:YV,Code:X4,Code2:Zj,Code2Icon:Zj,CodeIcon:X4,CodeSquare:ck,CodeSquareIcon:ck,CodeXml:Zj,CodeXmlIcon:Zj,Codepen:XV,CodepenIcon:XV,Codesandbox:QV,CodesandboxIcon:QV,Coffee:Q4,CoffeeIcon:Q4,Cog:JV,CogIcon:JV,Coins:eL,CoinsIcon:eL,Columns:Yj,Columns2:Yj,Columns2Icon:Yj,Columns3:Xj,Columns3Icon:Xj,Columns4:eH,Columns4Icon:eH,ColumnsIcon:Yj,Combine:tH,CombineIcon:tH,Command:sH,CommandIcon:sH,Compass:rH,CompassIcon:rH,Component:nH,ComponentIcon:nH,Computer:aH,ComputerIcon:aH,ConciergeBell:iH,ConciergeBellIcon:iH,Cone:oH,ConeIcon:oH,Construction:lH,ConstructionIcon:lH,Contact:J4,Contact2:Qj,Contact2Icon:Qj,ContactIcon:J4,ContactRound:Qj,ContactRoundIcon:Qj,Container:cH,ContainerIcon:cH,Contrast:dH,ContrastIcon:dH,Cookie:uH,CookieIcon:uH,CookingPot:hH,CookingPotIcon:hH,Copy:gi,CopyCheck:mH,CopyCheckIcon:mH,CopyIcon:gi,CopyMinus:pH,CopyMinusIcon:pH,CopyPlus:fH,CopyPlusIcon:fH,CopySlash:xH,CopySlashIcon:xH,CopyX:gH,CopyXIcon:gH,Copyleft:yH,CopyleftIcon:yH,Copyright:vH,CopyrightIcon:vH,CornerDownLeft:bH,CornerDownLeftIcon:bH,CornerDownRight:_H,CornerDownRightIcon:_H,CornerLeftDown:wH,CornerLeftDownIcon:wH,CornerLeftUp:jH,CornerLeftUpIcon:jH,CornerRightDown:NH,CornerRightDownIcon:NH,CornerRightUp:kH,CornerRightUpIcon:kH,CornerUpLeft:SH,CornerUpLeftIcon:SH,CornerUpRight:CH,CornerUpRightIcon:CH,Cpu:MH,CpuIcon:MH,CreativeCommons:TH,CreativeCommonsIcon:TH,CreditCard:Cx,CreditCardIcon:Cx,Croissant:AH,CroissantIcon:AH,Crop:EH,CropIcon:EH,Cross:PH,CrossIcon:PH,Crosshair:IH,CrosshairIcon:IH,Crown:Dm,CrownIcon:Dm,Cuboid:LH,CuboidIcon:LH,CupSoda:DH,CupSodaIcon:DH,CurlyBraces:ij,CurlyBracesIcon:ij,Currency:OH,CurrencyIcon:OH,Cylinder:RH,CylinderIcon:RH,Dam:FH,DamIcon:FH,Database:tL,DatabaseBackup:zH,DatabaseBackupIcon:zH,DatabaseIcon:tL,DatabaseZap:BH,DatabaseZapIcon:BH,Delete:$H,DeleteIcon:$H,Dessert:qH,DessertIcon:qH,Diameter:UH,DiameterIcon:UH,Diamond:WH,DiamondIcon:WH,DiamondMinus:VH,DiamondMinusIcon:VH,DiamondPercent:Jj,DiamondPercentIcon:Jj,DiamondPlus:HH,DiamondPlusIcon:HH,Dice1:GH,Dice1Icon:GH,Dice2:KH,Dice2Icon:KH,Dice3:ZH,Dice3Icon:ZH,Dice4:YH,Dice4Icon:YH,Dice5:XH,Dice5Icon:XH,Dice6:QH,Dice6Icon:QH,Dices:JH,DicesIcon:JH,Diff:eW,DiffIcon:eW,Disc:nW,Disc2:tW,Disc2Icon:tW,Disc3:sW,Disc3Icon:sW,DiscAlbum:rW,DiscAlbumIcon:rW,DiscIcon:nW,Divide:aW,DivideCircle:Pj,DivideCircleIcon:Pj,DivideIcon:aW,DivideSquare:mk,DivideSquareIcon:mk,Dna:oW,DnaIcon:oW,DnaOff:iW,DnaOffIcon:iW,Dock:lW,DockIcon:lW,Dog:cW,DogIcon:cW,DollarSign:nc,DollarSignIcon:nc,Donut:dW,DonutIcon:dW,DoorClosed:uW,DoorClosedIcon:uW,DoorOpen:s1,DoorOpenIcon:s1,Dot:hW,DotIcon:hW,DotSquare:pk,DotSquareIcon:pk,Download:yi,DownloadCloud:Gj,DownloadCloudIcon:Gj,DownloadIcon:yi,DraftingCompass:mW,DraftingCompassIcon:mW,Drama:pW,DramaIcon:pW,Dribbble:fW,DribbbleIcon:fW,Drill:xW,DrillIcon:xW,Droplet:gW,DropletIcon:gW,Droplets:Yg,DropletsIcon:Yg,Drum:yW,DrumIcon:yW,Drumstick:vW,DrumstickIcon:vW,Dumbbell:bW,DumbbellIcon:bW,Ear:wW,EarIcon:wW,EarOff:_W,EarOffIcon:_W,Earth:eN,EarthIcon:eN,EarthLock:jW,EarthLockIcon:jW,Eclipse:NW,EclipseIcon:NW,Edit:ud,Edit2:Jy,Edit2Icon:Jy,Edit3:Fv,Edit3Icon:Fv,EditIcon:ud,Egg:MM,EggFried:kW,EggFriedIcon:kW,EggIcon:MM,EggOff:SW,EggOffIcon:SW,Ellipsis:px,EllipsisIcon:px,EllipsisVertical:mx,EllipsisVerticalIcon:mx,Equal:TW,EqualApproximately:CW,EqualApproximatelyIcon:CW,EqualIcon:TW,EqualNot:MW,EqualNotIcon:MW,EqualSquare:fk,EqualSquareIcon:fk,Eraser:AW,EraserIcon:AW,EthernetPort:EW,EthernetPortIcon:EW,Euro:PW,EuroIcon:PW,Expand:sL,ExpandIcon:sL,ExternalLink:tn,ExternalLinkIcon:tn,Eye:On,EyeClosed:IW,EyeClosedIcon:IW,EyeIcon:On,EyeOff:kp,EyeOffIcon:kp,Facebook:Su,FacebookIcon:Su,Factory:LW,FactoryIcon:LW,Fan:DW,FanIcon:DW,FastForward:OW,FastForwardIcon:OW,Feather:RW,FeatherIcon:RW,Fence:FW,FenceIcon:FW,FerrisWheel:zW,FerrisWheelIcon:zW,Figma:BW,FigmaIcon:BW,File:TM,FileArchive:$W,FileArchiveIcon:$W,FileAudio:UW,FileAudio2:qW,FileAudio2Icon:qW,FileAudioIcon:UW,FileAxis3D:tN,FileAxis3DIcon:tN,FileAxis3d:tN,FileAxis3dIcon:tN,FileBadge:HW,FileBadge2:VW,FileBadge2Icon:VW,FileBadgeIcon:HW,FileBarChart:sN,FileBarChart2:rN,FileBarChart2Icon:rN,FileBarChartIcon:sN,FileBox:WW,FileBoxIcon:WW,FileChartColumn:rN,FileChartColumnIcon:rN,FileChartColumnIncreasing:sN,FileChartColumnIncreasingIcon:sN,FileChartLine:nN,FileChartLineIcon:nN,FileChartPie:aN,FileChartPieIcon:aN,FileCheck:KW,FileCheck2:GW,FileCheck2Icon:GW,FileCheckIcon:KW,FileClock:ZW,FileClockIcon:ZW,FileCode:XW,FileCode2:YW,FileCode2Icon:YW,FileCodeIcon:XW,FileCog:iN,FileCog2:iN,FileCog2Icon:iN,FileCogIcon:iN,FileDiff:QW,FileDiffIcon:QW,FileDigit:JW,FileDigitIcon:JW,FileDown:eG,FileDownIcon:eG,FileEdit:lN,FileEditIcon:lN,FileHeart:tG,FileHeartIcon:tG,FileIcon:TM,FileImage:F_,FileImageIcon:F_,FileInput:sG,FileInputIcon:sG,FileJson:nG,FileJson2:rG,FileJson2Icon:rG,FileJsonIcon:nG,FileKey:iG,FileKey2:aG,FileKey2Icon:aG,FileKeyIcon:iG,FileLineChart:nN,FileLineChartIcon:nN,FileLock:lG,FileLock2:oG,FileLock2Icon:oG,FileLockIcon:lG,FileMinus:dG,FileMinus2:cG,FileMinus2Icon:cG,FileMinusIcon:dG,FileMusic:uG,FileMusicIcon:uG,FileOutput:hG,FileOutputIcon:hG,FilePen:lN,FilePenIcon:lN,FilePenLine:oN,FilePenLineIcon:oN,FilePieChart:aN,FilePieChartIcon:aN,FilePlus:pG,FilePlus2:mG,FilePlus2Icon:mG,FilePlusIcon:pG,FileQuestion:fG,FileQuestionIcon:fG,FileScan:xG,FileScanIcon:xG,FileSearch:yG,FileSearch2:gG,FileSearch2Icon:gG,FileSearchIcon:yG,FileSignature:oN,FileSignatureIcon:oN,FileSliders:vG,FileSlidersIcon:vG,FileSpreadsheet:r1,FileSpreadsheetIcon:r1,FileStack:rL,FileStackIcon:rL,FileSymlink:bG,FileSymlinkIcon:bG,FileTerminal:_G,FileTerminalIcon:_G,FileText:Sn,FileTextIcon:Sn,FileType:jG,FileType2:wG,FileType2Icon:wG,FileTypeIcon:jG,FileUp:NG,FileUpIcon:NG,FileUser:kG,FileUserIcon:kG,FileVideo:CG,FileVideo2:SG,FileVideo2Icon:SG,FileVideoIcon:CG,FileVolume:TG,FileVolume2:MG,FileVolume2Icon:MG,FileVolumeIcon:TG,FileWarning:AG,FileWarningIcon:AG,FileX:PG,FileX2:EG,FileX2Icon:EG,FileXIcon:PG,Files:IG,FilesIcon:IG,Film:gu,FilmIcon:gu,Filter:Xg,FilterIcon:Xg,FilterX:LG,FilterXIcon:LG,Fingerprint:DG,FingerprintIcon:DG,FireExtinguisher:OG,FireExtinguisherIcon:OG,Fish:zG,FishIcon:zG,FishOff:RG,FishOffIcon:RG,FishSymbol:FG,FishSymbolIcon:FG,Flag:n1,FlagIcon:n1,FlagOff:BG,FlagOffIcon:BG,FlagTriangleLeft:$G,FlagTriangleLeftIcon:$G,FlagTriangleRight:qG,FlagTriangleRightIcon:qG,Flame:eh,FlameIcon:eh,FlameKindling:UG,FlameKindlingIcon:UG,Flashlight:HG,FlashlightIcon:HG,FlashlightOff:VG,FlashlightOffIcon:VG,FlaskConical:z_,FlaskConicalIcon:z_,FlaskConicalOff:WG,FlaskConicalOffIcon:WG,FlaskRound:GG,FlaskRoundIcon:GG,FlipHorizontal:nL,FlipHorizontal2:KG,FlipHorizontal2Icon:KG,FlipHorizontalIcon:nL,FlipVertical:YG,FlipVertical2:ZG,FlipVertical2Icon:ZG,FlipVerticalIcon:YG,Flower:XG,Flower2:Hg,Flower2Icon:Hg,FlowerIcon:XG,Focus:QG,FocusIcon:QG,FoldHorizontal:JG,FoldHorizontalIcon:JG,FoldVertical:eK,FoldVerticalIcon:eK,Folder:CK,FolderArchive:tK,FolderArchiveIcon:tK,FolderCheck:sK,FolderCheckIcon:sK,FolderClock:rK,FolderClockIcon:rK,FolderClosed:nK,FolderClosedIcon:nK,FolderCode:aK,FolderCodeIcon:aK,FolderCog:cN,FolderCog2:cN,FolderCog2Icon:cN,FolderCogIcon:cN,FolderDot:iK,FolderDotIcon:iK,FolderDown:oK,FolderDownIcon:oK,FolderEdit:dN,FolderEditIcon:dN,FolderGit:cK,FolderGit2:lK,FolderGit2Icon:lK,FolderGitIcon:cK,FolderHeart:dK,FolderHeartIcon:dK,FolderIcon:CK,FolderInput:uK,FolderInputIcon:uK,FolderKanban:hK,FolderKanbanIcon:hK,FolderKey:mK,FolderKeyIcon:mK,FolderLock:pK,FolderLockIcon:pK,FolderMinus:fK,FolderMinusIcon:fK,FolderOpen:Om,FolderOpenDot:xK,FolderOpenDotIcon:xK,FolderOpenIcon:Om,FolderOutput:gK,FolderOutputIcon:gK,FolderPen:dN,FolderPenIcon:dN,FolderPlus:yK,FolderPlusIcon:yK,FolderRoot:vK,FolderRootIcon:vK,FolderSearch:_K,FolderSearch2:bK,FolderSearch2Icon:bK,FolderSearchIcon:_K,FolderSymlink:wK,FolderSymlinkIcon:wK,FolderSync:jK,FolderSyncIcon:jK,FolderTree:NK,FolderTreeIcon:NK,FolderUp:kK,FolderUpIcon:kK,FolderX:SK,FolderXIcon:SK,Folders:MK,FoldersIcon:MK,Footprints:TK,FootprintsIcon:TK,ForkKnife:e4,ForkKnifeCrossed:Jk,ForkKnifeCrossedIcon:Jk,ForkKnifeIcon:e4,Forklift:AK,ForkliftIcon:AK,FormInput:DN,FormInputIcon:DN,Forward:EK,ForwardIcon:EK,Frame:PK,FrameIcon:PK,Framer:IK,FramerIcon:IK,Frown:LK,FrownIcon:LK,Fuel:DK,FuelIcon:DK,Fullscreen:OK,FullscreenIcon:OK,FunctionSquare:xk,FunctionSquareIcon:xk,GalleryHorizontal:FK,GalleryHorizontalEnd:RK,GalleryHorizontalEndIcon:RK,GalleryHorizontalIcon:FK,GalleryThumbnails:zK,GalleryThumbnailsIcon:zK,GalleryVertical:$K,GalleryVerticalEnd:BK,GalleryVerticalEndIcon:BK,GalleryVerticalIcon:$K,Gamepad:UK,Gamepad2:qK,Gamepad2Icon:qK,GamepadIcon:UK,GanttChart:gj,GanttChartIcon:gj,GanttChartSquare:Uy,GanttChartSquareIcon:Uy,Gauge:VK,GaugeCircle:Ij,GaugeCircleIcon:Ij,GaugeIcon:VK,Gavel:HK,GavelIcon:HK,Gem:WK,GemIcon:WK,Ghost:eS,GhostIcon:eS,Gift:ko,GiftIcon:ko,GitBranch:KK,GitBranchIcon:KK,GitBranchPlus:GK,GitBranchPlusIcon:GK,GitCommit:uN,GitCommitHorizontal:uN,GitCommitHorizontalIcon:uN,GitCommitIcon:uN,GitCommitVertical:ZK,GitCommitVerticalIcon:ZK,GitCompare:XK,GitCompareArrows:YK,GitCompareArrowsIcon:YK,GitCompareIcon:XK,GitFork:QK,GitForkIcon:QK,GitGraph:JK,GitGraphIcon:JK,GitMerge:eZ,GitMergeIcon:eZ,GitPullRequest:iZ,GitPullRequestArrow:tZ,GitPullRequestArrowIcon:tZ,GitPullRequestClosed:sZ,GitPullRequestClosedIcon:sZ,GitPullRequestCreate:nZ,GitPullRequestCreateArrow:rZ,GitPullRequestCreateArrowIcon:rZ,GitPullRequestCreateIcon:nZ,GitPullRequestDraft:aZ,GitPullRequestDraftIcon:aZ,GitPullRequestIcon:iZ,Github:oZ,GithubIcon:oZ,Gitlab:lZ,GitlabIcon:lZ,GlassWater:cZ,GlassWaterIcon:cZ,Glasses:dZ,GlassesIcon:dZ,Globe:su,Globe2:eN,Globe2Icon:eN,GlobeIcon:su,GlobeLock:uZ,GlobeLockIcon:uZ,Goal:hZ,GoalIcon:hZ,Grab:mZ,GrabIcon:mZ,GraduationCap:Kh,GraduationCapIcon:Kh,Grape:pZ,GrapeIcon:pZ,Grid:nx,Grid2X2:mN,Grid2X2Icon:mN,Grid2X2Plus:hN,Grid2X2PlusIcon:hN,Grid2x2:mN,Grid2x2Check:fZ,Grid2x2CheckIcon:fZ,Grid2x2Icon:mN,Grid2x2Plus:hN,Grid2x2PlusIcon:hN,Grid2x2X:xZ,Grid2x2XIcon:xZ,Grid3X3:nx,Grid3X3Icon:nx,Grid3x3:nx,Grid3x3Icon:nx,GridIcon:nx,Grip:yZ,GripHorizontal:gZ,GripHorizontalIcon:gZ,GripIcon:yZ,GripVertical:Cu,GripVerticalIcon:Cu,Group:vZ,GroupIcon:vZ,Guitar:bZ,GuitarIcon:bZ,Ham:_Z,HamIcon:_Z,Hammer:wZ,HammerIcon:wZ,Hand:aL,HandCoins:jZ,HandCoinsIcon:jZ,HandHeart:NZ,HandHeartIcon:NZ,HandHelping:pN,HandHelpingIcon:pN,HandIcon:aL,HandMetal:kZ,HandMetalIcon:kZ,HandPlatter:SZ,HandPlatterIcon:SZ,Handshake:iL,HandshakeIcon:iL,HardDrive:oL,HardDriveDownload:CZ,HardDriveDownloadIcon:CZ,HardDriveIcon:oL,HardDriveUpload:MZ,HardDriveUploadIcon:MZ,HardHat:TZ,HardHatIcon:TZ,Hash:B_,HashIcon:B_,Haze:AZ,HazeIcon:AZ,HdmiPort:EZ,HdmiPortIcon:EZ,Heading:DZ,Heading1:AM,Heading1Icon:AM,Heading2:EM,Heading2Icon:EM,Heading3:lL,Heading3Icon:lL,Heading4:PZ,Heading4Icon:PZ,Heading5:IZ,Heading5Icon:IZ,Heading6:LZ,Heading6Icon:LZ,HeadingIcon:DZ,HeadphoneOff:OZ,HeadphoneOffIcon:OZ,Headphones:RZ,HeadphonesIcon:RZ,Headset:FZ,HeadsetIcon:FZ,Heart:ni,HeartCrack:zZ,HeartCrackIcon:zZ,HeartHandshake:BZ,HeartHandshakeIcon:BZ,HeartIcon:ni,HeartOff:$Z,HeartOffIcon:$Z,HeartPulse:qZ,HeartPulseIcon:qZ,Heater:UZ,HeaterIcon:UZ,HelpCircle:Dv,HelpCircleIcon:Dv,HelpingHand:pN,HelpingHandIcon:pN,Hexagon:VZ,HexagonIcon:VZ,Highlighter:HZ,HighlighterIcon:HZ,History:PM,HistoryIcon:PM,Home:bn,HomeIcon:bn,Hop:GZ,HopIcon:GZ,HopOff:WZ,HopOffIcon:WZ,Hospital:KZ,HospitalIcon:KZ,Hotel:ZZ,HotelIcon:ZZ,Hourglass:YZ,HourglassIcon:YZ,House:bn,HouseIcon:bn,HousePlug:XZ,HousePlugIcon:XZ,HousePlus:QZ,HousePlusIcon:QZ,IceCream:xN,IceCream2:fN,IceCream2Icon:fN,IceCreamBowl:fN,IceCreamBowlIcon:fN,IceCreamCone:xN,IceCreamConeIcon:xN,IceCreamIcon:xN,Icon:aqe,IdCard:JZ,IdCardIcon:JZ,Image:gl,ImageDown:eY,ImageDownIcon:eY,ImageIcon:gl,ImageMinus:tY,ImageMinusIcon:tY,ImageOff:sY,ImageOffIcon:sY,ImagePlay:rY,ImagePlayIcon:rY,ImagePlus:a1,ImagePlusIcon:a1,ImageUp:nY,ImageUpIcon:nY,ImageUpscale:aY,ImageUpscaleIcon:aY,Images:iY,ImagesIcon:iY,Import:oY,ImportIcon:oY,Inbox:lY,InboxIcon:lY,Indent:yN,IndentDecrease:gN,IndentDecreaseIcon:gN,IndentIcon:yN,IndentIncrease:yN,IndentIncreaseIcon:yN,IndianRupee:cY,IndianRupeeIcon:cY,Infinity:dY,InfinityIcon:dY,Info:cL,InfoIcon:cL,Inspect:wk,InspectIcon:wk,InspectionPanel:uY,InspectionPanelIcon:uY,Instagram:Mu,InstagramIcon:Mu,Italic:tS,ItalicIcon:tS,IterationCcw:hY,IterationCcwIcon:hY,IterationCw:mY,IterationCwIcon:mY,JapaneseYen:pY,JapaneseYenIcon:pY,Joystick:fY,JoystickIcon:fY,Kanban:h0,KanbanIcon:h0,KanbanSquare:gk,KanbanSquareDashed:dk,KanbanSquareDashedIcon:dk,KanbanSquareIcon:gk,Key:Sp,KeyIcon:Sp,KeyRound:sS,KeyRoundIcon:sS,KeySquare:xY,KeySquareIcon:xY,Keyboard:vY,KeyboardIcon:vY,KeyboardMusic:gY,KeyboardMusicIcon:gY,KeyboardOff:yY,KeyboardOffIcon:yY,Lamp:kY,LampCeiling:bY,LampCeilingIcon:bY,LampDesk:_Y,LampDeskIcon:_Y,LampFloor:wY,LampFloorIcon:wY,LampIcon:kY,LampWallDown:jY,LampWallDownIcon:jY,LampWallUp:NY,LampWallUpIcon:NY,LandPlot:SY,LandPlotIcon:SY,Landmark:CY,LandmarkIcon:CY,Languages:MY,LanguagesIcon:MY,Laptop:AY,Laptop2:vN,Laptop2Icon:vN,LaptopIcon:AY,LaptopMinimal:vN,LaptopMinimalCheck:TY,LaptopMinimalCheckIcon:TY,LaptopMinimalIcon:vN,Lasso:PY,LassoIcon:PY,LassoSelect:EY,LassoSelectIcon:EY,Laugh:IY,LaughIcon:IY,Layers:IM,Layers2:LY,Layers2Icon:LY,Layers3:DY,Layers3Icon:DY,LayersIcon:IM,Layout:Rv,LayoutDashboard:rS,LayoutDashboardIcon:rS,LayoutGrid:Cp,LayoutGridIcon:Cp,LayoutIcon:Rv,LayoutList:OY,LayoutListIcon:OY,LayoutPanelLeft:RY,LayoutPanelLeftIcon:RY,LayoutPanelTop:FY,LayoutPanelTopIcon:FY,LayoutTemplate:nS,LayoutTemplateIcon:nS,Leaf:zY,LeafIcon:zY,LeafyGreen:BY,LeafyGreenIcon:BY,Lectern:$Y,LecternIcon:$Y,LetterText:qY,LetterTextIcon:qY,Library:LM,LibraryBig:UY,LibraryBigIcon:UY,LibraryIcon:LM,LibrarySquare:yk,LibrarySquareIcon:yk,LifeBuoy:DM,LifeBuoyIcon:DM,Ligature:VY,LigatureIcon:VY,Lightbulb:$_,LightbulbIcon:$_,LightbulbOff:HY,LightbulbOffIcon:HY,LineChart:pj,LineChartIcon:pj,Link:Bo,Link2:dl,Link2Icon:dl,Link2Off:WY,Link2OffIcon:WY,LinkIcon:Bo,Linkedin:Mp,LinkedinIcon:Mp,List:Mh,ListCheck:GY,ListCheckIcon:GY,ListChecks:KY,ListChecksIcon:KY,ListCollapse:ZY,ListCollapseIcon:ZY,ListEnd:YY,ListEndIcon:YY,ListFilter:XY,ListFilterIcon:XY,ListIcon:Mh,ListMinus:QY,ListMinusIcon:QY,ListMusic:JY,ListMusicIcon:JY,ListOrdered:m0,ListOrderedIcon:m0,ListPlus:eX,ListPlusIcon:eX,ListRestart:tX,ListRestartIcon:tX,ListStart:sX,ListStartIcon:sX,ListTodo:rX,ListTodoIcon:rX,ListTree:nX,ListTreeIcon:nX,ListVideo:aX,ListVideoIcon:aX,ListX:iX,ListXIcon:iX,Loader:lX,Loader2:ws,Loader2Icon:ws,LoaderCircle:ws,LoaderCircleIcon:ws,LoaderIcon:lX,LoaderPinwheel:oX,LoaderPinwheelIcon:oX,Locate:uX,LocateFixed:cX,LocateFixedIcon:cX,LocateIcon:uX,LocateOff:dX,LocateOffIcon:dX,Lock:Th,LockIcon:Th,LockKeyhole:hX,LockKeyholeIcon:hX,LockKeyholeOpen:bN,LockKeyholeOpenIcon:bN,LockOpen:_N,LockOpenIcon:_N,LogIn:aS,LogInIcon:aS,LogOut:iS,LogOutIcon:iS,Logs:mX,LogsIcon:mX,Lollipop:pX,LollipopIcon:pX,LucideAArrowDown:v9,LucideAArrowUp:b9,LucideALargeSmall:_9,LucideAccessibility:w9,LucideActivity:kh,LucideActivitySquare:UN,LucideAirVent:j9,LucideAirplay:N9,LucideAlarmCheck:W2,LucideAlarmClock:S9,LucideAlarmClockCheck:W2,LucideAlarmClockMinus:G2,LucideAlarmClockOff:k9,LucideAlarmClockPlus:K2,LucideAlarmMinus:G2,LucideAlarmPlus:K2,LucideAlarmSmoke:C9,LucideAlbum:M9,LucideAlertCircle:kl,LucideAlertOctagon:Ov,LucideAlertTriangle:Ku,LucideAlignCenter:H4,LucideAlignCenterHorizontal:T9,LucideAlignCenterVertical:A9,LucideAlignEndHorizontal:E9,LucideAlignEndVertical:P9,LucideAlignHorizontalDistributeCenter:I9,LucideAlignHorizontalDistributeEnd:L9,LucideAlignHorizontalDistributeStart:D9,LucideAlignHorizontalJustifyCenter:O9,LucideAlignHorizontalJustifyEnd:R9,LucideAlignHorizontalJustifyStart:F9,LucideAlignHorizontalSpaceAround:z9,LucideAlignHorizontalSpaceBetween:B9,LucideAlignJustify:$9,LucideAlignLeft:W4,LucideAlignRight:G4,LucideAlignStartHorizontal:q9,LucideAlignStartVertical:U9,LucideAlignVerticalDistributeCenter:V9,LucideAlignVerticalDistributeEnd:H9,LucideAlignVerticalDistributeStart:W9,LucideAlignVerticalJustifyCenter:G9,LucideAlignVerticalJustifyEnd:K9,LucideAlignVerticalJustifyStart:Z9,LucideAlignVerticalSpaceAround:Y9,LucideAlignVerticalSpaceBetween:X9,LucideAmbulance:Q9,LucideAmpersand:J9,LucideAmpersands:eB,LucideAmphora:tB,LucideAnchor:sB,LucideAngry:rB,LucideAnnoyed:nB,LucideAntenna:aB,LucideAnvil:iB,LucideAperture:oB,LucideAppWindow:UI,LucideAppWindowMac:lB,LucideApple:cB,LucideArchive:NM,LucideArchiveRestore:VI,LucideArchiveX:dB,LucideAreaChart:lj,LucideArmchair:uB,LucideArrowBigDown:mB,LucideArrowBigDownDash:hB,LucideArrowBigLeft:fB,LucideArrowBigLeftDash:pB,LucideArrowBigRight:gB,LucideArrowBigRightDash:xB,LucideArrowBigUp:vB,LucideArrowBigUpDash:yB,LucideArrowDown:Wh,LucideArrowDown01:bB,LucideArrowDown10:_B,LucideArrowDownAZ:Z2,LucideArrowDownAz:Z2,LucideArrowDownCircle:bj,LucideArrowDownFromLine:wB,LucideArrowDownLeft:jB,LucideArrowDownLeftFromCircle:wj,LucideArrowDownLeftFromSquare:KN,LucideArrowDownLeftSquare:VN,LucideArrowDownNarrowWide:NB,LucideArrowDownRight:HI,LucideArrowDownRightFromCircle:jj,LucideArrowDownRightFromSquare:ZN,LucideArrowDownRightSquare:HN,LucideArrowDownSquare:WN,LucideArrowDownToDot:kB,LucideArrowDownToLine:SB,LucideArrowDownUp:CB,LucideArrowDownWideNarrow:Y2,LucideArrowDownZA:X2,LucideArrowDownZa:X2,LucideArrowLeft:Ja,LucideArrowLeftCircle:_j,LucideArrowLeftFromLine:MB,LucideArrowLeftRight:TB,LucideArrowLeftSquare:GN,LucideArrowLeftToLine:AB,LucideArrowRight:Qa,LucideArrowRightCircle:Sj,LucideArrowRightFromLine:EB,LucideArrowRightLeft:e1,LucideArrowRightSquare:QN,LucideArrowRightToLine:PB,LucideArrowUp:ku,LucideArrowUp01:IB,LucideArrowUp10:LB,LucideArrowUpAZ:Q2,LucideArrowUpAz:Q2,LucideArrowUpCircle:Cj,LucideArrowUpDown:vd,LucideArrowUpFromDot:DB,LucideArrowUpFromLine:OB,LucideArrowUpLeft:RB,LucideArrowUpLeftFromCircle:Nj,LucideArrowUpLeftFromSquare:YN,LucideArrowUpLeftSquare:JN,LucideArrowUpNarrowWide:J2,LucideArrowUpRight:WI,LucideArrowUpRightFromCircle:kj,LucideArrowUpRightFromSquare:XN,LucideArrowUpRightSquare:ek,LucideArrowUpSquare:tk,LucideArrowUpToLine:FB,LucideArrowUpWideNarrow:zB,LucideArrowUpZA:ej,LucideArrowUpZa:ej,LucideArrowsUpFromLine:BB,LucideAsterisk:$B,LucideAsteriskSquare:sk,LucideAtSign:qB,LucideAtom:UB,LucideAudioLines:VB,LucideAudioWaveform:HB,LucideAward:Nc,LucideAxe:WB,LucideAxis3D:tj,LucideAxis3d:tj,LucideBaby:GB,LucideBackpack:KB,LucideBadge:d$,LucideBadgeAlert:ZB,LucideBadgeCent:YB,LucideBadgeCheck:sj,LucideBadgeDollarSign:XB,LucideBadgeEuro:QB,LucideBadgeHelp:JB,LucideBadgeIndianRupee:e$,LucideBadgeInfo:t$,LucideBadgeJapaneseYen:s$,LucideBadgeMinus:r$,LucideBadgePercent:n$,LucideBadgePlus:a$,LucideBadgePoundSterling:i$,LucideBadgeRussianRuble:o$,LucideBadgeSwissFranc:l$,LucideBadgeX:c$,LucideBaggageClaim:u$,LucideBan:GI,LucideBanana:h$,LucideBandage:m$,LucideBanknote:p$,LucideBarChart:fj,LucideBarChart2:xj,LucideBarChart3:No,LucideBarChart4:mj,LucideBarChartBig:hj,LucideBarChartHorizontal:dj,LucideBarChartHorizontalBig:cj,LucideBarcode:f$,LucideBaseline:x$,LucideBath:Ju,LucideBattery:w$,LucideBatteryCharging:g$,LucideBatteryFull:y$,LucideBatteryLow:v$,LucideBatteryMedium:b$,LucideBatteryWarning:_$,LucideBeaker:j$,LucideBean:k$,LucideBeanOff:N$,LucideBed:Im,LucideBedDouble:K4,LucideBedSingle:S$,LucideBeef:C$,LucideBeer:T$,LucideBeerOff:M$,LucideBell:Lm,LucideBellDot:A$,LucideBellElectric:E$,LucideBellMinus:P$,LucideBellOff:t1,LucideBellPlus:I$,LucideBellRing:L$,LucideBetweenHorizonalEnd:rj,LucideBetweenHorizonalStart:nj,LucideBetweenHorizontalEnd:rj,LucideBetweenHorizontalStart:nj,LucideBetweenVerticalEnd:D$,LucideBetweenVerticalStart:O$,LucideBicepsFlexed:R$,LucideBike:F$,LucideBinary:z$,LucideBinoculars:B$,LucideBiohazard:$$,LucideBird:q$,LucideBitcoin:U$,LucideBlend:V$,LucideBlinds:H$,LucideBlocks:W$,LucideBluetooth:Y$,LucideBluetoothConnected:G$,LucideBluetoothOff:K$,LucideBluetoothSearching:Z$,LucideBold:Z4,LucideBolt:X$,LucideBomb:Q$,LucideBone:J$,LucideBook:_q,LucideBookA:eq,LucideBookAudio:tq,LucideBookCheck:sq,LucideBookCopy:rq,LucideBookDashed:aj,LucideBookDown:nq,LucideBookHeadphones:aq,LucideBookHeart:iq,LucideBookImage:oq,LucideBookKey:lq,LucideBookLock:cq,LucideBookMarked:dq,LucideBookMinus:uq,LucideBookOpen:Sh,LucideBookOpenCheck:hq,LucideBookOpenText:mq,LucideBookPlus:pq,LucideBookTemplate:aj,LucideBookText:fq,LucideBookType:xq,LucideBookUp:yq,LucideBookUp2:gq,LucideBookUser:vq,LucideBookX:bq,LucideBookmark:Nx,LucideBookmarkCheck:wq,LucideBookmarkMinus:jq,LucideBookmarkPlus:KI,LucideBookmarkX:Nq,LucideBoomBox:kq,LucideBot:kM,LucideBotMessageSquare:Sq,LucideBotOff:Cq,LucideBox:Mq,LucideBoxSelect:hk,LucideBoxes:Tq,LucideBraces:ij,LucideBrackets:Aq,LucideBrain:ZI,LucideBrainCircuit:Eq,LucideBrainCog:Pq,LucideBrickWall:Iq,LucideBriefcase:Gh,LucideBriefcaseBusiness:Lq,LucideBriefcaseConveyorBelt:Dq,LucideBriefcaseMedical:Oq,LucideBringToFront:Rq,LucideBrush:Fq,LucideBug:$q,LucideBugOff:zq,LucideBugPlay:Bq,LucideBuilding:Y4,LucideBuilding2:ka,LucideBus:Uq,LucideBusFront:qq,LucideCable:Hq,LucideCableCar:Vq,LucideCake:Ch,LucideCakeSlice:Wq,LucideCalculator:YI,LucideCalendar:hn,LucideCalendar1:Gq,LucideCalendarArrowDown:Kq,LucideCalendarArrowUp:Zq,LucideCalendarCheck:XI,LucideCalendarCheck2:Yq,LucideCalendarClock:QI,LucideCalendarCog:Xq,LucideCalendarDays:Dd,LucideCalendarFold:Qq,LucideCalendarHeart:Jq,LucideCalendarMinus:tU,LucideCalendarMinus2:eU,LucideCalendarOff:JI,LucideCalendarPlus:O_,LucideCalendarPlus2:sU,LucideCalendarRange:rU,LucideCalendarSearch:nU,LucideCalendarSync:aU,LucideCalendarX:oU,LucideCalendarX2:iU,LucideCamera:kx,LucideCameraOff:lU,LucideCandlestickChart:uj,LucideCandy:uU,LucideCandyCane:cU,LucideCandyOff:dU,LucideCannabis:hU,LucideCaptions:oj,LucideCaptionsOff:mU,LucideCar:SM,LucideCarFront:pU,LucideCarTaxiFront:fU,LucideCaravan:xU,LucideCarrot:gU,LucideCaseLower:yU,LucideCaseSensitive:vU,LucideCaseUpper:bU,LucideCassetteTape:_U,LucideCast:wU,LucideCastle:jU,LucideCat:NU,LucideCctv:kU,LucideChartArea:lj,LucideChartBar:dj,LucideChartBarBig:cj,LucideChartBarDecreasing:SU,LucideChartBarIncreasing:CU,LucideChartBarStacked:MU,LucideChartCandlestick:uj,LucideChartColumn:No,LucideChartColumnBig:hj,LucideChartColumnDecreasing:TU,LucideChartColumnIncreasing:mj,LucideChartColumnStacked:AU,LucideChartGantt:EU,LucideChartLine:pj,LucideChartNetwork:PU,LucideChartNoAxesColumn:xj,LucideChartNoAxesColumnDecreasing:IU,LucideChartNoAxesColumnIncreasing:fj,LucideChartNoAxesCombined:LU,LucideChartNoAxesGantt:gj,LucideChartPie:yj,LucideChartScatter:vj,LucideChartSpline:DU,LucideCheck:va,LucideCheckCheck:OU,LucideCheckCircle:xi,LucideCheckCircle2:sa,LucideCheckSquare:zv,LucideCheckSquare2:nk,LucideChefHat:RU,LucideCherry:FU,LucideChevronDown:Eo,LucideChevronDownCircle:Mj,LucideChevronDownSquare:ak,LucideChevronFirst:zU,LucideChevronLast:BU,LucideChevronLeft:cl,LucideChevronLeftCircle:Tj,LucideChevronLeftSquare:ik,LucideChevronRight:da,LucideChevronRightCircle:Aj,LucideChevronRightSquare:ok,LucideChevronUp:pf,LucideChevronUpCircle:Ej,LucideChevronUpSquare:lk,LucideChevronsDown:qU,LucideChevronsDownUp:$U,LucideChevronsLeft:HU,LucideChevronsLeftRight:VU,LucideChevronsLeftRightEllipsis:UU,LucideChevronsRight:GU,LucideChevronsRightLeft:WU,LucideChevronsUp:KU,LucideChevronsUpDown:Sx,LucideChrome:ZU,LucideChurch:YU,LucideCigarette:QU,LucideCigaretteOff:XU,LucideCircle:bd,LucideCircleAlert:kl,LucideCircleArrowDown:bj,LucideCircleArrowLeft:_j,LucideCircleArrowOutDownLeft:wj,LucideCircleArrowOutDownRight:jj,LucideCircleArrowOutUpLeft:Nj,LucideCircleArrowOutUpRight:kj,LucideCircleArrowRight:Sj,LucideCircleArrowUp:Cj,LucideCircleCheck:sa,LucideCircleCheckBig:xi,LucideCircleChevronDown:Mj,LucideCircleChevronLeft:Tj,LucideCircleChevronRight:Aj,LucideCircleChevronUp:Ej,LucideCircleDashed:JU,LucideCircleDivide:Pj,LucideCircleDollarSign:eV,LucideCircleDot:sV,LucideCircleDotDashed:tV,LucideCircleEllipsis:rV,LucideCircleEqual:nV,LucideCircleFadingArrowUp:aV,LucideCircleFadingPlus:iV,LucideCircleGauge:Ij,LucideCircleHelp:Dv,LucideCircleMinus:Lj,LucideCircleOff:oV,LucideCircleParking:Oj,LucideCircleParkingOff:Dj,LucideCirclePause:Rj,LucideCirclePercent:Fj,LucideCirclePlay:pp,LucideCirclePlus:zj,LucideCirclePower:Bj,LucideCircleSlash:lV,LucideCircleSlash2:$j,LucideCircleSlashed:$j,LucideCircleStop:qj,LucideCircleUser:Vj,LucideCircleUserRound:Uj,LucideCircleX:vc,LucideCircuitBoard:cV,LucideCitrus:dV,LucideClapperboard:uV,LucideClipboard:yV,LucideClipboardCheck:CM,LucideClipboardCopy:hV,LucideClipboardEdit:Wj,LucideClipboardList:R_,LucideClipboardMinus:mV,LucideClipboardPaste:pV,LucideClipboardPen:Wj,LucideClipboardPenLine:Hj,LucideClipboardPlus:fV,LucideClipboardSignature:Hj,LucideClipboardType:xV,LucideClipboardX:gV,LucideClock:un,LucideClock1:vV,LucideClock10:bV,LucideClock11:_V,LucideClock12:wV,LucideClock2:jV,LucideClock3:NV,LucideClock4:kV,LucideClock5:SV,LucideClock6:CV,LucideClock7:MV,LucideClock8:TV,LucideClock9:AV,LucideClockAlert:EV,LucideClockArrowDown:PV,LucideClockArrowUp:IV,LucideCloud:KV,LucideCloudAlert:LV,LucideCloudCog:DV,LucideCloudDownload:Gj,LucideCloudDrizzle:OV,LucideCloudFog:RV,LucideCloudHail:FV,LucideCloudLightning:zV,LucideCloudMoon:$V,LucideCloudMoonRain:BV,LucideCloudOff:qV,LucideCloudRain:VV,LucideCloudRainWind:UV,LucideCloudSnow:HV,LucideCloudSun:GV,LucideCloudSunRain:WV,LucideCloudUpload:Kj,LucideCloudy:ZV,LucideClover:Kv,LucideClub:YV,LucideCode:X4,LucideCode2:Zj,LucideCodeSquare:ck,LucideCodeXml:Zj,LucideCodepen:XV,LucideCodesandbox:QV,LucideCoffee:Q4,LucideCog:JV,LucideCoins:eL,LucideColumns:Yj,LucideColumns2:Yj,LucideColumns3:Xj,LucideColumns4:eH,LucideCombine:tH,LucideCommand:sH,LucideCompass:rH,LucideComponent:nH,LucideComputer:aH,LucideConciergeBell:iH,LucideCone:oH,LucideConstruction:lH,LucideContact:J4,LucideContact2:Qj,LucideContactRound:Qj,LucideContainer:cH,LucideContrast:dH,LucideCookie:uH,LucideCookingPot:hH,LucideCopy:gi,LucideCopyCheck:mH,LucideCopyMinus:pH,LucideCopyPlus:fH,LucideCopySlash:xH,LucideCopyX:gH,LucideCopyleft:yH,LucideCopyright:vH,LucideCornerDownLeft:bH,LucideCornerDownRight:_H,LucideCornerLeftDown:wH,LucideCornerLeftUp:jH,LucideCornerRightDown:NH,LucideCornerRightUp:kH,LucideCornerUpLeft:SH,LucideCornerUpRight:CH,LucideCpu:MH,LucideCreativeCommons:TH,LucideCreditCard:Cx,LucideCroissant:AH,LucideCrop:EH,LucideCross:PH,LucideCrosshair:IH,LucideCrown:Dm,LucideCuboid:LH,LucideCupSoda:DH,LucideCurlyBraces:ij,LucideCurrency:OH,LucideCylinder:RH,LucideDam:FH,LucideDatabase:tL,LucideDatabaseBackup:zH,LucideDatabaseZap:BH,LucideDelete:$H,LucideDessert:qH,LucideDiameter:UH,LucideDiamond:WH,LucideDiamondMinus:VH,LucideDiamondPercent:Jj,LucideDiamondPlus:HH,LucideDice1:GH,LucideDice2:KH,LucideDice3:ZH,LucideDice4:YH,LucideDice5:XH,LucideDice6:QH,LucideDices:JH,LucideDiff:eW,LucideDisc:nW,LucideDisc2:tW,LucideDisc3:sW,LucideDiscAlbum:rW,LucideDivide:aW,LucideDivideCircle:Pj,LucideDivideSquare:mk,LucideDna:oW,LucideDnaOff:iW,LucideDock:lW,LucideDog:cW,LucideDollarSign:nc,LucideDonut:dW,LucideDoorClosed:uW,LucideDoorOpen:s1,LucideDot:hW,LucideDotSquare:pk,LucideDownload:yi,LucideDownloadCloud:Gj,LucideDraftingCompass:mW,LucideDrama:pW,LucideDribbble:fW,LucideDrill:xW,LucideDroplet:gW,LucideDroplets:Yg,LucideDrum:yW,LucideDrumstick:vW,LucideDumbbell:bW,LucideEar:wW,LucideEarOff:_W,LucideEarth:eN,LucideEarthLock:jW,LucideEclipse:NW,LucideEdit:ud,LucideEdit2:Jy,LucideEdit3:Fv,LucideEgg:MM,LucideEggFried:kW,LucideEggOff:SW,LucideEllipsis:px,LucideEllipsisVertical:mx,LucideEqual:TW,LucideEqualApproximately:CW,LucideEqualNot:MW,LucideEqualSquare:fk,LucideEraser:AW,LucideEthernetPort:EW,LucideEuro:PW,LucideExpand:sL,LucideExternalLink:tn,LucideEye:On,LucideEyeClosed:IW,LucideEyeOff:kp,LucideFacebook:Su,LucideFactory:LW,LucideFan:DW,LucideFastForward:OW,LucideFeather:RW,LucideFence:FW,LucideFerrisWheel:zW,LucideFigma:BW,LucideFile:TM,LucideFileArchive:$W,LucideFileAudio:UW,LucideFileAudio2:qW,LucideFileAxis3D:tN,LucideFileAxis3d:tN,LucideFileBadge:HW,LucideFileBadge2:VW,LucideFileBarChart:sN,LucideFileBarChart2:rN,LucideFileBox:WW,LucideFileChartColumn:rN,LucideFileChartColumnIncreasing:sN,LucideFileChartLine:nN,LucideFileChartPie:aN,LucideFileCheck:KW,LucideFileCheck2:GW,LucideFileClock:ZW,LucideFileCode:XW,LucideFileCode2:YW,LucideFileCog:iN,LucideFileCog2:iN,LucideFileDiff:QW,LucideFileDigit:JW,LucideFileDown:eG,LucideFileEdit:lN,LucideFileHeart:tG,LucideFileImage:F_,LucideFileInput:sG,LucideFileJson:nG,LucideFileJson2:rG,LucideFileKey:iG,LucideFileKey2:aG,LucideFileLineChart:nN,LucideFileLock:lG,LucideFileLock2:oG,LucideFileMinus:dG,LucideFileMinus2:cG,LucideFileMusic:uG,LucideFileOutput:hG,LucideFilePen:lN,LucideFilePenLine:oN,LucideFilePieChart:aN,LucideFilePlus:pG,LucideFilePlus2:mG,LucideFileQuestion:fG,LucideFileScan:xG,LucideFileSearch:yG,LucideFileSearch2:gG,LucideFileSignature:oN,LucideFileSliders:vG,LucideFileSpreadsheet:r1,LucideFileStack:rL,LucideFileSymlink:bG,LucideFileTerminal:_G,LucideFileText:Sn,LucideFileType:jG,LucideFileType2:wG,LucideFileUp:NG,LucideFileUser:kG,LucideFileVideo:CG,LucideFileVideo2:SG,LucideFileVolume:TG,LucideFileVolume2:MG,LucideFileWarning:AG,LucideFileX:PG,LucideFileX2:EG,LucideFiles:IG,LucideFilm:gu,LucideFilter:Xg,LucideFilterX:LG,LucideFingerprint:DG,LucideFireExtinguisher:OG,LucideFish:zG,LucideFishOff:RG,LucideFishSymbol:FG,LucideFlag:n1,LucideFlagOff:BG,LucideFlagTriangleLeft:$G,LucideFlagTriangleRight:qG,LucideFlame:eh,LucideFlameKindling:UG,LucideFlashlight:HG,LucideFlashlightOff:VG,LucideFlaskConical:z_,LucideFlaskConicalOff:WG,LucideFlaskRound:GG,LucideFlipHorizontal:nL,LucideFlipHorizontal2:KG,LucideFlipVertical:YG,LucideFlipVertical2:ZG,LucideFlower:XG,LucideFlower2:Hg,LucideFocus:QG,LucideFoldHorizontal:JG,LucideFoldVertical:eK,LucideFolder:CK,LucideFolderArchive:tK,LucideFolderCheck:sK,LucideFolderClock:rK,LucideFolderClosed:nK,LucideFolderCode:aK,LucideFolderCog:cN,LucideFolderCog2:cN,LucideFolderDot:iK,LucideFolderDown:oK,LucideFolderEdit:dN,LucideFolderGit:cK,LucideFolderGit2:lK,LucideFolderHeart:dK,LucideFolderInput:uK,LucideFolderKanban:hK,LucideFolderKey:mK,LucideFolderLock:pK,LucideFolderMinus:fK,LucideFolderOpen:Om,LucideFolderOpenDot:xK,LucideFolderOutput:gK,LucideFolderPen:dN,LucideFolderPlus:yK,LucideFolderRoot:vK,LucideFolderSearch:_K,LucideFolderSearch2:bK,LucideFolderSymlink:wK,LucideFolderSync:jK,LucideFolderTree:NK,LucideFolderUp:kK,LucideFolderX:SK,LucideFolders:MK,LucideFootprints:TK,LucideForkKnife:e4,LucideForkKnifeCrossed:Jk,LucideForklift:AK,LucideFormInput:DN,LucideForward:EK,LucideFrame:PK,LucideFramer:IK,LucideFrown:LK,LucideFuel:DK,LucideFullscreen:OK,LucideFunctionSquare:xk,LucideGalleryHorizontal:FK,LucideGalleryHorizontalEnd:RK,LucideGalleryThumbnails:zK,LucideGalleryVertical:$K,LucideGalleryVerticalEnd:BK,LucideGamepad:UK,LucideGamepad2:qK,LucideGanttChart:gj,LucideGanttChartSquare:Uy,LucideGauge:VK,LucideGaugeCircle:Ij,LucideGavel:HK,LucideGem:WK,LucideGhost:eS,LucideGift:ko,LucideGitBranch:KK,LucideGitBranchPlus:GK,LucideGitCommit:uN,LucideGitCommitHorizontal:uN,LucideGitCommitVertical:ZK,LucideGitCompare:XK,LucideGitCompareArrows:YK,LucideGitFork:QK,LucideGitGraph:JK,LucideGitMerge:eZ,LucideGitPullRequest:iZ,LucideGitPullRequestArrow:tZ,LucideGitPullRequestClosed:sZ,LucideGitPullRequestCreate:nZ,LucideGitPullRequestCreateArrow:rZ,LucideGitPullRequestDraft:aZ,LucideGithub:oZ,LucideGitlab:lZ,LucideGlassWater:cZ,LucideGlasses:dZ,LucideGlobe:su,LucideGlobe2:eN,LucideGlobeLock:uZ,LucideGoal:hZ,LucideGrab:mZ,LucideGraduationCap:Kh,LucideGrape:pZ,LucideGrid:nx,LucideGrid2X2:mN,LucideGrid2X2Plus:hN,LucideGrid2x2:mN,LucideGrid2x2Check:fZ,LucideGrid2x2Plus:hN,LucideGrid2x2X:xZ,LucideGrid3X3:nx,LucideGrid3x3:nx,LucideGrip:yZ,LucideGripHorizontal:gZ,LucideGripVertical:Cu,LucideGroup:vZ,LucideGuitar:bZ,LucideHam:_Z,LucideHammer:wZ,LucideHand:aL,LucideHandCoins:jZ,LucideHandHeart:NZ,LucideHandHelping:pN,LucideHandMetal:kZ,LucideHandPlatter:SZ,LucideHandshake:iL,LucideHardDrive:oL,LucideHardDriveDownload:CZ,LucideHardDriveUpload:MZ,LucideHardHat:TZ,LucideHash:B_,LucideHaze:AZ,LucideHdmiPort:EZ,LucideHeading:DZ,LucideHeading1:AM,LucideHeading2:EM,LucideHeading3:lL,LucideHeading4:PZ,LucideHeading5:IZ,LucideHeading6:LZ,LucideHeadphoneOff:OZ,LucideHeadphones:RZ,LucideHeadset:FZ,LucideHeart:ni,LucideHeartCrack:zZ,LucideHeartHandshake:BZ,LucideHeartOff:$Z,LucideHeartPulse:qZ,LucideHeater:UZ,LucideHelpCircle:Dv,LucideHelpingHand:pN,LucideHexagon:VZ,LucideHighlighter:HZ,LucideHistory:PM,LucideHome:bn,LucideHop:GZ,LucideHopOff:WZ,LucideHospital:KZ,LucideHotel:ZZ,LucideHourglass:YZ,LucideHouse:bn,LucideHousePlug:XZ,LucideHousePlus:QZ,LucideIceCream:xN,LucideIceCream2:fN,LucideIceCreamBowl:fN,LucideIceCreamCone:xN,LucideIdCard:JZ,LucideImage:gl,LucideImageDown:eY,LucideImageMinus:tY,LucideImageOff:sY,LucideImagePlay:rY,LucideImagePlus:a1,LucideImageUp:nY,LucideImageUpscale:aY,LucideImages:iY,LucideImport:oY,LucideInbox:lY,LucideIndent:yN,LucideIndentDecrease:gN,LucideIndentIncrease:yN,LucideIndianRupee:cY,LucideInfinity:dY,LucideInfo:cL,LucideInspect:wk,LucideInspectionPanel:uY,LucideInstagram:Mu,LucideItalic:tS,LucideIterationCcw:hY,LucideIterationCw:mY,LucideJapaneseYen:pY,LucideJoystick:fY,LucideKanban:h0,LucideKanbanSquare:gk,LucideKanbanSquareDashed:dk,LucideKey:Sp,LucideKeyRound:sS,LucideKeySquare:xY,LucideKeyboard:vY,LucideKeyboardMusic:gY,LucideKeyboardOff:yY,LucideLamp:kY,LucideLampCeiling:bY,LucideLampDesk:_Y,LucideLampFloor:wY,LucideLampWallDown:jY,LucideLampWallUp:NY,LucideLandPlot:SY,LucideLandmark:CY,LucideLanguages:MY,LucideLaptop:AY,LucideLaptop2:vN,LucideLaptopMinimal:vN,LucideLaptopMinimalCheck:TY,LucideLasso:PY,LucideLassoSelect:EY,LucideLaugh:IY,LucideLayers:IM,LucideLayers2:LY,LucideLayers3:DY,LucideLayout:Rv,LucideLayoutDashboard:rS,LucideLayoutGrid:Cp,LucideLayoutList:OY,LucideLayoutPanelLeft:RY,LucideLayoutPanelTop:FY,LucideLayoutTemplate:nS,LucideLeaf:zY,LucideLeafyGreen:BY,LucideLectern:$Y,LucideLetterText:qY,LucideLibrary:LM,LucideLibraryBig:UY,LucideLibrarySquare:yk,LucideLifeBuoy:DM,LucideLigature:VY,LucideLightbulb:$_,LucideLightbulbOff:HY,LucideLineChart:pj,LucideLink:Bo,LucideLink2:dl,LucideLink2Off:WY,LucideLinkedin:Mp,LucideList:Mh,LucideListCheck:GY,LucideListChecks:KY,LucideListCollapse:ZY,LucideListEnd:YY,LucideListFilter:XY,LucideListMinus:QY,LucideListMusic:JY,LucideListOrdered:m0,LucideListPlus:eX,LucideListRestart:tX,LucideListStart:sX,LucideListTodo:rX,LucideListTree:nX,LucideListVideo:aX,LucideListX:iX,LucideLoader:lX,LucideLoader2:ws,LucideLoaderCircle:ws,LucideLoaderPinwheel:oX,LucideLocate:uX,LucideLocateFixed:cX,LucideLocateOff:dX,LucideLock:Th,LucideLockKeyhole:hX,LucideLockKeyholeOpen:bN,LucideLockOpen:_N,LucideLogIn:aS,LucideLogOut:iS,LucideLogs:mX,LucideLollipop:pX,LucideLuggage:fX,LucideMSquare:vk,LucideMagnet:xX,LucideMail:cr,LucideMailCheck:gX,LucideMailMinus:yX,LucideMailOpen:vX,LucideMailPlus:dL,LucideMailQuestion:bX,LucideMailSearch:_X,LucideMailWarning:wX,LucideMailX:uL,LucideMailbox:jX,LucideMails:NX,LucideMap:i1,LucideMapPin:ma,LucideMapPinCheck:SX,LucideMapPinCheckInside:kX,LucideMapPinHouse:CX,LucideMapPinMinus:TX,LucideMapPinMinusInside:MX,LucideMapPinOff:AX,LucideMapPinPlus:PX,LucideMapPinPlusInside:EX,LucideMapPinX:LX,LucideMapPinXInside:IX,LucideMapPinned:DX,LucideMartini:OX,LucideMaximize:oS,LucideMaximize2:RX,LucideMedal:o1,LucideMegaphone:Ah,LucideMegaphoneOff:FX,LucideMeh:zX,LucideMemoryStick:BX,LucideMenu:OM,LucideMenuSquare:bk,LucideMerge:$X,LucideMessageCircle:$c,LucideMessageCircleCode:qX,LucideMessageCircleDashed:UX,LucideMessageCircleHeart:RM,LucideMessageCircleMore:VX,LucideMessageCircleOff:HX,LucideMessageCirclePlus:WX,LucideMessageCircleQuestion:hL,LucideMessageCircleReply:GX,LucideMessageCircleWarning:KX,LucideMessageCircleX:ZX,LucideMessageSquare:so,LucideMessageSquareCode:YX,LucideMessageSquareDashed:XX,LucideMessageSquareDiff:QX,LucideMessageSquareDot:JX,LucideMessageSquareHeart:eQ,LucideMessageSquareLock:tQ,LucideMessageSquareMore:mL,LucideMessageSquareOff:sQ,LucideMessageSquarePlus:FM,LucideMessageSquareQuote:pL,LucideMessageSquareReply:rQ,LucideMessageSquareShare:nQ,LucideMessageSquareText:aQ,LucideMessageSquareWarning:iQ,LucideMessageSquareX:oQ,LucideMessagesSquare:lQ,LucideMic:fL,LucideMic2:wN,LucideMicOff:cQ,LucideMicVocal:wN,LucideMicrochip:dQ,LucideMicroscope:uQ,LucideMicrowave:hQ,LucideMilestone:mQ,LucideMilk:fQ,LucideMilkOff:pQ,LucideMinimize:gQ,LucideMinimize2:xQ,LucideMinus:p0,LucideMinusCircle:Lj,LucideMinusSquare:_k,LucideMonitor:cS,LucideMonitorCheck:yQ,LucideMonitorCog:vQ,LucideMonitorDot:bQ,LucideMonitorDown:_Q,LucideMonitorOff:wQ,LucideMonitorPause:jQ,LucideMonitorPlay:NQ,LucideMonitorSmartphone:kQ,LucideMonitorSpeaker:SQ,LucideMonitorStop:CQ,LucideMonitorUp:lS,LucideMonitorX:MQ,LucideMoon:AQ,LucideMoonStar:TQ,LucideMoreHorizontal:px,LucideMoreVertical:mx,LucideMountain:PQ,LucideMountainSnow:EQ,LucideMouse:OQ,LucideMouseOff:IQ,LucideMousePointer:wh,LucideMousePointer2:LQ,LucideMousePointerBan:DQ,LucideMousePointerClick:Qg,LucideMousePointerSquareDashed:uk,LucideMove:ZQ,LucideMove3D:jN,LucideMove3d:jN,LucideMoveDiagonal:FQ,LucideMoveDiagonal2:RQ,LucideMoveDown:$Q,LucideMoveDownLeft:zQ,LucideMoveDownRight:BQ,LucideMoveHorizontal:qQ,LucideMoveLeft:UQ,LucideMoveRight:VQ,LucideMoveUp:GQ,LucideMoveUpLeft:HQ,LucideMoveUpRight:WQ,LucideMoveVertical:KQ,LucideMusic:JQ,LucideMusic2:YQ,LucideMusic3:XQ,LucideMusic4:QQ,LucideNavigation:rJ,LucideNavigation2:tJ,LucideNavigation2Off:eJ,LucideNavigationOff:sJ,LucideNetwork:nJ,LucideNewspaper:l1,LucideNfc:aJ,LucideNotebook:cJ,LucideNotebookPen:iJ,LucideNotebookTabs:oJ,LucideNotebookText:lJ,LucideNotepadText:uJ,LucideNotepadTextDashed:dJ,LucideNut:mJ,LucideNutOff:hJ,LucideOctagon:fJ,LucideOctagonAlert:Ov,LucideOctagonMinus:pJ,LucideOctagonPause:NN,LucideOctagonX:kN,LucideOmega:xJ,LucideOption:gJ,LucideOrbit:yJ,LucideOrigami:vJ,LucideOutdent:gN,LucidePackage:Ml,LucidePackage2:bJ,LucidePackageCheck:_J,LucidePackageMinus:wJ,LucidePackageOpen:jJ,LucidePackagePlus:NJ,LucidePackageSearch:kJ,LucidePackageX:SJ,LucidePaintBucket:CJ,LucidePaintRoller:MJ,LucidePaintbrush:TJ,LucidePaintbrush2:SN,LucidePaintbrushVertical:SN,LucidePalette:ac,LucidePalmtree:Uk,LucidePanelBottom:PJ,LucidePanelBottomClose:AJ,LucidePanelBottomDashed:CN,LucidePanelBottomInactive:CN,LucidePanelBottomOpen:EJ,LucidePanelLeft:EN,LucidePanelLeftClose:MN,LucidePanelLeftDashed:TN,LucidePanelLeftInactive:TN,LucidePanelLeftOpen:AN,LucidePanelRight:DJ,LucidePanelRightClose:IJ,LucidePanelRightDashed:PN,LucidePanelRightInactive:PN,LucidePanelRightOpen:LJ,LucidePanelTop:FJ,LucidePanelTopClose:OJ,LucidePanelTopDashed:IN,LucidePanelTopInactive:IN,LucidePanelTopOpen:RJ,LucidePanelsLeftBottom:zJ,LucidePanelsLeftRight:Xj,LucidePanelsRightBottom:BJ,LucidePanelsTopBottom:FN,LucidePanelsTopLeft:Rv,LucidePaperclip:dS,LucideParentheses:$J,LucideParkingCircle:Oj,LucideParkingCircleOff:Dj,LucideParkingMeter:qJ,LucideParkingSquare:Nk,LucideParkingSquareOff:jk,LucidePartyPopper:ru,LucidePause:Rm,LucidePauseCircle:Rj,LucidePauseOctagon:NN,LucidePawPrint:UJ,LucidePcCase:VJ,LucidePen:Jy,LucidePenBox:ud,LucidePenLine:Fv,LucidePenOff:HJ,LucidePenSquare:ud,LucidePenTool:q_,LucidePencil:Ra,LucidePencilLine:WJ,LucidePencilOff:GJ,LucidePencilRuler:KJ,LucidePentagon:ZJ,LucidePercent:uS,LucidePercentCircle:Fj,LucidePercentDiamond:Jj,LucidePercentSquare:kk,LucidePersonStanding:YJ,LucidePhilippinePeso:XJ,LucidePhone:Un,LucidePhoneCall:QJ,LucidePhoneForwarded:JJ,LucidePhoneIncoming:eee,LucidePhoneMissed:tee,LucidePhoneOff:see,LucidePhoneOutgoing:ree,LucidePi:nee,LucidePiSquare:Sk,LucidePiano:aee,LucidePickaxe:iee,LucidePictureInPicture:lee,LucidePictureInPicture2:oee,LucidePieChart:yj,LucidePiggyBank:cee,LucidePilcrow:hee,LucidePilcrowLeft:dee,LucidePilcrowRight:uee,LucidePilcrowSquare:Ck,LucidePill:pee,LucidePillBottle:mee,LucidePin:U_,LucidePinOff:xL,LucidePipette:fee,LucidePizza:xee,LucidePlane:vee,LucidePlaneLanding:gee,LucidePlaneTakeoff:yee,LucidePlay:nl,LucidePlayCircle:pp,LucidePlaySquare:Mk,LucidePlug:gL,LucidePlug2:bee,LucidePlugZap:LN,LucidePlugZap2:LN,LucidePlus:$s,LucidePlusCircle:zj,LucidePlusSquare:Tk,LucidePocket:wee,LucidePocketKnife:_ee,LucidePodcast:jee,LucidePointer:kee,LucidePointerOff:Nee,LucidePopcorn:See,LucidePopsicle:Cee,LucidePoundSterling:Mee,LucidePower:yL,LucidePowerCircle:Bj,LucidePowerOff:Tee,LucidePowerSquare:Ak,LucidePresentation:Jg,LucidePrinter:vL,LucidePrinterCheck:Aee,LucideProjector:Eee,LucideProportions:Pee,LucidePuzzle:Iee,LucidePyramid:Lee,LucideQrCode:c1,LucideQuote:V_,LucideRabbit:Dee,LucideRadar:Oee,LucideRadiation:Ree,LucideRadical:Fee,LucideRadio:d1,LucideRadioReceiver:zee,LucideRadioTower:Bee,LucideRadius:$ee,LucideRailSymbol:qee,LucideRainbow:Uee,LucideRat:Vee,LucideRatio:Hee,LucideReceipt:ete,LucideReceiptCent:Wee,LucideReceiptEuro:Gee,LucideReceiptIndianRupee:Kee,LucideReceiptJapaneseYen:Zee,LucideReceiptPoundSterling:Yee,LucideReceiptRussianRuble:Xee,LucideReceiptSwissFranc:Qee,LucideReceiptText:Jee,LucideRectangleEllipsis:DN,LucideRectangleHorizontal:tte,LucideRectangleVertical:ste,LucideRecycle:rte,LucideRedo:hS,LucideRedo2:nte,LucideRedoDot:ate,LucideRefreshCcw:zM,LucideRefreshCcwDot:ite,LucideRefreshCw:Go,LucideRefreshCwOff:ote,LucideRefrigerator:lte,LucideRegex:cte,LucideRemoveFormatting:dte,LucideRepeat:bL,LucideRepeat1:ute,LucideRepeat2:hte,LucideReplace:pte,LucideReplaceAll:mte,LucideReply:_L,LucideReplyAll:fte,LucideRewind:xte,LucideRibbon:gte,LucideRocket:f0,LucideRockingChair:yte,LucideRollerCoaster:vte,LucideRotate3D:ON,LucideRotate3d:ON,LucideRotateCcw:u1,LucideRotateCcwSquare:bte,LucideRotateCw:wL,LucideRotateCwSquare:_te,LucideRoute:jte,LucideRouteOff:wte,LucideRouter:Nte,LucideRows:RN,LucideRows2:RN,LucideRows3:FN,LucideRows4:kte,LucideRss:Ste,LucideRuler:x0,LucideRussianRuble:Cte,LucideSailboat:Mte,LucideSalad:Tte,LucideSandwich:Ate,LucideSatellite:Pte,LucideSatelliteDish:Ete,LucideSave:qc,LucideSaveAll:Ite,LucideSaveOff:Lte,LucideScale:jL,LucideScale3D:zN,LucideScale3d:zN,LucideScaling:Dte,LucideScan:Ute,LucideScanBarcode:Ote,LucideScanEye:Rte,LucideScanFace:Fte,LucideScanLine:zte,LucideScanQrCode:Bte,LucideScanSearch:$te,LucideScanText:qte,LucideScatterChart:vj,LucideSchool:Vte,LucideSchool2:Hk,LucideScissors:Wte,LucideScissorsLineDashed:Hte,LucideScissorsSquare:Ek,LucideScissorsSquareDashedBottom:rk,LucideScreenShare:Kte,LucideScreenShareOff:Gte,LucideScroll:Yte,LucideScrollText:Zte,LucideSearch:cn,LucideSearchCheck:Xte,LucideSearchCode:Qte,LucideSearchSlash:Jte,LucideSearchX:NL,LucideSection:ese,LucideSend:Bn,LucideSendHorizonal:BN,LucideSendHorizontal:BN,LucideSendToBack:tse,LucideSeparatorHorizontal:sse,LucideSeparatorVertical:rse,LucideServer:ose,LucideServerCog:nse,LucideServerCrash:ase,LucideServerOff:ise,LucideSettings:Xo,LucideSettings2:kL,LucideShapes:lse,LucideShare:SL,LucideShare2:_d,LucideSheet:cse,LucideShell:dse,LucideShield:th,LucideShieldAlert:use,LucideShieldBan:hse,LucideShieldCheck:CL,LucideShieldClose:$N,LucideShieldEllipsis:mse,LucideShieldHalf:pse,LucideShieldMinus:fse,LucideShieldOff:xse,LucideShieldPlus:gse,LucideShieldQuestion:yse,LucideShieldX:$N,LucideShip:bse,LucideShipWheel:vse,LucideShirt:_se,LucideShoppingBag:g0,LucideShoppingBasket:wse,LucideShoppingCart:vp,LucideShovel:jse,LucideShowerHead:Nse,LucideShrink:kse,LucideShrub:Sse,LucideShuffle:mS,LucideSidebar:EN,LucideSidebarClose:MN,LucideSidebarOpen:AN,LucideSigma:Cse,LucideSigmaSquare:Pk,LucideSignal:Pse,LucideSignalHigh:Mse,LucideSignalLow:Tse,LucideSignalMedium:Ase,LucideSignalZero:Ese,LucideSignature:Ise,LucideSignpost:Dse,LucideSignpostBig:Lse,LucideSiren:Ose,LucideSkipBack:Rse,LucideSkipForward:Fse,LucideSkull:zse,LucideSlack:Bse,LucideSlash:$se,LucideSlashSquare:Ik,LucideSlice:qse,LucideSliders:qN,LucideSlidersHorizontal:H_,LucideSlidersVertical:qN,LucideSmartphone:h1,LucideSmartphoneCharging:Use,LucideSmartphoneNfc:Vse,LucideSmile:Wse,LucideSmilePlus:Hse,LucideSnail:Gse,LucideSnowflake:n0,LucideSofa:Kse,LucideSortAsc:J2,LucideSortDesc:Y2,LucideSoup:Zse,LucideSpace:Yse,LucideSpade:Xse,LucideSparkle:Qse,LucideSparkles:pn,LucideSpeaker:Jse,LucideSpeech:ere,LucideSpellCheck:sre,LucideSpellCheck2:tre,LucideSpline:rre,LucideSplit:nre,LucideSplitSquareHorizontal:Lk,LucideSplitSquareVertical:Dk,LucideSprayCan:are,LucideSprout:ire,LucideSquare:y0,LucideSquareActivity:UN,LucideSquareArrowDown:WN,LucideSquareArrowDownLeft:VN,LucideSquareArrowDownRight:HN,LucideSquareArrowLeft:GN,LucideSquareArrowOutDownLeft:KN,LucideSquareArrowOutDownRight:ZN,LucideSquareArrowOutUpLeft:YN,LucideSquareArrowOutUpRight:XN,LucideSquareArrowRight:QN,LucideSquareArrowUp:tk,LucideSquareArrowUpLeft:JN,LucideSquareArrowUpRight:ek,LucideSquareAsterisk:sk,LucideSquareBottomDashedScissors:rk,LucideSquareChartGantt:Uy,LucideSquareCheck:nk,LucideSquareCheckBig:zv,LucideSquareChevronDown:ak,LucideSquareChevronLeft:ik,LucideSquareChevronRight:ok,LucideSquareChevronUp:lk,LucideSquareCode:ck,LucideSquareDashed:hk,LucideSquareDashedBottom:lre,LucideSquareDashedBottomCode:ore,LucideSquareDashedKanban:dk,LucideSquareDashedMousePointer:uk,LucideSquareDivide:mk,LucideSquareDot:pk,LucideSquareEqual:fk,LucideSquareFunction:xk,LucideSquareGanttChart:Uy,LucideSquareKanban:gk,LucideSquareLibrary:yk,LucideSquareM:vk,LucideSquareMenu:bk,LucideSquareMinus:_k,LucideSquareMousePointer:wk,LucideSquareParking:Nk,LucideSquareParkingOff:jk,LucideSquarePen:ud,LucideSquarePercent:kk,LucideSquarePi:Sk,LucideSquarePilcrow:Ck,LucideSquarePlay:Mk,LucideSquarePlus:Tk,LucideSquarePower:Ak,LucideSquareRadical:cre,LucideSquareScissors:Ek,LucideSquareSigma:Pk,LucideSquareSlash:Ik,LucideSquareSplitHorizontal:Lk,LucideSquareSplitVertical:Dk,LucideSquareSquare:dre,LucideSquareStack:ure,LucideSquareTerminal:Ok,LucideSquareUser:Fk,LucideSquareUserRound:Rk,LucideSquareX:zk,LucideSquircle:hre,LucideSquirrel:mre,LucideStamp:pre,LucideStar:Jn,LucideStarHalf:fre,LucideStarOff:xre,LucideStars:pn,LucideStepBack:gre,LucideStepForward:yre,LucideStethoscope:vre,LucideSticker:bre,LucideStickyNote:_re,LucideStopCircle:qj,LucideStore:BM,LucideStretchHorizontal:wre,LucideStretchVertical:jre,LucideStrikethrough:ML,LucideSubscript:Nre,LucideSubtitles:oj,LucideSun:m1,LucideSunDim:kre,LucideSunMedium:Sre,LucideSunMoon:Cre,LucideSunSnow:Mre,LucideSunrise:Tre,LucideSunset:Are,LucideSuperscript:Ere,LucideSwatchBook:Pre,LucideSwissFranc:Ire,LucideSwitchCamera:Lre,LucideSword:Dre,LucideSwords:Ore,LucideSyringe:Rre,LucideTable:qM,LucideTable2:$M,LucideTableCellsMerge:Fre,LucideTableCellsSplit:zre,LucideTableColumnsSplit:Bre,LucideTableOfContents:$re,LucideTableProperties:qre,LucideTableRowsSplit:Ure,LucideTablet:Hre,LucideTabletSmartphone:Vre,LucideTablets:Wre,LucideTag:Fm,LucideTags:Gre,LucideTally1:Kre,LucideTally2:Zre,LucideTally3:Yre,LucideTally4:Xre,LucideTally5:Qre,LucideTangent:Jre,LucideTarget:zm,LucideTelescope:ene,LucideTent:sne,LucideTentTree:tne,LucideTerminal:rne,LucideTerminalSquare:Ok,LucideTestTube:nne,LucideTestTube2:Bk,LucideTestTubeDiagonal:Bk,LucideTestTubes:ane,LucideText:dne,LucideTextCursor:one,LucideTextCursorInput:ine,LucideTextQuote:lne,LucideTextSearch:cne,LucideTextSelect:$k,LucideTextSelection:$k,LucideTheater:une,LucideThermometer:TL,LucideThermometerSnowflake:hne,LucideThermometerSun:mne,LucideThumbsDown:AL,LucideThumbsUp:sh,LucideTicket:EL,LucideTicketCheck:pne,LucideTicketMinus:fne,LucideTicketPercent:xne,LucideTicketPlus:gne,LucideTicketSlash:yne,LucideTicketX:vne,LucideTickets:_ne,LucideTicketsPlane:bne,LucideTimer:Nne,LucideTimerOff:wne,LucideTimerReset:jne,LucideToggleLeft:kne,LucideToggleRight:Sne,LucideToilet:Cne,LucideTornado:Mne,LucideTorus:Tne,LucideTouchpad:Ene,LucideTouchpadOff:Ane,LucideTowerControl:Pne,LucideToyBrick:Ine,LucideTractor:Lne,LucideTrafficCone:Dne,LucideTrain:qk,LucideTrainFront:Rne,LucideTrainFrontTunnel:One,LucideTrainTrack:Fne,LucideTramFront:qk,LucideTrash:zne,LucideTrash2:Nr,LucideTreeDeciduous:Bne,LucideTreePalm:Uk,LucideTreePine:p1,LucideTrees:$ne,LucideTrello:qne,LucideTrendingDown:pS,LucideTrendingUp:ul,LucideTrendingUpDown:Une,LucideTriangle:Hne,LucideTriangleAlert:Ku,LucideTriangleRight:Vne,LucideTrophy:xo,LucideTruck:PL,LucideTurtle:Wne,LucideTv:Kne,LucideTv2:Vk,LucideTvMinimal:Vk,LucideTvMinimalPlay:Gne,LucideTwitch:Zne,LucideTwitter:Yne,LucideType:Qne,LucideTypeOutline:Xne,LucideUmbrella:eae,LucideUmbrellaOff:Jne,LucideUnderline:IL,LucideUndo:fS,LucideUndo2:tae,LucideUndoDot:sae,LucideUnfoldHorizontal:rae,LucideUnfoldVertical:nae,LucideUngroup:aae,LucideUniversity:Hk,LucideUnlink:xS,LucideUnlink2:iae,LucideUnlock:_N,LucideUnlockKeyhole:bN,LucideUnplug:oae,LucideUpload:li,LucideUploadCloud:Kj,LucideUsb:lae,LucideUser:to,LucideUser2:Xk,LucideUserCheck:W_,LucideUserCheck2:Wk,LucideUserCircle:Vj,LucideUserCircle2:Uj,LucideUserCog:LL,LucideUserCog2:Gk,LucideUserMinus:DL,LucideUserMinus2:Kk,LucideUserPen:cae,LucideUserPlus:Tl,LucideUserPlus2:Zk,LucideUserRound:Xk,LucideUserRoundCheck:Wk,LucideUserRoundCog:Gk,LucideUserRoundMinus:Kk,LucideUserRoundPen:dae,LucideUserRoundPlus:Zk,LucideUserRoundSearch:uae,LucideUserRoundX:Yk,LucideUserSearch:hae,LucideUserSquare:Fk,LucideUserSquare2:Rk,LucideUserX:mae,LucideUserX2:Yk,LucideUsers:pr,LucideUsers2:Qk,LucideUsersRound:Qk,LucideUtensils:e4,LucideUtensilsCrossed:Jk,LucideUtilityPole:pae,LucideVariable:UM,LucideVault:fae,LucideVegan:xae,LucideVenetianMask:gae,LucideVerified:sj,LucideVibrate:vae,LucideVibrateOff:yae,LucideVideo:An,LucideVideoOff:bae,LucideVideotape:_ae,LucideView:wae,LucideVoicemail:jae,LucideVolleyball:Nae,LucideVolume:Tae,LucideVolume1:kae,LucideVolume2:Sae,LucideVolumeOff:Cae,LucideVolumeX:Mae,LucideVote:Aae,LucideWallet:OL,LucideWallet2:t4,LucideWalletCards:Eae,LucideWalletMinimal:t4,LucideWallpaper:Pae,LucideWand:Iae,LucideWand2:Bv,LucideWandSparkles:Bv,LucideWarehouse:Lae,LucideWashingMachine:Dae,LucideWatch:Oae,LucideWaves:RL,LucideWaypoints:Rae,LucideWebcam:Fae,LucideWebhook:Bae,LucideWebhookOff:zae,LucideWeight:$ae,LucideWheat:Uae,LucideWheatOff:qae,LucideWholeWord:Vae,LucideWifi:Zae,LucideWifiHigh:Hae,LucideWifiLow:Wae,LucideWifiOff:Gae,LucideWifiZero:Kae,LucideWind:Xae,LucideWindArrowDown:Yae,LucideWine:Jae,LucideWineOff:Qae,LucideWorkflow:eie,LucideWorm:tie,LucideWrapText:sie,LucideWrench:ey,LucideX:Rr,LucideXCircle:vc,LucideXOctagon:kN,LucideXSquare:zk,LucideYoutube:rie,LucideZap:Zh,LucideZapOff:nie,LucideZoomIn:G_,LucideZoomOut:VM,Luggage:fX,LuggageIcon:fX,MSquare:vk,MSquareIcon:vk,Magnet:xX,MagnetIcon:xX,Mail:cr,MailCheck:gX,MailCheckIcon:gX,MailIcon:cr,MailMinus:yX,MailMinusIcon:yX,MailOpen:vX,MailOpenIcon:vX,MailPlus:dL,MailPlusIcon:dL,MailQuestion:bX,MailQuestionIcon:bX,MailSearch:_X,MailSearchIcon:_X,MailWarning:wX,MailWarningIcon:wX,MailX:uL,MailXIcon:uL,Mailbox:jX,MailboxIcon:jX,Mails:NX,MailsIcon:NX,Map:i1,MapIcon:i1,MapPin:ma,MapPinCheck:SX,MapPinCheckIcon:SX,MapPinCheckInside:kX,MapPinCheckInsideIcon:kX,MapPinHouse:CX,MapPinHouseIcon:CX,MapPinIcon:ma,MapPinMinus:TX,MapPinMinusIcon:TX,MapPinMinusInside:MX,MapPinMinusInsideIcon:MX,MapPinOff:AX,MapPinOffIcon:AX,MapPinPlus:PX,MapPinPlusIcon:PX,MapPinPlusInside:EX,MapPinPlusInsideIcon:EX,MapPinX:LX,MapPinXIcon:LX,MapPinXInside:IX,MapPinXInsideIcon:IX,MapPinned:DX,MapPinnedIcon:DX,Martini:OX,MartiniIcon:OX,Maximize:oS,Maximize2:RX,Maximize2Icon:RX,MaximizeIcon:oS,Medal:o1,MedalIcon:o1,Megaphone:Ah,MegaphoneIcon:Ah,MegaphoneOff:FX,MegaphoneOffIcon:FX,Meh:zX,MehIcon:zX,MemoryStick:BX,MemoryStickIcon:BX,Menu:OM,MenuIcon:OM,MenuSquare:bk,MenuSquareIcon:bk,Merge:$X,MergeIcon:$X,MessageCircle:$c,MessageCircleCode:qX,MessageCircleCodeIcon:qX,MessageCircleDashed:UX,MessageCircleDashedIcon:UX,MessageCircleHeart:RM,MessageCircleHeartIcon:RM,MessageCircleIcon:$c,MessageCircleMore:VX,MessageCircleMoreIcon:VX,MessageCircleOff:HX,MessageCircleOffIcon:HX,MessageCirclePlus:WX,MessageCirclePlusIcon:WX,MessageCircleQuestion:hL,MessageCircleQuestionIcon:hL,MessageCircleReply:GX,MessageCircleReplyIcon:GX,MessageCircleWarning:KX,MessageCircleWarningIcon:KX,MessageCircleX:ZX,MessageCircleXIcon:ZX,MessageSquare:so,MessageSquareCode:YX,MessageSquareCodeIcon:YX,MessageSquareDashed:XX,MessageSquareDashedIcon:XX,MessageSquareDiff:QX,MessageSquareDiffIcon:QX,MessageSquareDot:JX,MessageSquareDotIcon:JX,MessageSquareHeart:eQ,MessageSquareHeartIcon:eQ,MessageSquareIcon:so,MessageSquareLock:tQ,MessageSquareLockIcon:tQ,MessageSquareMore:mL,MessageSquareMoreIcon:mL,MessageSquareOff:sQ,MessageSquareOffIcon:sQ,MessageSquarePlus:FM,MessageSquarePlusIcon:FM,MessageSquareQuote:pL,MessageSquareQuoteIcon:pL,MessageSquareReply:rQ,MessageSquareReplyIcon:rQ,MessageSquareShare:nQ,MessageSquareShareIcon:nQ,MessageSquareText:aQ,MessageSquareTextIcon:aQ,MessageSquareWarning:iQ,MessageSquareWarningIcon:iQ,MessageSquareX:oQ,MessageSquareXIcon:oQ,MessagesSquare:lQ,MessagesSquareIcon:lQ,Mic:fL,Mic2:wN,Mic2Icon:wN,MicIcon:fL,MicOff:cQ,MicOffIcon:cQ,MicVocal:wN,MicVocalIcon:wN,Microchip:dQ,MicrochipIcon:dQ,Microscope:uQ,MicroscopeIcon:uQ,Microwave:hQ,MicrowaveIcon:hQ,Milestone:mQ,MilestoneIcon:mQ,Milk:fQ,MilkIcon:fQ,MilkOff:pQ,MilkOffIcon:pQ,Minimize:gQ,Minimize2:xQ,Minimize2Icon:xQ,MinimizeIcon:gQ,Minus:p0,MinusCircle:Lj,MinusCircleIcon:Lj,MinusIcon:p0,MinusSquare:_k,MinusSquareIcon:_k,Monitor:cS,MonitorCheck:yQ,MonitorCheckIcon:yQ,MonitorCog:vQ,MonitorCogIcon:vQ,MonitorDot:bQ,MonitorDotIcon:bQ,MonitorDown:_Q,MonitorDownIcon:_Q,MonitorIcon:cS,MonitorOff:wQ,MonitorOffIcon:wQ,MonitorPause:jQ,MonitorPauseIcon:jQ,MonitorPlay:NQ,MonitorPlayIcon:NQ,MonitorSmartphone:kQ,MonitorSmartphoneIcon:kQ,MonitorSpeaker:SQ,MonitorSpeakerIcon:SQ,MonitorStop:CQ,MonitorStopIcon:CQ,MonitorUp:lS,MonitorUpIcon:lS,MonitorX:MQ,MonitorXIcon:MQ,Moon:AQ,MoonIcon:AQ,MoonStar:TQ,MoonStarIcon:TQ,MoreHorizontal:px,MoreHorizontalIcon:px,MoreVertical:mx,MoreVerticalIcon:mx,Mountain:PQ,MountainIcon:PQ,MountainSnow:EQ,MountainSnowIcon:EQ,Mouse:OQ,MouseIcon:OQ,MouseOff:IQ,MouseOffIcon:IQ,MousePointer:wh,MousePointer2:LQ,MousePointer2Icon:LQ,MousePointerBan:DQ,MousePointerBanIcon:DQ,MousePointerClick:Qg,MousePointerClickIcon:Qg,MousePointerIcon:wh,MousePointerSquareDashed:uk,MousePointerSquareDashedIcon:uk,Move:ZQ,Move3D:jN,Move3DIcon:jN,Move3d:jN,Move3dIcon:jN,MoveDiagonal:FQ,MoveDiagonal2:RQ,MoveDiagonal2Icon:RQ,MoveDiagonalIcon:FQ,MoveDown:$Q,MoveDownIcon:$Q,MoveDownLeft:zQ,MoveDownLeftIcon:zQ,MoveDownRight:BQ,MoveDownRightIcon:BQ,MoveHorizontal:qQ,MoveHorizontalIcon:qQ,MoveIcon:ZQ,MoveLeft:UQ,MoveLeftIcon:UQ,MoveRight:VQ,MoveRightIcon:VQ,MoveUp:GQ,MoveUpIcon:GQ,MoveUpLeft:HQ,MoveUpLeftIcon:HQ,MoveUpRight:WQ,MoveUpRightIcon:WQ,MoveVertical:KQ,MoveVerticalIcon:KQ,Music:JQ,Music2:YQ,Music2Icon:YQ,Music3:XQ,Music3Icon:XQ,Music4:QQ,Music4Icon:QQ,MusicIcon:JQ,Navigation:rJ,Navigation2:tJ,Navigation2Icon:tJ,Navigation2Off:eJ,Navigation2OffIcon:eJ,NavigationIcon:rJ,NavigationOff:sJ,NavigationOffIcon:sJ,Network:nJ,NetworkIcon:nJ,Newspaper:l1,NewspaperIcon:l1,Nfc:aJ,NfcIcon:aJ,Notebook:cJ,NotebookIcon:cJ,NotebookPen:iJ,NotebookPenIcon:iJ,NotebookTabs:oJ,NotebookTabsIcon:oJ,NotebookText:lJ,NotebookTextIcon:lJ,NotepadText:uJ,NotepadTextDashed:dJ,NotepadTextDashedIcon:dJ,NotepadTextIcon:uJ,Nut:mJ,NutIcon:mJ,NutOff:hJ,NutOffIcon:hJ,Octagon:fJ,OctagonAlert:Ov,OctagonAlertIcon:Ov,OctagonIcon:fJ,OctagonMinus:pJ,OctagonMinusIcon:pJ,OctagonPause:NN,OctagonPauseIcon:NN,OctagonX:kN,OctagonXIcon:kN,Omega:xJ,OmegaIcon:xJ,Option:gJ,OptionIcon:gJ,Orbit:yJ,OrbitIcon:yJ,Origami:vJ,OrigamiIcon:vJ,Outdent:gN,OutdentIcon:gN,Package:Ml,Package2:bJ,Package2Icon:bJ,PackageCheck:_J,PackageCheckIcon:_J,PackageIcon:Ml,PackageMinus:wJ,PackageMinusIcon:wJ,PackageOpen:jJ,PackageOpenIcon:jJ,PackagePlus:NJ,PackagePlusIcon:NJ,PackageSearch:kJ,PackageSearchIcon:kJ,PackageX:SJ,PackageXIcon:SJ,PaintBucket:CJ,PaintBucketIcon:CJ,PaintRoller:MJ,PaintRollerIcon:MJ,Paintbrush:TJ,Paintbrush2:SN,Paintbrush2Icon:SN,PaintbrushIcon:TJ,PaintbrushVertical:SN,PaintbrushVerticalIcon:SN,Palette:ac,PaletteIcon:ac,Palmtree:Uk,PalmtreeIcon:Uk,PanelBottom:PJ,PanelBottomClose:AJ,PanelBottomCloseIcon:AJ,PanelBottomDashed:CN,PanelBottomDashedIcon:CN,PanelBottomIcon:PJ,PanelBottomInactive:CN,PanelBottomInactiveIcon:CN,PanelBottomOpen:EJ,PanelBottomOpenIcon:EJ,PanelLeft:EN,PanelLeftClose:MN,PanelLeftCloseIcon:MN,PanelLeftDashed:TN,PanelLeftDashedIcon:TN,PanelLeftIcon:EN,PanelLeftInactive:TN,PanelLeftInactiveIcon:TN,PanelLeftOpen:AN,PanelLeftOpenIcon:AN,PanelRight:DJ,PanelRightClose:IJ,PanelRightCloseIcon:IJ,PanelRightDashed:PN,PanelRightDashedIcon:PN,PanelRightIcon:DJ,PanelRightInactive:PN,PanelRightInactiveIcon:PN,PanelRightOpen:LJ,PanelRightOpenIcon:LJ,PanelTop:FJ,PanelTopClose:OJ,PanelTopCloseIcon:OJ,PanelTopDashed:IN,PanelTopDashedIcon:IN,PanelTopIcon:FJ,PanelTopInactive:IN,PanelTopInactiveIcon:IN,PanelTopOpen:RJ,PanelTopOpenIcon:RJ,PanelsLeftBottom:zJ,PanelsLeftBottomIcon:zJ,PanelsLeftRight:Xj,PanelsLeftRightIcon:Xj,PanelsRightBottom:BJ,PanelsRightBottomIcon:BJ,PanelsTopBottom:FN,PanelsTopBottomIcon:FN,PanelsTopLeft:Rv,PanelsTopLeftIcon:Rv,Paperclip:dS,PaperclipIcon:dS,Parentheses:$J,ParenthesesIcon:$J,ParkingCircle:Oj,ParkingCircleIcon:Oj,ParkingCircleOff:Dj,ParkingCircleOffIcon:Dj,ParkingMeter:qJ,ParkingMeterIcon:qJ,ParkingSquare:Nk,ParkingSquareIcon:Nk,ParkingSquareOff:jk,ParkingSquareOffIcon:jk,PartyPopper:ru,PartyPopperIcon:ru,Pause:Rm,PauseCircle:Rj,PauseCircleIcon:Rj,PauseIcon:Rm,PauseOctagon:NN,PauseOctagonIcon:NN,PawPrint:UJ,PawPrintIcon:UJ,PcCase:VJ,PcCaseIcon:VJ,Pen:Jy,PenBox:ud,PenBoxIcon:ud,PenIcon:Jy,PenLine:Fv,PenLineIcon:Fv,PenOff:HJ,PenOffIcon:HJ,PenSquare:ud,PenSquareIcon:ud,PenTool:q_,PenToolIcon:q_,Pencil:Ra,PencilIcon:Ra,PencilLine:WJ,PencilLineIcon:WJ,PencilOff:GJ,PencilOffIcon:GJ,PencilRuler:KJ,PencilRulerIcon:KJ,Pentagon:ZJ,PentagonIcon:ZJ,Percent:uS,PercentCircle:Fj,PercentCircleIcon:Fj,PercentDiamond:Jj,PercentDiamondIcon:Jj,PercentIcon:uS,PercentSquare:kk,PercentSquareIcon:kk,PersonStanding:YJ,PersonStandingIcon:YJ,PhilippinePeso:XJ,PhilippinePesoIcon:XJ,Phone:Un,PhoneCall:QJ,PhoneCallIcon:QJ,PhoneForwarded:JJ,PhoneForwardedIcon:JJ,PhoneIcon:Un,PhoneIncoming:eee,PhoneIncomingIcon:eee,PhoneMissed:tee,PhoneMissedIcon:tee,PhoneOff:see,PhoneOffIcon:see,PhoneOutgoing:ree,PhoneOutgoingIcon:ree,Pi:nee,PiIcon:nee,PiSquare:Sk,PiSquareIcon:Sk,Piano:aee,PianoIcon:aee,Pickaxe:iee,PickaxeIcon:iee,PictureInPicture:lee,PictureInPicture2:oee,PictureInPicture2Icon:oee,PictureInPictureIcon:lee,PieChart:yj,PieChartIcon:yj,PiggyBank:cee,PiggyBankIcon:cee,Pilcrow:hee,PilcrowIcon:hee,PilcrowLeft:dee,PilcrowLeftIcon:dee,PilcrowRight:uee,PilcrowRightIcon:uee,PilcrowSquare:Ck,PilcrowSquareIcon:Ck,Pill:pee,PillBottle:mee,PillBottleIcon:mee,PillIcon:pee,Pin:U_,PinIcon:U_,PinOff:xL,PinOffIcon:xL,Pipette:fee,PipetteIcon:fee,Pizza:xee,PizzaIcon:xee,Plane:vee,PlaneIcon:vee,PlaneLanding:gee,PlaneLandingIcon:gee,PlaneTakeoff:yee,PlaneTakeoffIcon:yee,Play:nl,PlayCircle:pp,PlayCircleIcon:pp,PlayIcon:nl,PlaySquare:Mk,PlaySquareIcon:Mk,Plug:gL,Plug2:bee,Plug2Icon:bee,PlugIcon:gL,PlugZap:LN,PlugZap2:LN,PlugZap2Icon:LN,PlugZapIcon:LN,Plus:$s,PlusCircle:zj,PlusCircleIcon:zj,PlusIcon:$s,PlusSquare:Tk,PlusSquareIcon:Tk,Pocket:wee,PocketIcon:wee,PocketKnife:_ee,PocketKnifeIcon:_ee,Podcast:jee,PodcastIcon:jee,Pointer:kee,PointerIcon:kee,PointerOff:Nee,PointerOffIcon:Nee,Popcorn:See,PopcornIcon:See,Popsicle:Cee,PopsicleIcon:Cee,PoundSterling:Mee,PoundSterlingIcon:Mee,Power:yL,PowerCircle:Bj,PowerCircleIcon:Bj,PowerIcon:yL,PowerOff:Tee,PowerOffIcon:Tee,PowerSquare:Ak,PowerSquareIcon:Ak,Presentation:Jg,PresentationIcon:Jg,Printer:vL,PrinterCheck:Aee,PrinterCheckIcon:Aee,PrinterIcon:vL,Projector:Eee,ProjectorIcon:Eee,Proportions:Pee,ProportionsIcon:Pee,Puzzle:Iee,PuzzleIcon:Iee,Pyramid:Lee,PyramidIcon:Lee,QrCode:c1,QrCodeIcon:c1,Quote:V_,QuoteIcon:V_,Rabbit:Dee,RabbitIcon:Dee,Radar:Oee,RadarIcon:Oee,Radiation:Ree,RadiationIcon:Ree,Radical:Fee,RadicalIcon:Fee,Radio:d1,RadioIcon:d1,RadioReceiver:zee,RadioReceiverIcon:zee,RadioTower:Bee,RadioTowerIcon:Bee,Radius:$ee,RadiusIcon:$ee,RailSymbol:qee,RailSymbolIcon:qee,Rainbow:Uee,RainbowIcon:Uee,Rat:Vee,RatIcon:Vee,Ratio:Hee,RatioIcon:Hee,Receipt:ete,ReceiptCent:Wee,ReceiptCentIcon:Wee,ReceiptEuro:Gee,ReceiptEuroIcon:Gee,ReceiptIcon:ete,ReceiptIndianRupee:Kee,ReceiptIndianRupeeIcon:Kee,ReceiptJapaneseYen:Zee,ReceiptJapaneseYenIcon:Zee,ReceiptPoundSterling:Yee,ReceiptPoundSterlingIcon:Yee,ReceiptRussianRuble:Xee,ReceiptRussianRubleIcon:Xee,ReceiptSwissFranc:Qee,ReceiptSwissFrancIcon:Qee,ReceiptText:Jee,ReceiptTextIcon:Jee,RectangleEllipsis:DN,RectangleEllipsisIcon:DN,RectangleHorizontal:tte,RectangleHorizontalIcon:tte,RectangleVertical:ste,RectangleVerticalIcon:ste,Recycle:rte,RecycleIcon:rte,Redo:hS,Redo2:nte,Redo2Icon:nte,RedoDot:ate,RedoDotIcon:ate,RedoIcon:hS,RefreshCcw:zM,RefreshCcwDot:ite,RefreshCcwDotIcon:ite,RefreshCcwIcon:zM,RefreshCw:Go,RefreshCwIcon:Go,RefreshCwOff:ote,RefreshCwOffIcon:ote,Refrigerator:lte,RefrigeratorIcon:lte,Regex:cte,RegexIcon:cte,RemoveFormatting:dte,RemoveFormattingIcon:dte,Repeat:bL,Repeat1:ute,Repeat1Icon:ute,Repeat2:hte,Repeat2Icon:hte,RepeatIcon:bL,Replace:pte,ReplaceAll:mte,ReplaceAllIcon:mte,ReplaceIcon:pte,Reply:_L,ReplyAll:fte,ReplyAllIcon:fte,ReplyIcon:_L,Rewind:xte,RewindIcon:xte,Ribbon:gte,RibbonIcon:gte,Rocket:f0,RocketIcon:f0,RockingChair:yte,RockingChairIcon:yte,RollerCoaster:vte,RollerCoasterIcon:vte,Rotate3D:ON,Rotate3DIcon:ON,Rotate3d:ON,Rotate3dIcon:ON,RotateCcw:u1,RotateCcwIcon:u1,RotateCcwSquare:bte,RotateCcwSquareIcon:bte,RotateCw:wL,RotateCwIcon:wL,RotateCwSquare:_te,RotateCwSquareIcon:_te,Route:jte,RouteIcon:jte,RouteOff:wte,RouteOffIcon:wte,Router:Nte,RouterIcon:Nte,Rows:RN,Rows2:RN,Rows2Icon:RN,Rows3:FN,Rows3Icon:FN,Rows4:kte,Rows4Icon:kte,RowsIcon:RN,Rss:Ste,RssIcon:Ste,Ruler:x0,RulerIcon:x0,RussianRuble:Cte,RussianRubleIcon:Cte,Sailboat:Mte,SailboatIcon:Mte,Salad:Tte,SaladIcon:Tte,Sandwich:Ate,SandwichIcon:Ate,Satellite:Pte,SatelliteDish:Ete,SatelliteDishIcon:Ete,SatelliteIcon:Pte,Save:qc,SaveAll:Ite,SaveAllIcon:Ite,SaveIcon:qc,SaveOff:Lte,SaveOffIcon:Lte,Scale:jL,Scale3D:zN,Scale3DIcon:zN,Scale3d:zN,Scale3dIcon:zN,ScaleIcon:jL,Scaling:Dte,ScalingIcon:Dte,Scan:Ute,ScanBarcode:Ote,ScanBarcodeIcon:Ote,ScanEye:Rte,ScanEyeIcon:Rte,ScanFace:Fte,ScanFaceIcon:Fte,ScanIcon:Ute,ScanLine:zte,ScanLineIcon:zte,ScanQrCode:Bte,ScanQrCodeIcon:Bte,ScanSearch:$te,ScanSearchIcon:$te,ScanText:qte,ScanTextIcon:qte,ScatterChart:vj,ScatterChartIcon:vj,School:Vte,School2:Hk,School2Icon:Hk,SchoolIcon:Vte,Scissors:Wte,ScissorsIcon:Wte,ScissorsLineDashed:Hte,ScissorsLineDashedIcon:Hte,ScissorsSquare:Ek,ScissorsSquareDashedBottom:rk,ScissorsSquareDashedBottomIcon:rk,ScissorsSquareIcon:Ek,ScreenShare:Kte,ScreenShareIcon:Kte,ScreenShareOff:Gte,ScreenShareOffIcon:Gte,Scroll:Yte,ScrollIcon:Yte,ScrollText:Zte,ScrollTextIcon:Zte,Search:cn,SearchCheck:Xte,SearchCheckIcon:Xte,SearchCode:Qte,SearchCodeIcon:Qte,SearchIcon:cn,SearchSlash:Jte,SearchSlashIcon:Jte,SearchX:NL,SearchXIcon:NL,Section:ese,SectionIcon:ese,Send:Bn,SendHorizonal:BN,SendHorizonalIcon:BN,SendHorizontal:BN,SendHorizontalIcon:BN,SendIcon:Bn,SendToBack:tse,SendToBackIcon:tse,SeparatorHorizontal:sse,SeparatorHorizontalIcon:sse,SeparatorVertical:rse,SeparatorVerticalIcon:rse,Server:ose,ServerCog:nse,ServerCogIcon:nse,ServerCrash:ase,ServerCrashIcon:ase,ServerIcon:ose,ServerOff:ise,ServerOffIcon:ise,Settings:Xo,Settings2:kL,Settings2Icon:kL,SettingsIcon:Xo,Shapes:lse,ShapesIcon:lse,Share:SL,Share2:_d,Share2Icon:_d,ShareIcon:SL,Sheet:cse,SheetIcon:cse,Shell:dse,ShellIcon:dse,Shield:th,ShieldAlert:use,ShieldAlertIcon:use,ShieldBan:hse,ShieldBanIcon:hse,ShieldCheck:CL,ShieldCheckIcon:CL,ShieldClose:$N,ShieldCloseIcon:$N,ShieldEllipsis:mse,ShieldEllipsisIcon:mse,ShieldHalf:pse,ShieldHalfIcon:pse,ShieldIcon:th,ShieldMinus:fse,ShieldMinusIcon:fse,ShieldOff:xse,ShieldOffIcon:xse,ShieldPlus:gse,ShieldPlusIcon:gse,ShieldQuestion:yse,ShieldQuestionIcon:yse,ShieldX:$N,ShieldXIcon:$N,Ship:bse,ShipIcon:bse,ShipWheel:vse,ShipWheelIcon:vse,Shirt:_se,ShirtIcon:_se,ShoppingBag:g0,ShoppingBagIcon:g0,ShoppingBasket:wse,ShoppingBasketIcon:wse,ShoppingCart:vp,ShoppingCartIcon:vp,Shovel:jse,ShovelIcon:jse,ShowerHead:Nse,ShowerHeadIcon:Nse,Shrink:kse,ShrinkIcon:kse,Shrub:Sse,ShrubIcon:Sse,Shuffle:mS,ShuffleIcon:mS,Sidebar:EN,SidebarClose:MN,SidebarCloseIcon:MN,SidebarIcon:EN,SidebarOpen:AN,SidebarOpenIcon:AN,Sigma:Cse,SigmaIcon:Cse,SigmaSquare:Pk,SigmaSquareIcon:Pk,Signal:Pse,SignalHigh:Mse,SignalHighIcon:Mse,SignalIcon:Pse,SignalLow:Tse,SignalLowIcon:Tse,SignalMedium:Ase,SignalMediumIcon:Ase,SignalZero:Ese,SignalZeroIcon:Ese,Signature:Ise,SignatureIcon:Ise,Signpost:Dse,SignpostBig:Lse,SignpostBigIcon:Lse,SignpostIcon:Dse,Siren:Ose,SirenIcon:Ose,SkipBack:Rse,SkipBackIcon:Rse,SkipForward:Fse,SkipForwardIcon:Fse,Skull:zse,SkullIcon:zse,Slack:Bse,SlackIcon:Bse,Slash:$se,SlashIcon:$se,SlashSquare:Ik,SlashSquareIcon:Ik,Slice:qse,SliceIcon:qse,Sliders:qN,SlidersHorizontal:H_,SlidersHorizontalIcon:H_,SlidersIcon:qN,SlidersVertical:qN,SlidersVerticalIcon:qN,Smartphone:h1,SmartphoneCharging:Use,SmartphoneChargingIcon:Use,SmartphoneIcon:h1,SmartphoneNfc:Vse,SmartphoneNfcIcon:Vse,Smile:Wse,SmileIcon:Wse,SmilePlus:Hse,SmilePlusIcon:Hse,Snail:Gse,SnailIcon:Gse,Snowflake:n0,SnowflakeIcon:n0,Sofa:Kse,SofaIcon:Kse,SortAsc:J2,SortAscIcon:J2,SortDesc:Y2,SortDescIcon:Y2,Soup:Zse,SoupIcon:Zse,Space:Yse,SpaceIcon:Yse,Spade:Xse,SpadeIcon:Xse,Sparkle:Qse,SparkleIcon:Qse,Sparkles:pn,SparklesIcon:pn,Speaker:Jse,SpeakerIcon:Jse,Speech:ere,SpeechIcon:ere,SpellCheck:sre,SpellCheck2:tre,SpellCheck2Icon:tre,SpellCheckIcon:sre,Spline:rre,SplineIcon:rre,Split:nre,SplitIcon:nre,SplitSquareHorizontal:Lk,SplitSquareHorizontalIcon:Lk,SplitSquareVertical:Dk,SplitSquareVerticalIcon:Dk,SprayCan:are,SprayCanIcon:are,Sprout:ire,SproutIcon:ire,Square:y0,SquareActivity:UN,SquareActivityIcon:UN,SquareArrowDown:WN,SquareArrowDownIcon:WN,SquareArrowDownLeft:VN,SquareArrowDownLeftIcon:VN,SquareArrowDownRight:HN,SquareArrowDownRightIcon:HN,SquareArrowLeft:GN,SquareArrowLeftIcon:GN,SquareArrowOutDownLeft:KN,SquareArrowOutDownLeftIcon:KN,SquareArrowOutDownRight:ZN,SquareArrowOutDownRightIcon:ZN,SquareArrowOutUpLeft:YN,SquareArrowOutUpLeftIcon:YN,SquareArrowOutUpRight:XN,SquareArrowOutUpRightIcon:XN,SquareArrowRight:QN,SquareArrowRightIcon:QN,SquareArrowUp:tk,SquareArrowUpIcon:tk,SquareArrowUpLeft:JN,SquareArrowUpLeftIcon:JN,SquareArrowUpRight:ek,SquareArrowUpRightIcon:ek,SquareAsterisk:sk,SquareAsteriskIcon:sk,SquareBottomDashedScissors:rk,SquareBottomDashedScissorsIcon:rk,SquareChartGantt:Uy,SquareChartGanttIcon:Uy,SquareCheck:nk,SquareCheckBig:zv,SquareCheckBigIcon:zv,SquareCheckIcon:nk,SquareChevronDown:ak,SquareChevronDownIcon:ak,SquareChevronLeft:ik,SquareChevronLeftIcon:ik,SquareChevronRight:ok,SquareChevronRightIcon:ok,SquareChevronUp:lk,SquareChevronUpIcon:lk,SquareCode:ck,SquareCodeIcon:ck,SquareDashed:hk,SquareDashedBottom:lre,SquareDashedBottomCode:ore,SquareDashedBottomCodeIcon:ore,SquareDashedBottomIcon:lre,SquareDashedIcon:hk,SquareDashedKanban:dk,SquareDashedKanbanIcon:dk,SquareDashedMousePointer:uk,SquareDashedMousePointerIcon:uk,SquareDivide:mk,SquareDivideIcon:mk,SquareDot:pk,SquareDotIcon:pk,SquareEqual:fk,SquareEqualIcon:fk,SquareFunction:xk,SquareFunctionIcon:xk,SquareGanttChart:Uy,SquareGanttChartIcon:Uy,SquareIcon:y0,SquareKanban:gk,SquareKanbanIcon:gk,SquareLibrary:yk,SquareLibraryIcon:yk,SquareM:vk,SquareMIcon:vk,SquareMenu:bk,SquareMenuIcon:bk,SquareMinus:_k,SquareMinusIcon:_k,SquareMousePointer:wk,SquareMousePointerIcon:wk,SquareParking:Nk,SquareParkingIcon:Nk,SquareParkingOff:jk,SquareParkingOffIcon:jk,SquarePen:ud,SquarePenIcon:ud,SquarePercent:kk,SquarePercentIcon:kk,SquarePi:Sk,SquarePiIcon:Sk,SquarePilcrow:Ck,SquarePilcrowIcon:Ck,SquarePlay:Mk,SquarePlayIcon:Mk,SquarePlus:Tk,SquarePlusIcon:Tk,SquarePower:Ak,SquarePowerIcon:Ak,SquareRadical:cre,SquareRadicalIcon:cre,SquareScissors:Ek,SquareScissorsIcon:Ek,SquareSigma:Pk,SquareSigmaIcon:Pk,SquareSlash:Ik,SquareSlashIcon:Ik,SquareSplitHorizontal:Lk,SquareSplitHorizontalIcon:Lk,SquareSplitVertical:Dk,SquareSplitVerticalIcon:Dk,SquareSquare:dre,SquareSquareIcon:dre,SquareStack:ure,SquareStackIcon:ure,SquareTerminal:Ok,SquareTerminalIcon:Ok,SquareUser:Fk,SquareUserIcon:Fk,SquareUserRound:Rk,SquareUserRoundIcon:Rk,SquareX:zk,SquareXIcon:zk,Squircle:hre,SquircleIcon:hre,Squirrel:mre,SquirrelIcon:mre,Stamp:pre,StampIcon:pre,Star:Jn,StarHalf:fre,StarHalfIcon:fre,StarIcon:Jn,StarOff:xre,StarOffIcon:xre,Stars:pn,StarsIcon:pn,StepBack:gre,StepBackIcon:gre,StepForward:yre,StepForwardIcon:yre,Stethoscope:vre,StethoscopeIcon:vre,Sticker:bre,StickerIcon:bre,StickyNote:_re,StickyNoteIcon:_re,StopCircle:qj,StopCircleIcon:qj,Store:BM,StoreIcon:BM,StretchHorizontal:wre,StretchHorizontalIcon:wre,StretchVertical:jre,StretchVerticalIcon:jre,Strikethrough:ML,StrikethroughIcon:ML,Subscript:Nre,SubscriptIcon:Nre,Subtitles:oj,SubtitlesIcon:oj,Sun:m1,SunDim:kre,SunDimIcon:kre,SunIcon:m1,SunMedium:Sre,SunMediumIcon:Sre,SunMoon:Cre,SunMoonIcon:Cre,SunSnow:Mre,SunSnowIcon:Mre,Sunrise:Tre,SunriseIcon:Tre,Sunset:Are,SunsetIcon:Are,Superscript:Ere,SuperscriptIcon:Ere,SwatchBook:Pre,SwatchBookIcon:Pre,SwissFranc:Ire,SwissFrancIcon:Ire,SwitchCamera:Lre,SwitchCameraIcon:Lre,Sword:Dre,SwordIcon:Dre,Swords:Ore,SwordsIcon:Ore,Syringe:Rre,SyringeIcon:Rre,Table:qM,Table2:$M,Table2Icon:$M,TableCellsMerge:Fre,TableCellsMergeIcon:Fre,TableCellsSplit:zre,TableCellsSplitIcon:zre,TableColumnsSplit:Bre,TableColumnsSplitIcon:Bre,TableIcon:qM,TableOfContents:$re,TableOfContentsIcon:$re,TableProperties:qre,TablePropertiesIcon:qre,TableRowsSplit:Ure,TableRowsSplitIcon:Ure,Tablet:Hre,TabletIcon:Hre,TabletSmartphone:Vre,TabletSmartphoneIcon:Vre,Tablets:Wre,TabletsIcon:Wre,Tag:Fm,TagIcon:Fm,Tags:Gre,TagsIcon:Gre,Tally1:Kre,Tally1Icon:Kre,Tally2:Zre,Tally2Icon:Zre,Tally3:Yre,Tally3Icon:Yre,Tally4:Xre,Tally4Icon:Xre,Tally5:Qre,Tally5Icon:Qre,Tangent:Jre,TangentIcon:Jre,Target:zm,TargetIcon:zm,Telescope:ene,TelescopeIcon:ene,Tent:sne,TentIcon:sne,TentTree:tne,TentTreeIcon:tne,Terminal:rne,TerminalIcon:rne,TerminalSquare:Ok,TerminalSquareIcon:Ok,TestTube:nne,TestTube2:Bk,TestTube2Icon:Bk,TestTubeDiagonal:Bk,TestTubeDiagonalIcon:Bk,TestTubeIcon:nne,TestTubes:ane,TestTubesIcon:ane,Text:dne,TextCursor:one,TextCursorIcon:one,TextCursorInput:ine,TextCursorInputIcon:ine,TextIcon:dne,TextQuote:lne,TextQuoteIcon:lne,TextSearch:cne,TextSearchIcon:cne,TextSelect:$k,TextSelectIcon:$k,TextSelection:$k,TextSelectionIcon:$k,Theater:une,TheaterIcon:une,Thermometer:TL,ThermometerIcon:TL,ThermometerSnowflake:hne,ThermometerSnowflakeIcon:hne,ThermometerSun:mne,ThermometerSunIcon:mne,ThumbsDown:AL,ThumbsDownIcon:AL,ThumbsUp:sh,ThumbsUpIcon:sh,Ticket:EL,TicketCheck:pne,TicketCheckIcon:pne,TicketIcon:EL,TicketMinus:fne,TicketMinusIcon:fne,TicketPercent:xne,TicketPercentIcon:xne,TicketPlus:gne,TicketPlusIcon:gne,TicketSlash:yne,TicketSlashIcon:yne,TicketX:vne,TicketXIcon:vne,Tickets:_ne,TicketsIcon:_ne,TicketsPlane:bne,TicketsPlaneIcon:bne,Timer:Nne,TimerIcon:Nne,TimerOff:wne,TimerOffIcon:wne,TimerReset:jne,TimerResetIcon:jne,ToggleLeft:kne,ToggleLeftIcon:kne,ToggleRight:Sne,ToggleRightIcon:Sne,Toilet:Cne,ToiletIcon:Cne,Tornado:Mne,TornadoIcon:Mne,Torus:Tne,TorusIcon:Tne,Touchpad:Ene,TouchpadIcon:Ene,TouchpadOff:Ane,TouchpadOffIcon:Ane,TowerControl:Pne,TowerControlIcon:Pne,ToyBrick:Ine,ToyBrickIcon:Ine,Tractor:Lne,TractorIcon:Lne,TrafficCone:Dne,TrafficConeIcon:Dne,Train:qk,TrainFront:Rne,TrainFrontIcon:Rne,TrainFrontTunnel:One,TrainFrontTunnelIcon:One,TrainIcon:qk,TrainTrack:Fne,TrainTrackIcon:Fne,TramFront:qk,TramFrontIcon:qk,Trash:zne,Trash2:Nr,Trash2Icon:Nr,TrashIcon:zne,TreeDeciduous:Bne,TreeDeciduousIcon:Bne,TreePalm:Uk,TreePalmIcon:Uk,TreePine:p1,TreePineIcon:p1,Trees:$ne,TreesIcon:$ne,Trello:qne,TrelloIcon:qne,TrendingDown:pS,TrendingDownIcon:pS,TrendingUp:ul,TrendingUpDown:Une,TrendingUpDownIcon:Une,TrendingUpIcon:ul,Triangle:Hne,TriangleAlert:Ku,TriangleAlertIcon:Ku,TriangleIcon:Hne,TriangleRight:Vne,TriangleRightIcon:Vne,Trophy:xo,TrophyIcon:xo,Truck:PL,TruckIcon:PL,Turtle:Wne,TurtleIcon:Wne,Tv:Kne,Tv2:Vk,Tv2Icon:Vk,TvIcon:Kne,TvMinimal:Vk,TvMinimalIcon:Vk,TvMinimalPlay:Gne,TvMinimalPlayIcon:Gne,Twitch:Zne,TwitchIcon:Zne,Twitter:Yne,TwitterIcon:Yne,Type:Qne,TypeIcon:Qne,TypeOutline:Xne,TypeOutlineIcon:Xne,Umbrella:eae,UmbrellaIcon:eae,UmbrellaOff:Jne,UmbrellaOffIcon:Jne,Underline:IL,UnderlineIcon:IL,Undo:fS,Undo2:tae,Undo2Icon:tae,UndoDot:sae,UndoDotIcon:sae,UndoIcon:fS,UnfoldHorizontal:rae,UnfoldHorizontalIcon:rae,UnfoldVertical:nae,UnfoldVerticalIcon:nae,Ungroup:aae,UngroupIcon:aae,University:Hk,UniversityIcon:Hk,Unlink:xS,Unlink2:iae,Unlink2Icon:iae,UnlinkIcon:xS,Unlock:_N,UnlockIcon:_N,UnlockKeyhole:bN,UnlockKeyholeIcon:bN,Unplug:oae,UnplugIcon:oae,Upload:li,UploadCloud:Kj,UploadCloudIcon:Kj,UploadIcon:li,Usb:lae,UsbIcon:lae,User:to,User2:Xk,User2Icon:Xk,UserCheck:W_,UserCheck2:Wk,UserCheck2Icon:Wk,UserCheckIcon:W_,UserCircle:Vj,UserCircle2:Uj,UserCircle2Icon:Uj,UserCircleIcon:Vj,UserCog:LL,UserCog2:Gk,UserCog2Icon:Gk,UserCogIcon:LL,UserIcon:to,UserMinus:DL,UserMinus2:Kk,UserMinus2Icon:Kk,UserMinusIcon:DL,UserPen:cae,UserPenIcon:cae,UserPlus:Tl,UserPlus2:Zk,UserPlus2Icon:Zk,UserPlusIcon:Tl,UserRound:Xk,UserRoundCheck:Wk,UserRoundCheckIcon:Wk,UserRoundCog:Gk,UserRoundCogIcon:Gk,UserRoundIcon:Xk,UserRoundMinus:Kk,UserRoundMinusIcon:Kk,UserRoundPen:dae,UserRoundPenIcon:dae,UserRoundPlus:Zk,UserRoundPlusIcon:Zk,UserRoundSearch:uae,UserRoundSearchIcon:uae,UserRoundX:Yk,UserRoundXIcon:Yk,UserSearch:hae,UserSearchIcon:hae,UserSquare:Fk,UserSquare2:Rk,UserSquare2Icon:Rk,UserSquareIcon:Fk,UserX:mae,UserX2:Yk,UserX2Icon:Yk,UserXIcon:mae,Users:pr,Users2:Qk,Users2Icon:Qk,UsersIcon:pr,UsersRound:Qk,UsersRoundIcon:Qk,Utensils:e4,UtensilsCrossed:Jk,UtensilsCrossedIcon:Jk,UtensilsIcon:e4,UtilityPole:pae,UtilityPoleIcon:pae,Variable:UM,VariableIcon:UM,Vault:fae,VaultIcon:fae,Vegan:xae,VeganIcon:xae,VenetianMask:gae,VenetianMaskIcon:gae,Verified:sj,VerifiedIcon:sj,Vibrate:vae,VibrateIcon:vae,VibrateOff:yae,VibrateOffIcon:yae,Video:An,VideoIcon:An,VideoOff:bae,VideoOffIcon:bae,Videotape:_ae,VideotapeIcon:_ae,View:wae,ViewIcon:wae,Voicemail:jae,VoicemailIcon:jae,Volleyball:Nae,VolleyballIcon:Nae,Volume:Tae,Volume1:kae,Volume1Icon:kae,Volume2:Sae,Volume2Icon:Sae,VolumeIcon:Tae,VolumeOff:Cae,VolumeOffIcon:Cae,VolumeX:Mae,VolumeXIcon:Mae,Vote:Aae,VoteIcon:Aae,Wallet:OL,Wallet2:t4,Wallet2Icon:t4,WalletCards:Eae,WalletCardsIcon:Eae,WalletIcon:OL,WalletMinimal:t4,WalletMinimalIcon:t4,Wallpaper:Pae,WallpaperIcon:Pae,Wand:Iae,Wand2:Bv,Wand2Icon:Bv,WandIcon:Iae,WandSparkles:Bv,WandSparklesIcon:Bv,Warehouse:Lae,WarehouseIcon:Lae,WashingMachine:Dae,WashingMachineIcon:Dae,Watch:Oae,WatchIcon:Oae,Waves:RL,WavesIcon:RL,Waypoints:Rae,WaypointsIcon:Rae,Webcam:Fae,WebcamIcon:Fae,Webhook:Bae,WebhookIcon:Bae,WebhookOff:zae,WebhookOffIcon:zae,Weight:$ae,WeightIcon:$ae,Wheat:Uae,WheatIcon:Uae,WheatOff:qae,WheatOffIcon:qae,WholeWord:Vae,WholeWordIcon:Vae,Wifi:Zae,WifiHigh:Hae,WifiHighIcon:Hae,WifiIcon:Zae,WifiLow:Wae,WifiLowIcon:Wae,WifiOff:Gae,WifiOffIcon:Gae,WifiZero:Kae,WifiZeroIcon:Kae,Wind:Xae,WindArrowDown:Yae,WindArrowDownIcon:Yae,WindIcon:Xae,Wine:Jae,WineIcon:Jae,WineOff:Qae,WineOffIcon:Qae,Workflow:eie,WorkflowIcon:eie,Worm:tie,WormIcon:tie,WrapText:sie,WrapTextIcon:sie,Wrench:ey,WrenchIcon:ey,X:Rr,XCircle:vc,XCircleIcon:vc,XIcon:Rr,XOctagon:kN,XOctagonIcon:kN,XSquare:zk,XSquareIcon:zk,Youtube:rie,YoutubeIcon:rie,Zap:Zh,ZapIcon:Zh,ZapOff:nie,ZapOffIcon:nie,ZoomIn:G_,ZoomInIcon:G_,ZoomOut:VM,ZoomOutIcon:VM,createLucideIcon:Y,icons:Fxt},Symbol.toStringTag,{value:"Module"})),g2e="-",zxt=t=>{const s=$xt(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:l=>{const i=l.split(g2e);return i[0]===""&&i.length!==1&&i.shift(),iqe(i,s)||Bxt(l)},getConflictingClassGroupIds:(l,i)=>{const c=r[l]||[];return i&&n[l]?[...c,...n[l]]:c}}},iqe=(t,s)=>{var l;if(t.length===0)return s.classGroupId;const r=t[0],n=s.nextPart.get(r),a=n?iqe(t.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=t.join(g2e);return(l=s.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},EAe=/^\[(.+)\]$/,Bxt=t=>{if(EAe.test(t)){const s=EAe.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},$xt=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return Uxt(Object.entries(t.classGroups),r).forEach(([o,l])=>{L0e(l,n,o,s)}),n},L0e=(t,s,r,n)=>{t.forEach(a=>{if(typeof a=="string"){const o=a===""?s:PAe(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(qxt(a)){L0e(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{L0e(l,PAe(s,o),r,n)})})},PAe=(t,s)=>{let r=t;return s.split(g2e).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},qxt=t=>t.isThemeGetter,Uxt=(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,Vxt=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)}}},oqe="!",Hxt=t=>{const{separator:s,experimentalParseClassName:r}=t,n=s.length===1,a=s[0],o=s.length,l=i=>{const c=[];let u=0,p=0,f;for(let w=0;wp?f-p:void 0;return{modifiers:c,hasImportantModifier:b,baseClassName:_,maybePostfixModifierPosition:j}};return r?i=>r({className:i,parseClassName:l}):l},Wxt=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},Gxt=t=>({cache:Vxt(t.cacheSize),parseClassName:Hxt(t),...zxt(t)}),Kxt=/\s+/,Zxt=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(Kxt);let i="";for(let c=l.length-1;c>=0;c-=1){const u=l[c],{modifiers:p,hasImportantModifier:f,baseClassName:g,maybePostfixModifierPosition:b}=r(u);let _=!!b,j=n(_?g.substring(0,b):g);if(!j){if(!_){i=u+(i.length>0?" "+i:i);continue}if(j=n(g),!j){i=u+(i.length>0?" "+i:i);continue}_=!1}const w=Wxt(p).join(":"),k=f?w+oqe:w,S=k+j;if(o.includes(S))continue;o.push(S);const M=a(j,_);for(let L=0;L0?" "+i:i)}return i};function Yxt(){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=Gxt(u),n=r.cache.get,a=r.cache.set,o=i,i(c)}function i(c){const u=n(c);if(u)return u;const p=Zxt(c,r);return a(c,p),p}return function(){return o(Yxt.apply(null,arguments))}}const hc=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},cqe=/^\[(?:([a-z-]+):)?(.+)\]$/i,Qxt=/^\d+\/\d+$/,Jxt=new Set(["px","full","screen"]),egt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,tgt=/\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$/,sgt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,rgt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ngt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,vv=t=>HM(t)||Jxt.has(t)||Qxt.test(t),Tb=t=>FA(t,"length",hgt),HM=t=>!!t&&!Number.isNaN(Number(t)),Xfe=t=>FA(t,"number",HM),OP=t=>!!t&&Number.isInteger(Number(t)),agt=t=>t.endsWith("%")&&HM(t.slice(0,-1)),Yi=t=>cqe.test(t),Ab=t=>egt.test(t),igt=new Set(["length","size","percentage"]),ogt=t=>FA(t,igt,dqe),lgt=t=>FA(t,"position",dqe),cgt=new Set(["image","url"]),dgt=t=>FA(t,cgt,pgt),ugt=t=>FA(t,"",mgt),RP=()=>!0,FA=(t,s,r)=>{const n=cqe.exec(t);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},hgt=t=>tgt.test(t)&&!sgt.test(t),dqe=()=>!1,mgt=t=>rgt.test(t),pgt=t=>ngt.test(t),fgt=()=>{const t=hc("colors"),s=hc("spacing"),r=hc("blur"),n=hc("brightness"),a=hc("borderColor"),o=hc("borderRadius"),l=hc("borderSpacing"),i=hc("borderWidth"),c=hc("contrast"),u=hc("grayscale"),p=hc("hueRotate"),f=hc("invert"),g=hc("gap"),b=hc("gradientColorStops"),_=hc("gradientColorStopPositions"),j=hc("inset"),w=hc("margin"),k=hc("opacity"),S=hc("padding"),M=hc("saturate"),L=hc("scale"),I=hc("sepia"),O=hc("skew"),q=hc("space"),U=hc("translate"),B=()=>["auto","contain","none"],V=()=>["auto","hidden","clip","visible","scroll"],Z=()=>["auto",Yi,s],X=()=>[Yi,s],ee=()=>["",vv,Tb],Q=()=>["auto",HM,Yi],ie=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],re=()=>["solid","dashed","dotted","double","none"],oe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ce=()=>["start","end","center","between","around","evenly","stretch"],xe=()=>["","0",Yi],ge=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ue=()=>[HM,Yi];return{cacheSize:500,separator:":",theme:{colors:[RP],spacing:[vv,Tb],blur:["none","",Ab,Yi],brightness:ue(),borderColor:[t],borderRadius:["none","","full",Ab,Yi],borderSpacing:X(),borderWidth:ee(),contrast:ue(),grayscale:xe(),hueRotate:ue(),invert:xe(),gap:X(),gradientColorStops:[t],gradientColorStopPositions:[agt,Tb],inset:Z(),margin:Z(),opacity:ue(),padding:X(),saturate:ue(),scale:ue(),sepia:xe(),skew:ue(),space:X(),translate:X()},classGroups:{aspect:[{aspect:["auto","square","video",Yi]}],container:["container"],columns:[{columns:[Ab]}],"break-after":[{"break-after":ge()}],"break-before":[{"break-before":ge()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...ie(),Yi]}],overflow:[{overflow:V()}],"overflow-x":[{"overflow-x":V()}],"overflow-y":[{"overflow-y":V()}],overscroll:[{overscroll:B()}],"overscroll-x":[{"overscroll-x":B()}],"overscroll-y":[{"overscroll-y":B()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[j]}],"inset-x":[{"inset-x":[j]}],"inset-y":[{"inset-y":[j]}],start:[{start:[j]}],end:[{end:[j]}],top:[{top:[j]}],right:[{right:[j]}],bottom:[{bottom:[j]}],left:[{left:[j]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",OP,Yi]}],basis:[{basis:Z()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Yi]}],grow:[{grow:xe()}],shrink:[{shrink:xe()}],order:[{order:["first","last","none",OP,Yi]}],"grid-cols":[{"grid-cols":[RP]}],"col-start-end":[{col:["auto",{span:["full",OP,Yi]},Yi]}],"col-start":[{"col-start":Q()}],"col-end":[{"col-end":Q()}],"grid-rows":[{"grid-rows":[RP]}],"row-start-end":[{row:["auto",{span:[OP,Yi]},Yi]}],"row-start":[{"row-start":Q()}],"row-end":[{"row-end":Q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Yi]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Yi]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...ce()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ce(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ce(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[S]}],px:[{px:[S]}],py:[{py:[S]}],ps:[{ps:[S]}],pe:[{pe:[S]}],pt:[{pt:[S]}],pr:[{pr:[S]}],pb:[{pb:[S]}],pl:[{pl:[S]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[q]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[q]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Yi,s]}],"min-w":[{"min-w":[Yi,s,"min","max","fit"]}],"max-w":[{"max-w":[Yi,s,"none","full","min","max","fit","prose",{screen:[Ab]},Ab]}],h:[{h:[Yi,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Yi,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Yi,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Yi,s,"auto","min","max","fit"]}],"font-size":[{text:["base",Ab,Tb]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Xfe]}],"font-family":[{font:[RP]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Yi]}],"line-clamp":[{"line-clamp":["none",HM,Xfe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",vv,Yi]}],"list-image":[{"list-image":["none",Yi]}],"list-style-type":[{list:["none","disc","decimal",Yi]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...re(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",vv,Tb]}],"underline-offset":[{"underline-offset":["auto",vv,Yi]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:X()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Yi]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Yi]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ie(),lgt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",ogt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},dgt]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[_]}],"gradient-via-pos":[{via:[_]}],"gradient-to-pos":[{to:[_]}],"gradient-from":[{from:[b]}],"gradient-via":[{via:[b]}],"gradient-to":[{to:[b]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[i]}],"border-w-x":[{"border-x":[i]}],"border-w-y":[{"border-y":[i]}],"border-w-s":[{"border-s":[i]}],"border-w-e":[{"border-e":[i]}],"border-w-t":[{"border-t":[i]}],"border-w-r":[{"border-r":[i]}],"border-w-b":[{"border-b":[i]}],"border-w-l":[{"border-l":[i]}],"border-opacity":[{"border-opacity":[k]}],"border-style":[{border:[...re(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[k]}],"divide-style":[{divide:re()}],"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:["",...re()]}],"outline-offset":[{"outline-offset":[vv,Yi]}],"outline-w":[{outline:[vv,Tb]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:ee()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[vv,Tb]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Ab,ugt]}],"shadow-color":[{shadow:[RP]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...oe(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":oe()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",Ab,Yi]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[f]}],saturate:[{saturate:[M]}],sepia:[{sepia:[I]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[M]}],"backdrop-sepia":[{"backdrop-sepia":[I]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[l]}],"border-spacing-x":[{"border-spacing-x":[l]}],"border-spacing-y":[{"border-spacing-y":[l]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Yi]}],duration:[{duration:ue()}],ease:[{ease:["linear","in","out","in-out",Yi]}],delay:[{delay:ue()}],animate:[{animate:["none","spin","ping","pulse","bounce",Yi]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[L]}],"scale-x":[{"scale-x":[L]}],"scale-y":[{"scale-y":[L]}],rotate:[{rotate:[OP,Yi]}],"translate-x":[{"translate-x":[U]}],"translate-y":[{"translate-y":[U]}],"skew-x":[{"skew-x":[O]}],"skew-y":[{"skew-y":[O]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Yi]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Yi]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":X()}],"scroll-mx":[{"scroll-mx":X()}],"scroll-my":[{"scroll-my":X()}],"scroll-ms":[{"scroll-ms":X()}],"scroll-me":[{"scroll-me":X()}],"scroll-mt":[{"scroll-mt":X()}],"scroll-mr":[{"scroll-mr":X()}],"scroll-mb":[{"scroll-mb":X()}],"scroll-ml":[{"scroll-ml":X()}],"scroll-p":[{"scroll-p":X()}],"scroll-px":[{"scroll-px":X()}],"scroll-py":[{"scroll-py":X()}],"scroll-ps":[{"scroll-ps":X()}],"scroll-pe":[{"scroll-pe":X()}],"scroll-pt":[{"scroll-pt":X()}],"scroll-pr":[{"scroll-pr":X()}],"scroll-pb":[{"scroll-pb":X()}],"scroll-pl":[{"scroll-pl":X()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Yi]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[vv,Tb,Xfe]}],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"]}}},xgt=Xxt(fgt);function It(...t){return xgt(Vi(t))}function Kl(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 IAe(t){const s=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(s)}function wde(t){return t?t.replace(/<[^>]*>/g,""):""}const ggt=Dxt,uqe=N.forwardRef(({className:t,...s},r)=>e.jsx(X$e,{ref:r,className:It("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...s}));uqe.displayName=X$e.displayName;const ygt=mC("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"}}),hqe=N.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(Q$e,{ref:n,className:It(ygt({variant:s}),t),...r}));hqe.displayName=Q$e.displayName;const vgt=N.forwardRef(({className:t,...s},r)=>e.jsx(tqe,{ref:r,className:It("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",t),...s}));vgt.displayName=tqe.displayName;const mqe=N.forwardRef(({className:t,...s},r)=>e.jsx(sqe,{ref:r,className:It("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...s,children:e.jsx(Rr,{className:"h-4 w-4"})}));mqe.displayName=sqe.displayName;const pqe=N.forwardRef(({className:t,...s},r)=>e.jsx(J$e,{ref:r,className:It("text-sm font-semibold",t),...s}));pqe.displayName=J$e.displayName;const fqe=N.forwardRef(({className:t,...s},r)=>e.jsx(eqe,{ref:r,className:It("text-sm opacity-90",t),...s}));fqe.displayName=eqe.displayName;function bgt(){const{toasts:t}=Ua();return e.jsxs(ggt,{children:[t.map(function({id:s,title:r,description:n,action:a,...o}){return e.jsxs(hqe,{...o,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(pqe,{children:r}),n&&e.jsx(fqe,{children:n})]}),a,e.jsx(mqe,{})]},s)}),e.jsx(uqe,{})]})}var LAe=["light","dark"],_gt="(prefers-color-scheme: dark)",wgt=N.createContext(void 0),jgt={setTheme:t=>{},themes:[]},Ngt=()=>{var t;return(t=N.useContext(wgt))!=null?t:jgt};N.memo(({forcedTheme:t,storageKey:s,attribute:r,enableSystem:n,enableColorScheme:a,defaultTheme:o,value:l,attrs:i,nonce:c})=>{let u=o==="system",p=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${i.map(_=>`'${_}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,f=a?LAe.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",g=(_,j=!1,w=!0)=>{let k=l?l[_]:_,S=j?_+"|| ''":`'${k}'`,M="";return a&&w&&!j&&LAe.includes(_)&&(M+=`d.style.colorScheme = '${_}';`),r==="class"?j||k?M+=`c.add(${S})`:M+="null":k&&(M+=`d[s](n,${S})`),M},b=t?`!function(){${p}${g(t)}}()`:n?`!function(){try{${p}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${u})){var t='${_gt}',m=window.matchMedia(t);if(m.media!==t||m.matches){${g("dark")}}else{${g("light")}}}else if(e){${l?`var x=${JSON.stringify(l)};`:""}${g(l?"x[e]":"e",!0)}}${u?"":"else{"+g(o,!1,!1)+"}"}${f}}catch(e){}}()`:`!function(){try{${p}var e=localStorage.getItem('${s}');if(e){${l?`var x=${JSON.stringify(l)};`:""}${g(l?"x[e]":"e",!0)}}else{${g(o,!1,!1)};}${f}}catch(t){}}();`;return N.createElement("script",{nonce:c,dangerouslySetInnerHTML:{__html:b}})});var kgt=t=>{switch(t){case"success":return Mgt;case"info":return Agt;case"warning":return Tgt;case"error":return Egt;default:return null}},Sgt=Array(12).fill(0),Cgt=({visible:t,className:s})=>ht.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},ht.createElement("div",{className:"sonner-spinner"},Sgt.map((r,n)=>ht.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),Mgt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),Tgt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Agt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Egt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Pgt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ht.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ht.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Igt=()=>{let[t,s]=ht.useState(document.hidden);return ht.useEffect(()=>{let r=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},D0e=1,Lgt=class{constructor(){this.subscribe=s=>(this.subscribers.push(s),()=>{let r=this.subscribers.indexOf(s);this.subscribers.splice(r,1)}),this.publish=s=>{this.subscribers.forEach(r=>r(s))},this.addToast=s=>{this.publish(s),this.toasts=[...this.toasts,s]},this.create=s=>{var r;let{message:n,...a}=s,o=typeof(s==null?void 0:s.id)=="number"||((r=s.id)==null?void 0:r.length)>0?s.id:D0e++,l=this.toasts.find(c=>c.id===o),i=s.dismissible===void 0?!0:s.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),l?this.toasts=this.toasts.map(c=>c.id===o?(this.publish({...c,...s,id:o,title:n}),{...c,...s,id:o,dismissible:i,title:n}):c):this.addToast({title:n,...a,dismissible:i,id:o}),o},this.dismiss=s=>(this.dismissedToasts.add(s),s||this.toasts.forEach(r=>{this.subscribers.forEach(n=>n({id:r.id,dismiss:!0}))}),this.subscribers.forEach(r=>r({id:s,dismiss:!0})),s),this.message=(s,r)=>this.create({...r,message:s}),this.error=(s,r)=>this.create({...r,message:s,type:"error"}),this.success=(s,r)=>this.create({...r,type:"success",message:s}),this.info=(s,r)=>this.create({...r,type:"info",message:s}),this.warning=(s,r)=>this.create({...r,type:"warning",message:s}),this.loading=(s,r)=>this.create({...r,type:"loading",message:s}),this.promise=(s,r)=>{if(!r)return;let n;r.loading!==void 0&&(n=this.create({...r,promise:s,type:"loading",message:r.loading,description:typeof r.description!="function"?r.description:void 0}));let a=s instanceof Promise?s:s(),o=n!==void 0,l,i=a.then(async u=>{if(l=["resolve",u],ht.isValidElement(u))o=!1,this.create({id:n,type:"default",message:u});else if(Ogt(u)&&!u.ok){o=!1;let p=typeof r.error=="function"?await r.error(`HTTP error! status: ${u.status}`):r.error,f=typeof r.description=="function"?await r.description(`HTTP error! status: ${u.status}`):r.description;this.create({id:n,type:"error",message:p,description:f})}else if(r.success!==void 0){o=!1;let p=typeof r.success=="function"?await r.success(u):r.success,f=typeof r.description=="function"?await r.description(u):r.description;this.create({id:n,type:"success",message:p,description:f})}}).catch(async u=>{if(l=["reject",u],r.error!==void 0){o=!1;let p=typeof r.error=="function"?await r.error(u):r.error,f=typeof r.description=="function"?await r.description(u):r.description;this.create({id:n,type:"error",message:p,description:f})}}).finally(()=>{var u;o&&(this.dismiss(n),n=void 0),(u=r.finally)==null||u.call(r)}),c=()=>new Promise((u,p)=>i.then(()=>l[0]==="reject"?p(l[1]):u(l[1])).catch(p));return typeof n!="string"&&typeof n!="number"?{unwrap:c}:Object.assign(n,{unwrap:c})},this.custom=(s,r)=>{let n=(r==null?void 0:r.id)||D0e++;return this.create({jsx:s(n),id:n,...r}),n},this.getActiveToasts=()=>this.toasts.filter(s=>!this.dismissedToasts.has(s.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},up=new Lgt,Dgt=(t,s)=>{let r=(s==null?void 0:s.id)||D0e++;return up.addToast({title:t,...s,id:r}),r},Ogt=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",Rgt=Dgt,Fgt=()=>up.toasts,zgt=()=>up.getActiveToasts(),me=Object.assign(Rgt,{success:up.success,info:up.info,warning:up.warning,error:up.error,custom:up.custom,message:up.message,promise:up.promise,dismiss:up.dismiss,loading:up.loading},{getHistory:Fgt,getToasts:zgt});function Bgt(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))}Bgt(`: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 O7(t){return t.label!==void 0}var $gt=3,qgt="32px",Ugt="16px",DAe=4e3,Vgt=356,Hgt=14,Wgt=20,Ggt=200;function jg(...t){return t.filter(Boolean).join(" ")}function Kgt(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var Zgt=t=>{var s,r,n,a,o,l,i,c,u,p,f;let{invert:g,toast:b,unstyled:_,interacting:j,setHeights:w,visibleToasts:k,heights:S,index:M,toasts:L,expanded:I,removeToast:O,defaultRichColors:q,closeButton:U,style:B,cancelButtonStyle:V,actionButtonStyle:Z,className:X="",descriptionClassName:ee="",duration:Q,position:ie,gap:re,loadingIcon:oe,expandByDefault:ce,classNames:xe,icons:ge,closeButtonAriaLabel:ue="Close toast",pauseWhenPageIsHidden:pe}=t,[be,Me]=ht.useState(null),[Ne,Pe]=ht.useState(null),[Oe,Te]=ht.useState(!1),[ke,Be]=ht.useState(!1),[nt,Ae]=ht.useState(!1),[ft,fe]=ht.useState(!1),[Ve,at]=ht.useState(!1),[et,Ce]=ht.useState(0),[rt,Ge]=ht.useState(0),ct=ht.useRef(b.duration||Q||DAe),qe=ht.useRef(null),Ze=ht.useRef(null),Qe=M===0,He=M+1<=k,Je=b.type,it=b.dismissible!==!1,Lt=b.className||"",Vt=b.descriptionClassName||"",hs=ht.useMemo(()=>S.findIndex(Wr=>Wr.toastId===b.id)||0,[S,b.id]),Ts=ht.useMemo(()=>{var Wr;return(Wr=b.closeButton)!=null?Wr:U},[b.closeButton,U]),Cs=ht.useMemo(()=>b.duration||Q||DAe,[b.duration,Q]),cs=ht.useRef(0),er=ht.useRef(0),xt=ht.useRef(0),Es=ht.useRef(null),[ur,Mr]=ie.split("-"),Lr=ht.useMemo(()=>S.reduce((Wr,dn,Yr)=>Yr>=hs?Wr:Wr+dn.height,0),[S,hs]),fn=Igt(),ki=b.invert||g,Ea=Je==="loading";er.current=ht.useMemo(()=>hs*re+Lr,[hs,Lr]),ht.useEffect(()=>{ct.current=Cs},[Cs]),ht.useEffect(()=>{Te(!0)},[]),ht.useEffect(()=>{let Wr=Ze.current;if(Wr){let dn=Wr.getBoundingClientRect().height;return Ge(dn),w(Yr=>[{toastId:b.id,height:dn,position:b.position},...Yr]),()=>w(Yr=>Yr.filter(vi=>vi.toastId!==b.id))}},[w,b.id]),ht.useLayoutEffect(()=>{if(!Oe)return;let Wr=Ze.current,dn=Wr.style.height;Wr.style.height="auto";let Yr=Wr.getBoundingClientRect().height;Wr.style.height=dn,Ge(Yr),w(vi=>vi.find(pt=>pt.toastId===b.id)?vi.map(pt=>pt.toastId===b.id?{...pt,height:Yr}:pt):[{toastId:b.id,height:Yr,position:b.position},...vi])},[Oe,b.title,b.description,w,b.id]);let dr=ht.useCallback(()=>{Be(!0),Ce(er.current),w(Wr=>Wr.filter(dn=>dn.toastId!==b.id)),setTimeout(()=>{O(b)},Ggt)},[b,O,w,er]);ht.useEffect(()=>{if(b.promise&&Je==="loading"||b.duration===1/0||b.type==="loading")return;let Wr;return I||j||pe&&fn?(()=>{if(xt.current{var dn;(dn=b.onAutoClose)==null||dn.call(b,b),dr()},ct.current)),()=>clearTimeout(Wr)},[I,j,b,Je,pe,fn,dr]),ht.useEffect(()=>{b.delete&&dr()},[dr,b.delete]);function Jr(){var Wr,dn,Yr;return ge!=null&&ge.loading?ht.createElement("div",{className:jg(xe==null?void 0:xe.loader,(Wr=b==null?void 0:b.classNames)==null?void 0:Wr.loader,"sonner-loader"),"data-visible":Je==="loading"},ge.loading):oe?ht.createElement("div",{className:jg(xe==null?void 0:xe.loader,(dn=b==null?void 0:b.classNames)==null?void 0:dn.loader,"sonner-loader"),"data-visible":Je==="loading"},oe):ht.createElement(Cgt,{className:jg(xe==null?void 0:xe.loader,(Yr=b==null?void 0:b.classNames)==null?void 0:Yr.loader),visible:Je==="loading"})}return ht.createElement("li",{tabIndex:0,ref:Ze,className:jg(X,Lt,xe==null?void 0:xe.toast,(s=b==null?void 0:b.classNames)==null?void 0:s.toast,xe==null?void 0:xe.default,xe==null?void 0:xe[Je],(r=b==null?void 0:b.classNames)==null?void 0:r[Je]),"data-sonner-toast":"","data-rich-colors":(n=b.richColors)!=null?n:q,"data-styled":!(b.jsx||b.unstyled||_),"data-mounted":Oe,"data-promise":!!b.promise,"data-swiped":Ve,"data-removed":ke,"data-visible":He,"data-y-position":ur,"data-x-position":Mr,"data-index":M,"data-front":Qe,"data-swiping":nt,"data-dismissible":it,"data-type":Je,"data-invert":ki,"data-swipe-out":ft,"data-swipe-direction":Ne,"data-expanded":!!(I||ce&&Oe),style:{"--index":M,"--toasts-before":M,"--z-index":L.length-M,"--offset":`${ke?et:er.current}px`,"--initial-height":ce?"auto":`${rt}px`,...B,...b.style},onDragEnd:()=>{Ae(!1),Me(null),Es.current=null},onPointerDown:Wr=>{Ea||!it||(qe.current=new Date,Ce(er.current),Wr.target.setPointerCapture(Wr.pointerId),Wr.target.tagName!=="BUTTON"&&(Ae(!0),Es.current={x:Wr.clientX,y:Wr.clientY}))},onPointerUp:()=>{var Wr,dn,Yr,vi;if(ft||!it)return;Es.current=null;let pt=Number(((Wr=Ze.current)==null?void 0:Wr.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ir=Number(((dn=Ze.current)==null?void 0:dn.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Vn=new Date().getTime()-((Yr=qe.current)==null?void 0:Yr.getTime()),Sr=be==="x"?pt:ir,jr=Math.abs(Sr)/Vn;if(Math.abs(Sr)>=Wgt||jr>.11){Ce(er.current),(vi=b.onDismiss)==null||vi.call(b,b),Pe(be==="x"?pt>0?"right":"left":ir>0?"down":"up"),dr(),fe(!0),at(!1);return}Ae(!1),Me(null)},onPointerMove:Wr=>{var dn,Yr,vi,pt;if(!Es.current||!it||((dn=window.getSelection())==null?void 0:dn.toString().length)>0)return;let ir=Wr.clientY-Es.current.y,Vn=Wr.clientX-Es.current.x,Sr=(Yr=t.swipeDirections)!=null?Yr:Kgt(ie);!be&&(Math.abs(Vn)>1||Math.abs(ir)>1)&&Me(Math.abs(Vn)>Math.abs(ir)?"x":"y");let jr={x:0,y:0};be==="y"?(Sr.includes("top")||Sr.includes("bottom"))&&(Sr.includes("top")&&ir<0||Sr.includes("bottom")&&ir>0)&&(jr.y=ir):be==="x"&&(Sr.includes("left")||Sr.includes("right"))&&(Sr.includes("left")&&Vn<0||Sr.includes("right")&&Vn>0)&&(jr.x=Vn),(Math.abs(jr.x)>0||Math.abs(jr.y)>0)&&at(!0),(vi=Ze.current)==null||vi.style.setProperty("--swipe-amount-x",`${jr.x}px`),(pt=Ze.current)==null||pt.style.setProperty("--swipe-amount-y",`${jr.y}px`)}},Ts&&!b.jsx?ht.createElement("button",{"aria-label":ue,"data-disabled":Ea,"data-close-button":!0,onClick:Ea||!it?()=>{}:()=>{var Wr;dr(),(Wr=b.onDismiss)==null||Wr.call(b,b)},className:jg(xe==null?void 0:xe.closeButton,(a=b==null?void 0:b.classNames)==null?void 0:a.closeButton)},(o=ge==null?void 0:ge.close)!=null?o:Pgt):null,b.jsx||N.isValidElement(b.title)?b.jsx?b.jsx:typeof b.title=="function"?b.title():b.title:ht.createElement(ht.Fragment,null,Je||b.icon||b.promise?ht.createElement("div",{"data-icon":"",className:jg(xe==null?void 0:xe.icon,(l=b==null?void 0:b.classNames)==null?void 0:l.icon)},b.promise||b.type==="loading"&&!b.icon?b.icon||Jr():null,b.type!=="loading"?b.icon||(ge==null?void 0:ge[Je])||kgt(Je):null):null,ht.createElement("div",{"data-content":"",className:jg(xe==null?void 0:xe.content,(i=b==null?void 0:b.classNames)==null?void 0:i.content)},ht.createElement("div",{"data-title":"",className:jg(xe==null?void 0:xe.title,(c=b==null?void 0:b.classNames)==null?void 0:c.title)},typeof b.title=="function"?b.title():b.title),b.description?ht.createElement("div",{"data-description":"",className:jg(ee,Vt,xe==null?void 0:xe.description,(u=b==null?void 0:b.classNames)==null?void 0:u.description)},typeof b.description=="function"?b.description():b.description):null),N.isValidElement(b.cancel)?b.cancel:b.cancel&&O7(b.cancel)?ht.createElement("button",{"data-button":!0,"data-cancel":!0,style:b.cancelButtonStyle||V,onClick:Wr=>{var dn,Yr;O7(b.cancel)&&it&&((Yr=(dn=b.cancel).onClick)==null||Yr.call(dn,Wr),dr())},className:jg(xe==null?void 0:xe.cancelButton,(p=b==null?void 0:b.classNames)==null?void 0:p.cancelButton)},b.cancel.label):null,N.isValidElement(b.action)?b.action:b.action&&O7(b.action)?ht.createElement("button",{"data-button":!0,"data-action":!0,style:b.actionButtonStyle||Z,onClick:Wr=>{var dn,Yr;O7(b.action)&&((Yr=(dn=b.action).onClick)==null||Yr.call(dn,Wr),!Wr.defaultPrevented&&dr())},className:jg(xe==null?void 0:xe.actionButton,(f=b==null?void 0:b.classNames)==null?void 0:f.actionButton)},b.action.label):null))};function OAe(){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 Ygt(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?Ugt:qgt;function c(u){["top","right","bottom","left"].forEach(p=>{r[`${l}-${p}`]=typeof u=="number"?`${u}px`:u})}typeof n=="number"||typeof n=="string"?c(n):typeof n=="object"?["top","right","bottom","left"].forEach(u=>{n[u]===void 0?r[`${l}-${u}`]=i:r[`${l}-${u}`]=typeof n[u]=="number"?`${n[u]}px`:n[u]}):c(i)}),r}var Xgt=N.forwardRef(function(t,s){let{invert:r,position:n="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:l,className:i,offset:c,mobileOffset:u,theme:p="light",richColors:f,duration:g,style:b,visibleToasts:_=$gt,toastOptions:j,dir:w=OAe(),gap:k=Hgt,loadingIcon:S,icons:M,containerAriaLabel:L="Notifications",pauseWhenPageIsHidden:I}=t,[O,q]=ht.useState([]),U=ht.useMemo(()=>Array.from(new Set([n].concat(O.filter(pe=>pe.position).map(pe=>pe.position)))),[O,n]),[B,V]=ht.useState([]),[Z,X]=ht.useState(!1),[ee,Q]=ht.useState(!1),[ie,re]=ht.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),oe=ht.useRef(null),ce=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),xe=ht.useRef(null),ge=ht.useRef(!1),ue=ht.useCallback(pe=>{q(be=>{var Me;return(Me=be.find(Ne=>Ne.id===pe.id))!=null&&Me.delete||up.dismiss(pe.id),be.filter(({id:Ne})=>Ne!==pe.id)})},[]);return ht.useEffect(()=>up.subscribe(pe=>{if(pe.dismiss){q(be=>be.map(Me=>Me.id===pe.id?{...Me,delete:!0}:Me));return}setTimeout(()=>{d2e.flushSync(()=>{q(be=>{let Me=be.findIndex(Ne=>Ne.id===pe.id);return Me!==-1?[...be.slice(0,Me),{...be[Me],...pe},...be.slice(Me+1)]:[pe,...be]})})})}),[]),ht.useEffect(()=>{if(p!=="system"){re(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?re("dark"):re("light")),typeof window>"u")return;let pe=window.matchMedia("(prefers-color-scheme: dark)");try{pe.addEventListener("change",({matches:be})=>{re(be?"dark":"light")})}catch{pe.addListener(({matches:Me})=>{try{re(Me?"dark":"light")}catch(Ne){console.error(Ne)}})}},[p]),ht.useEffect(()=>{O.length<=1&&X(!1)},[O]),ht.useEffect(()=>{let pe=be=>{var Me,Ne;a.every(Pe=>be[Pe]||be.code===Pe)&&(X(!0),(Me=oe.current)==null||Me.focus()),be.code==="Escape"&&(document.activeElement===oe.current||(Ne=oe.current)!=null&&Ne.contains(document.activeElement))&&X(!1)};return document.addEventListener("keydown",pe),()=>document.removeEventListener("keydown",pe)},[a]),ht.useEffect(()=>{if(oe.current)return()=>{xe.current&&(xe.current.focus({preventScroll:!0}),xe.current=null,ge.current=!1)}},[oe.current]),ht.createElement("section",{ref:s,"aria-label":`${L} ${ce}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},U.map((pe,be)=>{var Me;let[Ne,Pe]=pe.split("-");return O.length?ht.createElement("ol",{key:pe,dir:w==="auto"?OAe():w,tabIndex:-1,ref:oe,className:i,"data-sonner-toaster":!0,"data-theme":ie,"data-y-position":Ne,"data-lifted":Z&&O.length>1&&!o,"data-x-position":Pe,style:{"--front-toast-height":`${((Me=B[0])==null?void 0:Me.height)||0}px`,"--width":`${Vgt}px`,"--gap":`${k}px`,...b,...Ygt(c,u)},onBlur:Oe=>{ge.current&&!Oe.currentTarget.contains(Oe.relatedTarget)&&(ge.current=!1,xe.current&&(xe.current.focus({preventScroll:!0}),xe.current=null))},onFocus:Oe=>{Oe.target instanceof HTMLElement&&Oe.target.dataset.dismissible==="false"||ge.current||(ge.current=!0,xe.current=Oe.relatedTarget)},onMouseEnter:()=>X(!0),onMouseMove:()=>X(!0),onMouseLeave:()=>{ee||X(!1)},onDragEnd:()=>X(!1),onPointerDown:Oe=>{Oe.target instanceof HTMLElement&&Oe.target.dataset.dismissible==="false"||Q(!0)},onPointerUp:()=>Q(!1)},O.filter(Oe=>!Oe.position&&be===0||Oe.position===pe).map((Oe,Te)=>{var ke,Be;return ht.createElement(Zgt,{key:Oe.id,icons:M,index:Te,toast:Oe,defaultRichColors:f,duration:(ke=j==null?void 0:j.duration)!=null?ke:g,className:j==null?void 0:j.className,descriptionClassName:j==null?void 0:j.descriptionClassName,invert:r,visibleToasts:_,closeButton:(Be=j==null?void 0:j.closeButton)!=null?Be:l,interacting:ee,position:pe,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:ue,toasts:O.filter(nt=>nt.position==Oe.position),heights:B.filter(nt=>nt.position==Oe.position),setHeights:V,expandByDefault:o,gap:k,loadingIcon:S,expanded:Z,pauseWhenPageIsHidden:I,swipeDirections:t.swipeDirections})})):null}))});const Qgt=({...t})=>{const{theme:s="system"}=Ngt();return e.jsx(Xgt,{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 Jgt=vwe[" useId ".trim().toString()]||(()=>{}),eyt=0;function Tu(t){const[s,r]=N.useState(Jgt());return wd(()=>{r(n=>n??String(eyt++))},[t]),s?`radix-${s}`:""}const tyt=["top","right","bottom","left"],lw=Math.min,rf=Math.max,ioe=Math.round,R7=Math.floor,v0=t=>({x:t,y:t}),syt={left:"right",right:"left",bottom:"top",top:"bottom"},ryt={start:"end",end:"start"};function O0e(t,s,r){return rf(t,lw(s,r))}function C1(t,s){return typeof t=="function"?t(s):t}function M1(t){return t.split("-")[0]}function zA(t){return t.split("-")[1]}function y2e(t){return t==="x"?"y":"x"}function v2e(t){return t==="y"?"height":"width"}const nyt=new Set(["top","bottom"]);function a0(t){return nyt.has(M1(t))?"y":"x"}function b2e(t){return y2e(a0(t))}function ayt(t,s,r){r===void 0&&(r=!1);const n=zA(t),a=b2e(t),o=v2e(a);let l=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(l=ooe(l)),[l,ooe(l)]}function iyt(t){const s=ooe(t);return[R0e(t),s,R0e(s)]}function R0e(t){return t.replace(/start|end/g,s=>ryt[s])}const RAe=["left","right"],FAe=["right","left"],oyt=["top","bottom"],lyt=["bottom","top"];function cyt(t,s,r){switch(t){case"top":case"bottom":return r?s?FAe:RAe:s?RAe:FAe;case"left":case"right":return s?oyt:lyt;default:return[]}}function dyt(t,s,r,n){const a=zA(t);let o=cyt(M1(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(R0e)))),o}function ooe(t){return t.replace(/left|right|bottom|top/g,s=>syt[s])}function uyt(t){return{top:0,right:0,bottom:0,left:0,...t}}function xqe(t){return typeof t!="number"?uyt(t):{top:t,right:t,bottom:t,left:t}}function loe(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 zAe(t,s,r){let{reference:n,floating:a}=t;const o=a0(s),l=b2e(s),i=v2e(l),c=M1(s),u=o==="y",p=n.x+n.width/2-a.width/2,f=n.y+n.height/2-a.height/2,g=n[i]/2-a[i]/2;let b;switch(c){case"top":b={x:p,y:n.y-a.height};break;case"bottom":b={x:p,y:n.y+n.height};break;case"right":b={x:n.x+n.width,y:f};break;case"left":b={x:n.x-a.width,y:f};break;default:b={x:n.x,y:n.y}}switch(zA(s)){case"start":b[l]-=g*(r&&u?-1:1);break;case"end":b[l]+=g*(r&&u?-1:1);break}return b}const hyt=async(t,s,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:o=[],platform:l}=r,i=o.filter(Boolean),c=await(l.isRTL==null?void 0:l.isRTL(s));let u=await l.getElementRects({reference:t,floating:s,strategy:a}),{x:p,y:f}=zAe(u,n,c),g=n,b={},_=0;for(let j=0;j({name:"arrow",options:t,async fn(s){const{x:r,y:n,placement:a,rects:o,platform:l,elements:i,middlewareData:c}=s,{element:u,padding:p=0}=C1(t,s)||{};if(u==null)return{};const f=xqe(p),g={x:r,y:n},b=b2e(a),_=v2e(b),j=await l.getDimensions(u),w=b==="y",k=w?"top":"left",S=w?"bottom":"right",M=w?"clientHeight":"clientWidth",L=o.reference[_]+o.reference[b]-g[b]-o.floating[_],I=g[b]-o.reference[b],O=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let q=O?O[M]:0;(!q||!await(l.isElement==null?void 0:l.isElement(O)))&&(q=i.floating[M]||o.floating[_]);const U=L/2-I/2,B=q/2-j[_]/2-1,V=lw(f[k],B),Z=lw(f[S],B),X=V,ee=q-j[_]-Z,Q=q/2-j[_]/2+U,ie=O0e(X,Q,ee),re=!c.arrow&&zA(a)!=null&&Q!==ie&&o.reference[_]/2-(QQ<=0)){var Z,X;const Q=(((Z=o.flip)==null?void 0:Z.index)||0)+1,ie=q[Q];if(ie&&(!(f==="alignment"?S!==a0(ie):!1)||V.every(ce=>ce.overflows[0]>0&&a0(ce.placement)===S)))return{data:{index:Q,overflows:V},reset:{placement:ie}};let re=(X=V.filter(oe=>oe.overflows[0]<=0).sort((oe,ce)=>oe.overflows[1]-ce.overflows[1])[0])==null?void 0:X.placement;if(!re)switch(b){case"bestFit":{var ee;const oe=(ee=V.filter(ce=>{if(O){const xe=a0(ce.placement);return xe===S||xe==="y"}return!0}).map(ce=>[ce.placement,ce.overflows.filter(xe=>xe>0).reduce((xe,ge)=>xe+ge,0)]).sort((ce,xe)=>ce[1]-xe[1])[0])==null?void 0:ee[0];oe&&(re=oe);break}case"initialPlacement":re=i;break}if(a!==re)return{reset:{placement:re}}}return{}}}};function BAe(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function $Ae(t){return tyt.some(s=>t[s]>=0)}const fyt=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=C1(t,s);switch(n){case"referenceHidden":{const o=await z8(s,{...a,elementContext:"reference"}),l=BAe(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:$Ae(l)}}}case"escaped":{const o=await z8(s,{...a,altBoundary:!0}),l=BAe(o,r.floating);return{data:{escapedOffsets:l,escaped:$Ae(l)}}}default:return{}}}}},gqe=new Set(["left","top"]);async function xyt(t,s){const{placement:r,platform:n,elements:a}=t,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=M1(r),i=zA(r),c=a0(r)==="y",u=gqe.has(l)?-1:1,p=o&&c?-1:1,f=C1(s,t);let{mainAxis:g,crossAxis:b,alignmentAxis:_}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return i&&typeof _=="number"&&(b=i==="end"?_*-1:_),c?{x:b*p,y:g*u}:{x:g*u,y:b*p}}const gyt=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var r,n;const{x:a,y:o,placement:l,middlewareData:i}=s,c=await xyt(s,t);return l===((r=i.offset)==null?void 0:r.placement)&&(n=i.arrow)!=null&&n.alignmentOffset?{}:{x:a+c.x,y:o+c.y,data:{...c,placement:l}}}}},yyt=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:k,y:S}=w;return{x:k,y:S}}},...c}=C1(t,s),u={x:r,y:n},p=await z8(s,c),f=a0(M1(a)),g=y2e(f);let b=u[g],_=u[f];if(o){const w=g==="y"?"top":"left",k=g==="y"?"bottom":"right",S=b+p[w],M=b-p[k];b=O0e(S,b,M)}if(l){const w=f==="y"?"top":"left",k=f==="y"?"bottom":"right",S=_+p[w],M=_-p[k];_=O0e(S,_,M)}const j=i.fn({...s,[g]:b,[f]:_});return{...j,data:{x:j.x-r,y:j.y-n,enabled:{[g]:o,[f]:l}}}}}},vyt=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:r,y:n,placement:a,rects:o,middlewareData:l}=s,{offset:i=0,mainAxis:c=!0,crossAxis:u=!0}=C1(t,s),p={x:r,y:n},f=a0(a),g=y2e(f);let b=p[g],_=p[f];const j=C1(i,s),w=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(c){const M=g==="y"?"height":"width",L=o.reference[g]-o.floating[M]+w.mainAxis,I=o.reference[g]+o.reference[M]-w.mainAxis;bI&&(b=I)}if(u){var k,S;const M=g==="y"?"width":"height",L=gqe.has(M1(a)),I=o.reference[f]-o.floating[M]+(L&&((k=l.offset)==null?void 0:k[f])||0)+(L?0:w.crossAxis),O=o.reference[f]+o.reference[M]+(L?0:((S=l.offset)==null?void 0:S[f])||0)-(L?w.crossAxis:0);_O&&(_=O)}return{[g]:b,[f]:_}}}},byt=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var r,n;const{placement:a,rects:o,platform:l,elements:i}=s,{apply:c=()=>{},...u}=C1(t,s),p=await z8(s,u),f=M1(a),g=zA(a),b=a0(a)==="y",{width:_,height:j}=o.floating;let w,k;f==="top"||f==="bottom"?(w=f,k=g===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(k=f,w=g==="end"?"top":"bottom");const S=j-p.top-p.bottom,M=_-p.left-p.right,L=lw(j-p[w],S),I=lw(_-p[k],M),O=!s.middlewareData.shift;let q=L,U=I;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&(U=M),(n=s.middlewareData.shift)!=null&&n.enabled.y&&(q=S),O&&!g){const V=rf(p.left,0),Z=rf(p.right,0),X=rf(p.top,0),ee=rf(p.bottom,0);b?U=_-2*(V!==0||Z!==0?V+Z:rf(p.left,p.right)):q=j-2*(X!==0||ee!==0?X+ee:rf(p.top,p.bottom))}await c({...s,availableWidth:U,availableHeight:q});const B=await l.getDimensions(i.floating);return _!==B.width||j!==B.height?{reset:{rects:!0}}:{}}}};function jde(){return typeof window<"u"}function BA(t){return yqe(t)?(t.nodeName||"").toLowerCase():"#document"}function ff(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function D0(t){var s;return(s=(yqe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function yqe(t){return jde()?t instanceof Node||t instanceof ff(t).Node:!1}function ay(t){return jde()?t instanceof Element||t instanceof ff(t).Element:!1}function S0(t){return jde()?t instanceof HTMLElement||t instanceof ff(t).HTMLElement:!1}function qAe(t){return!jde()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ff(t).ShadowRoot}const _yt=new Set(["inline","contents"]);function gO(t){const{overflow:s,overflowX:r,overflowY:n,display:a}=iy(t);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!_yt.has(a)}const wyt=new Set(["table","td","th"]);function jyt(t){return wyt.has(BA(t))}const Nyt=[":popover-open",":modal"];function Nde(t){return Nyt.some(s=>{try{return t.matches(s)}catch{return!1}})}const kyt=["transform","translate","scale","rotate","perspective"],Syt=["transform","translate","scale","rotate","perspective","filter"],Cyt=["paint","layout","strict","content"];function _2e(t){const s=w2e(),r=ay(t)?iy(t):t;return kyt.some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!s&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!s&&(r.filter?r.filter!=="none":!1)||Syt.some(n=>(r.willChange||"").includes(n))||Cyt.some(n=>(r.contain||"").includes(n))}function Myt(t){let s=cw(t);for(;S0(s)&&!AT(s);){if(_2e(s))return s;if(Nde(s))return null;s=cw(s)}return null}function w2e(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Tyt=new Set(["html","body","#document"]);function AT(t){return Tyt.has(BA(t))}function iy(t){return ff(t).getComputedStyle(t)}function kde(t){return ay(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function cw(t){if(BA(t)==="html")return t;const s=t.assignedSlot||t.parentNode||qAe(t)&&t.host||D0(t);return qAe(s)?s.host:s}function vqe(t){const s=cw(t);return AT(s)?t.ownerDocument?t.ownerDocument.body:t.body:S0(s)&&gO(s)?s:vqe(s)}function B8(t,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=vqe(t),o=a===((n=t.ownerDocument)==null?void 0:n.body),l=ff(a);if(o){const i=F0e(l);return s.concat(l,l.visualViewport||[],gO(a)?a:[],i&&r?B8(i):[])}return s.concat(a,B8(a,[],r))}function F0e(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function bqe(t){const s=iy(t);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=S0(t),o=a?t.offsetWidth:r,l=a?t.offsetHeight:n,i=ioe(r)!==o||ioe(n)!==l;return i&&(r=o,n=l),{width:r,height:n,$:i}}function j2e(t){return ay(t)?t:t.contextElement}function WM(t){const s=j2e(t);if(!S0(s))return v0(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:o}=bqe(s);let l=(o?ioe(r.width):r.width)/n,i=(o?ioe(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const Ayt=v0(0);function _qe(t){const s=ff(t);return!w2e()||!s.visualViewport?Ayt:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function Eyt(t,s,r){return s===void 0&&(s=!1),!r||s&&r!==ff(t)?!1:s}function OS(t,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=t.getBoundingClientRect(),o=j2e(t);let l=v0(1);s&&(n?ay(n)&&(l=WM(n)):l=WM(t));const i=Eyt(o,r,n)?_qe(o):v0(0);let c=(a.left+i.x)/l.x,u=(a.top+i.y)/l.y,p=a.width/l.x,f=a.height/l.y;if(o){const g=ff(o),b=n&&ay(n)?ff(n):n;let _=g,j=F0e(_);for(;j&&n&&b!==_;){const w=WM(j),k=j.getBoundingClientRect(),S=iy(j),M=k.left+(j.clientLeft+parseFloat(S.paddingLeft))*w.x,L=k.top+(j.clientTop+parseFloat(S.paddingTop))*w.y;c*=w.x,u*=w.y,p*=w.x,f*=w.y,c+=M,u+=L,_=ff(j),j=F0e(_)}}return loe({width:p,height:f,x:c,y:u})}function N2e(t,s){const r=kde(t).scrollLeft;return s?s.left+r:OS(D0(t)).left+r}function wqe(t,s,r){r===void 0&&(r=!1);const n=t.getBoundingClientRect(),a=n.left+s.scrollLeft-(r?0:N2e(t,n)),o=n.top+s.scrollTop;return{x:a,y:o}}function Pyt(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=D0(n),i=s?Nde(s.floating):!1;if(n===l||i&&o)return r;let c={scrollLeft:0,scrollTop:0},u=v0(1);const p=v0(0),f=S0(n);if((f||!f&&!o)&&((BA(n)!=="body"||gO(l))&&(c=kde(n)),S0(n))){const b=OS(n);u=WM(n),p.x=b.x+n.clientLeft,p.y=b.y+n.clientTop}const g=l&&!f&&!o?wqe(l,c,!0):v0(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-c.scrollLeft*u.x+p.x+g.x,y:r.y*u.y-c.scrollTop*u.y+p.y+g.y}}function Iyt(t){return Array.from(t.getClientRects())}function Lyt(t){const s=D0(t),r=kde(t),n=t.ownerDocument.body,a=rf(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),o=rf(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let l=-r.scrollLeft+N2e(t);const i=-r.scrollTop;return iy(n).direction==="rtl"&&(l+=rf(s.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}function Dyt(t,s){const r=ff(t),n=D0(t),a=r.visualViewport;let o=n.clientWidth,l=n.clientHeight,i=0,c=0;if(a){o=a.width,l=a.height;const u=w2e();(!u||u&&s==="fixed")&&(i=a.offsetLeft,c=a.offsetTop)}return{width:o,height:l,x:i,y:c}}const Oyt=new Set(["absolute","fixed"]);function Ryt(t,s){const r=OS(t,!0,s==="fixed"),n=r.top+t.clientTop,a=r.left+t.clientLeft,o=S0(t)?WM(t):v0(1),l=t.clientWidth*o.x,i=t.clientHeight*o.y,c=a*o.x,u=n*o.y;return{width:l,height:i,x:c,y:u}}function UAe(t,s,r){let n;if(s==="viewport")n=Dyt(t,r);else if(s==="document")n=Lyt(D0(t));else if(ay(s))n=Ryt(s,r);else{const a=_qe(t);n={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return loe(n)}function jqe(t,s){const r=cw(t);return r===s||!ay(r)||AT(r)?!1:iy(r).position==="fixed"||jqe(r,s)}function Fyt(t,s){const r=s.get(t);if(r)return r;let n=B8(t,[],!1).filter(i=>ay(i)&&BA(i)!=="body"),a=null;const o=iy(t).position==="fixed";let l=o?cw(t):t;for(;ay(l)&&!AT(l);){const i=iy(l),c=_2e(l);!c&&i.position==="fixed"&&(a=null),(o?!c&&!a:!c&&i.position==="static"&&!!a&&Oyt.has(a.position)||gO(l)&&!c&&jqe(t,l))?n=n.filter(p=>p!==l):a=i,l=cw(l)}return s.set(t,n),n}function zyt(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?Nde(s)?[]:Fyt(s,this._c):[].concat(r),n],i=l[0],c=l.reduce((u,p)=>{const f=UAe(s,p,a);return u.top=rf(f.top,u.top),u.right=lw(f.right,u.right),u.bottom=lw(f.bottom,u.bottom),u.left=rf(f.left,u.left),u},UAe(s,i,a));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Byt(t){const{width:s,height:r}=bqe(t);return{width:s,height:r}}function $yt(t,s,r){const n=S0(s),a=D0(s),o=r==="fixed",l=OS(t,!0,o,s);let i={scrollLeft:0,scrollTop:0};const c=v0(0);function u(){c.x=N2e(a)}if(n||!n&&!o)if((BA(s)!=="body"||gO(a))&&(i=kde(s)),n){const b=OS(s,!0,o,s);c.x=b.x+s.clientLeft,c.y=b.y+s.clientTop}else a&&u();o&&!n&&a&&u();const p=a&&!n&&!o?wqe(a,i):v0(0),f=l.left+i.scrollLeft-c.x-p.x,g=l.top+i.scrollTop-c.y-p.y;return{x:f,y:g,width:l.width,height:l.height}}function Qfe(t){return iy(t).position==="static"}function VAe(t,s){if(!S0(t)||iy(t).position==="fixed")return null;if(s)return s(t);let r=t.offsetParent;return D0(t)===r&&(r=r.ownerDocument.body),r}function Nqe(t,s){const r=ff(t);if(Nde(t))return r;if(!S0(t)){let a=cw(t);for(;a&&!AT(a);){if(ay(a)&&!Qfe(a))return a;a=cw(a)}return r}let n=VAe(t,s);for(;n&&jyt(n)&&Qfe(n);)n=VAe(n,s);return n&&AT(n)&&Qfe(n)&&!_2e(n)?r:n||Myt(t)||r}const qyt=async function(t){const s=this.getOffsetParent||Nqe,r=this.getDimensions,n=await r(t.floating);return{reference:$yt(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Uyt(t){return iy(t).direction==="rtl"}const Vyt={convertOffsetParentRelativeRectToViewportRelativeRect:Pyt,getDocumentElement:D0,getClippingRect:zyt,getOffsetParent:Nqe,getElementRects:qyt,getClientRects:Iyt,getDimensions:Byt,getScale:WM,isElement:ay,isRTL:Uyt};function kqe(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function Hyt(t,s){let r=null,n;const a=D0(t);function o(){var i;clearTimeout(n),(i=r)==null||i.disconnect(),r=null}function l(i,c){i===void 0&&(i=!1),c===void 0&&(c=1),o();const u=t.getBoundingClientRect(),{left:p,top:f,width:g,height:b}=u;if(i||s(),!g||!b)return;const _=R7(f),j=R7(a.clientWidth-(p+g)),w=R7(a.clientHeight-(f+b)),k=R7(p),M={rootMargin:-_+"px "+-j+"px "+-w+"px "+-k+"px",threshold:rf(0,lw(1,c))||1};let L=!0;function I(O){const q=O[0].intersectionRatio;if(q!==c){if(!L)return l();q?l(!1,q):n=setTimeout(()=>{l(!1,1e-7)},1e3)}q===1&&!kqe(u,t.getBoundingClientRect())&&l(),L=!1}try{r=new IntersectionObserver(I,{...M,root:a.ownerDocument})}catch{r=new IntersectionObserver(I,M)}r.observe(t)}return l(!0),o}function Wyt(t,s,r,n){n===void 0&&(n={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,u=j2e(t),p=a||o?[...u?B8(u):[],...B8(s)]:[];p.forEach(k=>{a&&k.addEventListener("scroll",r,{passive:!0}),o&&k.addEventListener("resize",r)});const f=u&&i?Hyt(u,r):null;let g=-1,b=null;l&&(b=new ResizeObserver(k=>{let[S]=k;S&&S.target===u&&b&&(b.unobserve(s),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var M;(M=b)==null||M.observe(s)})),r()}),u&&!c&&b.observe(u),b.observe(s));let _,j=c?OS(t):null;c&&w();function w(){const k=OS(t);j&&!kqe(j,k)&&r(),j=k,_=requestAnimationFrame(w)}return r(),()=>{var k;p.forEach(S=>{a&&S.removeEventListener("scroll",r),o&&S.removeEventListener("resize",r)}),f==null||f(),(k=b)==null||k.disconnect(),b=null,c&&cancelAnimationFrame(_)}}const Gyt=gyt,Kyt=yyt,Zyt=pyt,Yyt=byt,Xyt=fyt,HAe=myt,Qyt=vyt,Jyt=(t,s,r)=>{const n=new Map,a={platform:Vyt,...r},o={...a.platform,_c:n};return hyt(t,s,{...a,platform:o})};var e0t=typeof document<"u",t0t=function(){},aie=e0t?N.useLayoutEffect:t0t;function coe(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(!coe(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)&&!coe(t[o],s[o]))return!1}return!0}return t!==t&&s!==s}function Sqe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function WAe(t,s){const r=Sqe(t);return Math.round(s*r)/r}function Jfe(t){const s=N.useRef(t);return aie(()=>{s.current=t}),s}function s0t(t){t===void 0&&(t={});const{placement:s="bottom",strategy:r="absolute",middleware:n=[],platform:a,elements:{reference:o,floating:l}={},transform:i=!0,whileElementsMounted:c,open:u}=t,[p,f]=N.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[g,b]=N.useState(n);coe(g,n)||b(n);const[_,j]=N.useState(null),[w,k]=N.useState(null),S=N.useCallback(ce=>{ce!==O.current&&(O.current=ce,j(ce))},[]),M=N.useCallback(ce=>{ce!==q.current&&(q.current=ce,k(ce))},[]),L=o||_,I=l||w,O=N.useRef(null),q=N.useRef(null),U=N.useRef(p),B=c!=null,V=Jfe(c),Z=Jfe(a),X=Jfe(u),ee=N.useCallback(()=>{if(!O.current||!q.current)return;const ce={placement:s,strategy:r,middleware:g};Z.current&&(ce.platform=Z.current),Jyt(O.current,q.current,ce).then(xe=>{const ge={...xe,isPositioned:X.current!==!1};Q.current&&!coe(U.current,ge)&&(U.current=ge,yp.flushSync(()=>{f(ge)}))})},[g,s,r,Z,X]);aie(()=>{u===!1&&U.current.isPositioned&&(U.current.isPositioned=!1,f(ce=>({...ce,isPositioned:!1})))},[u]);const Q=N.useRef(!1);aie(()=>(Q.current=!0,()=>{Q.current=!1}),[]),aie(()=>{if(L&&(O.current=L),I&&(q.current=I),L&&I){if(V.current)return V.current(L,I,ee);ee()}},[L,I,ee,V,B]);const ie=N.useMemo(()=>({reference:O,floating:q,setReference:S,setFloating:M}),[S,M]),re=N.useMemo(()=>({reference:L,floating:I}),[L,I]),oe=N.useMemo(()=>{const ce={position:r,left:0,top:0};if(!re.floating)return ce;const xe=WAe(re.floating,p.x),ge=WAe(re.floating,p.y);return i?{...ce,transform:"translate("+xe+"px, "+ge+"px)",...Sqe(re.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:xe,top:ge}},[r,i,re.floating,p.x,p.y]);return N.useMemo(()=>({...p,update:ee,refs:ie,elements:re,floatingStyles:oe}),[p,ee,ie,re,oe])}const r0t=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?HAe({element:n.current,padding:a}).fn(r):{}:n?HAe({element:n,padding:a}).fn(r):{}}}},n0t=(t,s)=>({...Gyt(t),options:[t,s]}),a0t=(t,s)=>({...Kyt(t),options:[t,s]}),i0t=(t,s)=>({...Qyt(t),options:[t,s]}),o0t=(t,s)=>({...Zyt(t),options:[t,s]}),l0t=(t,s)=>({...Yyt(t),options:[t,s]}),c0t=(t,s)=>({...Xyt(t),options:[t,s]}),d0t=(t,s)=>({...r0t(t),options:[t,s]});var u0t="Arrow",Cqe=N.forwardRef((t,s)=>{const{children:r,width:n=10,height:a=5,...o}=t;return e.jsx(nn.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"})})});Cqe.displayName=u0t;var h0t=Cqe;function yO(t){const[s,r]=N.useState(void 0);return wd(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const n=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const o=a[0];let l,i;if("borderBoxSize"in o){const c=o.borderBoxSize,u=Array.isArray(c)?c[0]:c;l=u.inlineSize,i=u.blockSize}else l=t.offsetWidth,i=t.offsetHeight;r({width:l,height:i})});return n.observe(t,{box:"border-box"}),()=>n.unobserve(t)}else r(void 0)},[t]),s}var k2e="Popper",[Mqe,O0]=ad(k2e),[m0t,Tqe]=Mqe(k2e),Aqe=t=>{const{__scopePopper:s,children:r}=t,[n,a]=N.useState(null);return e.jsx(m0t,{scope:s,anchor:n,onAnchorChange:a,children:r})};Aqe.displayName=k2e;var Eqe="PopperAnchor",Pqe=N.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=Tqe(Eqe,r),l=N.useRef(null),i=qa(s,l);return N.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||l.current)}),n?null:e.jsx(nn.div,{...a,ref:i})});Pqe.displayName=Eqe;var S2e="PopperContent",[p0t,f0t]=Mqe(S2e),Iqe=N.forwardRef((t,s)=>{var Oe,Te,ke,Be,nt,Ae;const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:i=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:p=0,sticky:f="partial",hideWhenDetached:g=!1,updatePositionStrategy:b="optimized",onPlaced:_,...j}=t,w=Tqe(S2e,r),[k,S]=N.useState(null),M=qa(s,ft=>S(ft)),[L,I]=N.useState(null),O=yO(L),q=(O==null?void 0:O.width)??0,U=(O==null?void 0:O.height)??0,B=n+(o!=="center"?"-"+o:""),V=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},Z=Array.isArray(u)?u:[u],X=Z.length>0,ee={padding:V,boundary:Z.filter(g0t),altBoundary:X},{refs:Q,floatingStyles:ie,placement:re,isPositioned:oe,middlewareData:ce}=s0t({strategy:"fixed",placement:B,whileElementsMounted:(...ft)=>Wyt(...ft,{animationFrame:b==="always"}),elements:{reference:w.anchor},middleware:[n0t({mainAxis:a+U,alignmentAxis:l}),c&&a0t({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?i0t():void 0,...ee}),c&&o0t({...ee}),l0t({...ee,apply:({elements:ft,rects:fe,availableWidth:Ve,availableHeight:at})=>{const{width:et,height:Ce}=fe.reference,rt=ft.floating.style;rt.setProperty("--radix-popper-available-width",`${Ve}px`),rt.setProperty("--radix-popper-available-height",`${at}px`),rt.setProperty("--radix-popper-anchor-width",`${et}px`),rt.setProperty("--radix-popper-anchor-height",`${Ce}px`)}}),L&&d0t({element:L,padding:i}),y0t({arrowWidth:q,arrowHeight:U}),g&&c0t({strategy:"referenceHidden",...ee})]}),[xe,ge]=Oqe(re),ue=yd(_);wd(()=>{oe&&(ue==null||ue())},[oe,ue]);const pe=(Oe=ce.arrow)==null?void 0:Oe.x,be=(Te=ce.arrow)==null?void 0:Te.y,Me=((ke=ce.arrow)==null?void 0:ke.centerOffset)!==0,[Ne,Pe]=N.useState();return wd(()=>{k&&Pe(window.getComputedStyle(k).zIndex)},[k]),e.jsx("div",{ref:Q.setFloating,"data-radix-popper-content-wrapper":"",style:{...ie,transform:oe?ie.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ne,"--radix-popper-transform-origin":[(Be=ce.transformOrigin)==null?void 0:Be.x,(nt=ce.transformOrigin)==null?void 0:nt.y].join(" "),...((Ae=ce.hide)==null?void 0:Ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(p0t,{scope:r,placedSide:xe,onArrowChange:I,arrowX:pe,arrowY:be,shouldHideArrow:Me,children:e.jsx(nn.div,{"data-side":xe,"data-align":ge,...j,ref:M,style:{...j.style,animation:oe?void 0:"none"}})})})});Iqe.displayName=S2e;var Lqe="PopperArrow",x0t={top:"bottom",right:"left",bottom:"top",left:"right"},Dqe=N.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=f0t(Lqe,n),l=x0t[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(h0t,{...a,ref:r,style:{...a.style,display:"block"}})})});Dqe.displayName=Lqe;function g0t(t){return t!==null}var y0t=t=>({name:"transformOrigin",options:t,fn(s){var w,k,S;const{placement:r,rects:n,middlewareData:a}=s,l=((w=a.arrow)==null?void 0:w.centerOffset)!==0,i=l?0:t.arrowWidth,c=l?0:t.arrowHeight,[u,p]=Oqe(r),f={start:"0%",center:"50%",end:"100%"}[p],g=(((k=a.arrow)==null?void 0:k.x)??0)+i/2,b=(((S=a.arrow)==null?void 0:S.y)??0)+c/2;let _="",j="";return u==="bottom"?(_=l?f:`${g}px`,j=`${-c}px`):u==="top"?(_=l?f:`${g}px`,j=`${n.floating.height+c}px`):u==="right"?(_=`${-c}px`,j=l?f:`${b}px`):u==="left"&&(_=`${n.floating.width+c}px`,j=l?f:`${b}px`),{data:{x:_,y:j}}}});function Oqe(t){const[s,r="center"]=t.split("-");return[s,r]}var vO=Aqe,$A=Pqe,bO=Iqe,_O=Dqe,[Sde]=ad("Tooltip",[O0]),Cde=O0(),Rqe="TooltipProvider",v0t=700,z0e="tooltip.open",[b0t,C2e]=Sde(Rqe),Fqe=t=>{const{__scopeTooltip:s,delayDuration:r=v0t,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,l=N.useRef(!0),i=N.useRef(!1),c=N.useRef(0);return N.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),e.jsx(b0t,{scope:s,isOpenDelayedRef:l,delayDuration:r,onOpen:N.useCallback(()=>{window.clearTimeout(c.current),l.current=!1},[]),onClose:N.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:N.useCallback(u=>{i.current=u},[]),disableHoverableContent:a,children:o})};Fqe.displayName=Rqe;var $8="Tooltip",[_0t,Mde]=Sde($8),zqe=t=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,c=C2e($8,t.__scopeTooltip),u=Cde(s),[p,f]=N.useState(null),g=Tu(),b=N.useRef(0),_=l??c.disableHoverableContent,j=i??c.delayDuration,w=N.useRef(!1),[k,S]=ah({prop:n,defaultProp:a??!1,onChange:q=>{q?(c.onOpen(),document.dispatchEvent(new CustomEvent(z0e))):c.onClose(),o==null||o(q)},caller:$8}),M=N.useMemo(()=>k?w.current?"delayed-open":"instant-open":"closed",[k]),L=N.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w.current=!1,S(!0)},[S]),I=N.useCallback(()=>{window.clearTimeout(b.current),b.current=0,S(!1)},[S]),O=N.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{w.current=!0,S(!0),b.current=0},j)},[j,S]);return N.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),e.jsx(vO,{...u,children:e.jsx(_0t,{scope:s,contentId:g,open:k,stateAttribute:M,trigger:p,onTriggerChange:f,onTriggerEnter:N.useCallback(()=>{c.isOpenDelayedRef.current?O():L()},[c.isOpenDelayedRef,O,L]),onTriggerLeave:N.useCallback(()=>{_?I():(window.clearTimeout(b.current),b.current=0)},[I,_]),onOpen:L,onClose:I,disableHoverableContent:_,children:r})})};zqe.displayName=$8;var B0e="TooltipTrigger",Bqe=N.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=Mde(B0e,r),o=C2e(B0e,r),l=Cde(r),i=N.useRef(null),c=qa(s,i,a.onTriggerChange),u=N.useRef(!1),p=N.useRef(!1),f=N.useCallback(()=>u.current=!1,[]);return N.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),e.jsx($A,{asChild:!0,...l,children:e.jsx(nn.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:c,onPointerMove:Ir(t.onPointerMove,g=>{g.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Ir(t.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Ir(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Ir(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Ir(t.onBlur,a.onClose),onClick:Ir(t.onClick,a.onClose)})})});Bqe.displayName=B0e;var w0t="TooltipPortal",[kMs,j0t]=Sde(w0t,{forceMount:void 0}),ET="TooltipContent",$qe=N.forwardRef((t,s)=>{const r=j0t(ET,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=Mde(ET,t.__scopeTooltip);return e.jsx(Fd,{present:n||l.open,children:l.disableHoverableContent?e.jsx(qqe,{side:a,...o,ref:s}):e.jsx(N0t,{side:a,...o,ref:s})})}),N0t=N.forwardRef((t,s)=>{const r=Mde(ET,t.__scopeTooltip),n=C2e(ET,t.__scopeTooltip),a=N.useRef(null),o=qa(s,a),[l,i]=N.useState(null),{trigger:c,onClose:u}=r,p=a.current,{onPointerInTransitChange:f}=n,g=N.useCallback(()=>{i(null),f(!1)},[f]),b=N.useCallback((_,j)=>{const w=_.currentTarget,k={x:_.clientX,y:_.clientY},S=T0t(k,w.getBoundingClientRect()),M=A0t(k,S),L=E0t(j.getBoundingClientRect()),I=I0t([...M,...L]);i(I),f(!0)},[f]);return N.useEffect(()=>()=>g(),[g]),N.useEffect(()=>{if(c&&p){const _=w=>b(w,p),j=w=>b(w,c);return c.addEventListener("pointerleave",_),p.addEventListener("pointerleave",j),()=>{c.removeEventListener("pointerleave",_),p.removeEventListener("pointerleave",j)}}},[c,p,b,g]),N.useEffect(()=>{if(l){const _=j=>{const w=j.target,k={x:j.clientX,y:j.clientY},S=(c==null?void 0:c.contains(w))||(p==null?void 0:p.contains(w)),M=!P0t(k,l);S?g():M&&(g(),u())};return document.addEventListener("pointermove",_),()=>document.removeEventListener("pointermove",_)}},[c,p,l,u,g]),e.jsx(qqe,{...t,ref:o})}),[k0t,S0t]=Sde($8,{isInside:!1}),C0t=I$e("TooltipContent"),qqe=N.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,c=Mde(ET,r),u=Cde(r),{onClose:p}=c;return N.useEffect(()=>(document.addEventListener(z0e,p),()=>document.removeEventListener(z0e,p)),[p]),N.useEffect(()=>{if(c.trigger){const f=g=>{const b=g.target;b!=null&&b.contains(c.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,p]),e.jsx(Nw,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:e.jsxs(bO,{"data-state":c.stateAttribute,...u,...i,ref:s,style:{...i.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(C0t,{children:n}),e.jsx(k0t,{scope:r,isInside:!0,children:e.jsx(gxt,{id:c.contentId,role:"tooltip",children:a||n})})]})})});$qe.displayName=ET;var Uqe="TooltipArrow",M0t=N.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=Cde(r);return S0t(Uqe,r).isInside?null:e.jsx(_O,{...a,...n,ref:s})});M0t.displayName=Uqe;function T0t(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 A0t(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 E0t(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 P0t(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=g>n&&r<(f-u)*(n-p)/(g-p)+u&&(a=!a)}return a}function I0t(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),L0t(s)}function L0t(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 D0t=Fqe,O0t=zqe,R0t=Bqe,Vqe=$qe;const z1=D0t,bc=O0t,_c=R0t,Yl=N.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(Vqe,{ref:n,sideOffset:s,className:It("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));Yl.displayName=Vqe.displayName;var qA=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},RS=typeof window>"u"||"Deno"in globalThis;function _m(){}function F0t(t,s){return typeof t=="function"?t(s):t}function $0e(t){return typeof t=="number"&&t>=0&&t!==1/0}function Hqe(t,s){return Math.max(t+(s||0)-Date.now(),0)}function K_(t,s){return typeof t=="function"?t(s):t}function ox(t,s){return typeof t=="function"?t(s):t}function GAe(t,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=t;if(l){if(n){if(s.queryHash!==M2e(l,s.options))return!1}else if(!q8(s.queryKey,l))return!1}if(r!=="all"){const c=s.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof i=="boolean"&&s.isStale()!==i||a&&a!==s.state.fetchStatus||o&&!o(s))}function KAe(t,s){const{exact:r,status:n,predicate:a,mutationKey:o}=t;if(o){if(!s.options.mutationKey)return!1;if(r){if(FS(s.options.mutationKey)!==FS(o))return!1}else if(!q8(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function M2e(t,s){return((s==null?void 0:s.queryKeyHashFn)||FS)(t)}function FS(t){return JSON.stringify(t,(s,r)=>q0e(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function q8(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?Object.keys(s).every(r=>q8(t[r],s[r])):!1}function Wqe(t,s){if(t===s)return t;const r=ZAe(t)&&ZAe(s);if(r||q0e(t)&&q0e(s)){const n=r?t:Object.keys(t),a=n.length,o=r?s:Object.keys(s),l=o.length,i=r?[]:{},c=new Set(n);let u=0;for(let p=0;p{setTimeout(s,t)})}function U0e(t,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,s):r.structuralSharing!==!1?Wqe(t,s):s}function B0t(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function $0t(t,s,r=0){const n=[s,...t];return r&&n.length>r?n.slice(0,-1):n}var T2e=Symbol();function Gqe(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===T2e?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Kqe(t,s){return typeof t=="function"?t(...s):!!t}var I4,c_,uT,l9e,q0t=(l9e=class extends qA{constructor(){super();Xa(this,I4);Xa(this,c_);Xa(this,uT);Yn(this,uT,s=>{if(!RS&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){is(this,c_)||this.setEventListener(is(this,uT))}onUnsubscribe(){var s;this.hasListeners()||((s=is(this,c_))==null||s.call(this),Yn(this,c_,void 0))}setEventListener(s){var r;Yn(this,uT,s),(r=is(this,c_))==null||r.call(this),Yn(this,c_,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){is(this,I4)!==s&&(Yn(this,I4,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof is(this,I4)=="boolean"?is(this,I4):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},I4=new WeakMap,c_=new WeakMap,uT=new WeakMap,l9e),A2e=new q0t,hT,d_,mT,c9e,U0t=(c9e=class extends qA{constructor(){super();Xa(this,hT,!0);Xa(this,d_);Xa(this,mT);Yn(this,mT,s=>{if(!RS&&window.addEventListener){const r=()=>s(!0),n=()=>s(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){is(this,d_)||this.setEventListener(is(this,mT))}onUnsubscribe(){var s;this.hasListeners()||((s=is(this,d_))==null||s.call(this),Yn(this,d_,void 0))}setEventListener(s){var r;Yn(this,mT,s),(r=is(this,d_))==null||r.call(this),Yn(this,d_,s(this.setOnline.bind(this)))}setOnline(s){is(this,hT)!==s&&(Yn(this,hT,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return is(this,hT)}},hT=new WeakMap,d_=new WeakMap,mT=new WeakMap,c9e),uoe=new U0t;function V0e(){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 V0t(t){return Math.min(1e3*2**t,3e4)}function Zqe(t){return(t??"online")==="online"?uoe.isOnline():!0}var Yqe=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function exe(t){return t instanceof Yqe}function Xqe(t){let s=!1,r=0,n=!1,a;const o=V0e(),l=j=>{var w;n||(g(new Yqe(j)),(w=t.abort)==null||w.call(t))},i=()=>{s=!0},c=()=>{s=!1},u=()=>A2e.isFocused()&&(t.networkMode==="always"||uoe.isOnline())&&t.canRun(),p=()=>Zqe(t.networkMode)&&t.canRun(),f=j=>{var w;n||(n=!0,(w=t.onSuccess)==null||w.call(t,j),a==null||a(),o.resolve(j))},g=j=>{var w;n||(n=!0,(w=t.onError)==null||w.call(t,j),a==null||a(),o.reject(j))},b=()=>new Promise(j=>{var w;a=k=>{(n||u())&&j(k)},(w=t.onPause)==null||w.call(t)}).then(()=>{var j;a=void 0,n||(j=t.onContinue)==null||j.call(t)}),_=()=>{if(n)return;let j;const w=r===0?t.initialPromise:void 0;try{j=w??t.fn()}catch(k){j=Promise.reject(k)}Promise.resolve(j).then(f).catch(k=>{var O;if(n)return;const S=t.retry??(RS?0:3),M=t.retryDelay??V0t,L=typeof M=="function"?M(r,k):M,I=S===!0||typeof S=="number"&&ru()?void 0:b()).then(()=>{s?g(k):_()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:c,canStart:p,start:()=>(p()?_():b().then(_),o)}}var H0t=t=>setTimeout(t,0);function W0t(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=H0t;const o=i=>{s?t.push(i):a(()=>{r(i)})},l=()=>{const i=t;t=[],i.length&&a(()=>{n(()=>{i.forEach(c=>{r(c)})})})};return{batch:i=>{let c;s++;try{c=i()}finally{s--,s||l()}return c},batchCalls:i=>(...c)=>{o(()=>{i(...c)})},schedule:o,setNotifyFunction:i=>{r=i},setBatchNotifyFunction:i=>{n=i},setScheduler:i=>{a=i}}}var vu=W0t(),L4,d9e,Qqe=(d9e=class{constructor(){Xa(this,L4)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),$0e(this.gcTime)&&Yn(this,L4,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(RS?1/0:5*60*1e3))}clearGcTimeout(){is(this,L4)&&(clearTimeout(is(this,L4)),Yn(this,L4,void 0))}},L4=new WeakMap,d9e),pT,D4,ix,O4,zh,iO,R4,Ig,Cv,u9e,G0t=(u9e=class extends Qqe{constructor(s){super();Xa(this,Ig);Xa(this,pT);Xa(this,D4);Xa(this,ix);Xa(this,O4);Xa(this,zh);Xa(this,iO);Xa(this,R4);Yn(this,R4,!1),Yn(this,iO,s.defaultOptions),this.setOptions(s.options),this.observers=[],Yn(this,O4,s.client),Yn(this,ix,is(this,O4).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,Yn(this,pT,K0t(this.options)),this.state=s.state??is(this,pT),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=is(this,zh))==null?void 0:s.promise}setOptions(s){this.options={...is(this,iO),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&is(this,ix).remove(this)}setData(s,r){const n=U0e(this.state.data,s,this.options);return Qi(this,Ig,Cv).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,Ig,Cv).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=is(this,zh))==null?void 0:n.promise;return(a=is(this,zh))==null||a.cancel(s),r?r.then(_m).catch(_m):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(is(this,pT))}isActive(){return this.observers.some(s=>ox(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===T2e||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>K_(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:!Hqe(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=is(this,zh))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=is(this,zh))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),is(this,ix).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(r=>r!==s),this.observers.length||(is(this,zh)&&(is(this,R4)?is(this,zh).cancel({revert:!0}):is(this,zh).cancelRetry()),this.scheduleGc()),is(this,ix).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Qi(this,Ig,Cv).call(this,{type:"invalidate"})}fetch(s,r){var u,p,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(is(this,zh))return is(this,zh).continueRetry(),is(this,zh).promise}if(s&&this.setOptions(s),!this.options.queryFn){const g=this.observers.find(b=>b.options.queryFn);g&&this.setOptions(g.options)}const n=new AbortController,a=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(Yn(this,R4,!0),n.signal)})},o=()=>{const g=Gqe(this.options,r),_=(()=>{const j={client:is(this,O4),queryKey:this.queryKey,meta:this.meta};return a(j),j})();return Yn(this,R4,!1),this.options.persister?this.options.persister(g,_,this):g(_)},i=(()=>{const g={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:is(this,O4),state:this.state,fetchFn:o};return a(g),g})();(u=this.options.behavior)==null||u.onFetch(i,this),Yn(this,D4,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=i.fetchOptions)==null?void 0:p.meta))&&Qi(this,Ig,Cv).call(this,{type:"fetch",meta:(f=i.fetchOptions)==null?void 0:f.meta});const c=g=>{var b,_,j,w;exe(g)&&g.silent||Qi(this,Ig,Cv).call(this,{type:"error",error:g}),exe(g)||((_=(b=is(this,ix).config).onError)==null||_.call(b,g,this),(w=(j=is(this,ix).config).onSettled)==null||w.call(j,this.state.data,g,this)),this.scheduleGc()};return Yn(this,zh,Xqe({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:g=>{var b,_,j,w;if(g===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(g)}catch(k){c(k);return}(_=(b=is(this,ix).config).onSuccess)==null||_.call(b,g,this),(w=(j=is(this,ix).config).onSettled)==null||w.call(j,g,this.state.error,this),this.scheduleGc()},onError:c,onFail:(g,b)=>{Qi(this,Ig,Cv).call(this,{type:"failed",failureCount:g,error:b})},onPause:()=>{Qi(this,Ig,Cv).call(this,{type:"pause"})},onContinue:()=>{Qi(this,Ig,Cv).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),is(this,zh).start()}},pT=new WeakMap,D4=new WeakMap,ix=new WeakMap,O4=new WeakMap,zh=new WeakMap,iO=new WeakMap,R4=new WeakMap,Ig=new WeakSet,Cv=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,...Jqe(n.data,this.options),fetchMeta:s.meta??null};case"success":return Yn(this,D4,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 exe(a)&&a.revert&&is(this,D4)?{...is(this,D4),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),vu.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),is(this,ix).notify({query:this,type:"updated",action:s})})},u9e);function Jqe(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Zqe(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function K0t(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 Yy,h9e,Z0t=(h9e=class extends qA{constructor(s={}){super();Xa(this,Yy);this.config=s,Yn(this,Yy,new Map)}build(s,r,n){const a=r.queryKey,o=r.queryHash??M2e(a,r);let l=this.get(o);return l||(l=new G0t({client:s,queryKey:a,queryHash:o,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(l)),l}add(s){is(this,Yy).has(s.queryHash)||(is(this,Yy).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=is(this,Yy).get(s.queryHash);r&&(s.destroy(),r===s&&is(this,Yy).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){vu.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return is(this,Yy).get(s)}getAll(){return[...is(this,Yy).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>GAe(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>GAe(s,n)):r}notify(s){vu.batch(()=>{this.listeners.forEach(r=>{r(s)})})}onFocus(){vu.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){vu.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},Yy=new WeakMap,h9e),Xy,ym,F4,Qy,Fb,m9e,Y0t=(m9e=class extends Qqe{constructor(s){super();Xa(this,Qy);Xa(this,Xy);Xa(this,ym);Xa(this,F4);this.mutationId=s.mutationId,Yn(this,ym,s.mutationCache),Yn(this,Xy,[]),this.state=s.state||eUe(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){is(this,Xy).includes(s)||(is(this,Xy).push(s),this.clearGcTimeout(),is(this,ym).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){Yn(this,Xy,is(this,Xy).filter(r=>r!==s)),this.scheduleGc(),is(this,ym).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){is(this,Xy).length||(this.state.status==="pending"?this.scheduleGc():is(this,ym).remove(this))}continue(){var s;return((s=is(this,F4))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var o,l,i,c,u,p,f,g,b,_,j,w,k,S,M,L,I,O,q,U;const r=()=>{Qi(this,Qy,Fb).call(this,{type:"continue"})};Yn(this,F4,Xqe({fn:()=>this.options.mutationFn?this.options.mutationFn(s):Promise.reject(new Error("No mutationFn found")),onFail:(B,V)=>{Qi(this,Qy,Fb).call(this,{type:"failed",failureCount:B,error:V})},onPause:()=>{Qi(this,Qy,Fb).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>is(this,ym).canRun(this)}));const n=this.state.status==="pending",a=!is(this,F4).canStart();try{if(n)r();else{Qi(this,Qy,Fb).call(this,{type:"pending",variables:s,isPaused:a}),await((l=(o=is(this,ym).config).onMutate)==null?void 0:l.call(o,s,this));const V=await((c=(i=this.options).onMutate)==null?void 0:c.call(i,s));V!==this.state.context&&Qi(this,Qy,Fb).call(this,{type:"pending",context:V,variables:s,isPaused:a})}const B=await is(this,F4).start();return await((p=(u=is(this,ym).config).onSuccess)==null?void 0:p.call(u,B,s,this.state.context,this)),await((g=(f=this.options).onSuccess)==null?void 0:g.call(f,B,s,this.state.context)),await((_=(b=is(this,ym).config).onSettled)==null?void 0:_.call(b,B,null,this.state.variables,this.state.context,this)),await((w=(j=this.options).onSettled)==null?void 0:w.call(j,B,null,s,this.state.context)),Qi(this,Qy,Fb).call(this,{type:"success",data:B}),B}catch(B){try{throw await((S=(k=is(this,ym).config).onError)==null?void 0:S.call(k,B,s,this.state.context,this)),await((L=(M=this.options).onError)==null?void 0:L.call(M,B,s,this.state.context)),await((O=(I=is(this,ym).config).onSettled)==null?void 0:O.call(I,void 0,B,this.state.variables,this.state.context,this)),await((U=(q=this.options).onSettled)==null?void 0:U.call(q,void 0,B,s,this.state.context)),B}finally{Qi(this,Qy,Fb).call(this,{type:"error",error:B})}}finally{is(this,ym).runNext(this)}}},Xy=new WeakMap,ym=new WeakMap,F4=new WeakMap,Qy=new WeakSet,Fb=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),vu.batch(()=>{is(this,Xy).forEach(n=>{n.onMutationUpdate(s)}),is(this,ym).notify({mutation:this,type:"updated",action:s})})},m9e);function eUe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var $v,Lg,oO,p9e,X0t=(p9e=class extends qA{constructor(s={}){super();Xa(this,$v);Xa(this,Lg);Xa(this,oO);this.config=s,Yn(this,$v,new Set),Yn(this,Lg,new Map),Yn(this,oO,0)}build(s,r,n){const a=new Y0t({mutationCache:this,mutationId:++x7(this,oO)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){is(this,$v).add(s);const r=F7(s);if(typeof r=="string"){const n=is(this,Lg).get(r);n?n.push(s):is(this,Lg).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(is(this,$v).delete(s)){const r=F7(s);if(typeof r=="string"){const n=is(this,Lg).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&is(this,Lg).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=F7(s);if(typeof r=="string"){const n=is(this,Lg).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=F7(s);if(typeof r=="string"){const a=(n=is(this,Lg).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(){vu.batch(()=>{is(this,$v).forEach(s=>{this.notify({type:"removed",mutation:s})}),is(this,$v).clear(),is(this,Lg).clear()})}getAll(){return Array.from(is(this,$v))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>KAe(r,n))}findAll(s={}){return this.getAll().filter(r=>KAe(s,r))}notify(s){vu.batch(()=>{this.listeners.forEach(r=>{r(s)})})}resumePausedMutations(){const s=this.getAll().filter(r=>r.state.isPaused);return vu.batch(()=>Promise.all(s.map(r=>r.continue().catch(_m))))}},$v=new WeakMap,Lg=new WeakMap,oO=new WeakMap,p9e);function F7(t){var s;return(s=t.options.scope)==null?void 0:s.id}function hoe(t){return{onFetch:(s,r)=>{var p,f,g,b,_;const n=s.options,a=(g=(f=(p=s.fetchOptions)==null?void 0:p.meta)==null?void 0:f.fetchMore)==null?void 0:g.direction,o=((b=s.state.data)==null?void 0:b.pages)||[],l=((_=s.state.data)==null?void 0:_.pageParams)||[];let i={pages:[],pageParams:[]},c=0;const u=async()=>{let j=!1;const w=M=>{Object.defineProperty(M,"signal",{enumerable:!0,get:()=>(s.signal.aborted?j=!0:s.signal.addEventListener("abort",()=>{j=!0}),s.signal)})},k=Gqe(s.options,s.fetchOptions),S=async(M,L,I)=>{if(j)return Promise.reject();if(L==null&&M.pages.length)return Promise.resolve(M);const q=(()=>{const Z={client:s.client,queryKey:s.queryKey,pageParam:L,direction:I?"backward":"forward",meta:s.options.meta};return w(Z),Z})(),U=await k(q),{maxPages:B}=s.options,V=I?$0t:B0t;return{pages:V(M.pages,U,B),pageParams:V(M.pageParams,L,B)}};if(a&&o.length){const M=a==="backward",L=M?tUe:H0e,I={pages:o,pageParams:l},O=L(n,I);i=await S(I,O,M)}else{const M=t??o.length;do{const L=c===0?l[0]??n.initialPageParam:H0e(n,i);if(c>0&&L==null)break;i=await S(i,L),c++}while(c{var j,w;return(w=(j=s.options).persister)==null?void 0:w.call(j,u,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r)}:s.fetchFn=u}}}function H0e(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 tUe(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 Q0t(t,s){return s?H0e(t,s)!=null:!1}function J0t(t,s){return!s||!t.getPreviousPageParam?!1:tUe(t,s)!=null}var dd,u_,h_,fT,xT,m_,gT,yT,f9e,evt=(f9e=class{constructor(t={}){Xa(this,dd);Xa(this,u_);Xa(this,h_);Xa(this,fT);Xa(this,xT);Xa(this,m_);Xa(this,gT);Xa(this,yT);Yn(this,dd,t.queryCache||new Z0t),Yn(this,u_,t.mutationCache||new X0t),Yn(this,h_,t.defaultOptions||{}),Yn(this,fT,new Map),Yn(this,xT,new Map),Yn(this,m_,0)}mount(){x7(this,m_)._++,is(this,m_)===1&&(Yn(this,gT,A2e.subscribe(async t=>{t&&(await this.resumePausedMutations(),is(this,dd).onFocus())})),Yn(this,yT,uoe.subscribe(async t=>{t&&(await this.resumePausedMutations(),is(this,dd).onOnline())})))}unmount(){var t,s;x7(this,m_)._--,is(this,m_)===0&&((t=is(this,gT))==null||t.call(this),Yn(this,gT,void 0),(s=is(this,yT))==null||s.call(this),Yn(this,yT,void 0))}isFetching(t){return is(this,dd).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return is(this,u_).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=is(this,dd).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=is(this,dd).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(K_(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(t){return is(this,dd).findAll(t).map(({queryKey:s,state:r})=>{const n=r.data;return[s,n]})}setQueryData(t,s,r){const n=this.defaultQueryOptions({queryKey:t}),a=is(this,dd).get(n.queryHash),o=a==null?void 0:a.state.data,l=F0t(s,o);if(l!==void 0)return is(this,dd).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return vu.batch(()=>is(this,dd).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=is(this,dd).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=is(this,dd);vu.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=is(this,dd);return vu.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},s)))}cancelQueries(t,s={}){const r={revert:!0,...s},n=vu.batch(()=>is(this,dd).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(_m).catch(_m)}invalidateQueries(t,s={}){return vu.batch(()=>(is(this,dd).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=vu.batch(()=>is(this,dd).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(_m)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(_m)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const r=is(this,dd).build(this,s);return r.isStaleByTime(K_(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(_m).catch(_m)}fetchInfiniteQuery(t){return t.behavior=hoe(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(_m).catch(_m)}ensureInfiniteQueryData(t){return t.behavior=hoe(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return uoe.isOnline()?is(this,u_).resumePausedMutations():Promise.resolve()}getQueryCache(){return is(this,dd)}getMutationCache(){return is(this,u_)}getDefaultOptions(){return is(this,h_)}setDefaultOptions(t){Yn(this,h_,t)}setQueryDefaults(t,s){is(this,fT).set(FS(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...is(this,fT).values()],r={};return s.forEach(n=>{q8(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){is(this,xT).set(FS(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...is(this,xT).values()],r={};return s.forEach(n=>{q8(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const s={...is(this,h_).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=M2e(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===T2e&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...is(this,h_).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){is(this,dd).clear(),is(this,u_).clear()}},dd=new WeakMap,u_=new WeakMap,h_=new WeakMap,fT=new WeakMap,xT=new WeakMap,m_=new WeakMap,gT=new WeakMap,yT=new WeakMap,f9e),lp,Mo,lO,vm,z4,vT,p_,f_,cO,bT,_T,B4,$4,x_,wT,ll,gI,W0e,G0e,K0e,Z0e,Y0e,X0e,Q0e,rUe,x9e,sUe=(x9e=class extends qA{constructor(s,r){super();Xa(this,ll);Xa(this,lp);Xa(this,Mo);Xa(this,lO);Xa(this,vm);Xa(this,z4);Xa(this,vT);Xa(this,p_);Xa(this,f_);Xa(this,cO);Xa(this,bT);Xa(this,_T);Xa(this,B4);Xa(this,$4);Xa(this,x_);Xa(this,wT,new Set);this.options=r,Yn(this,lp,s),Yn(this,f_,null),Yn(this,p_,V0e()),this.options.experimental_prefetchInRender||is(this,p_).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(is(this,Mo).addObserver(this),XAe(is(this,Mo),this.options)?Qi(this,ll,gI).call(this):this.updateResult(),Qi(this,ll,Z0e).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return J0e(is(this,Mo),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return J0e(is(this,Mo),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Qi(this,ll,Y0e).call(this),Qi(this,ll,X0e).call(this),is(this,Mo).removeObserver(this)}setOptions(s){const r=this.options,n=is(this,Mo);if(this.options=is(this,lp).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ox(this.options.enabled,is(this,Mo))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Qi(this,ll,Q0e).call(this),is(this,Mo).setOptions(this.options),r._defaulted&&!doe(this.options,r)&&is(this,lp).getQueryCache().notify({type:"observerOptionsUpdated",query:is(this,Mo),observer:this});const a=this.hasListeners();a&&QAe(is(this,Mo),n,this.options,r)&&Qi(this,ll,gI).call(this),this.updateResult(),a&&(is(this,Mo)!==n||ox(this.options.enabled,is(this,Mo))!==ox(r.enabled,is(this,Mo))||K_(this.options.staleTime,is(this,Mo))!==K_(r.staleTime,is(this,Mo)))&&Qi(this,ll,W0e).call(this);const o=Qi(this,ll,G0e).call(this);a&&(is(this,Mo)!==n||ox(this.options.enabled,is(this,Mo))!==ox(r.enabled,is(this,Mo))||o!==is(this,x_))&&Qi(this,ll,K0e).call(this,o)}getOptimisticResult(s){const r=is(this,lp).getQueryCache().build(is(this,lp),s),n=this.createResult(r,s);return svt(this,n)&&(Yn(this,vm,n),Yn(this,vT,this.options),Yn(this,z4,is(this,Mo).state)),n}getCurrentResult(){return is(this,vm)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(n,a))})}trackProp(s){is(this,wT).add(s)}getCurrentQuery(){return is(this,Mo)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=is(this,lp).defaultQueryOptions(s),n=is(this,lp).getQueryCache().build(is(this,lp),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return Qi(this,ll,gI).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),is(this,vm)))}createResult(s,r){var B;const n=is(this,Mo),a=this.options,o=is(this,vm),l=is(this,z4),i=is(this,vT),u=s!==n?s.state:is(this,lO),{state:p}=s;let f={...p},g=!1,b;if(r._optimisticResults){const V=this.hasListeners(),Z=!V&&XAe(s,r),X=V&&QAe(s,n,r,a);(Z||X)&&(f={...f,...Jqe(p.data,s.options)}),r._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:_,errorUpdatedAt:j,status:w}=f;b=f.data;let k=!1;if(r.placeholderData!==void 0&&b===void 0&&w==="pending"){let V;o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(V=o.data,k=!0):V=typeof r.placeholderData=="function"?r.placeholderData((B=is(this,_T))==null?void 0:B.state.data,is(this,_T)):r.placeholderData,V!==void 0&&(w="success",b=U0e(o==null?void 0:o.data,V,r),g=!0)}if(r.select&&b!==void 0&&!k)if(o&&b===(l==null?void 0:l.data)&&r.select===is(this,cO))b=is(this,bT);else try{Yn(this,cO,r.select),b=r.select(b),b=U0e(o==null?void 0:o.data,b,r),Yn(this,bT,b),Yn(this,f_,null)}catch(V){Yn(this,f_,V)}is(this,f_)&&(_=is(this,f_),b=is(this,bT),j=Date.now(),w="error");const S=f.fetchStatus==="fetching",M=w==="pending",L=w==="error",I=M&&S,O=b!==void 0,U={status:w,fetchStatus:f.fetchStatus,isPending:M,isSuccess:w==="success",isError:L,isInitialLoading:I,isLoading:I,data:b,dataUpdatedAt:f.dataUpdatedAt,error:_,errorUpdatedAt:j,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!M,isLoadingError:L&&!O,isPaused:f.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:L&&O,isStale:E2e(s,r),refetch:this.refetch,promise:is(this,p_),isEnabled:ox(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const V=ee=>{U.status==="error"?ee.reject(U.error):U.data!==void 0&&ee.resolve(U.data)},Z=()=>{const ee=Yn(this,p_,U.promise=V0e());V(ee)},X=is(this,p_);switch(X.status){case"pending":s.queryHash===n.queryHash&&V(X);break;case"fulfilled":(U.status==="error"||U.data!==X.value)&&Z();break;case"rejected":(U.status!=="error"||U.error!==X.reason)&&Z();break}}return U}updateResult(){const s=is(this,vm),r=this.createResult(is(this,Mo),this.options);if(Yn(this,z4,is(this,Mo).state),Yn(this,vT,this.options),is(this,z4).data!==void 0&&Yn(this,_T,is(this,Mo)),doe(r,s))return;Yn(this,vm,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!is(this,wT).size)return!0;const l=new Set(o??is(this,wT));return this.options.throwOnError&&l.add("error"),Object.keys(is(this,vm)).some(i=>{const c=i;return is(this,vm)[c]!==s[c]&&l.has(c)})};Qi(this,ll,rUe).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Qi(this,ll,Z0e).call(this)}},lp=new WeakMap,Mo=new WeakMap,lO=new WeakMap,vm=new WeakMap,z4=new WeakMap,vT=new WeakMap,p_=new WeakMap,f_=new WeakMap,cO=new WeakMap,bT=new WeakMap,_T=new WeakMap,B4=new WeakMap,$4=new WeakMap,x_=new WeakMap,wT=new WeakMap,ll=new WeakSet,gI=function(s){Qi(this,ll,Q0e).call(this);let r=is(this,Mo).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(_m)),r},W0e=function(){Qi(this,ll,Y0e).call(this);const s=K_(this.options.staleTime,is(this,Mo));if(RS||is(this,vm).isStale||!$0e(s))return;const n=Hqe(is(this,vm).dataUpdatedAt,s)+1;Yn(this,B4,setTimeout(()=>{is(this,vm).isStale||this.updateResult()},n))},G0e=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(is(this,Mo)):this.options.refetchInterval)??!1},K0e=function(s){Qi(this,ll,X0e).call(this),Yn(this,x_,s),!(RS||ox(this.options.enabled,is(this,Mo))===!1||!$0e(is(this,x_))||is(this,x_)===0)&&Yn(this,$4,setInterval(()=>{(this.options.refetchIntervalInBackground||A2e.isFocused())&&Qi(this,ll,gI).call(this)},is(this,x_)))},Z0e=function(){Qi(this,ll,W0e).call(this),Qi(this,ll,K0e).call(this,Qi(this,ll,G0e).call(this))},Y0e=function(){is(this,B4)&&(clearTimeout(is(this,B4)),Yn(this,B4,void 0))},X0e=function(){is(this,$4)&&(clearInterval(is(this,$4)),Yn(this,$4,void 0))},Q0e=function(){const s=is(this,lp).getQueryCache().build(is(this,lp),this.options);if(s===is(this,Mo))return;const r=is(this,Mo);Yn(this,Mo,s),Yn(this,lO,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},rUe=function(s){vu.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(is(this,vm))}),is(this,lp).getQueryCache().notify({query:is(this,Mo),type:"observerResultsUpdated"})})},x9e);function tvt(t,s){return ox(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function XAe(t,s){return tvt(t,s)||t.state.data!==void 0&&J0e(t,s,s.refetchOnMount)}function J0e(t,s,r){if(ox(s.enabled,t)!==!1&&K_(s.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&E2e(t,s)}return!1}function QAe(t,s,r,n){return(t!==s||ox(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&E2e(t,r)}function E2e(t,s){return ox(s.enabled,t)!==!1&&t.isStaleByTime(K_(s.staleTime,t))}function svt(t,s){return!doe(t.getCurrentResult(),s)}var rvt=class extends sUe{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:hoe()})}getOptimisticResult(t){return t.behavior=hoe(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,s){var _,j;const{state:r}=t,n=super.createResult(t,s),{isFetching:a,isRefetching:o,isError:l,isRefetchError:i}=n,c=(j=(_=r.fetchMeta)==null?void 0:_.fetchMore)==null?void 0:j.direction,u=l&&c==="forward",p=a&&c==="forward",f=l&&c==="backward",g=a&&c==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Q0t(s,r.data),hasPreviousPage:J0t(s,r.data),isFetchNextPageError:u,isFetchingNextPage:p,isFetchPreviousPageError:f,isFetchingPreviousPage:g,isRefetchError:i&&!u&&!f,isRefetching:o&&!p&&!g}}},g_,y_,cp,qv,_1,iie,eve,g9e,nvt=(g9e=class extends qA{constructor(r,n){super();Xa(this,_1);Xa(this,g_);Xa(this,y_);Xa(this,cp);Xa(this,qv);Yn(this,g_,r),this.setOptions(n),this.bindMethods(),Qi(this,_1,iie).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var a;const n=this.options;this.options=is(this,g_).defaultMutationOptions(r),doe(this.options,n)||is(this,g_).getMutationCache().notify({type:"observerOptionsUpdated",mutation:is(this,cp),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&FS(n.mutationKey)!==FS(this.options.mutationKey)?this.reset():((a=is(this,cp))==null?void 0:a.state.status)==="pending"&&is(this,cp).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=is(this,cp))==null||r.removeObserver(this)}onMutationUpdate(r){Qi(this,_1,iie).call(this),Qi(this,_1,eve).call(this,r)}getCurrentResult(){return is(this,y_)}reset(){var r;(r=is(this,cp))==null||r.removeObserver(this),Yn(this,cp,void 0),Qi(this,_1,iie).call(this),Qi(this,_1,eve).call(this)}mutate(r,n){var a;return Yn(this,qv,n),(a=is(this,cp))==null||a.removeObserver(this),Yn(this,cp,is(this,g_).getMutationCache().build(is(this,g_),this.options)),is(this,cp).addObserver(this),is(this,cp).execute(r)}},g_=new WeakMap,y_=new WeakMap,cp=new WeakMap,qv=new WeakMap,_1=new WeakSet,iie=function(){var n;const r=((n=is(this,cp))==null?void 0:n.state)??eUe();Yn(this,y_,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},eve=function(r){vu.batch(()=>{var n,a,o,l,i,c,u,p;if(is(this,qv)&&this.hasListeners()){const f=is(this,y_).variables,g=is(this,y_).context;(r==null?void 0:r.type)==="success"?((a=(n=is(this,qv)).onSuccess)==null||a.call(n,r.data,f,g),(l=(o=is(this,qv)).onSettled)==null||l.call(o,r.data,null,f,g)):(r==null?void 0:r.type)==="error"&&((c=(i=is(this,qv)).onError)==null||c.call(i,r.error,f,g),(p=(u=is(this,qv)).onSettled)==null||p.call(u,void 0,r.error,f,g))}this.listeners.forEach(f=>{f(is(this,y_))})})},g9e),nUe=N.createContext(void 0),Qt=t=>{const s=N.useContext(nUe);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},avt=({client:t,children:s})=>(N.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(nUe.Provider,{value:t,children:s})),aUe=N.createContext(!1),ivt=()=>N.useContext(aUe);aUe.Provider;function ovt(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var lvt=N.createContext(ovt()),cvt=()=>N.useContext(lvt),dvt=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},uvt=t=>{N.useEffect(()=>{t.clearReset()},[t])},hvt=({result:t,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>t.isError&&!s.isReset()&&!t.isFetching&&n&&(a&&t.data===void 0||Kqe(r,[t.error,n])),mvt=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))}},pvt=(t,s)=>t.isLoading&&t.isFetching&&!s,fvt=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,JAe=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function iUe(t,s,r){var f,g,b,_,j;const n=ivt(),a=cvt(),o=Qt(),l=o.defaultQueryOptions(t);(g=(f=o.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||g.call(f,l),l._optimisticResults=n?"isRestoring":"optimistic",mvt(l),dvt(l,a),uvt(a);const i=!o.getQueryCache().get(l.queryHash),[c]=N.useState(()=>new s(o,l)),u=c.getOptimisticResult(l),p=!n&&t.subscribed!==!1;if(N.useSyncExternalStore(N.useCallback(w=>{const k=p?c.subscribe(vu.batchCalls(w)):_m;return c.updateResult(),k},[c,p]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),N.useEffect(()=>{c.setOptions(l)},[l,c]),fvt(l,u))throw JAe(l,c,a);if(hvt({result:u,errorResetBoundary:a,throwOnError:l.throwOnError,query:o.getQueryCache().get(l.queryHash),suspense:l.suspense}))throw u.error;if((_=(b=o.getDefaultOptions().queries)==null?void 0:b._experimental_afterQuery)==null||_.call(b,l,u),l.experimental_prefetchInRender&&!RS&&pvt(u,n)){const w=i?JAe(l,c,a):(j=o.getQueryCache().get(l.queryHash))==null?void 0:j.promise;w==null||w.catch(_m).finally(()=>{c.updateResult()})}return l.notifyOnChangeProps?u:c.trackResult(u)}function mt(t,s){return iUe(t,sUe)}function Dt(t,s){const r=Qt(),[n]=N.useState(()=>new nvt(r,t));N.useEffect(()=>{n.setOptions(t)},[n,t]);const a=N.useSyncExternalStore(N.useCallback(l=>n.subscribe(vu.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=N.useCallback((l,i)=>{n.mutate(l,i).catch(_m)},[n]);if(a.error&&Kqe(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function oUe(t,s){return iUe(t,rvt)}/** * @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 U8(){return U8=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function lUe(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function gvt(){return Math.random().toString(36).substr(2,8)}function tEe(t,s){return{usr:t.state,key:t.key,idx:s}}function tve(t,s,r,n){return r===void 0&&(r=null),U8({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?UA(s):s,{state:r,key:s&&s.key||n||gvt()})}function moe(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 UA(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 yvt(t,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,i=__.Pop,c=null,u=p();u==null&&(u=0,l.replaceState(U8({},l.state,{idx:u}),""));function p(){return(l.state||{idx:null}).idx}function f(){i=__.Pop;let w=p(),k=w==null?null:w-u;u=w,c&&c({action:i,location:j.location,delta:k})}function g(w,k){i=__.Push;let S=tve(j.location,w,k);u=p()+1;let M=tEe(S,u),L=j.createHref(S);try{l.pushState(M,"",L)}catch(I){if(I instanceof DOMException&&I.name==="DataCloneError")throw I;a.location.assign(L)}o&&c&&c({action:i,location:j.location,delta:1})}function b(w,k){i=__.Replace;let S=tve(j.location,w,k);u=p();let M=tEe(S,u),L=j.createHref(S);l.replaceState(M,"",L),o&&c&&c({action:i,location:j.location,delta:0})}function _(w){let k=a.location.origin!=="null"?a.location.origin:a.location.href,S=typeof w=="string"?w:moe(w);return S=S.replace(/ $/,"%20"),Od(k,"No window.location.(origin|href) available to create URL for href: "+S),new URL(S,k)}let j={get action(){return i},get location(){return t(a,l)},listen(w){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(eEe,f),c=w,()=>{a.removeEventListener(eEe,f),c=null}},createHref(w){return s(a,w)},createURL:_,encodeLocation(w){let k=_(w);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:g,replace:b,go(w){return l.go(w)}};return j}var sEe;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(sEe||(sEe={}));function vvt(t,s,r){return r===void 0&&(r="/"),bvt(t,s,r)}function bvt(t,s,r,n){let a=typeof s=="string"?UA(s):s,o=P2e(a.pathname||"/",r);if(o==null)return null;let l=cUe(t);_vt(l);let i=null;for(let c=0;i==null&&c{let c={relativePath:i===void 0?o.path||"":i,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};c.relativePath.startsWith("/")&&(Od(c.relativePath.startsWith(n),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(n.length));let u=Z_([n,c.relativePath]),p=r.concat(c);o.children&&o.children.length>0&&(Od(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),cUe(o.children,s,p,u)),!(o.path==null&&!o.index)&&s.push({path:u,score:Mvt(u,o.index),routesMeta:p})};return t.forEach((o,l)=>{var i;if(o.path===""||!((i=o.path)!=null&&i.includes("?")))a(o,l);else for(let c of dUe(o.path))a(o,l,c)}),s}function dUe(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=dUe(n.join("/")),i=[];return i.push(...l.map(c=>c===""?o:[o,c].join("/"))),a&&i.push(...l),i.map(c=>t.startsWith("/")&&c===""?"/":c)}function _vt(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:Tvt(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const wvt=/^:[\w-]+$/,jvt=3,Nvt=2,kvt=1,Svt=10,Cvt=-2,rEe=t=>t==="*";function Mvt(t,s){let r=t.split("/"),n=r.length;return r.some(rEe)&&(n+=Cvt),s&&(n+=Nvt),r.filter(a=>!rEe(a)).reduce((a,o)=>a+(wvt.test(o)?jvt:o===""?kvt:Svt),n)}function Tvt(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 Avt(t,s,r){let{routesMeta:n}=t,a={},o="/",l=[];for(let i=0;i{let{paramName:g,isOptional:b}=p;if(g==="*"){let j=i[f]||"";l=o.slice(0,o.length-j.length).replace(/(.)\/+$/,"$1")}const _=i[f];return b&&!_?u[g]=void 0:u[g]=(_||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:l,pattern:t}}function Pvt(t,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),lUe(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let n=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,i,c)=>(n.push({paramName:i,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(n.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,s?void 0:"i"),n]}function Ivt(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return lUe(!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 P2e(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 Lvt(t,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof t=="string"?UA(t):t;return{pathname:r?r.startsWith("/")?r:Dvt(r,s):s,search:Fvt(n),hash:zvt(a)}}function Dvt(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 txe(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 Ovt(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function I2e(t,s){let r=Ovt(t);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function L2e(t,s,r,n){n===void 0&&(n=!1);let a;typeof t=="string"?a=UA(t):(a=U8({},t),Od(!a.pathname||!a.pathname.includes("?"),txe("?","pathname","search",a)),Od(!a.pathname||!a.pathname.includes("#"),txe("#","pathname","hash",a)),Od(!a.search||!a.search.includes("#"),txe("#","search","hash",a)));let o=t===""||a.pathname==="",l=o?"/":a.pathname,i;if(l==null)i=r;else{let f=s.length-1;if(!n&&l.startsWith("..")){let g=l.split("/");for(;g[0]==="..";)g.shift(),f-=1;a.pathname=g.join("/")}i=f>=0?s[f]:"/"}let c=Lvt(a,i),u=l&&l!=="/"&&l.endsWith("/"),p=(o||l===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(u||p)&&(c.pathname+="/"),c}const Z_=t=>t.join("/").replace(/\/\/+/g,"/"),Rvt=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Fvt=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,zvt=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function Bvt(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const uUe=["post","put","patch","delete"];new Set(uUe);const $vt=["get",...uUe];new Set($vt);/** * 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 V8(){return V8=Object.assign?Object.assign.bind():function(t){for(var s=1;s{i.current=!0}),N.useCallback(function(u,p){if(p===void 0&&(p={}),!i.current)return;if(typeof u=="number"){n.go(u);return}let f=L2e(u,JSON.parse(l),o,p.relative==="path");t==null&&s!=="/"&&(f.pathname=f.pathname==="/"?s:Z_([s,f.pathname])),(p.replace?n.replace:n.push)(f,p.state,p)},[s,n,l,o,t])}const Hvt=N.createContext(null);function Wvt(t){let s=N.useContext(R0).outlet;return s&&N.createElement(Hvt.Provider,{value:t},s)}function yo(){let{matches:t}=N.useContext(R0),s=t[t.length-1];return s?s.params:{}}function pUe(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=N.useContext(kw),{matches:a}=N.useContext(R0),{pathname:o}=zd(),l=JSON.stringify(I2e(a,n.v7_relativeSplatPath));return N.useMemo(()=>L2e(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function Gvt(t,s){return Kvt(t,s)}function Kvt(t,s,r,n){VA()||Od(!1);let{navigator:a}=N.useContext(kw),{matches:o}=N.useContext(R0),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=zd(),p;if(s){var f;let w=typeof s=="string"?UA(s):s;c==="/"||(f=w.pathname)!=null&&f.startsWith(c)||Od(!1),p=w}else p=u;let g=p.pathname||"/",b=g;if(c!=="/"){let w=c.replace(/^\//,"").split("/");b="/"+g.replace(/^\//,"").split("/").slice(w.length).join("/")}let _=vvt(t,{pathname:b}),j=Jvt(_&&_.map(w=>Object.assign({},w,{params:Object.assign({},i,w.params),pathname:Z_([c,a.encodeLocation?a.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?c:Z_([c,a.encodeLocation?a.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),o,r,n);return s&&j?N.createElement(Tde.Provider,{value:{location:V8({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:__.Pop}},j):j}function Zvt(){let t=r1t(),s=Bvt(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),r=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return N.createElement(N.Fragment,null,N.createElement("h2",null,"Unexpected Application Error!"),N.createElement("h3",{style:{fontStyle:"italic"}},s),r?N.createElement("pre",{style:a},r):null,null)}const Yvt=N.createElement(Zvt,null);class Xvt extends N.Component{constructor(s){super(s),this.state={location:s.location,revalidation:s.revalidation,error:s.error}}static getDerivedStateFromError(s){return{error:s}}static getDerivedStateFromProps(s,r){return r.location!==s.location||r.revalidation!=="idle"&&s.revalidation==="idle"?{error:s.error,location:s.location,revalidation:s.revalidation}:{error:s.error!==void 0?s.error:r.error,location:r.location,revalidation:s.revalidation||r.revalidation}}componentDidCatch(s,r){console.error("React Router caught the following error during render",s,r)}render(){return this.state.error!==void 0?N.createElement(R0.Provider,{value:this.props.routeContext},N.createElement(hUe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Qvt(t){let{routeContext:s,match:r,children:n}=t,a=N.useContext(D2e);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),N.createElement(R0.Provider,{value:s},n)}function Jvt(t,s,r,n){var a;if(s===void 0&&(s=[]),r===void 0&&(r=null),n===void 0&&(n=null),t==null){var o;if(!r)return null;if(r.errors)t=r.matches;else if((o=n)!=null&&o.v7_partialHydration&&s.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let l=t,i=(a=r)==null?void 0:a.errors;if(i!=null){let p=l.findIndex(f=>f.route.id&&(i==null?void 0:i[f.route.id])!==void 0);p>=0||Od(!1),l=l.slice(0,Math.min(l.length,p+1))}let c=!1,u=-1;if(r&&n&&n.v7_partialHydration)for(let p=0;p=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((p,f,g)=>{let b,_=!1,j=null,w=null;r&&(b=i&&f.route.id?i[f.route.id]:void 0,j=f.route.errorElement||Yvt,c&&(u<0&&g===0?(a1t("route-fallback"),_=!0,w=null):u===g&&(_=!0,w=f.route.hydrateFallbackElement||null)));let k=s.concat(l.slice(0,g+1)),S=()=>{let M;return b?M=j:_?M=w:f.route.Component?M=N.createElement(f.route.Component,null):f.route.element?M=f.route.element:M=p,N.createElement(Qvt,{match:f,routeContext:{outlet:p,matches:k,isDataRoute:r!=null},children:M})};return r&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?N.createElement(Xvt,{location:r.location,revalidation:r.revalidation,component:j,error:b,children:S(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):S()},null)}var fUe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(fUe||{}),xUe=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}(xUe||{});function e1t(t){let s=N.useContext(D2e);return s||Od(!1),s}function t1t(t){let s=N.useContext(qvt);return s||Od(!1),s}function s1t(t){let s=N.useContext(R0);return s||Od(!1),s}function gUe(t){let s=s1t(),r=s.matches[s.matches.length-1];return r.route.id||Od(!1),r.route.id}function r1t(){var t;let s=N.useContext(hUe),r=t1t(),n=gUe();return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function n1t(){let{router:t}=e1t(fUe.UseNavigateStable),s=gUe(xUe.UseNavigateStable),r=N.useRef(!1);return mUe(()=>{r.current=!0}),N.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,V8({fromRouteId:s},o)))},[t,s])}const nEe={};function a1t(t,s,r){nEe[t]||(nEe[t]=!0)}function i1t(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function sxe(t){let{to:s,replace:r,state:n,relative:a}=t;VA()||Od(!1);let{future:o,static:l}=N.useContext(kw),{matches:i}=N.useContext(R0),{pathname:c}=zd(),u=fr(),p=L2e(s,I2e(i,o.v7_relativeSplatPath),c,a==="path"),f=JSON.stringify(p);return N.useEffect(()=>u(JSON.parse(f),{replace:r,state:n,relative:a}),[u,f,a,r,n]),null}function o1t(t){return Wvt(t.context)}function ks(t){Od(!1)}function l1t(t){let{basename:s="/",children:r=null,location:n,navigationType:a=__.Pop,navigator:o,static:l=!1,future:i}=t;VA()&&Od(!1);let c=s.replace(/^\/*/,"/"),u=N.useMemo(()=>({basename:c,navigator:o,static:l,future:V8({v7_relativeSplatPath:!1},i)}),[c,i,o,l]);typeof n=="string"&&(n=UA(n));let{pathname:p="/",search:f="",hash:g="",state:b=null,key:_="default"}=n,j=N.useMemo(()=>{let w=P2e(p,c);return w==null?null:{location:{pathname:w,search:f,hash:g,state:b,key:_},navigationType:a}},[c,p,f,g,b,_,a]);return j==null?null:N.createElement(kw.Provider,{value:u},N.createElement(Tde.Provider,{children:r,value:j}))}function O2e(t){let{children:s,location:r}=t;return Gvt(sve(s),r)}new Promise(()=>{});function sve(t,s){s===void 0&&(s=[]);let r=[];return N.Children.forEach(t,(n,a)=>{if(!N.isValidElement(n))return;let o=[...s,a];if(n.type===N.Fragment){r.push.apply(r,sve(n.props.children,o));return}n.type!==ks&&Od(!1),!n.props.index||!n.props.children||Od(!1);let l={id:n.props.id||o.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(l.children=sve(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 rve(){return rve=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&(r[a]=t[a]);return r}function d1t(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function u1t(t,s){return t.button===0&&(!s||s==="_self")&&!d1t(t)}function nve(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 h1t(t,s){let r=nve(t);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const m1t=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],p1t="6";try{window.__reactRouterVersion=p1t}catch{}const f1t="startTransition",aEe=vwe[f1t];function x1t(t){let{basename:s,children:r,future:n,window:a}=t,o=N.useRef();o.current==null&&(o.current=xvt({window:a,v5Compat:!0}));let l=o.current,[i,c]=N.useState({action:l.action,location:l.location}),{v7_startTransition:u}=n||{},p=N.useCallback(f=>{u&&aEe?aEe(()=>c(f)):c(f)},[c,u]);return N.useLayoutEffect(()=>l.listen(p),[l,p]),N.useEffect(()=>i1t(n),[n]),N.createElement(l1t,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const g1t=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",y1t=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Pi=N.forwardRef(function(s,r){let{onClick:n,relative:a,reloadDocument:o,replace:l,state:i,target:c,to:u,preventScrollReset:p,viewTransition:f}=s,g=c1t(s,m1t),{basename:b}=N.useContext(kw),_,j=!1;if(typeof u=="string"&&y1t.test(u)&&(_=u,g1t))try{let M=new URL(window.location.href),L=u.startsWith("//")?new URL(M.protocol+u):new URL(u),I=P2e(L.pathname,b);L.origin===M.origin&&I!=null?u=I+L.search+L.hash:j=!0}catch{}let w=Uvt(u,{relative:a}),k=v1t(u,{replace:l,state:i,target:c,preventScrollReset:p,relative:a,viewTransition:f});function S(M){n&&n(M),M.defaultPrevented||k(M)}return N.createElement("a",rve({},g,{href:_||w,onClick:j||o?n:S,ref:r,target:c}))});var iEe;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(iEe||(iEe={}));var oEe;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(oEe||(oEe={}));function v1t(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,c=fr(),u=zd(),p=pUe(t,{relative:l});return N.useCallback(f=>{if(u1t(f,r)){f.preventDefault();let g=n!==void 0?n:moe(u)===moe(p);c(t,{replace:g,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[u,c,p,n,a,r,t,o,l,i])}function Cc(t){let s=N.useRef(nve(t)),r=N.useRef(!1),n=zd(),a=N.useMemo(()=>h1t(n.search,r.current?null:s.current),[n.search]),o=fr(),l=N.useCallback((i,c)=>{const u=nve(typeof i=="function"?i(a):i);r.current=!0,o("?"+u,c)},[o,a]);return[a,l]}var b1t=typeof Element<"u",_1t=typeof Map=="function",w1t=typeof Set=="function",j1t=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function oie(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(!oie(t[n],s[n]))return!1;return!0}var o;if(_1t&&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(!oie(n.value[1],s.get(n.value[0])))return!1;return!0}if(w1t&&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(j1t&&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(b1t&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&t.$$typeof)&&!oie(t[a[n]],s[a[n]]))return!1;return!0}return t!==t&&s!==s}var N1t=function(s,r){try{return oie(s,r)}catch(n){if((n.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw n}};const k1t=Po(N1t);var S1t=function(t,s,r,n,a,o,l,i){if(!t){var c;if(s===void 0)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,a,o,l,i],p=0;c=new Error(s.replace(/%s/g,function(){return u[p++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}},C1t=S1t;const lEe=Po(C1t);var M1t=function(s,r,n,a){var o=n?n.call(a,s,r):void 0;if(o!==void 0)return!!o;if(s===r)return!0;if(typeof s!="object"||!s||typeof r!="object"||!r)return!1;var l=Object.keys(s),i=Object.keys(r);if(l.length!==i.length)return!1;for(var c=Object.prototype.hasOwnProperty.bind(r),u=0;u(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(yUe||{}),rxe={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"]}},cEe=Object.values(yUe),R2e={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},A1t=Object.entries(R2e).reduce((t,[s,r])=>(t[r]=s,t),{}),Wg="data-rh",GM={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},KM=(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},E1t=t=>{let s=KM(t,"title");const r=KM(t,GM.TITLE_TEMPLATE);if(Array.isArray(s)&&(s=s.join("")),r&&s)return r.replace(/%s/g,()=>s);const n=KM(t,GM.DEFAULT_TITLE);return s||n||void 0},P1t=t=>KM(t,GM.ON_CHANGE_CLIENT_STATE)||(()=>{}),nxe=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),I1t=(t,s)=>s.filter(r=>typeof r.base<"u").map(r=>r.base).reverse().reduce((r,n)=>{if(!r.length){const a=Object.keys(n);for(let o=0;oconsole&&typeof console.warn=="function"&&console.warn(t),FP=(t,s,r)=>{const n={};return r.filter(a=>Array.isArray(a[t])?!0:(typeof a[t]<"u"&&L1t(`Helmet: ${t} should be of type "Array". Instead found type "${typeof a[t]}"`),!1)).map(a=>a[t]).reverse().reduce((a,o)=>{const l={};o.filter(c=>{let u;const p=Object.keys(c);for(let g=0;ga.push(c));const i=Object.keys(l);for(let c=0;c{if(Array.isArray(t)&&t.length){for(let r=0;r({baseTag:I1t(["href"],t),bodyAttributes:nxe("bodyAttributes",t),defer:KM(t,GM.DEFER),encode:KM(t,GM.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:nxe("htmlAttributes",t),linkTags:FP("link",["rel","href"],t),metaTags:FP("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:FP("noscript",["innerHTML"],t),onChangeClientState:P1t(t),scriptTags:FP("script",["src","innerHTML"],t),styleTags:FP("style",["cssText"],t),title:E1t(t),titleAttributes:nxe("titleAttributes",t),prioritizeSeoTags:D1t(t,GM.PRIORITIZE_SEO_TAGS)}),vUe=t=>Array.isArray(t)?t.join(""):t,R1t=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(R1t(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},dEe=(t,s)=>({...t,[s]:void 0}),F1t=["noscript","script","style"],ave=(t,s=!0)=>s===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),bUe=t=>Object.keys(t).reduce((s,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return s?`${s} ${n}`:n},""),z1t=(t,s,r,n)=>{const a=bUe(r),o=vUe(s);return a?`<${t} ${Wg}="true" ${a}>${ave(o,n)}`:`<${t} ${Wg}="true">${ave(o,n)}`},B1t=(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}="${ave(o[p],r)}"`;return u?`${u} ${f}`:f},""),i=o.innerHTML||o.cssText||"",c=F1t.indexOf(t)===-1;return`${n}<${t} ${Wg}="true" ${l}${c?"/>":`>${i}`}`},""),_Ue=(t,s={})=>Object.keys(t).reduce((r,n)=>{const a=R2e[n];return r[a||n]=t[n],r},s),$1t=(t,s,r)=>{const n={key:s,[Wg]:!0},a=_Ue(r,n);return[ht.createElement("title",a,s)]},lie=(t,s)=>s.map((r,n)=>{const a={key:n,[Wg]:!0};return Object.keys(r).forEach(o=>{const i=R2e[o]||o;if(i==="innerHTML"||i==="cssText"){const c=r.innerHTML||r.cssText;a.dangerouslySetInnerHTML={__html:c}}else a[i]=r[o]}),ht.createElement(t,a)}),ax=(t,s,r=!0)=>{switch(t){case"title":return{toComponent:()=>$1t(t,s.title,s.titleAttributes),toString:()=>z1t(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>_Ue(s),toString:()=>bUe(s)};default:return{toComponent:()=>lie(t,s),toString:()=>B1t(t,s,r)}}},q1t=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=axe(t,rxe.meta),o=axe(s,rxe.link),l=axe(r,rxe.script);return{priorityMethods:{toComponent:()=>[...lie("meta",a.priority),...lie("link",o.priority),...lie("script",l.priority)],toString:()=>`${ax("meta",a.priority,n)} ${ax("link",o.priority,n)} ${ax("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},U1t=t=>{const{baseTag:s,bodyAttributes:r,encode:n=!0,htmlAttributes:a,noscriptTags:o,styleTags:l,title:i="",titleAttributes:c,prioritizeSeoTags:u}=t;let{linkTags:p,metaTags:f,scriptTags:g}=t,b={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:b,linkTags:p,metaTags:f,scriptTags:g}=q1t(t)),{priority:b,base:ax("base",s,n),bodyAttributes:ax("bodyAttributes",r,n),htmlAttributes:ax("htmlAttributes",a,n),link:ax("link",p,n),meta:ax("meta",f,n),noscript:ax("noscript",o,n),script:ax("script",g,n),style:ax("style",l,n),title:ax("title",{title:i,titleAttributes:c},n)}},ive=U1t,z7=[],wUe=!!(typeof window<"u"&&window.document&&window.document.createElement),ove=class{constructor(t,s){Mn(this,"instances",[]);Mn(this,"canUseDOM",wUe);Mn(this,"context");Mn(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?z7:this.instances,add:t=>{(this.canUseDOM?z7:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?z7:this.instances).indexOf(t);(this.canUseDOM?z7:this.instances).splice(s,1)}}});this.context=t,this.canUseDOM=s||!1,s||(t.helmet=ive({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},V1t={},jUe=ht.createContext(V1t),q4,NUe=(q4=class extends N.Component{constructor(r){super(r);Mn(this,"helmetData");this.helmetData=new ove(this.props.context||{},q4.canUseDOM)}render(){return ht.createElement(jUe.Provider,{value:this.helmetData.value},this.props.children)}},Mn(q4,"canUseDOM",wUe),q4),d5=(t,s)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${Wg}]`),a=[].slice.call(n),o=[];let l;return s&&s.length&&s.forEach(i=>{const c=document.createElement(t);for(const u in i)if(Object.prototype.hasOwnProperty.call(i,u))if(u==="innerHTML")c.innerHTML=i.innerHTML;else if(u==="cssText")c.styleSheet?c.styleSheet.cssText=i.cssText:c.appendChild(document.createTextNode(i.cssText));else{const p=u,f=typeof i[p]>"u"?"":i[p];c.setAttribute(u,f)}c.setAttribute(Wg,"true"),a.some((u,p)=>(l=p,c.isEqualNode(u)))?a.splice(l,1):o.push(c)}),a.forEach(i=>{var c;return(c=i.parentNode)==null?void 0:c.removeChild(i)}),o.forEach(i=>r.appendChild(i)),{oldTags:a,newTags:o}},lve=(t,s)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(Wg),a=n?n.split(","):[],o=[...a],l=Object.keys(s);for(const i of l){const c=s[i]||"";r.getAttribute(i)!==c&&r.setAttribute(i,c),a.indexOf(i)===-1&&a.push(i);const u=o.indexOf(i);u!==-1&&o.splice(u,1)}for(let i=o.length-1;i>=0;i-=1)r.removeAttribute(o[i]);a.length===o.length?r.removeAttribute(Wg):r.getAttribute(Wg)!==l.join(",")&&r.setAttribute(Wg,l.join(","))},H1t=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=vUe(t)),lve("title",s)},uEe=(t,s)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:a,linkTags:o,metaTags:l,noscriptTags:i,onChangeClientState:c,scriptTags:u,styleTags:p,title:f,titleAttributes:g}=t;lve("body",n),lve("html",a),H1t(f,g);const b={baseTag:d5("base",r),linkTags:d5("link",o),metaTags:d5("meta",l),noscriptTags:d5("noscript",i),scriptTags:d5("script",u),styleTags:d5("style",p)},_={},j={};Object.keys(b).forEach(w=>{const{newTags:k,oldTags:S}=b[w];k.length&&(_[w]=k),S.length&&(j[w]=b[w].oldTags)}),s&&s(),c(t,_,j)},zP=null,W1t=t=>{zP&&cancelAnimationFrame(zP),t.defer?zP=requestAnimationFrame(()=>{uEe(t,()=>{zP=null})}):(uEe(t),zP=null)},G1t=W1t,hEe=class extends N.Component{constructor(){super(...arguments);Mn(this,"rendered",!1)}shouldComponentUpdate(s){return!T1t(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=O1t(s.get().map(o=>{const l={...o.props};return delete l.context,l}));NUe.canUseDOM?G1t(a):ive&&(n=ive(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}},Rye,Sc=(Rye=class extends N.Component{shouldComponentUpdate(t){return!k1t(dEe(this.props,"helmetData"),dEe(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 lEe(cEe.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 ${cEe.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),lEe(!s||typeof s=="string"||Array.isArray(s)&&!s.some(r=>typeof r!="string"),`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`),!0}mapChildrenToProps(t,s){let r={};return ht.Children.forEach(t,n=>{if(!n||!n.props)return;const{children:a,...o}=n.props,l=Object.keys(o).reduce((c,u)=>(c[A1t[u]||u]=o[u],c),{});let{type:i}=n;switch(typeof i=="symbol"?i=i.toString():this.warnOnInvalidChildren(n,a),i){case"Symbol(react.fragment)":s=this.mapChildrenToProps(a,s);break;case"link":case"meta":case"noscript":case"script":case"style":r=this.flattenArrayTypeChildren(n,r,l,a);break;default:s=this.mapObjectTypeChildren(n,s,l,a);break}}),this.mapArrayTypeChildrenToProps(r,s)}render(){const{children:t,...s}=this.props;let r={...s},{helmetData:n}=s;if(t&&(r=this.mapChildrenToProps(t,r)),n&&!(n instanceof ove)){const a=n;n=new ove(a.context,!0),delete r.helmetData}return n?ht.createElement(hEe,{...r,context:n.value}):ht.createElement(jUe.Consumer,null,a=>ht.createElement(hEe,{...r,context:a}))}},Mn(Rye,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),Rye),cve=function(t,s){return cve=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])},cve(t,s)};function kUe(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");cve(t,s);function r(){this.constructor=t}t.prototype=s===null?Object.create(s):(r.prototype=s.prototype,new r)}var fx=function(){return fx=Object.assign||function(s){for(var r,n=1,a=arguments.length;n=0;i--)(l=t[i])&&(o=(a<3?l(o):a>3?l(s,r,o):l(s,r))||o);return a>3&&o&&Object.defineProperty(s,r,o),o}function CUe(t,s){return function(r,n){s(r,n,t)}}function MUe(t,s,r,n,a,o){function l(k){if(k!==void 0&&typeof k!="function")throw new TypeError("Function expected");return k}for(var i=n.kind,c=i==="getter"?"get":i==="setter"?"set":"value",u=!s&&t?n.static?t:t.prototype:null,p=s||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),f,g=!1,b=r.length-1;b>=0;b--){var _={};for(var j in n)_[j]=j==="access"?{}:n[j];for(var j in n.access)_.access[j]=n.access[j];_.addInitializer=function(k){if(g)throw new TypeError("Cannot add initializers after decoration has completed");o.push(l(k||null))};var w=(0,r[b])(i==="accessor"?{get:p.get,set:p.set}:p[c],_);if(i==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(f=l(w.get))&&(p.get=f),(f=l(w.set))&&(p.set=f),(f=l(w.init))&&a.unshift(f)}else(f=l(w))&&(i==="field"?a.unshift(f):p[c]=f)}u&&Object.defineProperty(u,n.name,p),g=!0}function TUe(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 F2e(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 DUe(){for(var t=[],s=0;s1||c(b,j)})},_&&(a[b]=_(a[b])))}function c(b,_){try{u(n[b](_))}catch(j){g(o[0][3],j)}}function u(b){b.value instanceof PT?Promise.resolve(b.value.v).then(p,f):g(o[0][2],b)}function p(b){c("next",b)}function f(b){c("throw",b)}function g(b,_){b(_),o.shift(),o.length&&c(o[0][0],o[0][1])}}function FUe(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:PT(t[a](l)),done:!1}:o?o(l):l}:o}}function zUe(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 poe=="function"?poe(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=t[o]&&function(l){return new Promise(function(i,c){l=t[o](l),a(i,c,l.done,l.value)})}}function a(o,l,i,c){Promise.resolve(c).then(function(u){o({value:u,done:i})},l)}}function BUe(t,s){return Object.defineProperty?Object.defineProperty(t,"raw",{value:s}):t.raw=s,t}var K1t=Object.create?function(t,s){Object.defineProperty(t,"default",{enumerable:!0,value:s})}:function(t,s){t.default=s},dve=function(t){return dve=Object.getOwnPropertyNames||function(s){var r=[];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[r.length]=n);return r},dve(t)};function $Ue(t){if(t&&t.__esModule)return t;var s={};if(t!=null)for(var r=dve(t),n=0;n{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>oc(async()=>{const{default:n}=await Promise.resolve().then(()=>pC);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class B2e extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class mEe extends B2e{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class pEe extends B2e{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class fEe extends B2e{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var uve;(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"})(uve||(uve={}));class J1t{constructor(s,{headers:r={},customFetch:n,region:a=uve.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=Q1t(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s){return ya(this,arguments,void 0,function*(r,n={}){var a;try{const{headers:o,method:l,body:i,signal:c}=n;let u={},{region:p}=n;p||(p=this.region);const f=new URL(`${this.url}/${r}`);p&&p!=="any"&&(u["x-region"]=p,f.searchParams.set("forceFunctionRegion",p));let g;i&&(o&&!Object.prototype.hasOwnProperty.call(o,"Content-Type")||!o)?typeof Blob<"u"&&i instanceof Blob||i instanceof ArrayBuffer?(u["Content-Type"]="application/octet-stream",g=i):typeof i=="string"?(u["Content-Type"]="text/plain",g=i):typeof FormData<"u"&&i instanceof FormData?g=i:(u["Content-Type"]="application/json",g=JSON.stringify(i)):g=i;const b=yield this.fetch(f.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},u),this.headers),o),body:g,signal:c}).catch(k=>{throw k.name==="AbortError"?k:new mEe(k)}),_=b.headers.get("x-relay-error");if(_&&_==="true")throw new pEe(b);if(!b.ok)throw new fEe(b);let j=((a=b.headers.get("Content-Type"))!==null&&a!==void 0?a:"text/plain").split(";")[0].trim(),w;return j==="application/json"?w=yield b.json():j==="application/octet-stream"||j==="application/pdf"?w=yield b.blob():j==="text/event-stream"?w=b:j==="multipart/form-data"?w=yield b.formData():w=yield b.text(),{data:w,error:null,response:b}}catch(o){return o instanceof Error&&o.name==="AbortError"?{data:null,error:new mEe(o)}:{data:null,error:o,response:o instanceof fEe||o instanceof pEe?o.context:void 0}}})}}var fp={};const HA=y9e(X1t);var B7={},$7={},q7={},U7={},V7={},ebt=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")},IT=ebt();const tbt=IT.fetch,ZUe=IT.fetch.bind(IT),YUe=IT.Headers,sbt=IT.Request,rbt=IT.Response,pC=Object.freeze(Object.defineProperty({__proto__:null,Headers:YUe,Request:sbt,Response:rbt,default:ZUe,fetch:tbt},Symbol.toStringTag,{value:"Module"})),nbt=y9e(pC);var H7={},xEe;function XUe(){if(xEe)return H7;xEe=1,Object.defineProperty(H7,"__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 H7.default=t,H7}var gEe;function QUe(){if(gEe)return V7;gEe=1,Object.defineProperty(V7,"__esModule",{value:!0});const t=HA,s=t.__importDefault(nbt),r=t.__importDefault(XUe());class n{constructor(o){var l,i;this.shouldThrowOnError=!1,this.method=o.method,this.url=o.url,this.headers=new Headers(o.headers),this.schema=o.schema,this.body=o.body,this.shouldThrowOnError=(l=o.shouldThrowOnError)!==null&&l!==void 0?l:!1,this.signal=o.signal,this.isMaybeSingle=(i=o.isMaybeSingle)!==null&&i!==void 0?i:!1,o.fetch?this.fetch=o.fetch:typeof fetch>"u"?this.fetch=s.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(o,l){return this.headers=new Headers(this.headers),this.headers.set(o,l),this}then(o,l){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const i=this.fetch;let c=i(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var p,f,g,b;let _=null,j=null,w=null,k=u.status,S=u.statusText;if(u.ok){if(this.method!=="HEAD"){const O=await u.text();O===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((p=this.headers.get("Accept"))===null||p===void 0)&&p.includes("application/vnd.pgrst.plan+text"))?j=O:j=JSON.parse(O))}const L=(f=this.headers.get("Prefer"))===null||f===void 0?void 0:f.match(/count=(exact|planned|estimated)/),I=(g=u.headers.get("content-range"))===null||g===void 0?void 0:g.split("/");L&&I&&I.length>1&&(w=parseInt(I[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(j)&&(j.length>1?(_={code:"PGRST116",details:`Results contain ${j.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},j=null,w=null,k=406,S="Not Acceptable"):j.length===1?j=j[0]:j=null)}else{const L=await u.text();try{_=JSON.parse(L),Array.isArray(_)&&u.status===404&&(j=[],_=null,k=200,S="OK")}catch{u.status===404&&L===""?(k=204,S="No Content"):_={message:L}}if(_&&this.isMaybeSingle&&(!((b=_==null?void 0:_.details)===null||b===void 0)&&b.includes("0 rows"))&&(_=null,k=200,S="OK"),_&&this.shouldThrowOnError)throw new r.default(_)}return{error:_,data:j,count:w,status:k,statusText:S}});return this.shouldThrowOnError||(c=c.catch(u=>{var p,f,g;return{error:{message:`${(p=u==null?void 0:u.name)!==null&&p!==void 0?p:"FetchError"}: ${u==null?void 0:u.message}`,details:`${(f=u==null?void 0:u.stack)!==null&&f!==void 0?f:""}`,hint:"",code:`${(g=u==null?void 0:u.code)!==null&&g!==void 0?g:""}`},data:null,count:null,status:0,statusText:""}})),c.then(o,l)}returns(){return this}overrideTypes(){return this}}return V7.default=n,V7}var yEe;function JUe(){if(yEe)return U7;yEe=1,Object.defineProperty(U7,"__esModule",{value:!0});const s=HA.__importDefault(QUe());class r extends s.default{select(a){let o=!1;const l=(a??"*").split("").map(i=>/\s/.test(i)&&!o?"":(i==='"'&&(o=!o),i)).join("");return this.url.searchParams.set("select",l),this.headers.append("Prefer","return=representation"),this}order(a,{ascending:o=!0,nullsFirst:l,foreignTable:i,referencedTable:c=i}={}){const u=c?`${c}.order`:"order",p=this.url.searchParams.get(u);return this.url.searchParams.set(u,`${p?`${p},`:""}${a}.${o?"asc":"desc"}${l===void 0?"":l?".nullsfirst":".nullslast"}`),this}limit(a,{foreignTable:o,referencedTable:l=o}={}){const i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(i,`${a}`),this}range(a,o,{foreignTable:l,referencedTable:i=l}={}){const c=typeof i>"u"?"offset":`${i}.offset`,u=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(c,`${a}`),this.url.searchParams.set(u,`${o-a+1}`),this}abortSignal(a){return this.signal=a,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:a=!1,verbose:o=!1,settings:l=!1,buffers:i=!1,wal:c=!1,format:u="text"}={}){var p;const f=[a?"analyze":null,o?"verbose":null,l?"settings":null,i?"buffers":null,c?"wal":null].filter(Boolean).join("|"),g=(p=this.headers.get("Accept"))!==null&&p!==void 0?p:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${u}; for="${g}"; options=${f};`),u==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(a){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${a}`),this}}return U7.default=r,U7}var vEe;function $2e(){if(vEe)return q7;vEe=1,Object.defineProperty(q7,"__esModule",{value:!0});const s=HA.__importDefault(JUe()),r=new RegExp("[,()]");class n extends s.default{eq(o,l){return this.url.searchParams.append(o,`eq.${l}`),this}neq(o,l){return this.url.searchParams.append(o,`neq.${l}`),this}gt(o,l){return this.url.searchParams.append(o,`gt.${l}`),this}gte(o,l){return this.url.searchParams.append(o,`gte.${l}`),this}lt(o,l){return this.url.searchParams.append(o,`lt.${l}`),this}lte(o,l){return this.url.searchParams.append(o,`lte.${l}`),this}like(o,l){return this.url.searchParams.append(o,`like.${l}`),this}likeAllOf(o,l){return this.url.searchParams.append(o,`like(all).{${l.join(",")}}`),this}likeAnyOf(o,l){return this.url.searchParams.append(o,`like(any).{${l.join(",")}}`),this}ilike(o,l){return this.url.searchParams.append(o,`ilike.${l}`),this}ilikeAllOf(o,l){return this.url.searchParams.append(o,`ilike(all).{${l.join(",")}}`),this}ilikeAnyOf(o,l){return this.url.searchParams.append(o,`ilike(any).{${l.join(",")}}`),this}is(o,l){return this.url.searchParams.append(o,`is.${l}`),this}in(o,l){const i=Array.from(new Set(l)).map(c=>typeof c=="string"&&r.test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(o,`in.(${i})`),this}contains(o,l){return typeof l=="string"?this.url.searchParams.append(o,`cs.${l}`):Array.isArray(l)?this.url.searchParams.append(o,`cs.{${l.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(l)}`),this}containedBy(o,l){return typeof l=="string"?this.url.searchParams.append(o,`cd.${l}`):Array.isArray(l)?this.url.searchParams.append(o,`cd.{${l.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(l)}`),this}rangeGt(o,l){return this.url.searchParams.append(o,`sr.${l}`),this}rangeGte(o,l){return this.url.searchParams.append(o,`nxl.${l}`),this}rangeLt(o,l){return this.url.searchParams.append(o,`sl.${l}`),this}rangeLte(o,l){return this.url.searchParams.append(o,`nxr.${l}`),this}rangeAdjacent(o,l){return this.url.searchParams.append(o,`adj.${l}`),this}overlaps(o,l){return typeof l=="string"?this.url.searchParams.append(o,`ov.${l}`):this.url.searchParams.append(o,`ov.{${l.join(",")}}`),this}textSearch(o,l,{config:i,type:c}={}){let u="";c==="plain"?u="pl":c==="phrase"?u="ph":c==="websearch"&&(u="w");const p=i===void 0?"":`(${i})`;return this.url.searchParams.append(o,`${u}fts${p}.${l}`),this}match(o){return Object.entries(o).forEach(([l,i])=>{this.url.searchParams.append(l,`eq.${i}`)}),this}not(o,l,i){return this.url.searchParams.append(o,`not.${l}.${i}`),this}or(o,{foreignTable:l,referencedTable:i=l}={}){const c=i?`${i}.or`:"or";return this.url.searchParams.append(c,`(${o})`),this}filter(o,l,i){return this.url.searchParams.append(o,`${l}.${i}`),this}}return q7.default=n,q7}var bEe;function eVe(){if(bEe)return $7;bEe=1,Object.defineProperty($7,"__esModule",{value:!0});const s=HA.__importDefault($2e());class r{constructor(a,{headers:o={},schema:l,fetch:i}){this.url=a,this.headers=new Headers(o),this.schema=l,this.fetch=i}select(a,o){const{head:l=!1,count:i}=o??{},c=l?"HEAD":"GET";let u=!1;const p=(a??"*").split("").map(f=>/\s/.test(f)&&!u?"":(f==='"'&&(u=!u),f)).join("");return this.url.searchParams.set("select",p),i&&this.headers.append("Prefer",`count=${i}`),new s.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(a,{count:o,defaultToNull:l=!0}={}){var i;const c="POST";if(o&&this.headers.append("Prefer",`count=${o}`),l||this.headers.append("Prefer","missing=default"),Array.isArray(a)){const u=a.reduce((p,f)=>p.concat(Object.keys(f)),[]);if(u.length>0){const p=[...new Set(u)].map(f=>`"${f}"`);this.url.searchParams.set("columns",p.join(","))}}return new s.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}upsert(a,{onConflict:o,ignoreDuplicates:l=!1,count:i,defaultToNull:c=!0}={}){var u;const p="POST";if(this.headers.append("Prefer",`resolution=${l?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),i&&this.headers.append("Prefer",`count=${i}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(a)){const f=a.reduce((g,b)=>g.concat(Object.keys(b)),[]);if(f.length>0){const g=[...new Set(f)].map(b=>`"${b}"`);this.url.searchParams.set("columns",g.join(","))}}return new s.default({method:p,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}update(a,{count:o}={}){var l;const i="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new s.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}delete({count:a}={}){var o;const l="DELETE";return a&&this.headers.append("Prefer",`count=${a}`),new s.default({method:l,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}}return $7.default=r,$7}var _Ee;function abt(){if(_Ee)return B7;_Ee=1,Object.defineProperty(B7,"__esModule",{value:!0});const t=HA,s=t.__importDefault(eVe()),r=t.__importDefault($2e());class n{constructor(o,{headers:l={},schema:i,fetch:c}={}){this.url=o,this.headers=new Headers(l),this.schemaName=i,this.fetch=c}from(o){const l=new URL(`${this.url}/${o}`);return new s.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(o){return new n(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,l={},{head:i=!1,get:c=!1,count:u}={}){var p;let f;const g=new URL(`${this.url}/rpc/${o}`);let b;i||c?(f=i?"HEAD":"GET",Object.entries(l).filter(([j,w])=>w!==void 0).map(([j,w])=>[j,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([j,w])=>{g.searchParams.append(j,w)})):(f="POST",b=l);const _=new Headers(this.headers);return u&&_.set("Prefer",`count=${u}`),new r.default({method:f,url:g,headers:_,schema:this.schemaName,body:b,fetch:(p=this.fetch)!==null&&p!==void 0?p:fetch})}}return B7.default=n,B7}Object.defineProperty(fp,"__esModule",{value:!0});var tVe=fp.PostgrestError=uVe=fp.PostgrestBuilder=cVe=fp.PostgrestTransformBuilder=oVe=fp.PostgrestFilterBuilder=aVe=fp.PostgrestQueryBuilder=rVe=fp.PostgrestClient=void 0;const WA=HA,sVe=WA.__importDefault(abt());var rVe=fp.PostgrestClient=sVe.default;const nVe=WA.__importDefault(eVe());var aVe=fp.PostgrestQueryBuilder=nVe.default;const iVe=WA.__importDefault($2e());var oVe=fp.PostgrestFilterBuilder=iVe.default;const lVe=WA.__importDefault(JUe());var cVe=fp.PostgrestTransformBuilder=lVe.default;const dVe=WA.__importDefault(QUe());var uVe=fp.PostgrestBuilder=dVe.default;const hVe=WA.__importDefault(XUe());tVe=fp.PostgrestError=hVe.default;var mVe=fp.default={PostgrestClient:sVe.default,PostgrestQueryBuilder:nVe.default,PostgrestFilterBuilder:iVe.default,PostgrestTransformBuilder:lVe.default,PostgrestBuilder:dVe.default,PostgrestError:hVe.default};const ibt=Object.freeze(Object.defineProperty({__proto__:null,get PostgrestBuilder(){return uVe},get PostgrestClient(){return rVe},get PostgrestError(){return tVe},get PostgrestFilterBuilder(){return oVe},get PostgrestQueryBuilder(){return aVe},get PostgrestTransformBuilder(){return cVe},default:mVe},Symbol.toStringTag,{value:"Module"})),{PostgrestClient:obt,PostgrestQueryBuilder:CMs,PostgrestFilterBuilder:MMs,PostgrestTransformBuilder:TMs,PostgrestBuilder:AMs,PostgrestError:EMs}=mVe||ibt;class lbt{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 cbt="2.78.0",dbt=`realtime-js/${cbt}`,ubt="1.0.0",hve=1e4,hbt=1e3,mbt=100;var FL;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(FL||(FL={}));var mu;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(mu||(mu={}));var Og;(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"})(Og||(Og={}));var mve;(function(t){t.websocket="websocket"})(mve||(mve={}));var l4;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(l4||(l4={}));class pbt{constructor(){this.HEADER_LENGTH=1}decode(s,r){return s.constructor===ArrayBuffer?r(this._binaryDecode(s)):r(typeof s=="string"?JSON.parse(s):{})}_binaryDecode(s){const r=new DataView(s),n=new TextDecoder;return this._decodeBroadcast(s,r,n)}_decodeBroadcast(s,r,n){const a=r.getUint8(1),o=r.getUint8(2);let l=this.HEADER_LENGTH+2;const i=n.decode(s.slice(l,l+a));l=l+a;const c=n.decode(s.slice(l,l+o));l=l+o;const u=JSON.parse(n.decode(s.slice(l,s.byteLength)));return{ref:null,topic:i,event:c,payload:u}}}class pVe{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 Hl;(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"})(Hl||(Hl={}));const wEe=(t,s,r={})=>{var n;const a=(n=r.skipTypes)!==null&&n!==void 0?n:[];return s?Object.keys(s).reduce((o,l)=>(o[l]=fbt(l,t,s,a),o),{}):{}},fbt=(t,s,r,n)=>{const a=s.find(i=>i.name===t),o=a==null?void 0:a.type,l=r[t];return o&&!n.includes(o)?fVe(o,l):pve(l)},fVe=(t,s)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return vbt(s,r)}switch(t){case Hl.bool:return xbt(s);case Hl.float4:case Hl.float8:case Hl.int2:case Hl.int4:case Hl.int8:case Hl.numeric:case Hl.oid:return gbt(s);case Hl.json:case Hl.jsonb:return ybt(s);case Hl.timestamp:return bbt(s);case Hl.abstime:case Hl.date:case Hl.daterange:case Hl.int4range:case Hl.int8range:case Hl.money:case Hl.reltime:case Hl.text:case Hl.time:case Hl.timestamptz:case Hl.timetz:case Hl.tsrange:case Hl.tstzrange:return pve(s);default:return pve(s)}},pve=t=>t,xbt=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},gbt=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},ybt=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},vbt=(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=>fVe(s,i))}return t},bbt=t=>typeof t=="string"?t.replace(" ","T"):t,xVe=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 ixe{constructor(s,r,n={},a=hve){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 jEe;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(jEe||(jEe={}));class zL{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=zL.syncState(this.state,a,o,l),this.pendingDiffs.forEach(c=>{this.state=zL.syncDiff(this.state,c,o,l)}),this.pendingDiffs=[],i()}),this.channel._on(n.diff,{},a=>{const{onJoin:o,onLeave:l,onSync:i}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(a):(this.state=zL.syncDiff(this.state,a,o,l),i())}),this.onJoin((a,o,l)=>{this.channel._trigger("presence",{event:"join",key:a,currentPresences:o,newPresences:l})}),this.onLeave((a,o,l)=>{this.channel._trigger("presence",{event:"leave",key:a,currentPresences:o,leftPresences:l})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(s,r,n,a){const o=this.cloneDeep(s),l=this.transformState(r),i={},c={};return this.map(o,(u,p)=>{l[u]||(c[u]=p)}),this.map(l,(u,p)=>{const f=o[u];if(f){const g=p.map(w=>w.presence_ref),b=f.map(w=>w.presence_ref),_=p.filter(w=>b.indexOf(w.presence_ref)<0),j=f.filter(w=>g.indexOf(w.presence_ref)<0);_.length>0&&(i[u]=_),j.length>0&&(c[u]=j)}else i[u]=p}),this.syncDiff(o,{joins:i,leaves:c},n,a)}static syncDiff(s,r,n,a){const{joins:o,leaves:l}={joins:this.transformState(r.joins),leaves:this.transformState(r.leaves)};return n||(n=()=>{}),a||(a=()=>{}),this.map(o,(i,c)=>{var u;const p=(u=s[i])!==null&&u!==void 0?u:[];if(s[i]=this.cloneDeep(c),p.length>0){const f=s[i].map(b=>b.presence_ref),g=p.filter(b=>f.indexOf(b.presence_ref)<0);s[i].unshift(...g)}n(i,p,c)}),this.map(l,(i,c)=>{let u=s[i];if(!u)return;const p=c.map(f=>f.presence_ref);u=u.filter(f=>p.indexOf(f.presence_ref)<0),s[i]=u,a(i,u,c),u.length===0&&delete s[i]}),s}static map(s,r){return Object.getOwnPropertyNames(s).map(n=>r(n,s[n]))}static transformState(s){return s=this.cloneDeep(s),Object.getOwnPropertyNames(s).reduce((r,n)=>{const a=s[n];return"metas"in a?r[n]=a.metas.map(o=>(o.presence_ref=o.phx_ref,delete o.phx_ref,delete o.phx_ref_prev,o)):r[n]=a,r},{})}static cloneDeep(s){return JSON.parse(JSON.stringify(s))}onJoin(s){this.caller.onJoin=s}onLeave(s){this.caller.onLeave=s}onSync(s){this.caller.onSync=s}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var NEe;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(NEe||(NEe={}));var BL;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(BL||(BL={}));var Ev;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(Ev||(Ev={}));class q2e{constructor(s,r={config:{}},n){var a,o;if(this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=mu.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 ixe(this,Og.join,this.params,this.timeout),this.rejoinTimer=new pVe(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=mu.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=mu.closed,this.socket._remove(this)}),this._onError(l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=mu.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=mu.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=mu.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Og.reply,{},(l,i)=>{this._trigger(this._replyEventName(i),l)}),this.presence=new zL(this),this.broadcastEndpointURL=xVe(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==mu.closed){const{config:{broadcast:l,presence:i,private:c}}=this.params,u=(a=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(b=>b.filter))!==null&&a!==void 0?a:[],p=!!this.bindings[BL.PRESENCE]&&this.bindings[BL.PRESENCE].length>0||((o=this.params.config.presence)===null||o===void 0?void 0:o.enabled)===!0,f={},g={broadcast:l,presence:Object.assign(Object.assign({},i),{enabled:p}),postgres_changes:u,private:c};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this._onError(b=>s==null?void 0:s(Ev.CHANNEL_ERROR,b)),this._onClose(()=>s==null?void 0:s(Ev.CLOSED)),this.updateJoinPayload(Object.assign({config:g},f)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:b})=>{var _;if(this.socket.setAuth(),b===void 0){s==null||s(Ev.SUBSCRIBED);return}else{const j=this.bindings.postgres_changes,w=(_=j==null?void 0:j.length)!==null&&_!==void 0?_:0,k=[];for(let S=0;S{this.state=mu.errored,s==null||s(Ev.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(b).join(", ")||"error")))}).receive("timeout",()=>{s==null||s(Ev.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===mu.joined&&s===BL.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(()=>this.subscribe())),this._on(s,r,n)}async httpSend(s,r,n={}){var a;const o=this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"";if(r==null)return Promise.reject("Payload is required for httpSend()");const l={method:"POST",headers:{Authorization:o,apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:s,payload:r,private:this.private}]})},i=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(a=n.timeout)!==null&&a!==void 0?a:this.timeout);if(i.status===202)return{success:!0};let c=i.statusText;try{const u=await i.json();c=u.error||u.message||c}catch{}return Promise.reject(new Error(c))}async send(s,r={}){var n,a;if(!this._canPush()&&s.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:o,payload:l}=s,c={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:o,payload:l,private:this.private}]})};try{const u=await this._fetchWithTimeout(this.broadcastEndpointURL,c,(n=r.timeout)!==null&&n!==void 0?n:this.timeout);return await((a=u.body)===null||a===void 0?void 0:a.cancel()),u.ok?"ok":"error"}catch(u){return u.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var l,i,c;const u=this._push(s.type,s,r.timeout||this.timeout);s.type==="broadcast"&&!(!((c=(i=(l=this.params)===null||l===void 0?void 0:l.config)===null||i===void 0?void 0:i.broadcast)===null||c===void 0)&&c.ack)&&o("ok"),u.receive("ok",()=>o("ok")),u.receive("error",()=>o("error")),u.receive("timeout",()=>o("timed out"))})}updateJoinPayload(s){this.joinPush.updatePayload(s)}unsubscribe(s=this.timeout){this.state=mu.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Og.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(a=>{n=new ixe(this,Og.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=mu.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 ixe(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>mbt){const r=this.pushBuffer.shift();r&&(r.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${r.event}`,r.payload))}}_onMessage(s,r,n){return r}_isMember(s){return this.topic===s}_joinRef(){return this.joinPush.ref}_trigger(s,r,n){var a,o;const l=s.toLocaleLowerCase(),{close:i,error:c,leave:u,join:p}=Og;if(n&&[i,c,u,p].indexOf(l)>=0&&n!==this._joinRef())return;let g=this._onMessage(l,r,n);if(r&&!g)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(l)?(a=this.bindings.postgres_changes)===null||a===void 0||a.filter(b=>{var _,j,w;return((_=b.filter)===null||_===void 0?void 0:_.event)==="*"||((w=(j=b.filter)===null||j===void 0?void 0:j.event)===null||w===void 0?void 0:w.toLocaleLowerCase())===l}).map(b=>b.callback(g,n)):(o=this.bindings[l])===null||o===void 0||o.filter(b=>{var _,j,w,k,S,M;if(["broadcast","presence","postgres_changes"].includes(l))if("id"in b){const L=b.id,I=(_=b.filter)===null||_===void 0?void 0:_.event;return L&&((j=r.ids)===null||j===void 0?void 0:j.includes(L))&&(I==="*"||(I==null?void 0:I.toLocaleLowerCase())===((w=r.data)===null||w===void 0?void 0:w.type.toLocaleLowerCase()))}else{const L=(S=(k=b==null?void 0:b.filter)===null||k===void 0?void 0:k.event)===null||S===void 0?void 0:S.toLocaleLowerCase();return L==="*"||L===((M=r==null?void 0:r.event)===null||M===void 0?void 0:M.toLocaleLowerCase())}else return b.type.toLocaleLowerCase()===l}).map(b=>{if(typeof g=="object"&&"ids"in g){const _=g.data,{schema:j,table:w,commit_timestamp:k,type:S,errors:M}=_;g=Object.assign(Object.assign({},{schema:j,table:w,commit_timestamp:k,eventType:S,new:{},old:{},errors:M}),this._getPayloadRecords(_))}b.callback(g,n)})}_isClosed(){return this.state===mu.closed}_isJoined(){return this.state===mu.joined}_isJoining(){return this.state===mu.joining}_isLeaving(){return this.state===mu.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&&q2e.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(Og.close,{},s)}_onError(s){this._on(Og.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=mu.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=wEe(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=wEe(s.columns,s.old_record)),r}}const oxe=()=>{},W7={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},_bt=[1e3,2e3,5e3,1e4],wbt=1e4,jbt=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class Nbt{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=hve,this.transport=null,this.heartbeatIntervalMs=W7.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=oxe,this.ref=0,this.reconnectTimer=null,this.logger=oxe,this.conn=null,this.sendBuffer=[],this.serializer=new pbt,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)=>oc(async()=>{const{default:i}=await Promise.resolve().then(()=>pC);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}/${mve.websocket}`,this.httpEndpoint=xVe(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=lbt.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:ubt}))}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 FL.connecting:return l4.Connecting;case FL.open:return l4.Open;case FL.closing:return l4.Closing;default:return l4.Closed}}isConnected(){return this.connectionState()===l4.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 q2e(`realtime:${s}`,r,this);return this.channels.push(o),o}}push(s){const{topic:r,event:n,payload:a,ref:o}=s,l=()=>{this.encode(s,i=>{var c;(c=this.conn)===null||c===void 0||c.send(i)})};this.log("push",`${r} ${n} (${o})`,a),this.isConnected()?l():this.sendBuffer.push(l)}async setAuth(s=null){this._authPromise=this._performAuth(s);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var s;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(r){this.log("error","error in heartbeat callback",r)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(r){this.log("error","error in heartbeat callback",r)}this._wasManualDisconnect=!1,(s=this.conn)===null||s===void 0||s.close(hbt,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},W7.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(r){this.log("error","error in heartbeat callback",r)}this._setAuthSafely("heartbeat")}onHeartbeat(s){this.heartbeatCallback=s}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(s=>s()),this.sendBuffer=[])}_makeRef(){let s=this.ref+1;return s===this.ref?this.ref=0:this.ref=s,this.ref.toString()}_leaveOpenTopic(s){let r=this.channels.find(n=>n.topic===s&&(n._isJoined()||n._isJoining()));r&&(this.log("transport",`leaving duplicate topic "${s}"`),r.unsubscribe())}_remove(s){this.channels=this.channels.filter(r=>r.topic!==s.topic)}_onConnMessage(s){this.decode(s.data,r=>{if(r.topic==="phoenix"&&r.event==="phx_reply")try{this.heartbeatCallback(r.payload.status==="ok"?"ok":"error")}catch(u){this.log("error","error in heartbeat callback",u)}r.ref&&r.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:n,event:a,payload:o,ref:l}=r,i=l?`(${l})`:"",c=o.status||"";this.log("receive",`${c} ${n} ${a} ${i}`.trim(),o),this.channels.filter(u=>u._isMember(n)).forEach(u=>u._trigger(a,o,l)),this._triggerStateCallbacks("message",r)})}_clearTimer(s){var r;s==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):s==="reconnect"&&((r=this.reconnectTimer)===null||r===void 0||r.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=s=>this._onConnError(s),this.conn.onmessage=s=>this._onConnMessage(s),this.conn.onclose=s=>this._onConnClose(s))}_teardownConnection(){this.conn&&(this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null),this._clearAllTimers(),this.channels.forEach(s=>s.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const s=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(s),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this.workerRef.terminate()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(s){var r;this._setConnectionState("disconnected"),this.log("transport","close",s),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout(),this._triggerStateCallbacks("close",s)}_onConnError(s){this._setConnectionState("disconnected"),this.log("transport",`${s}`),this._triggerChanError(),this._triggerStateCallbacks("error",s)}_triggerChanError(){this.channels.forEach(s=>s._trigger(Og.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([jbt],{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:dbt};r&&n.updateJoinPayload(a),n.joinedOnce&&n._isJoined()&&n._push(Og.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 pVe(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},W7.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(s){var r,n,a,o,l,i,c,u,p;if(this.transport=(r=s==null?void 0:s.transport)!==null&&r!==void 0?r:null,this.timeout=(n=s==null?void 0:s.timeout)!==null&&n!==void 0?n:hve,this.heartbeatIntervalMs=(a=s==null?void 0:s.heartbeatIntervalMs)!==null&&a!==void 0?a:W7.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:oxe,s!=null&&s.params&&(this.params=s.params),s!=null&&s.logger&&(this.logger=s.logger),(s!=null&&s.logLevel||s!=null&&s.log_level)&&(this.logLevel=s.logLevel||s.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(c=s==null?void 0:s.reconnectAfterMs)!==null&&c!==void 0?c:f=>_bt[f-1]||wbt,this.encode=(u=s==null?void 0:s.encode)!==null&&u!==void 0?u:(f,g)=>g(JSON.stringify(f)),this.decode=(p=s==null?void 0:s.decode)!==null&&p!==void 0?p:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=s==null?void 0:s.workerUrl}}}class U2e extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function Yc(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class kbt extends U2e{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 fve extends U2e{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}const V2e=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>oc(async()=>{const{default:n}=await Promise.resolve().then(()=>pC);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},Sbt=()=>ya(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield oc(()=>Promise.resolve().then(()=>pC),void 0)).Response:Response}),xve=t=>{if(Array.isArray(t))return t.map(r=>xve(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]=xve(n)}),s},Cbt=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)},lxe=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)},Mbt=(t,s,r)=>ya(void 0,void 0,void 0,function*(){const n=yield Sbt();t instanceof n&&!(r!=null&&r.noResolveJson)?t.json().then(a=>{const o=t.status||500,l=(a==null?void 0:a.statusCode)||o+"";s(new kbt(lxe(a),o,l))}).catch(a=>{s(new fve(lxe(a),a))}):s(new fve(lxe(t),t))}),Tbt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"||!n?a:(Cbt(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 wO(t,s,r,n,a,o){return ya(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,Tbt(s,n,a,o)).then(c=>{if(!c.ok)throw c;return n!=null&&n.noResolveJson?c:c.json()}).then(c=>l(c)).catch(c=>Mbt(c,i,n))})})}function H8(t,s,r,n){return ya(this,void 0,void 0,function*(){return wO(t,"GET",s,r,n)})}function Pg(t,s,r,n,a){return ya(this,void 0,void 0,function*(){return wO(t,"POST",s,n,a,r)})}function gve(t,s,r,n,a){return ya(this,void 0,void 0,function*(){return wO(t,"PUT",s,n,a,r)})}function Abt(t,s,r,n){return ya(this,void 0,void 0,function*(){return wO(t,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function H2e(t,s,r,n,a){return ya(this,void 0,void 0,function*(){return wO(t,"DELETE",s,n,a,r)})}class Ebt{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r}then(s,r){return this.execute().then(s,r)}execute(){return ya(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Yc(s))return{data:null,error:s};throw s}})}}var gVe;class Pbt{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r,this[gVe]="BlobDownloadBuilder",this.promise=null}asStream(){return new Ebt(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 ya(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Yc(s))return{data:null,error:s};throw s}})}}gVe=Symbol.toStringTag;const Ibt={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},kEe={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class Lbt{constructor(s,r={},n,a){this.shouldThrowOnError=!1,this.url=s,this.headers=r,this.bucketId=n,this.fetch=V2e(a)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(s,r,n,a){return ya(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},kEe),a);let i=Object.assign(Object.assign({},this.headers),s==="POST"&&{"x-upsert":String(l.upsert)});const c=l.metadata;typeof Blob<"u"&&n instanceof Blob?(o=new FormData,o.append("cacheControl",l.cacheControl),c&&o.append("metadata",this.encodeMetadata(c)),o.append("",n)):typeof FormData<"u"&&n instanceof FormData?(o=n,o.append("cacheControl",l.cacheControl),c&&o.append("metadata",this.encodeMetadata(c))):(o=n,i["cache-control"]=`max-age=${l.cacheControl}`,i["content-type"]=l.contentType,c&&(i["x-metadata"]=this.toBase64(this.encodeMetadata(c)))),a!=null&&a.headers&&(i=Object.assign(Object.assign({},i),a.headers));const u=this._removeEmptyFolders(r),p=this._getFinalPath(u),f=yield(s=="PUT"?gve:Pg)(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(Yc(o))return{data:null,error:o};throw o}})}upload(s,r,n){return ya(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return ya(this,void 0,void 0,function*(){const o=this._removeEmptyFolders(s),l=this._getFinalPath(o),i=new URL(this.url+`/object/upload/sign/${l}`);i.searchParams.set("token",r);try{let c;const u=Object.assign({upsert:kEe.upsert},a),p=Object.assign(Object.assign({},this.headers),{"x-upsert":String(u.upsert)});typeof Blob<"u"&&n instanceof Blob?(c=new FormData,c.append("cacheControl",u.cacheControl),c.append("",n)):typeof FormData<"u"&&n instanceof FormData?(c=n,c.append("cacheControl",u.cacheControl)):(c=n,p["cache-control"]=`max-age=${u.cacheControl}`,p["content-type"]=u.contentType);const f=yield gve(this.fetch,i.toString(),c,{headers:p});return{data:{path:o,fullPath:f.Key},error:null}}catch(c){if(this.shouldThrowOnError)throw c;if(Yc(c))return{data:null,error:c};throw c}})}createSignedUploadUrl(s,r){return ya(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 Pg(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 U2e("No token returned by API");return{data:{signedUrl:l.toString(),path:s,token:i},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Yc(n))return{data:null,error:n};throw n}})}update(s,r,n){return ya(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return ya(this,void 0,void 0,function*(){try{return{data:yield Pg(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(Yc(a))return{data:null,error:a};throw a}})}copy(s,r,n){return ya(this,void 0,void 0,function*(){try{return{data:{path:(yield Pg(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(Yc(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return ya(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),o=yield Pg(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(Yc(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return ya(this,void 0,void 0,function*(){try{const a=yield Pg(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(Yc(a))return{data:null,error:a};throw a}})}download(s,r){const a=typeof(r==null?void 0:r.transform)<"u"?"render/image/authenticated":"object",o=this.transformOptsToQueryString((r==null?void 0:r.transform)||{}),l=o?`?${o}`:"",i=this._getFinalPath(s),c=()=>H8(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0});return new Pbt(c,this.shouldThrowOnError)}info(s){return ya(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield H8(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:xve(n),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Yc(n))return{data:null,error:n};throw n}})}exists(s){return ya(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield Abt(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Yc(n)&&n instanceof fve){const a=n.originalError;if([400,404].includes(a==null?void 0:a.status))return{data:!1,error:n}}throw n}})}getPublicUrl(s,r){const n=this._getFinalPath(s),a=[],o=r!=null&&r.download?`download=${r.download===!0?"":r.download}`:"";o!==""&&a.push(o);const i=typeof(r==null?void 0:r.transform)<"u"?"render/image":"object",c=this.transformOptsToQueryString((r==null?void 0:r.transform)||{});c!==""&&a.push(c);let u=a.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${n}${u}`)}}}remove(s){return ya(this,void 0,void 0,function*(){try{return{data:yield H2e(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}list(s,r,n){return ya(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},Ibt),r),{prefix:s||""});return{data:yield Pg(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Yc(a))return{data:null,error:a};throw a}})}listV2(s,r){return ya(this,void 0,void 0,function*(){try{const n=Object.assign({},s);return{data:yield Pg(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Yc(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 yVe="2.78.0",vVe={"X-Client-Info":`storage-js/${yVe}`};class Dbt{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({},vVe),r),this.fetch=V2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(s){return ya(this,void 0,void 0,function*(){try{const r=this.listBucketOptionsToQueryString(s);return{data:yield H8(this.fetch,`${this.url}/bucket${r}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}getBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:yield H8(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}createBucket(s){return ya(this,arguments,void 0,function*(r,n={public:!1}){try{return{data:yield Pg(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(Yc(a))return{data:null,error:a};throw a}})}updateBucket(s,r){return ya(this,void 0,void 0,function*(){try{return{data:yield gve(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(Yc(n))return{data:null,error:n};throw n}})}emptyBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:yield Pg(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:yield H2e(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(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 Obt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},vVe),r),this.fetch=V2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:yield Pg(this.fetch,`${this.url}/bucket`,{name:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}listBuckets(s){return ya(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 H8(this.fetch,a,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:yield H2e(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}}const W2e={"X-Client-Info":`storage-js/${yVe}`,"Content-Type":"application/json"};class bVe extends Error{constructor(s){super(s),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function af(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}class cxe extends bVe{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 Rbt extends bVe{constructor(s,r){super(s),this.name="StorageVectorsUnknownError",this.originalError=r}}var SEe;(function(t){t.InternalError="InternalError",t.S3VectorConflictException="S3VectorConflictException",t.S3VectorNotFoundException="S3VectorNotFoundException",t.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",t.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",t.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(SEe||(SEe={}));const G2e=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>oc(async()=>{const{default:n}=await Promise.resolve().then(()=>pC);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},Fbt=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)},CEe=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),zbt=(t,s,r)=>ya(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 cxe(CEe(l),a,i))}).catch(()=>{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new cxe(i,a,l))});else{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new cxe(i,a,l))}}else s(new Rbt(CEe(t),t))}),Bbt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return n?(Fbt(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 $bt(t,s,r,n,a,o){return ya(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,Bbt(s,n,a,o)).then(c=>{if(!c.ok)throw c;if(n!=null&&n.noResolveJson)return c;const u=c.headers.get("content-type");return!u||!u.includes("application/json")?{}:c.json()}).then(c=>l(c)).catch(c=>zbt(c,i,n))})})}function of(t,s,r,n,a){return ya(this,void 0,void 0,function*(){return $bt(t,"POST",s,n,a,r)})}class qbt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},W2e),r),this.fetch=G2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(s){return ya(this,void 0,void 0,function*(){try{return{data:(yield of(this.fetch,`${this.url}/CreateIndex`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}getIndex(s,r){return ya(this,void 0,void 0,function*(){try{return{data:yield of(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(af(n))return{data:null,error:n};throw n}})}listIndexes(s){return ya(this,void 0,void 0,function*(){try{return{data:yield of(this.fetch,`${this.url}/ListIndexes`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}deleteIndex(s,r){return ya(this,void 0,void 0,function*(){try{return{data:(yield of(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(af(n))return{data:null,error:n};throw n}})}}class Ubt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},W2e),r),this.fetch=G2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(s){return ya(this,void 0,void 0,function*(){try{if(s.vectors.length<1||s.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return{data:(yield of(this.fetch,`${this.url}/PutVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}getVectors(s){return ya(this,void 0,void 0,function*(){try{return{data:yield of(this.fetch,`${this.url}/GetVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}listVectors(s){return ya(this,void 0,void 0,function*(){try{if(s.segmentCount!==void 0){if(s.segmentCount<1||s.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(s.segmentIndex!==void 0&&(s.segmentIndex<0||s.segmentIndex>=s.segmentCount))throw new Error(`segmentIndex must be between 0 and ${s.segmentCount-1}`)}return{data:yield of(this.fetch,`${this.url}/ListVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}queryVectors(s){return ya(this,void 0,void 0,function*(){try{return{data:yield of(this.fetch,`${this.url}/QueryVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}deleteVectors(s){return ya(this,void 0,void 0,function*(){try{if(s.keys.length<1||s.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return{data:(yield of(this.fetch,`${this.url}/DeleteVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}}class Vbt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},W2e),r),this.fetch=G2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:(yield of(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}getBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:yield of(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}listBuckets(){return ya(this,arguments,void 0,function*(s={}){try{return{data:yield of(this.fetch,`${this.url}/ListVectorBuckets`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:(yield of(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}}class Hbt extends Vbt{constructor(s,r={}){super(s,r.headers||{},r.fetch)}from(s){return new Wbt(this.url,this.headers,s,this.fetch)}}class Wbt extends qbt{constructor(s,r,n,a){super(s,r,a),this.vectorBucketName=n}createIndex(s){const r=Object.create(null,{createIndex:{get:()=>super.createIndex}});return ya(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 ya(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 ya(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 ya(this,void 0,void 0,function*(){return r.deleteIndex.call(this,this.vectorBucketName,s)})}index(s){return new Gbt(this.url,this.headers,this.vectorBucketName,s,this.fetch)}}class Gbt extends Ubt{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 ya(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 ya(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 ya(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 ya(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 ya(this,void 0,void 0,function*(){return r.deleteVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class Kbt extends Dbt{constructor(s,r={},n,a){super(s,r,n,a)}from(s){return new Lbt(this.url,this.headers,s,this.fetch)}get vectors(){return new Hbt(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new Obt(this.url+"/iceberg",this.headers,this.fetch)}}const Zbt="2.78.0";let yI="";typeof Deno<"u"?yI="deno":typeof document<"u"?yI="web":typeof navigator<"u"&&navigator.product==="ReactNative"?yI="react-native":yI="node";const Ybt={"X-Client-Info":`supabase-js-${yI}/${Zbt}`},Xbt={headers:Ybt},Qbt={schema:"public"},Jbt={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},e_t={},t_t=t=>{let s;return t?s=t:typeof fetch>"u"?s=ZUe:s=fetch,(...r)=>s(...r)},s_t=()=>typeof Headers>"u"?YUe:Headers,r_t=(t,s,r)=>{const n=t_t(r),a=s_t();return async(o,l)=>{var i;const c=(i=await s())!==null&&i!==void 0?i:t;let u=new a(l==null?void 0:l.headers);return u.has("apikey")||u.set("apikey",t),u.has("Authorization")||u.set("Authorization",`Bearer ${c}`),n(o,Object.assign(Object.assign({},l),{headers:u}))}};function n_t(t){return t.endsWith("/")?t:t+"/"}function a_t(t,s){var r,n;const{db:a,auth:o,realtime:l,global:i}=t,{db:c,auth:u,realtime:p,global:f}=s,g={db:Object.assign(Object.assign({},c),a),auth:Object.assign(Object.assign({},u),o),realtime:Object.assign(Object.assign({},p),l),storage:{},global:Object.assign(Object.assign(Object.assign({},f),i),{headers:Object.assign(Object.assign({},(r=f==null?void 0:f.headers)!==null&&r!==void 0?r:{}),(n=i==null?void 0:i.headers)!==null&&n!==void 0?n:{})}),accessToken:async()=>""};return t.accessToken?g.accessToken=t.accessToken:delete g.accessToken,g}function i_t(t){const s=t==null?void 0:t.trim();if(!s)throw new Error("supabaseUrl is required.");if(!s.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(n_t(s))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const _Ve="2.78.0",O5=30*1e3,yve=3,dxe=yve*O5,o_t="http://localhost:9999",l_t="supabase.auth.token",c_t={"X-Client-Info":`gotrue-js/${_Ve}`},vve="X-Supabase-Api-Version",wVe={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},d_t=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,u_t=10*60*1e3;class W8 extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Ba(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class h_t extends W8{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function m_t(t){return Ba(t)&&t.name==="AuthApiError"}class c4 extends W8{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class Cw extends W8{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class Sg extends Cw{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function p_t(t){return Ba(t)&&t.name==="AuthSessionMissingError"}class u5 extends Cw{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class G7 extends Cw{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class K7 extends Cw{constructor(s,r=null){super(s,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function f_t(t){return Ba(t)&&t.name==="AuthImplicitGrantRedirectError"}class MEe extends Cw{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 bve extends Cw{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function uxe(t){return Ba(t)&&t.name==="AuthRetryableFetchError"}class TEe extends Cw{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class _ve extends Cw{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const foe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),AEe=` \r=`.split(""),x_t=(()=>{const t=new Array(128);for(let s=0;s=6;){const n=s.queue>>s.queuedBits-6&63;r(foe[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(foe[n]),s.queuedBits-=6}}function jVe(t,s,r){const n=x_t[t];if(n>-1)for(s.queue=s.queue<<6|n,s.queuedBits+=6;s.queuedBits>=8;)r(s.queue>>s.queuedBits-8&255),s.queuedBits-=8;else{if(n===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function PEe(t){const s=[],r=l=>{s.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{v_t(l,n,r)};for(let l=0;l>6),s(128|t&63);return}else if(t<=65535){s(224|t>>12),s(128|t>>6&63),s(128|t&63);return}else if(t<=1114111){s(240|t>>18),s(128|t>>12&63),s(128|t>>6&63),s(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function y_t(t,s){for(let r=0;r55295&&n<=56319){const a=(n-55296)*1024&65535;n=(t.charCodeAt(r+1)-56320&65535|a)+65536,r+=1}g_t(n,s)}}function v_t(t,s,r){if(s.utf8seq===0){if(t<=127){r(t);return}for(let n=1;n<6;n+=1)if(!(t>>7-n&1)){s.utf8seq=n;break}if(s.utf8seq===2)s.codepoint=t&31;else if(s.utf8seq===3)s.codepoint=t&15;else if(s.utf8seq===4)s.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");s.utf8seq-=1}else if(s.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");s.codepoint=s.codepoint<<6|t&63,s.utf8seq-=1,s.utf8seq===0&&r(s.codepoint)}}function ZM(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function x4(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};return t.forEach(a=>EEe(a,r,n)),EEe(null,r,n),s.join("")}function __t(t){return Math.round(Date.now()/1e3)+t}function w_t(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const s=Math.random()*16|0;return(t=="x"?s:s&3|8).toString(16)})}const gm=()=>typeof window<"u"&&typeof document<"u",D2={tested:!1,writable:!1},NVe=()=>{if(!gm())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(D2.tested)return D2.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),D2.tested=!0,D2.writable=!0}catch{D2.tested=!0,D2.writable=!1}return D2.writable};function j_t(t){const s={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((a,o)=>{s[o]=a})}catch{}return r.searchParams.forEach((n,a)=>{s[a]=n}),s}const kVe=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>oc(async()=>{const{default:n}=await Promise.resolve().then(()=>pC);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},N_t=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",R5=async(t,s,r)=>{await t.setItem(s,JSON.stringify(r))},O2=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},Eb=async(t,s)=>{await t.removeItem(s)};class Ede{constructor(){this.promise=new Ede.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}Ede.promiseConstructor=Promise;function hxe(t){const s=t.split(".");if(s.length!==3)throw new _ve("Invalid JWT structure");for(let n=0;n{setTimeout(()=>s(null),t)})}function S_t(t,s){return new Promise((n,a)=>{(async()=>{for(let o=0;o<1/0;o++)try{const l=await t(o);if(!s(o,null,l)){n(l);return}}catch(l){if(!s(o,l)){a(l);return}}})()})}function C_t(t){return("0"+t.toString(16)).substr(-2)}function M_t(){const s=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=r.length;let a="";for(let o=0;o<56;o++)a+=r.charAt(Math.floor(Math.random()*n));return a}return crypto.getRandomValues(s),Array.from(s,C_t).join("")}async function T_t(t){const r=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",r),a=new Uint8Array(n);return Array.from(a).map(o=>String.fromCharCode(o)).join("")}async function A_t(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await T_t(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function h5(t,s,r=!1){const n=M_t();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await R5(t,`${s}-code-verifier`,a);const o=await A_t(n);return[o,n===o?"plain":"s256"]}const E_t=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function P_t(t){const s=t.headers.get(vve);if(!s||!s.match(E_t))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function I_t(t){if(!t)throw new Error("Missing exp claim");const s=Math.floor(Date.now()/1e3);if(t<=s)throw new Error("JWT has expired")}function L_t(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const D_t=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function m5(t){if(!D_t.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function mxe(){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 O_t(t,s){return new Proxy(t,{get:(r,n,a)=>{if(n==="__isInsecureUserWarningProxy")return!0;if(typeof n=="symbol"){const o=n.toString();if(o==="Symbol(Symbol.toPrimitive)"||o==="Symbol(Symbol.toStringTag)"||o==="Symbol(util.inspect.custom)"||o==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(r,n,a)}return!s.value&&typeof n=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),s.value=!0),Reflect.get(r,n,a)}})}function IEe(t){return JSON.parse(JSON.stringify(t))}const s4=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),R_t=[502,503,504];async function LEe(t){var s;if(!N_t(t))throw new bve(s4(t),0);if(R_t.includes(t.status))throw new bve(s4(t),t.status);let r;try{r=await t.json()}catch(o){throw new c4(s4(o),o)}let n;const a=P_t(t);if(a&&a.getTime()>=wVe["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 TEe(s4(r),t.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new Sg}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 TEe(s4(r),t.status,r.weak_password.reasons);throw new h_t(s4(r),t.status||500,n)}const F_t=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"?a:(a.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},s==null?void 0:s.headers),a.body=JSON.stringify(n),Object.assign(Object.assign({},a),r))};async function ji(t,s,r,n){var a;const o=Object.assign({},n==null?void 0:n.headers);o[vve]||(o[vve]=wVe["2024-01-01"].name),n!=null&&n.jwt&&(o.Authorization=`Bearer ${n.jwt}`);const l=(a=n==null?void 0:n.query)!==null&&a!==void 0?a:{};n!=null&&n.redirectTo&&(l.redirect_to=n.redirectTo);const i=Object.keys(l).length?"?"+new URLSearchParams(l).toString():"",c=await z_t(t,s,r+i,{headers:o,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(c):{data:Object.assign({},c),error:null}}async function z_t(t,s,r,n,a,o){const l=F_t(s,n,a,o);let i;try{i=await t(r,Object.assign({},l))}catch(c){throw console.error(c),new bve(s4(c),0)}if(i.ok||await LEe(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(c){await LEe(c)}}function Cg(t){var s;let r=null;q_t(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=__t(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function DEe(t){const s=Cg(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 r_(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function B_t(t){return{data:t,error:null}}function $_t(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=Sw(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),i={action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o},c=Object.assign({},l);return{data:{properties:i,user:c},error:null}}function OEe(t){return t}function q_t(t){return t.access_token&&t.refresh_token&&t.expires_in}const pxe=["global","local","others"];class U_t{constructor({url:s="",headers:r={},fetch:n}){this.url=s,this.headers=r,this.fetch=kVe(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=pxe[0]){if(pxe.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${pxe.join(", ")}`);try{return await ji(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:s,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Ba(n))return{data:null,error:n};throw n}}async inviteUserByEmail(s,r={}){try{return await ji(this.fetch,"POST",`${this.url}/invite`,{body:{email:s,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:r_})}catch(n){if(Ba(n))return{data:{user:null},error:n};throw n}}async generateLink(s){try{const{options:r}=s,n=Sw(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 ji(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:a,headers:this.headers,xform:$_t,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(Ba(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(s){try{return await ji(this.fetch,"POST",`${this.url}/admin/users`,{body:s,headers:this.headers,xform:r_})}catch(r){if(Ba(r))return{data:{user:null},error:r};throw r}}async listUsers(s){var r,n,a,o,l,i,c;try{const u={nextPage:null,lastPage:0,total:0},p=await ji(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:OEe});if(p.error)throw p.error;const f=await p.json(),g=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,b=(c=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&c!==void 0?c:[];return b.length>0&&(b.forEach(_=>{const j=parseInt(_.split(";")[0].split("=")[1].substring(0,1)),w=JSON.parse(_.split(";")[1].split("=")[1]);u[`${w}Page`]=j}),u.total=parseInt(g)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Ba(u))return{data:{users:[]},error:u};throw u}}async getUserById(s){m5(s);try{return await ji(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:r_})}catch(r){if(Ba(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){m5(s);try{return await ji(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:r_})}catch(n){if(Ba(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){m5(s);try{return await ji(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:r_})}catch(n){if(Ba(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){m5(s.userId);try{const{data:r,error:n}=await ji(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(Ba(r))return{data:null,error:r};throw r}}async _deleteFactor(s){m5(s.userId),m5(s.id);try{return{data:await ji(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(r){if(Ba(r))return{data:null,error:r};throw r}}async _listOAuthClients(s){var r,n,a,o,l,i,c;try{const u={nextPage:null,lastPage:0,total:0},p=await ji(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:OEe});if(p.error)throw p.error;const f=await p.json(),g=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,b=(c=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&c!==void 0?c:[];return b.length>0&&(b.forEach(_=>{const j=parseInt(_.split(";")[0].split("=")[1].substring(0,1)),w=JSON.parse(_.split(";")[1].split("=")[1]);u[`${w}Page`]=j}),u.total=parseInt(g)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Ba(u))return{data:{clients:[]},error:u};throw u}}async _createOAuthClient(s){try{return await ji(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ba(r))return{data:null,error:r};throw r}}async _getOAuthClient(s){try{return await ji(this.fetch,"GET",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ba(r))return{data:null,error:r};throw r}}async _updateOAuthClient(s,r){try{return await ji(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${s}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Ba(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(s){try{return await ji(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(Ba(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(s){try{return await ji(this.fetch,"POST",`${this.url}/admin/oauth/clients/${s}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ba(r))return{data:null,error:r};throw r}}}function REe(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}const p5={debug:!!(globalThis&&NVe()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class SVe extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class V_t extends SVe{}async function H_t(t,s,r){p5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),p5.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){p5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,a.name);try{return await r()}finally{p5.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,a.name)}}else{if(s===0)throw p5.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new V_t(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(p5.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 W_t(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function CVe(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function G_t(t){return parseInt(t,16)}function K_t(t){const s=new TextEncoder().encode(t);return"0x"+Array.from(s,n=>n.toString(16).padStart(2,"0")).join("")}function Z_t(t){var s;const{chainId:r,domain:n,expirationTime:a,issuedAt:o=new Date,nonce:l,notBefore:i,requestId:c,resources:u,scheme:p,uri:f,version:g}=t;{if(!Number.isInteger(r))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!n)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(l&&l.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${l}`);if(!f)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(g!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${g}`);if(!((s=t.statement)===null||s===void 0)&&s.includes(` `))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const b=CVe(t.address),_=p?`${p}://${n}`:n,j=t.statement?`${t.statement} `:"",w=`${_} wants you to sign in with your Ethereum account: ${b} ${j}`;let k=`URI: ${f} Version: ${g} Chain ID: ${r}${l?` Nonce: ${l}`:""} Issued At: ${o.toISOString()}`;if(a&&(k+=` Expiration Time: ${a.toISOString()}`),i&&(k+=` Not Before: ${i.toISOString()}`),c&&(k+=` Request ID: ${c}`),u){let S=` Resources:`;for(const M of u){if(!M||typeof M!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${M}`);S+=` - ${M}`}k+=S}return`${w} ${k}`}class Zd extends Error{constructor({message:s,code:r,cause:n,name:a}){var o;super(s,{cause:n}),this.__isWebAuthnError=!0,this.name=(o=a??(n instanceof Error?n.name:void 0))!==null&&o!==void 0?o:"Unknown Error",this.code=r}}class xoe extends Zd{constructor(s,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:s}),this.name="WebAuthnUnknownError",this.originalError=r}}function Y_t({error:t,options:s}){var r,n,a;const{publicKey:o}=s;if(!o)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(s.signal instanceof AbortSignal)return new Zd({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((r=o.authenticatorSelection)===null||r===void 0?void 0:r.requireResidentKey)===!0)return new Zd({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(s.mediation==="conditional"&&((n=o.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new Zd({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((a=o.authenticatorSelection)===null||a===void 0?void 0:a.userVerification)==="required")return new Zd({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new Zd({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new Zd({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return o.pubKeyCredParams.filter(i=>i.type==="public-key").length===0?new Zd({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new Zd({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const l=window.location.hostname;if(MVe(l)){if(o.rp.id!==l)return new Zd({message:`The RP ID "${o.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Zd({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(o.user.id.byteLength<1||o.user.id.byteLength>64)return new Zd({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new Zd({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Zd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function X_t({error:t,options:s}){const{publicKey:r}=s;if(!r)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(s.signal instanceof AbortSignal)return new Zd({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new Zd({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(MVe(n)){if(r.rpId!==n)return new Zd({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Zd({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new Zd({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Zd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class Q_t{createNewAbortSignal(){if(this.controller){const r=new Error("Cancelling existing WebAuthn API call for new one");r.name="AbortError",this.controller.abort(r)}const s=new AbortController;return this.controller=s,s.signal}cancelCeremony(){if(this.controller){const s=new Error("Manually cancelling existing WebAuthn API call");s.name="AbortError",this.controller.abort(s),this.controller=void 0}}}const J_t=new Q_t;function ewt(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=Sw(t,["challenge","user","excludeCredentials"]),o=ZM(s).buffer,l=Object.assign(Object.assign({},r),{id:ZM(r.id).buffer}),i=Object.assign(Object.assign({},a),{challenge:o,user:l});if(n&&n.length>0){i.excludeCredentials=new Array(n.length);for(let c=0;c0){o.allowCredentials=new Array(r.length);for(let l=0;la!==null&&typeof a=="object"&&!Array.isArray(a),r=a=>a instanceof ArrayBuffer||ArrayBuffer.isView(a),n={};for(const a of t)if(a)for(const o in a){const l=a[o];if(l!==void 0)if(Array.isArray(l))n[o]=l;else if(r(l))n[o]=l;else if(s(l)){const i=n[o];s(i)?n[o]=goe(i,l):n[o]=goe(l)}else n[o]=l}return n}function lwt(t,s){return goe(iwt,t,s||{})}function cwt(t,s){return goe(owt,t,s||{})}class dwt{constructor(s){this.client=s,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(s){return this.client.mfa.enroll(Object.assign(Object.assign({},s),{factorType:"webauthn"}))}async _challenge({factorId:s,webauthn:r,friendlyName:n,signal:a},o){try{const{data:l,error:i}=await this.client.mfa.challenge({factorId:s,webauthn:r});if(!l)return{data:null,error:i};const c=a??J_t.createNewAbortSignal();if(l.webauthn.type==="create"){const{user:u}=l.webauthn.credential_options.publicKey;u.name||(u.name=`${u.id}:${n}`),u.displayName||(u.displayName=u.name)}switch(l.webauthn.type){case"create":{const u=lwt(l.webauthn.credential_options.publicKey,o==null?void 0:o.create),{data:p,error:f}=await nwt({publicKey:u,signal:c});return p?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:p}},error:null}:{data:null,error:f}}case"request":{const u=cwt(l.webauthn.credential_options.publicKey,o==null?void 0:o.request),{data:p,error:f}=await awt(Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:u,signal:c}));return p?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:p}},error:null}:{data:null,error:f}}}}catch(l){return Ba(l)?{data:null,error:l}:{data:null,error:new c4("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 W8("rpId is required for WebAuthn authentication")};try{if(!FEe())return{data:null,error:new c4("Browser does not support WebAuthn",null)};const{data:l,error:i}=await this.challenge({factorId:s,webauthn:{rpId:r,rpOrigins:n},signal:a},{request:o});if(!l)return{data:null,error:i};const{webauthn:c}=l;return this._verify({factorId:s,challengeId:l.challengeId,webauthn:{type:c.type,rpId:r,rpOrigins:n,credential_response:c.credential_response}})}catch(l){return Ba(l)?{data:null,error:l}:{data:null,error:new c4("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 W8("rpId is required for WebAuthn registration")};try{if(!FEe())return{data:null,error:new c4("Browser does not support WebAuthn",null)};const{data:l,error:i}=await this._enroll({friendlyName:s});if(!l)return await this.client.mfa.listFactors().then(p=>{var f;return(f=p.data)===null||f===void 0?void 0:f.all.find(g=>g.factor_type==="webauthn"&&g.friendly_name===s&&g.status!=="unverified")}).then(p=>p?this.client.mfa.unenroll({factorId:p==null?void 0:p.id}):void 0),{data:null,error:i};const{data:c,error:u}=await this._challenge({factorId:l.id,friendlyName:l.friendly_name,webauthn:{rpId:r,rpOrigins:n},signal:a},{create:o});return c?this._verify({factorId:l.id,challengeId:c.challengeId,webauthn:{rpId:r,rpOrigins:n,type:c.webauthn.type,credential_response:c.webauthn.credential_response}}):{data:null,error:u}}catch(l){return Ba(l)?{data:null,error:l}:{data:null,error:new c4("Unexpected error in register",l)}}}}W_t();const uwt={url:o_t,storageKey:l_t,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:c_t,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function zEe(t,s,r){return await r()}const f5={};class G8{get jwks(){var s,r;return(r=(s=f5[this.storageKey])===null||s===void 0?void 0:s.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(s){f5[this.storageKey]=Object.assign(Object.assign({},f5[this.storageKey]),{jwks:s})}get jwks_cached_at(){var s,r;return(r=(s=f5[this.storageKey])===null||s===void 0?void 0:s.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(s){f5[this.storageKey]=Object.assign(Object.assign({},f5[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=G8.nextInstanceID,G8.nextInstanceID+=1,this.instanceID>0&&gm()&&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({},uwt),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 U_t({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=kVe(a.fetch),this.lock=a.lock||zEe,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:gm()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=H_t:this.lock=zEe,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 dwt(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:NVe()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=REe(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=REe(this.memoryStorage)),gm()&&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} (${_Ve}) ${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=j_t(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),gm()&&this.detectSessionInUrl&&n!=="none"){const{data:a,error:o}=await this._getSessionFromURL(r,n);if(o){if(this._debug("#_initialize()","error detecting session from URL",o),f_t(o)){const c=(s=o.details)===null||s===void 0?void 0:s.code;if(c==="identity_already_exists"||c==="identity_not_found"||c==="single_identity_not_deletable")return{error:o}}return await this._removeSession(),{error:o}}const{session:l,redirectType:i}=a;return this._debug("#_initialize()","detected session in URL",l,"redirect type",i),await this._saveSession(l),setTimeout(async()=>{i==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",l):await this._notifyAllSubscribers("SIGNED_IN",l)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return Ba(r)?{error:r}:{error:new c4("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var r,n,a;try{const o=await ji(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:Cg}),{data:l,error:i}=o;if(i||!l)return{data:{user:null,session:null},error:i};const c=l.session,u=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",c)),{data:{user:u,session:c},error:null}}catch(o){if(Ba(o))return{data:{user:null,session:null},error:o};throw o}}async signUp(s){var r,n,a;try{let o;if("email"in s){const{email:p,password:f,options:g}=s;let b=null,_=null;this.flowType==="pkce"&&([b,_]=await h5(this.storage,this.storageKey)),o=await ji(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:g==null?void 0:g.emailRedirectTo,body:{email:p,password:f,data:(r=g==null?void 0:g.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:g==null?void 0:g.captchaToken},code_challenge:b,code_challenge_method:_},xform:Cg})}else if("phone"in s){const{phone:p,password:f,options:g}=s;o=await ji(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:p,password:f,data:(n=g==null?void 0:g.data)!==null&&n!==void 0?n:{},channel:(a=g==null?void 0:g.channel)!==null&&a!==void 0?a:"sms",gotrue_meta_security:{captcha_token:g==null?void 0:g.captchaToken}},xform:Cg})}else throw new G7("You must provide either an email or phone number and a password");const{data:l,error:i}=o;if(i||!l)return{data:{user:null,session:null},error:i};const c=l.session,u=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",c)),{data:{user:u,session:c},error:null}}catch(o){if(Ba(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 ji(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:DEe})}else if("phone"in s){const{phone:o,password:l,options:i}=s;r=await ji(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:DEe})}else throw new G7("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 u5}:(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(Ba(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOAuth(s){var r,n,a,o;return await this._handleProviderSignIn(s.provider,{redirectTo:(r=s.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=s.options)===null||n===void 0?void 0:n.scopes,queryParams:(a=s.options)===null||a===void 0?void 0:a.queryParams,skipBrowserRedirect:(o=s.options)===null||o===void 0?void 0:o.skipBrowserRedirect})}async exchangeCodeForSession(s){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(s))}async signInWithWeb3(s){const{chain:r}=s;switch(r){case"ethereum":return await this.signInWithEthereum(s);case"solana":return await this.signInWithSolana(s);default:throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}}async signInWithEthereum(s){var r,n,a,o,l,i,c,u,p,f,g;let b,_;if("message"in s)b=s.message,_=s.signature;else{const{chain:j,wallet:w,statement:k,options:S}=s;let M;if(gm())if(typeof w=="object")M=w;else{const B=window;if("ethereum"in B&&typeof B.ethereum=="object"&&"request"in B.ethereum&&typeof B.ethereum.request=="function")M=B.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof w!="object"||!(S!=null&&S.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");M=w}const L=new URL((r=S==null?void 0:S.url)!==null&&r!==void 0?r:window.location.href),I=await M.request({method:"eth_requestAccounts"}).then(B=>B).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!I||I.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const O=CVe(I[0]);let q=(n=S==null?void 0:S.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!q){const B=await M.request({method:"eth_chainId"});q=G_t(B)}const U={domain:L.host,address:O,statement:k,uri:L.href,version:"1",chainId:q,nonce:(a=S==null?void 0:S.signInWithEthereum)===null||a===void 0?void 0:a.nonce,issuedAt:(l=(o=S==null?void 0:S.signInWithEthereum)===null||o===void 0?void 0:o.issuedAt)!==null&&l!==void 0?l:new Date,expirationTime:(i=S==null?void 0:S.signInWithEthereum)===null||i===void 0?void 0:i.expirationTime,notBefore:(c=S==null?void 0:S.signInWithEthereum)===null||c===void 0?void 0:c.notBefore,requestId:(u=S==null?void 0:S.signInWithEthereum)===null||u===void 0?void 0:u.requestId,resources:(p=S==null?void 0:S.signInWithEthereum)===null||p===void 0?void 0:p.resources};b=Z_t(U),_=await M.request({method:"personal_sign",params:[K_t(b),O]})}try{const{data:j,error:w}=await ji(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:b,signature:_},!((f=s.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(g=s.options)===null||g===void 0?void 0:g.captchaToken}}:null),xform:Cg});if(w)throw w;return!j||!j.session||!j.user?{data:{user:null,session:null},error:new u5}:(j.session&&(await this._saveSession(j.session),await this._notifyAllSubscribers("SIGNED_IN",j.session)),{data:Object.assign({},j),error:w})}catch(j){if(Ba(j))return{data:{user:null,session:null},error:j};throw j}}async signInWithSolana(s){var r,n,a,o,l,i,c,u,p,f,g,b;let _,j;if("message"in s)_=s.message,j=s.signature;else{const{chain:w,wallet:k,statement:S,options:M}=s;let L;if(gm())if(typeof k=="object")L=k;else{const O=window;if("solana"in O&&typeof O.solana=="object"&&("signIn"in O.solana&&typeof O.solana.signIn=="function"||"signMessage"in O.solana&&typeof O.solana.signMessage=="function"))L=O.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof k!="object"||!(M!=null&&M.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");L=k}const I=new URL((r=M==null?void 0:M.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in L&&L.signIn){const O=await L.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},M==null?void 0:M.signInWithSolana),{version:"1",domain:I.host,uri:I.href}),S?{statement:S}:null));let q;if(Array.isArray(O)&&O[0]&&typeof O[0]=="object")q=O[0];else if(O&&typeof O=="object"&&"signedMessage"in O&&"signature"in O)q=O;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in q&&"signature"in q&&(typeof q.signedMessage=="string"||q.signedMessage instanceof Uint8Array)&&q.signature instanceof Uint8Array)_=typeof q.signedMessage=="string"?q.signedMessage:new TextDecoder().decode(q.signedMessage),j=q.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in L)||typeof L.signMessage!="function"||!("publicKey"in L)||typeof L!="object"||!L.publicKey||!("toBase58"in L.publicKey)||typeof L.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");_=[`${I.host} wants you to sign in with your Solana account:`,L.publicKey.toBase58(),...S?["",S,""]:[""],"Version: 1",`URI: ${I.href}`,`Issued At: ${(a=(n=M==null?void 0:M.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&a!==void 0?a:new Date().toISOString()}`,...!((o=M==null?void 0:M.signInWithSolana)===null||o===void 0)&&o.notBefore?[`Not Before: ${M.signInWithSolana.notBefore}`]:[],...!((l=M==null?void 0:M.signInWithSolana)===null||l===void 0)&&l.expirationTime?[`Expiration Time: ${M.signInWithSolana.expirationTime}`]:[],...!((i=M==null?void 0:M.signInWithSolana)===null||i===void 0)&&i.chainId?[`Chain ID: ${M.signInWithSolana.chainId}`]:[],...!((c=M==null?void 0:M.signInWithSolana)===null||c===void 0)&&c.nonce?[`Nonce: ${M.signInWithSolana.nonce}`]:[],...!((u=M==null?void 0:M.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${M.signInWithSolana.requestId}`]:[],...!((f=(p=M==null?void 0:M.signInWithSolana)===null||p===void 0?void 0:p.resources)===null||f===void 0)&&f.length?["Resources",...M.signInWithSolana.resources.map(q=>`- ${q}`)]:[]].join(` `);const O=await L.signMessage(new TextEncoder().encode(_),"utf8");if(!O||!(O instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");j=O}}try{const{data:w,error:k}=await ji(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:_,signature:x4(j)},!((g=s.options)===null||g===void 0)&&g.captchaToken?{gotrue_meta_security:{captcha_token:(b=s.options)===null||b===void 0?void 0:b.captchaToken}}:null),xform:Cg});if(k)throw k;return!w||!w.session||!w.user?{data:{user:null,session:null},error:new u5}:(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),{data:Object.assign({},w),error:k})}catch(w){if(Ba(w))return{data:{user:null,session:null},error:w};throw w}}async _exchangeCodeForSession(s){const r=await O2(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(r??"").split("/");try{const{data:o,error:l}=await ji(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:n},xform:Cg});if(await Eb(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new u5}:(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(Ba(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 ji(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:Cg}),{data:c,error:u}=i;return u?{data:{user:null,session:null},error:u}:!c||!c.session||!c.user?{data:{user:null,session:null},error:new u5}:(c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",c.session)),{data:c,error:u})}catch(r){if(Ba(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(s){var r,n,a,o,l;try{if("email"in s){const{email:i,options:c}=s;let u=null,p=null;this.flowType==="pkce"&&([u,p]=await h5(this.storage,this.storageKey));const{error:f}=await ji(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:i,data:(r=c==null?void 0:c.data)!==null&&r!==void 0?r:{},create_user:(n=c==null?void 0:c.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},code_challenge:u,code_challenge_method:p},redirectTo:c==null?void 0:c.emailRedirectTo});return{data:{user:null,session:null},error:f}}if("phone"in s){const{phone:i,options:c}=s,{data:u,error:p}=await ji(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:i,data:(a=c==null?void 0:c.data)!==null&&a!==void 0?a:{},create_user:(o=c==null?void 0:c.shouldCreateUser)!==null&&o!==void 0?o:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},channel:(l=c==null?void 0:c.channel)!==null&&l!==void 0?l:"sms"}});return{data:{user:null,session:null,messageId:u==null?void 0:u.message_id},error:p}}throw new G7("You must provide either an email or phone number.")}catch(i){if(Ba(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 ji(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:o}}),redirectTo:a,xform:Cg});if(i)throw i;if(!l)throw new Error("An error occurred on token verification.");const c=l.session,u=l.user;return c!=null&&c.access_token&&(await this._saveSession(c),await this._notifyAllSubscribers(s.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",c)),{data:{user:u,session:c},error:null}}catch(a){if(Ba(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 h5(this.storage,this.storageKey)),await ji(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:B_t})}catch(o){if(Ba(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 Sg;const{error:a}=await ji(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(s){if(Ba(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 ji(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 ji(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 G7("You must provide either an email or phone number and a type")}catch(r){if(Ba(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 O2(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?s=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!s)return{data:{session:null},error:null};const n=s.expires_at?s.expires_at*1e3-Date.now()await this._getUser()))}async _getUser(s){try{return s?await ji(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:r_}):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 Sg}:await ji(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:r_})})}catch(r){if(Ba(r))return p_t(r)&&(await this._removeSession(),await Eb(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 Sg;const l=a.session;let i=null,c=null;this.flowType==="pkce"&&s.email!=null&&([i,c]=await h5(this.storage,this.storageKey));const{data:u,error:p}=await ji(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},s),{code_challenge:i,code_challenge_method:c}),jwt:l.access_token,xform:r_});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(Ba(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 Sg;const r=Date.now()/1e3;let n=r,a=!0,o=null;const{payload:l}=hxe(s.access_token);if(l.exp&&(n=l.exp,a=n<=r),a){const{data:i,error:c}=await this._callRefreshToken(s.refresh_token);if(c)return{data:{user:null,session:null},error:c};if(!i)return{data:{user:null,session:null},error:null};o=i}else{const{data:i,error:c}=await this._getUser(s.access_token);if(c)throw c;o={access_token:s.access_token,refresh_token:s.refresh_token,user:i.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(o),await this._notifyAllSubscribers("SIGNED_IN",o)}return{data:{user:o.user,session:o},error:null}}catch(r){if(Ba(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 Sg;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(Ba(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!gm())throw new K7("No browser detected.");if(s.error||s.error_description||s.error_code)throw new K7(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 MEe("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new K7("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 MEe("No code detected.");const{data:S,error:M}=await this._exchangeCodeForSession(s.code);if(M)throw M;const L=new URL(window.location.href);return L.searchParams.delete("code"),window.history.replaceState(window.history.state,"",L.toString()),{data:{session:S.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:o,refresh_token:l,expires_in:i,expires_at:c,token_type:u}=s;if(!o||!i||!l||!u)throw new K7("No session defined in URL");const p=Math.round(Date.now()/1e3),f=parseInt(i);let g=p+f;c&&(g=parseInt(c));const b=g-p;b*1e3<=O5&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${b}s, should have been closer to ${f}s`);const _=g-f;p-_>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",_,g,p):p-_<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",_,g,p);const{data:j,error:w}=await this._getUser(o);if(w)throw w;const k={provider_token:n,provider_refresh_token:a,access_token:o,expires_in:f,expires_at:g,refresh_token:l,token_type:u,user:j.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:k,redirectType:s.type},error:null}}catch(n){if(Ba(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 O2(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&&!(m_t(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await Eb(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=w_t(),n={id:r,callback:s,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:n}}}async _emitInitialSession(s){return await this._useSession(async r=>{var n,a;try{const{data:{session:o},error:l}=r;if(l)throw l;await((n=this.stateChangeEmitters.get(s))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",o)),this._debug("INITIAL_SESSION","callback id",s,"session",o)}catch(o){await((a=this.stateChangeEmitters.get(s))===null||a===void 0?void 0:a.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",s,"error",o),console.error(o)}})}async resetPasswordForEmail(s,r={}){let n=null,a=null;this.flowType==="pkce"&&([n,a]=await h5(this.storage,this.storageKey,!0));try{return await ji(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(Ba(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(Ba(r))return{data:null,error:r};throw r}}async linkIdentity(s){return"token"in s?this.linkIdentityIdToken(s):this.linkIdentityOAuth(s)}async linkIdentityOAuth(s){var r;try{const{data:n,error:a}=await this._useSession(async o=>{var l,i,c,u,p;const{data:f,error:g}=o;if(g)throw g;const b=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,s.provider,{redirectTo:(l=s.options)===null||l===void 0?void 0:l.redirectTo,scopes:(i=s.options)===null||i===void 0?void 0:i.scopes,queryParams:(c=s.options)===null||c===void 0?void 0:c.queryParams,skipBrowserRedirect:!0});return await ji(this.fetch,"GET",b,{headers:this.headers,jwt:(p=(u=f.session)===null||u===void 0?void 0:u.access_token)!==null&&p!==void 0?p:void 0})});if(a)throw a;return gm()&&!(!((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(Ba(n))return{data:{provider:s.provider,url:null},error:n};throw n}}async linkIdentityIdToken(s){return await this._useSession(async r=>{var n;try{const{error:a,data:{session:o}}=r;if(a)throw a;const{options:l,provider:i,token:c,access_token:u,nonce:p}=s,f=await ji(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(n=o==null?void 0:o.access_token)!==null&&n!==void 0?n:void 0,body:{provider:i,id_token:c,access_token:u,nonce:p,link_identity:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:Cg}),{data:g,error:b}=f;return b?{data:{user:null,session:null},error:b}:!g||!g.session||!g.user?{data:{user:null,session:null},error:new u5}:(g.session&&(await this._saveSession(g.session),await this._notifyAllSubscribers("USER_UPDATED",g.session)),{data:g,error:b})}catch(a){if(Ba(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 ji(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(Ba(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 S_t(async a=>(a>0&&await k_t(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await ji(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:Cg})),(a,o)=>{const l=200*Math.pow(2,a);return o&&uxe(o)&&Date.now()+l-n{try{await i.callback(s,r)}catch(c){o.push(c)}});if(await Promise.all(l),o.length>0){for(let i=0;ithis._autoRefreshTokenTick(),O5);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)/O5);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${O5}ms, refresh threshold is ${yve} ticks`),a<=yve&&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 SVe)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!gm()||!(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 h5(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 ji(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(Ba(r))return{data:null,error:r};throw r}}async _enroll(s){try{return await this._useSession(async r=>{var n,a;const{data:o,error:l}=r;if(l)return{data:null,error:l};const i=Object.assign({friendly_name:s.friendlyName,factor_type:s.factorType},s.factorType==="phone"?{phone:s.phone}:s.factorType==="totp"?{issuer:s.issuer}:{}),{data:c,error:u}=await ji(this.fetch,"POST",`${this.url}/factors`,{body:i,headers:this.headers,jwt:(n=o==null?void 0:o.session)===null||n===void 0?void 0:n.access_token});return u?{data:null,error:u}:(s.factorType==="totp"&&c.type==="totp"&&(!((a=c==null?void 0:c.totp)===null||a===void 0)&&a.qr_code)&&(c.totp.qr_code=`data:image/svg+xml;utf-8,${c.totp.qr_code}`),{data:c,error:null})})}catch(r){if(Ba(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"?swt(s.webauthn.credential_response):rwt(s.webauthn.credential_response)})}:{code:s.code}),{data:i,error:c}=await ji(this.fetch,"POST",`${this.url}/factors/${s.factorId}/verify`,{body:l,headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});return c?{data:null,error:c}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+i.expires_in},i)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",i),{data:i,error:c})})}catch(r){if(Ba(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 ji(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:ewt(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:twt(i.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(Ba(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}=hxe(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 ji(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 Sg}})}catch(r){if(Ba(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 Sg};const l=await ji(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&&gm()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Ba(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 Sg};const l=await ji(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&&gm()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Ba(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+u_t>a)return n;const{data:o,error:l}=await ji(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(l)throw l;return!o.keys||o.keys.length===0||(this.jwks=o,this.jwks_cached_at=a,n=o.keys.find(i=>i.kid===s),!n)?null:n}async getClaims(s,r={}){try{let n=s;if(!n){const{data:b,error:_}=await this.getSession();if(_||!b.session)return{data:null,error:_};n=b.session.access_token}const{header:a,payload:o,signature:l,raw:{header:i,payload:c}}=hxe(n);r!=null&&r.allowExpired||I_t(o.exp);const u=!a.alg||a.alg.startsWith("HS")||!a.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(a.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!u){const{error:b}=await this.getUser(n);if(b)throw b;return{data:{claims:o,header:a,signature:l},error:null}}const p=L_t(a.alg),f=await crypto.subtle.importKey("jwk",u,p,!0,["verify"]);if(!await crypto.subtle.verify(p,f,l,b_t(`${i}.${c}`)))throw new _ve("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(Ba(n))return{data:null,error:n};throw n}}}G8.nextInstanceID=0;const hwt=G8;class mwt extends hwt{constructor(s){super(s)}}class pwt{constructor(s,r,n){var a,o,l;this.supabaseUrl=s,this.supabaseKey=r;const i=i_t(s);if(!r)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);const c=`sb-${i.hostname.split(".")[0]}-auth-token`,u={db:Qbt,realtime:e_t,auth:Object.assign(Object.assign({},Jbt),{storageKey:c}),global:Xbt},p=a_t(n??{},u);this.storageKey=(a=p.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(o=p.global.headers)!==null&&o!==void 0?o:{},p.accessToken?(this.accessToken=p.accessToken,this.auth=new Proxy({},{get:(f,g)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(g)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((l=p.auth)!==null&&l!==void 0?l:{},this.headers,p.global.fetch),this.fetch=r_t(r,this._getAccessToken.bind(this),p.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},p.realtime)),this.rest=new obt(new URL("rest/v1",i).href,{headers:this.headers,schema:p.db.schema,fetch:this.fetch}),this.storage=new Kbt(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),p.accessToken||this._listenForAuthEvents()}get functions(){return new J1t(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(s){return this.rest.from(s)}schema(s){return this.rest.schema(s)}rpc(s,r={},n={head:!1,get:!1,count:void 0}){return this.rest.rpc(s,r,n)}channel(s,r={config:{}}){return this.realtime.channel(s,r)}getChannels(){return this.realtime.getChannels()}removeChannel(s){return this.realtime.removeChannel(s)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var s,r;if(this.accessToken)return await this.accessToken();const{data:n}=await this.auth.getSession();return(r=(s=n.session)===null||s===void 0?void 0:s.access_token)!==null&&r!==void 0?r:this.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,userStorage:o,storageKey:l,flowType:i,lock:c,debug:u},p,f){const g={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new mwt({url:this.authUrl.href,headers:Object.assign(Object.assign({},g),p),storageKey:l,autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,userStorage:o,flowType:i,lock:c,debug:u,fetch:f,hasCustomAuthorizationHeader:Object.keys(this.headers).some(b=>b.toLowerCase()==="authorization")})}_initRealtimeClient(s){return new Nbt(this.realtimeUrl.href,Object.assign(Object.assign({},s),{params:Object.assign({apikey:this.supabaseKey},s==null?void 0:s.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((r,n)=>{this._handleTokenChanged(r,"CLIENT",n==null?void 0:n.access_token)})}_handleTokenChanged(s,r,n){(s==="TOKEN_REFRESHED"||s==="SIGNED_IN")&&this.changedAccessToken!==n?(this.changedAccessToken=n,this.realtime.setAuth(n)):s==="SIGNED_OUT"&&(this.realtime.setAuth(),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const fwt=(t,s,r)=>new pwt(t,s,r);function xwt(){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}xwt()&&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 gwt="https://relzejiswnotikjgvjhz.supabase.co",ywt="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",H=fwt(gwt,ywt,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),TVe=N.createContext(void 0),vwt=({children:t})=>{const[s,r]=N.useState(null),[n,a]=N.useState(null),[o,l]=N.useState(!0),[i,c]=N.useState(!0),[u,p]=N.useState(!1),[f,g]=N.useState(!1),[b,_]=N.useState(null),[j,w]=N.useState([]),[k,S]=N.useState(null),M=N.useRef(null),L=N.useRef(!1),I=fr(),O=()=>{p(!1),g(!1),_(null),w([]),S(null),M.current=null,L.current=!1},q=async Z=>{if(!(L.current&&M.current===Z)){c(!0);try{console.log("Checking roles via RPC for user:",Z);const[{data:X,error:ee},{data:Q,error:ie}]=await Promise.all([H.rpc("has_role",{_user_id:Z,_role:"admin"}),H.rpc("has_role",{_user_id:Z,_role:"brokerage_manager"})]);if(ee||ie)console.error("Role RPC errors:",{isAdminError:ee,isBrokerError:ie}),p(!1),g(!1);else{const ce=!!X,xe=!!Q;console.log("RPC roles result:",{adminValue:ce,brokerValue:xe}),p(ce),g(xe)}const{data:re,error:oe}=await H.from("profiles").select("brokerage_id").eq("id",Z).single();if(_(!oe&&re?re.brokerage_id:null),Q){console.log("Fetching managed brokerages for user:",Z);const{data:ce,error:xe}=await H.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",Z);if(console.log("Managed brokerage assignments result:",{assignments:ce,assignmentsError:xe}),xe||!ce){console.error("Error fetching managed brokerage assignments:",xe),w([]);return}const ge=Array.from(new Set(ce.map(Me=>Me.brokerage_id).filter(Boolean)));if(ge.length===0){w([]);return}const{data:ue,error:pe}=await H.from("brokerages").select("id, name").in("id",ge);if(console.log("Managed brokerages details result:",{brokeragesData:ue,brokeragesError:pe}),pe||!ue){console.error("Error fetching managed brokerages details:",pe),w([]);return}const be=ue.map(Me=>({id:Me.id,name:Me.name})).sort((Me,Ne)=>ge.indexOf(Me.id)-ge.indexOf(Ne.id));console.log("Parsed managed brokerages:",be),w(be),be.length>0&&S(Me=>Me??be[0].id)}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),w([]);M.current=Z,L.current=!0}catch(X){console.error("Unexpected error in checkRoles:",X),O()}finally{c(!1)}}};N.useEffect(()=>{let Z=!0,X=!1;const ee=()=>{!Z||X||(X=!0,l(!1))},{data:{subscription:Q}}=H.auth.onAuthStateChange((oe,ce)=>{console.log("Auth event:",oe),Z&&(a(ce),r((ce==null?void 0:ce.user)??null),ee(),oe==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{I("/profile?reset=true")},100)),ce!=null&&ce.user?(!L.current||M.current!==ce.user.id)&&setTimeout(()=>{q(ce.user.id)},0):(O(),c(!1)))}),ie=window.setTimeout(()=>{console.warn("Auth initialization timeout reached. Continuing without blocking UI."),ee()},4e3);return(async()=>{try{const{data:{session:oe}}=await H.auth.getSession();if(!Z)return;a(oe),r((oe==null?void 0:oe.user)??null),oe!=null&&oe.user?await q(oe.user.id):O()}catch(oe){console.error("Error restoring auth session:",oe),Z&&(a(null),r(null),O())}finally{ee()}})(),()=>{Z=!1,window.clearTimeout(ie),Q.unsubscribe()}},[]);const U=async(Z,X)=>{const{error:ee}=await H.auth.signInWithPassword({email:Z,password:X});if(ee)throw me.error(ee.message),ee;me.success("Welcome back!"),I("/dashboard")},B=async(Z,X,ee)=>{const Q=`${window.location.origin}/dashboard`,{error:ie}=await H.auth.signUp({email:Z,password:X,options:{emailRedirectTo:Q,data:{name:ee}}});if(ie)throw me.error(ie.message),ie;me.success("Account created! Welcome to LevelUp."),I("/dashboard")},V=async()=>{try{const{data:{session:Z}}=await H.auth.getSession();if(Z){const{error:X}=await H.auth.signOut();X?X.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",X.message):(console.error("Sign out error:",X),me.error(X.message)):me.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");r(null),a(null),p(!1),g(!1),_(null),w([]),S(null),I("/auth")}catch(Z){console.error("Unexpected sign out error:",Z),I("/auth")}};return e.jsx(TVe.Provider,{value:{user:s,session:n,loading:o,rolesLoading:i,signIn:U,signUp:B,signOut:V,isAdmin:u,isBrokerageManager:f,brokerageId:b,managedBrokerages:j,selectedBrokerageId:k,setSelectedBrokerageId:S},children:t})},Ds=()=>{const t=N.useContext(TVe);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},AVe=N.createContext(void 0),R2="levelup_admin_session",Pb="levelup_impersonation",fxe="levelup_impersonation_return",bwt=({children:t})=>{const[s,r]=N.useState(!1),[n,a]=N.useState(null),[o,l]=N.useState(!1);N.useEffect(()=>{const u=sessionStorage.getItem(Pb);if(u)try{const p=JSON.parse(u);r(!0),a(p)}catch{sessionStorage.removeItem(Pb)}},[]);const i=async(u,p)=>{l(!0);try{const{data:{session:f}}=await H.auth.getSession();if(!f)return me.error("No active session found"),!1;const g={access_token:f.access_token,refresh_token:f.refresh_token};sessionStorage.setItem(R2,JSON.stringify(g)),p&&sessionStorage.setItem(fxe,p);const b=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/impersonate-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.access_token}`},body:JSON.stringify({targetUserId:u})}),_=await b.json();if(!b.ok)throw new Error(_.error||"Failed to impersonate user");const j={id:_.targetUser.id,name:_.targetUser.name,email:_.targetUser.email};if(sessionStorage.setItem(Pb,JSON.stringify(j)),_.method==="session"){const{error:w}=await H.auth.setSession({access_token:_.access_token,refresh_token:_.refresh_token});if(w)throw console.error("Set session error:",w),sessionStorage.removeItem(R2),sessionStorage.removeItem(Pb),new Error("Failed to establish impersonation session")}else{const w=_.type||"recovery",{error:k}=await H.auth.verifyOtp({token_hash:_.token_hash,type:w});if(k)throw console.error("Verify OTP error:",k),sessionStorage.removeItem(R2),sessionStorage.removeItem(Pb),new Error("Failed to establish impersonation session")}return r(!0),a(j),me.success(`Now viewing as ${j.name}`),window.location.href="/dashboard",!0}catch(f){return console.error("Impersonation error:",f),me.error(f.message||"Failed to impersonate user"),sessionStorage.removeItem(R2),sessionStorage.removeItem(Pb),!1}finally{l(!1)}},c=async()=>{l(!0);try{const u=sessionStorage.getItem(R2);if(!u){await H.auth.signOut(),window.location.href="/auth";return}const p=JSON.parse(u);await H.auth.signOut();const{error:f}=await H.auth.setSession({access_token:p.access_token,refresh_token:p.refresh_token});if(sessionStorage.removeItem(R2),sessionStorage.removeItem(Pb),f){console.error("Failed to restore admin session:",f),me.error("Admin session expired, please sign in again"),window.location.href="/auth";return}r(!1),a(null),me.success("Returned to your account");const g=sessionStorage.getItem(fxe)||"/admin/members";sessionStorage.removeItem(fxe),window.location.href=g}catch(u){console.error("Stop impersonation error:",u),me.error("Failed to restore admin session"),sessionStorage.removeItem(R2),sessionStorage.removeItem(Pb),window.location.href="/auth"}finally{l(!1)}};return e.jsx(AVe.Provider,{value:{isImpersonating:s,impersonatedUser:n,startImpersonation:i,stopImpersonation:c,isLoading:o},children:t})},Pde=()=>{const t=N.useContext(AVe);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},K8=mC("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-full px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),K=N.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?u2e:"button";return e.jsx(l,{className:It(K8({variant:s,size:r,className:t})),ref:o,...a})});K.displayName="Button";const _wt=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=Pde();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(Ku,{className:"h-5 w-5 flex-shrink-0"}),e.jsxs("span",{className:"font-medium text-sm md:text-base",children:[e.jsx("span",{className:"hidden sm:inline",children:"You are viewing as "}),e.jsx("strong",{children:s.name}),e.jsxs("span",{className:"hidden md:inline text-amber-800",children:[" (",s.email,")"]})]})]}),e.jsx(K,{size:"sm",variant:"secondary",onClick:r,disabled:n,className:"bg-amber-100 hover:bg-amber-200 text-amber-950 border-0",children:n?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Rr,{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"})]})})]})})},EVe=N.createContext(void 0),x5="levelup_acting_as",Z7="levelup_acting_as_self",wwt=({children:t})=>{const{user:s}=Ds(),[r,n]=N.useState(!1),[a,o]=N.useState([]),[l,i]=N.useState(null),[c,u]=N.useState({}),[p,f]=N.useState(!0),[g,b]=N.useState(()=>sessionStorage.getItem(Z7)==="true");N.useEffect(()=>{if(!(s!=null&&s.id)){n(!1),o([]),i(null),u({}),f(!1);return}(async()=>{f(!0);try{const{data:M}=await H.rpc("has_role",{_user_id:s.id,_role:"assistant"});if(!M){n(!1),o([]),i(null),u({}),f(!1);return}n(!0);const{data:L,error:I}=await H.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",s.id);if(I||!L||L.length===0){o([]),f(!1);return}const O=L.map(B=>B.agent_id),{data:q}=await H.from("profiles").select("id, name, email, avatar_url").in("id",O),U=(q||[]).map(B=>({id:B.id,name:B.name||B.email||"Unknown",email:B.email||"",avatar_url:B.avatar_url}));if(o(U),sessionStorage.getItem(Z7)==="true")b(!0),i(null),u({});else{const B=sessionStorage.getItem(x5);if(B){const V=U.find(Z=>Z.id===B);if(V){i(V);const Z=L.find(X=>X.agent_id===B);u((Z==null?void 0:Z.permissions)||{})}else if(U.length>0){i(U[0]);const Z=L.find(X=>X.agent_id===U[0].id);u((Z==null?void 0:Z.permissions)||{}),sessionStorage.setItem(x5,U[0].id)}}else if(U.length>0){i(U[0]);const V=L.find(Z=>Z.agent_id===U[0].id);u((V==null?void 0:V.permissions)||{}),sessionStorage.setItem(x5,U[0].id)}}}catch(M){console.error("Error loading assistant data:",M)}finally{f(!1)}})()},[s==null?void 0:s.id]);const _=S=>{i(S),b(!1),sessionStorage.removeItem(Z7),S?(sessionStorage.setItem(x5,S.id),H.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(s==null?void 0:s.id)||"").eq("agent_id",S.id).single().then(({data:M})=>{u((M==null?void 0:M.permissions)||{})})):(sessionStorage.removeItem(x5),u({}))},j=()=>{b(!0),i(null),u({}),sessionStorage.setItem(Z7,"true"),sessionStorage.removeItem(x5)},w=S=>!r||g?!0:c[S]===!0,k=r&&l&&!g?l.id:(s==null?void 0:s.id)||null;return e.jsx(EVe.Provider,{value:{isAssistant:r,assignedAgents:a,actingAsAgent:l,setActingAsAgent:_,effectiveUserId:k,permissions:c,hasPermission:w,isLoading:p,isActingAsSelf:g,setActingAsSelf:j},children:t})},K2e=()=>{const t=N.useContext(EVe);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},ci=()=>{const{effectiveUserId:t}=K2e();return t};var PVe={exports:{}},IVe={};/** * @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 LT=N;function jwt(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Nwt=typeof Object.is=="function"?Object.is:jwt,kwt=LT.useState,Swt=LT.useEffect,Cwt=LT.useLayoutEffect,Mwt=LT.useDebugValue;function Twt(t,s){var r=s(),n=kwt({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return Cwt(function(){a.value=r,a.getSnapshot=s,xxe(a)&&o({inst:a})},[t,r,s]),Swt(function(){return xxe(a)&&o({inst:a}),t(function(){xxe(a)&&o({inst:a})})},[t]),Mwt(r),r}function xxe(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!Nwt(t,r)}catch{return!0}}function Awt(t,s){return s()}var Ewt=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Awt:Twt;IVe.useSyncExternalStore=LT.useSyncExternalStore!==void 0?LT.useSyncExternalStore:Ewt;PVe.exports=IVe;var Pwt=PVe.exports;function Iwt(){return Pwt.useSyncExternalStore(Lwt,()=>!0,()=>!1)}function Lwt(){return()=>{}}var Z2e="Avatar",[Dwt]=ad(Z2e),[Owt,LVe]=Dwt(Z2e),DVe=N.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=N.useState("idle");return e.jsx(Owt,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(nn.span,{...n,ref:s})})});DVe.displayName=Z2e;var OVe="AvatarImage",RVe=N.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=LVe(OVe,r),i=Rwt(n,o),c=yd(u=>{a(u),l.onImageLoadingStatusChange(u)});return wd(()=>{i!=="idle"&&c(i)},[i,c]),i==="loaded"?e.jsx(nn.img,{...o,ref:s,src:n}):null});RVe.displayName=OVe;var FVe="AvatarFallback",zVe=N.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=LVe(FVe,r),[l,i]=N.useState(n===void 0);return N.useEffect(()=>{if(n!==void 0){const c=window.setTimeout(()=>i(!0),n);return()=>window.clearTimeout(c)}},[n]),l&&o.imageLoadingStatus!=="loaded"?e.jsx(nn.span,{...a,ref:s}):null});zVe.displayName=FVe;function BEe(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Rwt(t,{referrerPolicy:s,crossOrigin:r}){const n=Iwt(),a=N.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=N.useState(()=>BEe(o,t));return wd(()=>{i(BEe(o,t))},[o,t]),wd(()=>{const c=f=>()=>{i(f)};if(!o)return;const u=c("loaded"),p=c("error");return o.addEventListener("load",u),o.addEventListener("error",p),s&&(o.referrerPolicy=s),typeof r=="string"&&(o.crossOrigin=r),()=>{o.removeEventListener("load",u),o.removeEventListener("error",p)}},[o,r,s]),l}var BVe=DVe,$Ve=RVe,qVe=zVe;const Nn=N.forwardRef(({className:t,...s},r)=>e.jsx(BVe,{ref:r,className:It("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));Nn.displayName=BVe.displayName;const $a=N.forwardRef(({className:t,...s},r)=>e.jsx($Ve,{ref:r,className:It("aspect-square h-full w-full",t),...s}));$a.displayName=$Ve.displayName;const kn=N.forwardRef(({className:t,...s},r)=>e.jsx(qVe,{ref:r,className:It("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));kn.displayName=qVe.displayName;const Fwt=mC("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function tt({className:t,variant:s,...r}){return e.jsx("div",{className:It(Fwt({variant:s}),t),...r})}var zwt=N.createContext(void 0);function Mw(t){const s=N.useContext(zwt);return t||s||"ltr"}var gxe=0;function Ide(){N.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??$Ee()),document.body.insertAdjacentElement("beforeend",t[1]??$Ee()),gxe++,()=>{gxe===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),gxe--}},[])}function $Ee(){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 yxe="focusScope.autoFocusOnMount",vxe="focusScope.autoFocusOnUnmount",qEe={bubbles:!1,cancelable:!0},Bwt="FocusScope",jO=N.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,c]=N.useState(null),u=yd(a),p=yd(o),f=N.useRef(null),g=qa(s,j=>c(j)),b=N.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;N.useEffect(()=>{if(n){let j=function(M){if(b.paused||!i)return;const L=M.target;i.contains(L)?f.current=L:zb(f.current,{select:!0})},w=function(M){if(b.paused||!i)return;const L=M.relatedTarget;L!==null&&(i.contains(L)||zb(f.current,{select:!0}))},k=function(M){if(document.activeElement===document.body)for(const I of M)I.removedNodes.length>0&&zb(i)};document.addEventListener("focusin",j),document.addEventListener("focusout",w);const S=new MutationObserver(k);return i&&S.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",w),S.disconnect()}}},[n,i,b.paused]),N.useEffect(()=>{if(i){VEe.add(b);const j=document.activeElement;if(!i.contains(j)){const k=new CustomEvent(yxe,qEe);i.addEventListener(yxe,u),i.dispatchEvent(k),k.defaultPrevented||($wt(Wwt(UVe(i)),{select:!0}),document.activeElement===j&&zb(i))}return()=>{i.removeEventListener(yxe,u),setTimeout(()=>{const k=new CustomEvent(vxe,qEe);i.addEventListener(vxe,p),i.dispatchEvent(k),k.defaultPrevented||zb(j??document.body,{select:!0}),i.removeEventListener(vxe,p),VEe.remove(b)},0)}}},[i,u,p,b]);const _=N.useCallback(j=>{if(!r&&!n||b.paused)return;const w=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,k=document.activeElement;if(w&&k){const S=j.currentTarget,[M,L]=qwt(S);M&&L?!j.shiftKey&&k===L?(j.preventDefault(),r&&zb(M,{select:!0})):j.shiftKey&&k===M&&(j.preventDefault(),r&&zb(L,{select:!0})):k===S&&j.preventDefault()}},[r,n,b.paused]);return e.jsx(nn.div,{tabIndex:-1,...l,ref:g,onKeyDown:_})});jO.displayName=Bwt;function $wt(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(zb(n,{select:s}),document.activeElement!==r)return}function qwt(t){const s=UVe(t),r=UEe(s,t),n=UEe(s.reverse(),t);return[r,n]}function UVe(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 UEe(t,s){for(const r of t)if(!Uwt(r,{upTo:s}))return r}function Uwt(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 Vwt(t){return t instanceof HTMLInputElement&&"select"in t}function zb(t,{select:s=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&Vwt(t)&&s&&t.select()}}var VEe=Hwt();function Hwt(){let t=[];return{add(s){const r=t[0];s!==r&&(r==null||r.pause()),t=HEe(t,s),t.unshift(s)},remove(s){var r;t=HEe(t,s),(r=t[0])==null||r.resume()}}}function HEe(t,s){const r=[...t],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function Wwt(t){return t.filter(s=>s.tagName!=="A")}var bxe="rovingFocusGroup.onEntryFocus",Gwt={bubbles:!1,cancelable:!0},NO="RovingFocusGroup",[wve,VVe,Kwt]=fO(NO),[Zwt,Tw]=ad(NO,[Kwt]),[Ywt,Xwt]=Zwt(NO),HVe=N.forwardRef((t,s)=>e.jsx(wve.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(wve.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Qwt,{...t,ref:s})})}));HVe.displayName=NO;var Qwt=N.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...f}=t,g=N.useRef(null),b=qa(s,g),_=Mw(o),[j,w]=ah({prop:l,defaultProp:i??null,onChange:c,caller:NO}),[k,S]=N.useState(!1),M=yd(u),L=VVe(r),I=N.useRef(!1),[O,q]=N.useState(0);return N.useEffect(()=>{const U=g.current;if(U)return U.addEventListener(bxe,M),()=>U.removeEventListener(bxe,M)},[M]),e.jsx(Ywt,{scope:r,orientation:n,dir:_,loop:a,currentTabStopId:j,onItemFocus:N.useCallback(U=>w(U),[w]),onItemShiftTab:N.useCallback(()=>S(!0),[]),onFocusableItemAdd:N.useCallback(()=>q(U=>U+1),[]),onFocusableItemRemove:N.useCallback(()=>q(U=>U-1),[]),children:e.jsx(nn.div,{tabIndex:k||O===0?-1:0,"data-orientation":n,...f,ref:b,style:{outline:"none",...t.style},onMouseDown:Ir(t.onMouseDown,()=>{I.current=!0}),onFocus:Ir(t.onFocus,U=>{const B=!I.current;if(U.target===U.currentTarget&&B&&!k){const V=new CustomEvent(bxe,Gwt);if(U.currentTarget.dispatchEvent(V),!V.defaultPrevented){const Z=L().filter(re=>re.focusable),X=Z.find(re=>re.active),ee=Z.find(re=>re.id===j),ie=[X,ee,...Z].filter(Boolean).map(re=>re.ref.current);KVe(ie,p)}}I.current=!1}),onBlur:Ir(t.onBlur,()=>S(!1))})})}),WVe="RovingFocusGroupItem",GVe=N.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,c=Tu(),u=o||c,p=Xwt(WVe,r),f=p.currentTabStopId===u,g=VVe(r),{onFocusableItemAdd:b,onFocusableItemRemove:_,currentTabStopId:j}=p;return N.useEffect(()=>{if(n)return b(),()=>_()},[n,b,_]),e.jsx(wve.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:e.jsx(nn.span,{tabIndex:f?0:-1,"data-orientation":p.orientation,...i,ref:s,onMouseDown:Ir(t.onMouseDown,w=>{n?p.onItemFocus(u):w.preventDefault()}),onFocus:Ir(t.onFocus,()=>p.onItemFocus(u)),onKeyDown:Ir(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const k=t2t(w,p.orientation,p.dir);if(k!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let M=g().filter(L=>L.focusable).map(L=>L.ref.current);if(k==="last")M.reverse();else if(k==="prev"||k==="next"){k==="prev"&&M.reverse();const L=M.indexOf(w.currentTarget);M=p.loop?s2t(M,L+1):M.slice(L+1)}setTimeout(()=>KVe(M))}}),children:typeof l=="function"?l({isCurrentTabStop:f,hasTabStop:j!=null}):l})})});GVe.displayName=WVe;var Jwt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function e2t(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function t2t(t,s,r){const n=e2t(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return Jwt[n]}function KVe(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function s2t(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var Lde=HVe,Dde=GVe,r2t=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},g5=new WeakMap,Y7=new WeakMap,X7={},_xe=0,ZVe=function(t){return t&&(t.host||ZVe(t.parentNode))},n2t=function(t,s){return s.map(function(r){if(t.contains(r))return r;var n=ZVe(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})},a2t=function(t,s,r,n){var a=n2t(s,Array.isArray(t)?t:[t]);X7[r]||(X7[r]=new WeakMap);var o=X7[r],l=[],i=new Set,c=new Set(a),u=function(f){!f||i.has(f)||(i.add(f),u(f.parentNode))};a.forEach(u);var p=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(g){if(i.has(g))p(g);else try{var b=g.getAttribute(n),_=b!==null&&b!=="false",j=(g5.get(g)||0)+1,w=(o.get(g)||0)+1;g5.set(g,j),o.set(g,w),l.push(g),j===1&&_&&Y7.set(g,!0),w===1&&g.setAttribute(r,"true"),_||g.setAttribute(n,"true")}catch(k){console.error("aria-hidden: cannot operate on ",g,k)}})};return p(s),i.clear(),_xe++,function(){l.forEach(function(f){var g=g5.get(f)-1,b=o.get(f)-1;g5.set(f,g),o.set(f,b),g||(Y7.has(f)||f.removeAttribute(n),Y7.delete(f)),b||f.removeAttribute(r)}),_xe--,_xe||(g5=new WeakMap,g5=new WeakMap,Y7=new WeakMap,X7={})}},Ode=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=r2t(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),a2t(n,a,r,"aria-hidden")):function(){return null}},cie="right-scroll-bar-position",die="width-before-scroll-bar",i2t="with-scroll-bars-hidden",o2t="--removed-body-scroll-bar-size";function wxe(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function l2t(t,s){var r=N.useState(function(){return{value:t,callback:s,facade:{get current(){return r.value},set current(n){var a=r.value;a!==n&&(r.value=n,r.callback(n,a))}}}})[0];return r.callback=s,r.facade}var c2t=typeof window<"u"?N.useLayoutEffect:N.useEffect,WEe=new WeakMap;function d2t(t,s){var r=l2t(null,function(n){return t.forEach(function(a){return wxe(a,n)})});return c2t(function(){var n=WEe.get(r);if(n){var a=new Set(n),o=new Set(t),l=r.current;a.forEach(function(i){o.has(i)||wxe(i,null)}),o.forEach(function(i){a.has(i)||wxe(i,l)})}WEe.set(r,t)},[t]),r}function u2t(t){return t}function h2t(t,s){s===void 0&&(s=u2t);var r=[],n=!1,a={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:t},useMedium:function(o){var l=s(o,n);return r.push(l),function(){r=r.filter(function(i){return i!==l})}},assignSyncMedium:function(o){for(n=!0;r.length;){var l=r;r=[],l.forEach(o)}r={push:function(i){return o(i)},filter:function(){return r}}},assignMedium:function(o){n=!0;var l=[];if(r.length){var i=r;r=[],i.forEach(o),l=r}var c=function(){var p=l;l=[],p.forEach(o)},u=function(){return Promise.resolve().then(c)};u(),r={push:function(p){l.push(p),u()},filter:function(p){return l=l.filter(p),r}}}};return a}function m2t(t){t===void 0&&(t={});var s=h2t(null);return s.options=fx({async:!0,ssr:!1},t),s}var YVe=function(t){var s=t.sideCar,r=Sw(t,["sideCar"]);if(!s)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=s.read();if(!n)throw new Error("Sidecar medium not found");return N.createElement(n,fx({},r))};YVe.isSideCarExport=!0;function p2t(t,s){return t.useMedium(s),YVe}var XVe=m2t(),jxe=function(){},Rde=N.forwardRef(function(t,s){var r=N.useRef(null),n=N.useState({onScrollCapture:jxe,onWheelCapture:jxe,onTouchMoveCapture:jxe}),a=n[0],o=n[1],l=t.forwardProps,i=t.children,c=t.className,u=t.removeScrollBar,p=t.enabled,f=t.shards,g=t.sideCar,b=t.noRelative,_=t.noIsolation,j=t.inert,w=t.allowPinchZoom,k=t.as,S=k===void 0?"div":k,M=t.gapMode,L=Sw(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),I=g,O=d2t([r,s]),q=fx(fx({},L),a);return N.createElement(N.Fragment,null,p&&N.createElement(I,{sideCar:XVe,removeScrollBar:u,shards:f,noRelative:b,noIsolation:_,inert:j,setCallbacks:o,allowPinchZoom:!!w,lockRef:r,gapMode:M}),l?N.cloneElement(N.Children.only(i),fx(fx({},q),{ref:O})):N.createElement(S,fx({},q,{className:c,ref:O}),i))});Rde.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Rde.classNames={fullWidth:die,zeroRight:cie};var f2t=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function x2t(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=f2t();return s&&t.setAttribute("nonce",s),t}function g2t(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function y2t(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var v2t=function(){var t=0,s=null;return{add:function(r){t==0&&(s=x2t())&&(g2t(s,r),y2t(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},b2t=function(){var t=v2t();return function(s,r){N.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&r])}},QVe=function(){var t=b2t(),s=function(r){var n=r.styles,a=r.dynamic;return t(n,a),null};return s},_2t={left:0,top:0,right:0,gap:0},Nxe=function(t){return parseInt(t||"",10)||0},w2t=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[Nxe(r),Nxe(n),Nxe(a)]},j2t=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return _2t;var s=w2t(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])}},N2t=QVe(),YM="data-scroll-locked",k2t=function(t,s,r,n){var a=t.left,o=t.top,l=t.right,i=t.gap;return r===void 0&&(r="margin"),` .`.concat(i2t,` { overflow: hidden `).concat(n,`; padding-right: `).concat(i,"px ").concat(n,`; } body[`).concat(YM,`] { 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(cie,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(die,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(cie," .").concat(cie,` { right: 0 `).concat(n,`; } .`).concat(die," .").concat(die,` { margin-right: 0 `).concat(n,`; } body[`).concat(YM,`] { `).concat(o2t,": ").concat(i,`px; } `)},GEe=function(){var t=parseInt(document.body.getAttribute(YM)||"0",10);return isFinite(t)?t:0},S2t=function(){N.useEffect(function(){return document.body.setAttribute(YM,(GEe()+1).toString()),function(){var t=GEe()-1;t<=0?document.body.removeAttribute(YM):document.body.setAttribute(YM,t.toString())}},[])},C2t=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;S2t();var o=N.useMemo(function(){return j2t(a)},[a]);return N.createElement(N2t,{styles:k2t(o,!s,a,r?"":"!important")})},jve=!1;if(typeof window<"u")try{var Q7=Object.defineProperty({},"passive",{get:function(){return jve=!0,!0}});window.addEventListener("test",Q7,Q7),window.removeEventListener("test",Q7,Q7)}catch{jve=!1}var y5=jve?{passive:!1}:!1,M2t=function(t){return t.tagName==="TEXTAREA"},JVe=function(t,s){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!M2t(t)&&r[s]==="visible")},T2t=function(t){return JVe(t,"overflowY")},A2t=function(t){return JVe(t,"overflowX")},KEe=function(t,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=eHe(t,n);if(a){var o=tHe(t,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},E2t=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},P2t=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},eHe=function(t,s){return t==="v"?T2t(s):A2t(s)},tHe=function(t,s){return t==="v"?E2t(s):P2t(s)},I2t=function(t,s){return t==="h"&&s==="rtl"?-1:1},L2t=function(t,s,r,n,a){var o=I2t(t,window.getComputedStyle(s).direction),l=o*n,i=r.target,c=s.contains(i),u=!1,p=l>0,f=0,g=0;do{if(!i)break;var b=tHe(t,i),_=b[0],j=b[1],w=b[2],k=j-w-o*_;(_||k)&&eHe(t,i)&&(f+=k,g+=_);var S=i.parentNode;i=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!c&&i!==document.body||c&&(s.contains(i)||s===i));return(p&&Math.abs(f)<1||!p&&Math.abs(g)<1)&&(u=!0),u},J7=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},ZEe=function(t){return[t.deltaX,t.deltaY]},YEe=function(t){return t&&"current"in t?t.current:t},D2t=function(t,s){return t[0]===s[0]&&t[1]===s[1]},O2t=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},R2t=0,v5=[];function F2t(t){var s=N.useRef([]),r=N.useRef([0,0]),n=N.useRef(),a=N.useState(R2t++)[0],o=N.useState(QVe)[0],l=N.useRef(t);N.useEffect(function(){l.current=t},[t]),N.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var j=z2e([t.lockRef.current],(t.shards||[]).map(YEe),!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=N.useCallback(function(j,w){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!l.current.allowPinchZoom;var k=J7(j),S=r.current,M="deltaX"in j?j.deltaX:S[0]-k[0],L="deltaY"in j?j.deltaY:S[1]-k[1],I,O=j.target,q=Math.abs(M)>Math.abs(L)?"h":"v";if("touches"in j&&q==="h"&&O.type==="range")return!1;var U=KEe(q,O);if(!U)return!0;if(U?I=q:(I=q==="v"?"h":"v",U=KEe(q,O)),!U)return!1;if(!n.current&&"changedTouches"in j&&(M||L)&&(n.current=I),!I)return!0;var B=n.current||I;return L2t(B,w,j,B==="h"?M:L)},[]),c=N.useCallback(function(j){var w=j;if(!(!v5.length||v5[v5.length-1]!==o)){var k="deltaY"in w?ZEe(w):J7(w),S=s.current.filter(function(I){return I.name===w.type&&(I.target===w.target||w.target===I.shadowParent)&&D2t(I.delta,k)})[0];if(S&&S.should){w.cancelable&&w.preventDefault();return}if(!S){var M=(l.current.shards||[]).map(YEe).filter(Boolean).filter(function(I){return I.contains(w.target)}),L=M.length>0?i(w,M[0]):!l.current.noIsolation;L&&w.cancelable&&w.preventDefault()}}},[]),u=N.useCallback(function(j,w,k,S){var M={name:j,delta:w,target:k,should:S,shadowParent:z2t(k)};s.current.push(M),setTimeout(function(){s.current=s.current.filter(function(L){return L!==M})},1)},[]),p=N.useCallback(function(j){r.current=J7(j),n.current=void 0},[]),f=N.useCallback(function(j){u(j.type,ZEe(j),j.target,i(j,t.lockRef.current))},[]),g=N.useCallback(function(j){u(j.type,J7(j),j.target,i(j,t.lockRef.current))},[]);N.useEffect(function(){return v5.push(o),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:g}),document.addEventListener("wheel",c,y5),document.addEventListener("touchmove",c,y5),document.addEventListener("touchstart",p,y5),function(){v5=v5.filter(function(j){return j!==o}),document.removeEventListener("wheel",c,y5),document.removeEventListener("touchmove",c,y5),document.removeEventListener("touchstart",p,y5)}},[]);var b=t.removeScrollBar,_=t.inert;return N.createElement(N.Fragment,null,_?N.createElement(o,{styles:O2t(a)}):null,b?N.createElement(C2t,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function z2t(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const B2t=p2t(XVe,F2t);var kO=N.forwardRef(function(t,s){return N.createElement(Rde,fx({},t,{ref:s,sideCar:B2t}))});kO.classNames=Rde.classNames;var Nve=["Enter"," "],$2t=["ArrowDown","PageUp","Home"],sHe=["ArrowUp","PageDown","End"],q2t=[...$2t,...sHe],U2t={ltr:[...Nve,"ArrowRight"],rtl:[...Nve,"ArrowLeft"]},V2t={ltr:["ArrowLeft"],rtl:["ArrowRight"]},SO="Menu",[Z8,H2t,W2t]=fO(SO),[fC,rHe]=ad(SO,[W2t,O0,Tw]),Fde=O0(),nHe=Tw(),[G2t,xC]=fC(SO),[K2t,CO]=fC(SO),aHe=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=Fde(s),[c,u]=N.useState(null),p=N.useRef(!1),f=yd(o),g=Mw(a);return N.useEffect(()=>{const b=()=>{p.current=!0,document.addEventListener("pointerdown",_,{capture:!0,once:!0}),document.addEventListener("pointermove",_,{capture:!0,once:!0})},_=()=>p.current=!1;return document.addEventListener("keydown",b,{capture:!0}),()=>{document.removeEventListener("keydown",b,{capture:!0}),document.removeEventListener("pointerdown",_,{capture:!0}),document.removeEventListener("pointermove",_,{capture:!0})}},[]),e.jsx(vO,{...i,children:e.jsx(G2t,{scope:s,open:r,onOpenChange:f,content:c,onContentChange:u,children:e.jsx(K2t,{scope:s,onClose:N.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:p,dir:g,modal:l,children:n})})})};aHe.displayName=SO;var Z2t="MenuAnchor",Y2e=N.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=Fde(r);return e.jsx($A,{...a,...n,ref:s})});Y2e.displayName=Z2t;var X2e="MenuPortal",[Y2t,iHe]=fC(X2e,{forceMount:void 0}),oHe=t=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=t,o=xC(X2e,s);return e.jsx(Y2t,{scope:s,forceMount:r,children:e.jsx(Fd,{present:r||o.open,children:e.jsx(RA,{asChild:!0,container:a,children:n})})})};oHe.displayName=X2e;var Mx="MenuContent",[X2t,Q2e]=fC(Mx),lHe=N.forwardRef((t,s)=>{const r=iHe(Mx,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=xC(Mx,t.__scopeMenu),l=CO(Mx,t.__scopeMenu);return e.jsx(Z8.Provider,{scope:t.__scopeMenu,children:e.jsx(Fd,{present:n||o.open,children:e.jsx(Z8.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(Q2t,{...a,ref:s}):e.jsx(J2t,{...a,ref:s})})})})}),Q2t=N.forwardRef((t,s)=>{const r=xC(Mx,t.__scopeMenu),n=N.useRef(null),a=qa(s,n);return N.useEffect(()=>{const o=n.current;if(o)return Ode(o)},[]),e.jsx(J2e,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Ir(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),J2t=N.forwardRef((t,s)=>{const r=xC(Mx,t.__scopeMenu);return e.jsx(J2e,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),ejt=ow("MenuContent.ScrollLock"),J2e=N.forwardRef((t,s)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:i,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:g,onDismiss:b,disableOutsideScroll:_,...j}=t,w=xC(Mx,r),k=CO(Mx,r),S=Fde(r),M=nHe(r),L=H2t(r),[I,O]=N.useState(null),q=N.useRef(null),U=qa(s,q,w.onContentChange),B=N.useRef(0),V=N.useRef(""),Z=N.useRef(0),X=N.useRef(null),ee=N.useRef("right"),Q=N.useRef(0),ie=_?kO:N.Fragment,re=_?{as:ejt,allowPinchZoom:!0}:void 0,oe=xe=>{var Oe,Te;const ge=V.current+xe,ue=L().filter(ke=>!ke.disabled),pe=document.activeElement,be=(Oe=ue.find(ke=>ke.ref.current===pe))==null?void 0:Oe.textValue,Me=ue.map(ke=>ke.textValue),Ne=hjt(Me,ge,be),Pe=(Te=ue.find(ke=>ke.textValue===Ne))==null?void 0:Te.ref.current;(function ke(Be){V.current=Be,window.clearTimeout(B.current),Be!==""&&(B.current=window.setTimeout(()=>ke(""),1e3))})(ge),Pe&&setTimeout(()=>Pe.focus())};N.useEffect(()=>()=>window.clearTimeout(B.current),[]),Ide();const ce=N.useCallback(xe=>{var ue,pe;return ee.current===((ue=X.current)==null?void 0:ue.side)&&pjt(xe,(pe=X.current)==null?void 0:pe.area)},[]);return e.jsx(X2t,{scope:r,searchRef:V,onItemEnter:N.useCallback(xe=>{ce(xe)&&xe.preventDefault()},[ce]),onItemLeave:N.useCallback(xe=>{var ge;ce(xe)||((ge=q.current)==null||ge.focus(),O(null))},[ce]),onTriggerLeave:N.useCallback(xe=>{ce(xe)&&xe.preventDefault()},[ce]),pointerGraceTimerRef:Z,onPointerGraceIntentChange:N.useCallback(xe=>{X.current=xe},[]),children:e.jsx(ie,{...re,children:e.jsx(jO,{asChild:!0,trapped:a,onMountAutoFocus:Ir(o,xe=>{var ge;xe.preventDefault(),(ge=q.current)==null||ge.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(Nw,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:g,onDismiss:b,children:e.jsx(Lde,{asChild:!0,...M,dir:k.dir,orientation:"vertical",loop:n,currentTabStopId:I,onCurrentTabStopIdChange:O,onEntryFocus:Ir(c,xe=>{k.isUsingKeyboardRef.current||xe.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(bO,{role:"menu","aria-orientation":"vertical","data-state":NHe(w.open),"data-radix-menu-content":"",dir:k.dir,...S,...j,ref:U,style:{outline:"none",...j.style},onKeyDown:Ir(j.onKeyDown,xe=>{const ue=xe.target.closest("[data-radix-menu-content]")===xe.currentTarget,pe=xe.ctrlKey||xe.altKey||xe.metaKey,be=xe.key.length===1;ue&&(xe.key==="Tab"&&xe.preventDefault(),!pe&&be&&oe(xe.key));const Me=q.current;if(xe.target!==Me||!q2t.includes(xe.key))return;xe.preventDefault();const Pe=L().filter(Oe=>!Oe.disabled).map(Oe=>Oe.ref.current);sHe.includes(xe.key)&&Pe.reverse(),djt(Pe)}),onBlur:Ir(t.onBlur,xe=>{xe.currentTarget.contains(xe.target)||(window.clearTimeout(B.current),V.current="")}),onPointerMove:Ir(t.onPointerMove,Y8(xe=>{const ge=xe.target,ue=Q.current!==xe.clientX;if(xe.currentTarget.contains(ge)&&ue){const pe=xe.clientX>Q.current?"right":"left";ee.current=pe,Q.current=xe.clientX}}))})})})})})})});lHe.displayName=Mx;var tjt="MenuGroup",eje=N.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(nn.div,{role:"group",...n,ref:s})});eje.displayName=tjt;var sjt="MenuLabel",cHe=N.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(nn.div,{...n,ref:s})});cHe.displayName=sjt;var yoe="MenuItem",XEe="menu.itemSelect",zde=N.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=N.useRef(null),l=CO(yoe,t.__scopeMenu),i=Q2e(yoe,t.__scopeMenu),c=qa(s,o),u=N.useRef(!1),p=()=>{const f=o.current;if(!r&&f){const g=new CustomEvent(XEe,{bubbles:!0,cancelable:!0});f.addEventListener(XEe,b=>n==null?void 0:n(b),{once:!0}),h2e(f,g),g.defaultPrevented?u.current=!1:l.onClose()}};return e.jsx(dHe,{...a,ref:c,disabled:r,onClick:Ir(t.onClick,p),onPointerDown:f=>{var g;(g=t.onPointerDown)==null||g.call(t,f),u.current=!0},onPointerUp:Ir(t.onPointerUp,f=>{var g;u.current||(g=f.currentTarget)==null||g.click()}),onKeyDown:Ir(t.onKeyDown,f=>{const g=i.searchRef.current!=="";r||g&&f.key===" "||Nve.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});zde.displayName=yoe;var dHe=N.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=Q2e(yoe,r),i=nHe(r),c=N.useRef(null),u=qa(s,c),[p,f]=N.useState(!1),[g,b]=N.useState("");return N.useEffect(()=>{const _=c.current;_&&b((_.textContent??"").trim())},[o.children]),e.jsx(Z8.ItemSlot,{scope:r,disabled:n,textValue:a??g,children:e.jsx(Dde,{asChild:!0,...i,focusable:!n,children:e.jsx(nn.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:u,onPointerMove:Ir(t.onPointerMove,Y8(_=>{n?l.onItemLeave(_):(l.onItemEnter(_),_.defaultPrevented||_.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ir(t.onPointerLeave,Y8(_=>l.onItemLeave(_))),onFocus:Ir(t.onFocus,()=>f(!0)),onBlur:Ir(t.onBlur,()=>f(!1))})})})}),rjt="MenuCheckboxItem",uHe=N.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(xHe,{scope:t.__scopeMenu,checked:r,children:e.jsx(zde,{role:"menuitemcheckbox","aria-checked":voe(r)?"mixed":r,...a,ref:s,"data-state":sje(r),onSelect:Ir(a.onSelect,()=>n==null?void 0:n(voe(r)?!0:!r),{checkForDefaultPrevented:!1})})})});uHe.displayName=rjt;var hHe="MenuRadioGroup",[njt,ajt]=fC(hHe,{value:void 0,onValueChange:()=>{}}),mHe=N.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=yd(n);return e.jsx(njt,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(eje,{...a,ref:s})})});mHe.displayName=hHe;var pHe="MenuRadioItem",fHe=N.forwardRef((t,s)=>{const{value:r,...n}=t,a=ajt(pHe,t.__scopeMenu),o=r===a.value;return e.jsx(xHe,{scope:t.__scopeMenu,checked:o,children:e.jsx(zde,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":sje(o),onSelect:Ir(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});fHe.displayName=pHe;var tje="MenuItemIndicator",[xHe,ijt]=fC(tje,{checked:!1}),gHe=N.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=ijt(tje,r);return e.jsx(Fd,{present:n||voe(o.checked)||o.checked===!0,children:e.jsx(nn.span,{...a,ref:s,"data-state":sje(o.checked)})})});gHe.displayName=tje;var ojt="MenuSeparator",yHe=N.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(nn.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});yHe.displayName=ojt;var ljt="MenuArrow",vHe=N.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=Fde(r);return e.jsx(_O,{...a,...n,ref:s})});vHe.displayName=ljt;var cjt="MenuSub",[PMs,bHe]=fC(cjt),vI="MenuSubTrigger",_He=N.forwardRef((t,s)=>{const r=xC(vI,t.__scopeMenu),n=CO(vI,t.__scopeMenu),a=bHe(vI,t.__scopeMenu),o=Q2e(vI,t.__scopeMenu),l=N.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:c}=o,u={__scopeMenu:t.__scopeMenu},p=N.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return N.useEffect(()=>p,[p]),N.useEffect(()=>{const f=i.current;return()=>{window.clearTimeout(f),c(null)}},[i,c]),e.jsx(Y2e,{asChild:!0,...u,children:e.jsx(dHe,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":NHe(r.open),...t,ref:S1(s,a.onTriggerChange),onClick:f=>{var g;(g=t.onClick)==null||g.call(t,f),!(t.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Ir(t.onPointerMove,Y8(f=>{o.onItemEnter(f),!f.defaultPrevented&&!t.disabled&&!r.open&&!l.current&&(o.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),p()},100))})),onPointerLeave:Ir(t.onPointerLeave,Y8(f=>{var b,_;p();const g=(b=r.content)==null?void 0:b.getBoundingClientRect();if(g){const j=(_=r.content)==null?void 0:_.dataset.side,w=j==="right",k=w?-5:5,S=g[w?"left":"right"],M=g[w?"right":"left"];o.onPointerGraceIntentChange({area:[{x:f.clientX+k,y:f.clientY},{x:S,y:g.top},{x:M,y:g.top},{x:M,y:g.bottom},{x:S,y:g.bottom}],side:j}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(f),f.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Ir(t.onKeyDown,f=>{var b;const g=o.searchRef.current!=="";t.disabled||g&&f.key===" "||U2t[n.dir].includes(f.key)&&(r.onOpenChange(!0),(b=r.content)==null||b.focus(),f.preventDefault())})})})});_He.displayName=vI;var wHe="MenuSubContent",jHe=N.forwardRef((t,s)=>{const r=iHe(Mx,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=xC(Mx,t.__scopeMenu),l=CO(Mx,t.__scopeMenu),i=bHe(wHe,t.__scopeMenu),c=N.useRef(null),u=qa(s,c);return e.jsx(Z8.Provider,{scope:t.__scopeMenu,children:e.jsx(Fd,{present:n||o.open,children:e.jsx(Z8.Slot,{scope:t.__scopeMenu,children:e.jsx(J2e,{id:i.contentId,"aria-labelledby":i.triggerId,...a,ref:u,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{var f;l.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Ir(t.onFocusOutside,p=>{p.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Ir(t.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:Ir(t.onKeyDown,p=>{var b;const f=p.currentTarget.contains(p.target),g=V2t[l.dir].includes(p.key);f&&g&&(o.onOpenChange(!1),(b=i.trigger)==null||b.focus(),p.preventDefault())})})})})})});jHe.displayName=wHe;function NHe(t){return t?"open":"closed"}function voe(t){return t==="indeterminate"}function sje(t){return voe(t)?"indeterminate":t?"checked":"unchecked"}function djt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function ujt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function hjt(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=ujt(t,Math.max(o,0));a.length===1&&(l=l.filter(u=>u!==r));const c=l.find(u=>u.toLowerCase().startsWith(a.toLowerCase()));return c!==r?c:void 0}function mjt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=g>n&&r<(f-u)*(n-p)/(g-p)+u&&(a=!a)}return a}function pjt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return mjt(r,s)}function Y8(t){return s=>s.pointerType==="mouse"?t(s):void 0}var fjt=aHe,xjt=Y2e,gjt=oHe,yjt=lHe,vjt=eje,bjt=cHe,_jt=zde,wjt=uHe,jjt=mHe,Njt=fHe,kjt=gHe,Sjt=yHe,Cjt=vHe,Mjt=_He,Tjt=jHe,Bde="DropdownMenu",[Ajt]=ad(Bde,[rHe]),Wm=rHe(),[Ejt,kHe]=Ajt(Bde),SHe=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,c=Wm(s),u=N.useRef(null),[p,f]=ah({prop:a,defaultProp:o??!1,onChange:l,caller:Bde});return e.jsx(Ejt,{scope:s,triggerId:Tu(),triggerRef:u,contentId:Tu(),open:p,onOpenChange:f,onOpenToggle:N.useCallback(()=>f(g=>!g),[f]),modal:i,children:e.jsx(fjt,{...c,open:p,onOpenChange:f,dir:n,modal:i,children:r})})};SHe.displayName=Bde;var CHe="DropdownMenuTrigger",MHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=kHe(CHe,r),l=Wm(r);return e.jsx(xjt,{asChild:!0,...l,children:e.jsx(nn.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:S1(s,o.triggerRef),onPointerDown:Ir(t.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:Ir(t.onKeyDown,i=>{n||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});MHe.displayName=CHe;var Pjt="DropdownMenuPortal",THe=t=>{const{__scopeDropdownMenu:s,...r}=t,n=Wm(s);return e.jsx(gjt,{...n,...r})};THe.displayName=Pjt;var AHe="DropdownMenuContent",EHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=kHe(AHe,r),o=Wm(r),l=N.useRef(!1);return e.jsx(yjt,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:s,onCloseAutoFocus:Ir(t.onCloseAutoFocus,i=>{var c;l.current||(c=a.triggerRef.current)==null||c.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:Ir(t.onInteractOutside,i=>{const c=i.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,p=c.button===2||u;(!a.modal||p)&&(l.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});EHe.displayName=AHe;var Ijt="DropdownMenuGroup",Ljt=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(vjt,{...a,...n,ref:s})});Ljt.displayName=Ijt;var Djt="DropdownMenuLabel",PHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(bjt,{...a,...n,ref:s})});PHe.displayName=Djt;var Ojt="DropdownMenuItem",IHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(_jt,{...a,...n,ref:s})});IHe.displayName=Ojt;var Rjt="DropdownMenuCheckboxItem",LHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(wjt,{...a,...n,ref:s})});LHe.displayName=Rjt;var Fjt="DropdownMenuRadioGroup",zjt=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(jjt,{...a,...n,ref:s})});zjt.displayName=Fjt;var Bjt="DropdownMenuRadioItem",DHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(Njt,{...a,...n,ref:s})});DHe.displayName=Bjt;var $jt="DropdownMenuItemIndicator",OHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(kjt,{...a,...n,ref:s})});OHe.displayName=$jt;var qjt="DropdownMenuSeparator",RHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(Sjt,{...a,...n,ref:s})});RHe.displayName=qjt;var Ujt="DropdownMenuArrow",Vjt=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(Cjt,{...a,...n,ref:s})});Vjt.displayName=Ujt;var Hjt="DropdownMenuSubTrigger",FHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(Mjt,{...a,...n,ref:s})});FHe.displayName=Hjt;var Wjt="DropdownMenuSubContent",zHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(Tjt,{...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)"}})});zHe.displayName=Wjt;var Gjt=SHe,Kjt=MHe,Zjt=THe,BHe=EHe,$He=PHe,qHe=IHe,UHe=LHe,VHe=DHe,HHe=OHe,WHe=RHe,GHe=FHe,KHe=zHe;const iu=Gjt,ou=Kjt,Yjt=N.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(GHe,{ref:a,className:It("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",s&&"pl-8",t),...n,children:[r,e.jsx(da,{className:"ml-auto h-4 w-4"})]}));Yjt.displayName=GHe.displayName;const Xjt=N.forwardRef(({className:t,...s},r)=>e.jsx(KHe,{ref:r,className:It("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s}));Xjt.displayName=KHe.displayName;const Bd=N.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(Zjt,{children:e.jsx(BHe,{ref:n,sideOffset:s,className:It("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})}));Bd.displayName=BHe.displayName;const Ma=N.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(qHe,{ref:n,className:It("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",s&&"pl-8",t),...r}));Ma.displayName=qHe.displayName;const Qjt=N.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(UHe,{ref:a,className:It("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),checked:r,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(HHe,{children:e.jsx(va,{className:"h-4 w-4"})})}),s]}));Qjt.displayName=UHe.displayName;const Jjt=N.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(VHe,{ref:n,className:It("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(HHe,{children:e.jsx(bd,{className:"h-2 w-2 fill-current"})})}),s]}));Jjt.displayName=VHe.displayName;const kve=N.forwardRef(({className:t,inset:s,...r},n)=>e.jsx($He,{ref:n,className:It("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));kve.displayName=$He.displayName;const dw=N.forwardRef(({className:t,...s},r)=>e.jsx(WHe,{ref:r,className:It("-mx-1 my-1 h-px bg-muted",t),...s}));dw.displayName=WHe.displayName;const eNt=()=>{const{isAssistant:t,actingAsAgent:s,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:a,setActingAsSelf:o}=K2e();if(!t)return null;const l=i=>i.split(" ").map(c=>c[0]).join("").toUpperCase().slice(0,2);return e.jsx("div",{className:"fixed top-0 left-0 right-0 z-[2147483647] bg-primary text-primary-foreground px-4 py-1.5 shadow-lg",style:{height:"40px"},children:e.jsxs("div",{className:"container mx-auto flex items-center justify-between gap-4 h-full",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[a?e.jsxs(e.Fragment,{children:[e.jsx(to,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"My Account"})]}):e.jsxs(e.Fragment,{children:[e.jsx(pr,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"Acting as"})]}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{variant:"secondary",size:"sm",className:"gap-2 bg-primary-foreground/20 hover:bg-primary-foreground/30 text-primary-foreground border-0",children:[a?e.jsxs(e.Fragment,{children:[e.jsx(to,{className:"h-4 w-4"}),e.jsx("strong",{children:"My Account"})]}):s?e.jsxs(e.Fragment,{children:[e.jsxs(Nn,{className:"h-5 w-5",children:[e.jsx($a,{src:s.avatar_url||void 0}),e.jsx(kn,{className:"text-[10px] bg-primary-foreground/30",children:l(s.name)})]}),e.jsx("strong",{children:s.name})]}):e.jsx("strong",{children:"Select..."}),e.jsx(Eo,{className:"h-3 w-3"})]})}),e.jsxs(Bd,{align:"start",className:"z-[2147483647]",children:[e.jsxs(Ma,{onClick:o,className:"gap-2",children:[e.jsx(to,{className:"h-4 w-4"}),e.jsx("span",{children:"My Account"}),a&&e.jsx(tt,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),e.jsx(dw,{}),r.map(i=>e.jsxs(Ma,{onClick:()=>n(i),className:"gap-2",children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx($a,{src:i.avatar_url||void 0}),e.jsx(kn,{className:"text-[10px]",children:l(i.name)})]}),e.jsx("span",{children:i.name}),!a&&i.id===(s==null?void 0:s.id)&&e.jsx(tt,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},i.id))]})]})]}),e.jsx(tt,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:a?"Personal Mode":"Assistant Mode"})]})})},nr=({children:t,requireAdmin:s=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:a,rolesLoading:o,isAdmin:l,isBrokerageManager:i}=Ds();return a||(s||r)&&o?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})}):n?s&&!l?e.jsx(sxe,{to:"/dashboard",replace:!0}):r&&!i&&!l?e.jsx(sxe,{to:"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t}):e.jsx(sxe,{to:"/auth",replace:!0})};var rje={};(function t(s,r,n,a){var o=!!(s.Worker&&s.Blob&&s.Promise&&s.OffscreenCanvas&&s.OffscreenCanvasRenderingContext2D&&s.HTMLCanvasElement&&s.HTMLCanvasElement.prototype.transferControlToOffscreen&&s.URL&&s.URL.createObjectURL),l=typeof Path2D=="function"&&typeof DOMMatrix=="function",i=function(){if(!s.OffscreenCanvas)return!1;try{var ge=new OffscreenCanvas(1,1),ue=ge.getContext("2d");ue.fillRect(0,0,1,1);var pe=ge.transferToImageBitmap();ue.createPattern(pe,"no-repeat")}catch{return!1}return!0}();function c(){}function u(ge){var ue=r.exports.Promise,pe=ue!==void 0?ue:s.Promise;return typeof pe=="function"?new pe(ge):(ge(c,c),null)}var p=function(ge,ue){return{transform:function(pe){if(ge)return pe;if(ue.has(pe))return ue.get(pe);var be=new OffscreenCanvas(pe.width,pe.height),Me=be.getContext("2d");return Me.drawImage(pe,0,0),ue.set(pe,be),be},clear:function(){ue.clear()}}}(i,new Map),f=function(){var ge=Math.floor(16.666666666666668),ue,pe,be={},Me=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(ue=function(Ne){var Pe=Math.random();return be[Pe]=requestAnimationFrame(function Oe(Te){Me===Te||Me+ge-1{const{data:s,error:r}=await H.from("celebration_queue").select("*").eq("user_id",t.id).is("seen_at",null).order("created_at",{ascending:!0});if(r)throw r;return s},enabled:!!(t!=null&&t.id),refetchOnWindowFocus:!0,staleTime:0})}function sNt(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("celebration_queue").update({seen_at:new Date().toISOString()}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}function rNt(){const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async r=>{const{error:n}=await H.from("celebration_queue").insert({user_id:r.user_id,celebration_type:r.celebration_type,title:r.title,message:r.message||null,points_amount:r.points_amount||null,created_by:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}var $de="Dialog",[ZHe,YHe]=ad($de),[nNt,uy]=ZHe($de),XHe=t=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=t,i=N.useRef(null),c=N.useRef(null),[u,p]=ah({prop:n,defaultProp:a??!1,onChange:o,caller:$de});return e.jsx(nNt,{scope:s,triggerRef:i,contentRef:c,contentId:Tu(),titleId:Tu(),descriptionId:Tu(),open:u,onOpenChange:p,onOpenToggle:N.useCallback(()=>p(f=>!f),[p]),modal:l,children:r})};XHe.displayName=$de;var QHe="DialogTrigger",JHe=N.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=uy(QHe,r),o=qa(s,a.triggerRef);return e.jsx(nn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":ije(a.open),...n,ref:o,onClick:Ir(t.onClick,a.onOpenToggle)})});JHe.displayName=QHe;var nje="DialogPortal",[aNt,eWe]=ZHe(nje,{forceMount:void 0}),tWe=t=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=t,o=uy(nje,s);return e.jsx(aNt,{scope:s,forceMount:r,children:N.Children.map(n,l=>e.jsx(Fd,{present:r||o.open,children:e.jsx(RA,{asChild:!0,container:a,children:l})}))})};tWe.displayName=nje;var boe="DialogOverlay",sWe=N.forwardRef((t,s)=>{const r=eWe(boe,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=uy(boe,t.__scopeDialog);return o.modal?e.jsx(Fd,{present:n||o.open,children:e.jsx(oNt,{...a,ref:s})}):null});sWe.displayName=boe;var iNt=ow("DialogOverlay.RemoveScroll"),oNt=N.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=uy(boe,r);return e.jsx(kO,{as:iNt,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(nn.div,{"data-state":ije(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),zS="DialogContent",rWe=N.forwardRef((t,s)=>{const r=eWe(zS,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=uy(zS,t.__scopeDialog);return e.jsx(Fd,{present:n||o.open,children:o.modal?e.jsx(lNt,{...a,ref:s}):e.jsx(cNt,{...a,ref:s})})});rWe.displayName=zS;var lNt=N.forwardRef((t,s)=>{const r=uy(zS,t.__scopeDialog),n=N.useRef(null),a=qa(s,r.contentRef,n);return N.useEffect(()=>{const o=n.current;if(o)return Ode(o)},[]),e.jsx(nWe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ir(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Ir(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:Ir(t.onFocusOutside,o=>o.preventDefault())})}),cNt=N.forwardRef((t,s)=>{const r=uy(zS,t.__scopeDialog),n=N.useRef(!1),a=N.useRef(!1);return e.jsx(nWe,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,i;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(n.current||(i=r.triggerRef.current)==null||i.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{var c,u;(c=t.onInteractOutside)==null||c.call(t,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((u=r.triggerRef.current)==null?void 0:u.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),nWe=N.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=uy(zS,r),c=N.useRef(null),u=qa(s,c);return Ide(),e.jsxs(e.Fragment,{children:[e.jsx(jO,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(Nw,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":ije(i.open),...l,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(uNt,{titleId:i.titleId}),e.jsx(mNt,{contentRef:c,descriptionId:i.descriptionId})]})]})}),aje="DialogTitle",aWe=N.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=uy(aje,r);return e.jsx(nn.h2,{id:a.titleId,...n,ref:s})});aWe.displayName=aje;var iWe="DialogDescription",oWe=N.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=uy(iWe,r);return e.jsx(nn.p,{id:a.descriptionId,...n,ref:s})});oWe.displayName=iWe;var lWe="DialogClose",cWe=N.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=uy(lWe,r);return e.jsx(nn.button,{type:"button",...n,ref:s,onClick:Ir(t.onClick,()=>a.onOpenChange(!1))})});cWe.displayName=lWe;function ije(t){return t?"open":"closed"}var dWe="DialogTitleWarning",[dNt,uWe]=Gft(dWe,{contentName:zS,titleName:aje,docsSlug:"dialog"}),uNt=({titleId:t})=>{const s=uWe(dWe),r=`\`${s.contentName}\` requires a \`${s.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${s.titleName}\`, you can wrap it with our VisuallyHidden component. For more information, see https://radix-ui.com/primitives/docs/components/${s.docsSlug}`;return N.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},hNt="DialogDescriptionWarning",mNt=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${uWe(hNt).contentName}}.`;return N.useEffect(()=>{var o;const a=(o=t.current)==null?void 0:o.getAttribute("aria-describedby");s&&a&&(document.getElementById(s)||console.warn(n))},[n,t,s]),null},qde=XHe,oje=JHe,Ude=tWe,GA=sWe,KA=rWe,MO=aWe,TO=oWe,AO=cWe;const fs=qde,qi=oje,pNt=Ude,IMs=AO,hWe=N.forwardRef(({className:t,...s},r)=>e.jsx(GA,{ref:r,className:It("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));hWe.displayName=GA.displayName;const ps=N.forwardRef(({className:t,children:s,overlayClassName:r,...n},a)=>e.jsxs(pNt,{children:[e.jsx(hWe,{className:r}),e.jsxs(KA,{ref:a,className:It("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:[s,e.jsxs(AO,{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(Rr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ps.displayName=KA.displayName;const _s=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});_s.displayName="DialogHeader";const qn=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});qn.displayName="DialogFooter";const vs=N.forwardRef(({className:t,...s},r)=>e.jsx(MO,{ref:r,className:It("text-lg font-semibold leading-none tracking-tight",t),...s}));vs.displayName=MO.displayName;const Gr=N.forwardRef(({className:t,...s},r)=>e.jsx(TO,{ref:r,className:It("text-sm text-muted-foreground",t),...s}));Gr.displayName=TO.displayName;const fNt={points_earned:xo,listing_created:bn,deal_closed:nc,custom:Jn},JEe={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"},e6e=()=>{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 xNt(){const{user:t}=Ds(),s=Qt(),{data:r}=tNt(),n=sNt(),[a,o]=N.useState(null),[l,i]=N.useState(!1),c=N.useCallback(()=>{const b=Date.now()+3e3,_={startVelocity:30,spread:360,ticks:60,zIndex:9999},j=(k,S)=>Math.random()*(S-k)+k,w=setInterval(()=>{const k=b-Date.now();if(k<=0){clearInterval(w);return}const S=50*(k/3e3);QEe({..._,particleCount:S,origin:{x:j(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),QEe({..._,particleCount:S,origin:{x:j(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);N.useEffect(()=>{e6e()||r&&r.length>0&&!a&&(o(r[0]),i(!0),setTimeout(c,100))},[r,a,c]);const u=async()=>{if(a){const g=a.id;i(!1),o(null),s.setQueryData(["celebrations","pending",t==null?void 0:t.id],b=>(b==null?void 0:b.filter(_=>_.id!==g))??[]),await n.mutateAsync(g)}};if(e6e()||!a)return null;const p=fNt[a.celebration_type]||Jn,f=JEe[a.celebration_type]||JEe.custom;return e.jsx(fs,{open:l,onOpenChange:g=>!g&&u(),children:e.jsxs(ps,{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(pn,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),e.jsx(pn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),e.jsx(pn,{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 mWe="/assets/levelup-logo-horizontal-DEFNc0ms.png",lje="/assets/levelup-logo-white-C2RAgAoG.png",gNt="/assets/listings-hero-BI9Ki9Dq.jpg",ze=N.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:It("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...r}));ze.displayName="Input";var pWe={exports:{}};(function(t,s){(function(r,n){t.exports=n()})(Hv,function(){var r,n,a;function o(i,c){if(!r)r=c;else if(!n)n=c;else{var u="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+r+")(sharedChunk); ("+n+")(sharedChunk); self.onerror = null;",p={};r(p),a=c(p),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(a.workerUrl=window.URL.createObjectURL(new Blob([u],{type:"text/javascript"})))}}o(["exports"],function(i){var c=1e-6,u=typeof Float32Array<"u"?Float32Array:Array;function p(x,d){var m=d[0],v=d[1],C=d[2],E=d[3],P=m*E-C*v;return P?(x[0]=E*(P=1/P),x[1]=-v*P,x[2]=-C*P,x[3]=m*P,x):null}function f(){var x=new u(9);return u!=Float32Array&&(x[1]=0,x[2]=0,x[3]=0,x[5]=0,x[6]=0,x[7]=0),x[0]=1,x[4]=1,x[8]=1,x}function g(x,d){var m=d[0],v=d[1],C=d[2],E=d[3],P=d[4],R=d[5],$=d[6],G=d[7],te=d[8];return x[0]=P*te-R*G,x[1]=C*G-v*te,x[2]=v*R-C*P,x[3]=R*$-E*te,x[4]=m*te-C*$,x[5]=C*E-m*R,x[6]=E*G-P*$,x[7]=v*$-m*G,x[8]=m*P-v*E,x}function b(x,d,m){var v=d[0],C=d[1],E=d[2],P=d[3],R=d[4],$=d[5],G=d[6],te=d[7],se=d[8],ae=m[0],de=m[1],he=m[2],Se=m[3],Fe=m[4],Re=m[5],Ke=m[6],Xe=m[7],lt=m[8];return x[0]=ae*v+de*P+he*G,x[1]=ae*C+de*R+he*te,x[2]=ae*E+de*$+he*se,x[3]=Se*v+Fe*P+Re*G,x[4]=Se*C+Fe*R+Re*te,x[5]=Se*E+Fe*$+Re*se,x[6]=Ke*v+Xe*P+lt*G,x[7]=Ke*C+Xe*R+lt*te,x[8]=Ke*E+Xe*$+lt*se,x}function _(){var x=new u(16);return u!=Float32Array&&(x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[11]=0,x[12]=0,x[13]=0,x[14]=0),x[0]=1,x[5]=1,x[10]=1,x[15]=1,x}function j(x){var d=new u(16);return d[0]=x[0],d[1]=x[1],d[2]=x[2],d[3]=x[3],d[4]=x[4],d[5]=x[5],d[6]=x[6],d[7]=x[7],d[8]=x[8],d[9]=x[9],d[10]=x[10],d[11]=x[11],d[12]=x[12],d[13]=x[13],d[14]=x[14],d[15]=x[15],d}function w(x){return x[0]=1,x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=1,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=1,x[11]=0,x[12]=0,x[13]=0,x[14]=0,x[15]=1,x}function k(x,d){var m=d[0],v=d[1],C=d[2],E=d[3],P=d[4],R=d[5],$=d[6],G=d[7],te=d[8],se=d[9],ae=d[10],de=d[11],he=d[12],Se=d[13],Fe=d[14],Re=d[15],Ke=m*R-v*P,Xe=m*$-C*P,lt=m*G-E*P,kt=v*$-C*R,vt=v*G-E*R,At=C*G-E*$,zt=te*Se-se*he,qt=te*Fe-ae*he,ss=te*Re-de*he,Gt=se*Fe-ae*Se,ds=se*Re-de*Se,js=ae*Re-de*Fe,Ns=Ke*js-Xe*ds+lt*Gt+kt*ss-vt*qt+At*zt;return Ns?(x[0]=(R*js-$*ds+G*Gt)*(Ns=1/Ns),x[1]=(C*ds-v*js-E*Gt)*Ns,x[2]=(Se*At-Fe*vt+Re*kt)*Ns,x[3]=(ae*vt-se*At-de*kt)*Ns,x[4]=($*ss-P*js-G*qt)*Ns,x[5]=(m*js-C*ss+E*qt)*Ns,x[6]=(Fe*lt-he*At-Re*Xe)*Ns,x[7]=(te*At-ae*lt+de*Xe)*Ns,x[8]=(P*ds-R*ss+G*zt)*Ns,x[9]=(v*ss-m*ds-E*zt)*Ns,x[10]=(he*vt-Se*lt+Re*Ke)*Ns,x[11]=(se*lt-te*vt-de*Ke)*Ns,x[12]=(R*qt-P*Gt-$*zt)*Ns,x[13]=(m*Gt-v*qt+C*zt)*Ns,x[14]=(Se*Xe-he*kt-Fe*Ke)*Ns,x[15]=(te*kt-se*Xe+ae*Ke)*Ns,x):null}function S(x,d,m){var v=d[0],C=d[1],E=d[2],P=d[3],R=d[4],$=d[5],G=d[6],te=d[7],se=d[8],ae=d[9],de=d[10],he=d[11],Se=d[12],Fe=d[13],Re=d[14],Ke=d[15],Xe=m[0],lt=m[1],kt=m[2],vt=m[3];return x[0]=Xe*v+lt*R+kt*se+vt*Se,x[1]=Xe*C+lt*$+kt*ae+vt*Fe,x[2]=Xe*E+lt*G+kt*de+vt*Re,x[3]=Xe*P+lt*te+kt*he+vt*Ke,x[4]=(Xe=m[4])*v+(lt=m[5])*R+(kt=m[6])*se+(vt=m[7])*Se,x[5]=Xe*C+lt*$+kt*ae+vt*Fe,x[6]=Xe*E+lt*G+kt*de+vt*Re,x[7]=Xe*P+lt*te+kt*he+vt*Ke,x[8]=(Xe=m[8])*v+(lt=m[9])*R+(kt=m[10])*se+(vt=m[11])*Se,x[9]=Xe*C+lt*$+kt*ae+vt*Fe,x[10]=Xe*E+lt*G+kt*de+vt*Re,x[11]=Xe*P+lt*te+kt*he+vt*Ke,x[12]=(Xe=m[12])*v+(lt=m[13])*R+(kt=m[14])*se+(vt=m[15])*Se,x[13]=Xe*C+lt*$+kt*ae+vt*Fe,x[14]=Xe*E+lt*G+kt*de+vt*Re,x[15]=Xe*P+lt*te+kt*he+vt*Ke,x}function M(x,d,m){var v,C,E,P,R,$,G,te,se,ae,de,he,Se=m[0],Fe=m[1],Re=m[2];return d===x?(x[12]=d[0]*Se+d[4]*Fe+d[8]*Re+d[12],x[13]=d[1]*Se+d[5]*Fe+d[9]*Re+d[13],x[14]=d[2]*Se+d[6]*Fe+d[10]*Re+d[14],x[15]=d[3]*Se+d[7]*Fe+d[11]*Re+d[15]):(C=d[1],E=d[2],P=d[3],R=d[4],$=d[5],G=d[6],te=d[7],se=d[8],ae=d[9],de=d[10],he=d[11],x[0]=v=d[0],x[1]=C,x[2]=E,x[3]=P,x[4]=R,x[5]=$,x[6]=G,x[7]=te,x[8]=se,x[9]=ae,x[10]=de,x[11]=he,x[12]=v*Se+R*Fe+se*Re+d[12],x[13]=C*Se+$*Fe+ae*Re+d[13],x[14]=E*Se+G*Fe+de*Re+d[14],x[15]=P*Se+te*Fe+he*Re+d[15]),x}function L(x,d,m){var v=m[0],C=m[1],E=m[2];return x[0]=d[0]*v,x[1]=d[1]*v,x[2]=d[2]*v,x[3]=d[3]*v,x[4]=d[4]*C,x[5]=d[5]*C,x[6]=d[6]*C,x[7]=d[7]*C,x[8]=d[8]*E,x[9]=d[9]*E,x[10]=d[10]*E,x[11]=d[11]*E,x[12]=d[12],x[13]=d[13],x[14]=d[14],x[15]=d[15],x}function I(x,d,m){var v=Math.sin(m),C=Math.cos(m),E=d[4],P=d[5],R=d[6],$=d[7],G=d[8],te=d[9],se=d[10],ae=d[11];return d!==x&&(x[0]=d[0],x[1]=d[1],x[2]=d[2],x[3]=d[3],x[12]=d[12],x[13]=d[13],x[14]=d[14],x[15]=d[15]),x[4]=E*C+G*v,x[5]=P*C+te*v,x[6]=R*C+se*v,x[7]=$*C+ae*v,x[8]=G*C-E*v,x[9]=te*C-P*v,x[10]=se*C-R*v,x[11]=ae*C-$*v,x}function O(x,d,m){var v=Math.sin(m),C=Math.cos(m),E=d[0],P=d[1],R=d[2],$=d[3],G=d[8],te=d[9],se=d[10],ae=d[11];return d!==x&&(x[4]=d[4],x[5]=d[5],x[6]=d[6],x[7]=d[7],x[12]=d[12],x[13]=d[13],x[14]=d[14],x[15]=d[15]),x[0]=E*C-G*v,x[1]=P*C-te*v,x[2]=R*C-se*v,x[3]=$*C-ae*v,x[8]=E*v+G*C,x[9]=P*v+te*C,x[10]=R*v+se*C,x[11]=$*v+ae*C,x}function q(x,d,m){var v=Math.sin(m),C=Math.cos(m),E=d[0],P=d[1],R=d[2],$=d[3],G=d[4],te=d[5],se=d[6],ae=d[7];return d!==x&&(x[8]=d[8],x[9]=d[9],x[10]=d[10],x[11]=d[11],x[12]=d[12],x[13]=d[13],x[14]=d[14],x[15]=d[15]),x[0]=E*C+G*v,x[1]=P*C+te*v,x[2]=R*C+se*v,x[3]=$*C+ae*v,x[4]=G*C-E*v,x[5]=te*C-P*v,x[6]=se*C-R*v,x[7]=ae*C-$*v,x}function U(x,d){return x[0]=d[0],x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=d[1],x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=d[2],x[11]=0,x[12]=0,x[13]=0,x[14]=0,x[15]=1,x}function B(x,d,m){var v,C,E,P=m[0],R=m[1],$=m[2],G=Math.sqrt(P*P+R*R+$*$);return G0&&(E=1/Math.sqrt(E)),x[0]=d[0]*E,x[1]=d[1]*E,x[2]=d[2]*E,x}function Be(x,d){return x[0]*d[0]+x[1]*d[1]+x[2]*d[2]}function nt(x,d,m){var v=d[0],C=d[1],E=d[2],P=m[0],R=m[1],$=m[2];return x[0]=C*$-E*R,x[1]=E*P-v*$,x[2]=v*R-C*P,x}function Ae(x,d,m,v){var C=d[0],E=d[1],P=d[2];return x[0]=C+v*(m[0]-C),x[1]=E+v*(m[1]-E),x[2]=P+v*(m[2]-P),x}function ft(x,d,m){var v=d[0],C=d[1],E=d[2],P=m[3]*v+m[7]*C+m[11]*E+m[15];return x[0]=(m[0]*v+m[4]*C+m[8]*E+m[12])/(P=P||1),x[1]=(m[1]*v+m[5]*C+m[9]*E+m[13])/P,x[2]=(m[2]*v+m[6]*C+m[10]*E+m[14])/P,x}function fe(x,d,m){var v=d[0],C=d[1],E=d[2];return x[0]=v*m[0]+C*m[3]+E*m[6],x[1]=v*m[1]+C*m[4]+E*m[7],x[2]=v*m[2]+C*m[5]+E*m[8],x}function Ve(x,d,m){var v=m[0],C=m[1],E=m[2],P=m[3],R=d[0],$=d[1],G=d[2],te=C*G-E*$,se=E*R-v*G,ae=v*$-C*R;return x[0]=R+P*(te+=te)+C*(ae+=ae)-E*(se+=se),x[1]=$+P*se+E*te-v*ae,x[2]=G+P*ae+v*se-C*te,x}function at(x){return x[0]=0,x[1]=0,x[2]=0,x}function et(x,d){return x[0]===d[0]&&x[1]===d[1]&&x[2]===d[2]}var Ce=xe,rt=ge,Ge=ie;function ct(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0,x[3]=0),x}function qe(x,d,m){return x[0]=d[0]*m,x[1]=d[1]*m,x[2]=d[2]*m,x[3]=d[3]*m,x}function Ze(x,d){var m=d[0],v=d[1],C=d[2],E=d[3],P=m*m+v*v+C*C+E*E;return P>0&&(P=1/Math.sqrt(P)),x[0]=m*P,x[1]=v*P,x[2]=C*P,x[3]=E*P,x}function Qe(x,d,m){var v=d[0],C=d[1],E=d[2],P=d[3];return x[0]=m[0]*v+m[4]*C+m[8]*E+m[12]*P,x[1]=m[1]*v+m[5]*C+m[9]*E+m[13]*P,x[2]=m[2]*v+m[6]*C+m[10]*E+m[14]*P,x[3]=m[3]*v+m[7]*C+m[11]*E+m[15]*P,x}function He(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0),x[3]=1,x}function Je(x){return x[0]=0,x[1]=0,x[2]=0,x[3]=1,x}function it(x,d,m){m*=.5;var v=d[0],C=d[1],E=d[2],P=d[3],R=Math.sin(m),$=Math.cos(m);return x[0]=v*$+P*R,x[1]=C*$+E*R,x[2]=E*$-C*R,x[3]=P*$-v*R,x}function Lt(x,d,m){m*=.5;var v=d[0],C=d[1],E=d[2],P=d[3],R=Math.sin(m),$=Math.cos(m);return x[0]=v*$-E*R,x[1]=C*$+P*R,x[2]=E*$+v*R,x[3]=P*$-C*R,x}ee(),ct();var Vt,hs,Ts,Cs=Ze,cs=(Vt=ee(),hs=re(1,0,0),Ts=re(0,1,0),function(x,d,m){var v=Be(d,m);return v<-.999999?(nt(Vt,hs,d),Ge(Vt)<1e-6&&nt(Vt,Ts,d),ke(Vt,Vt),function(C,E,P){P*=.5;var R=Math.sin(P);C[0]=R*E[0],C[1]=R*E[1],C[2]=R*E[2],C[3]=Math.cos(P)}(x,Vt,Math.PI),x):v>.999999?(x[0]=0,x[1]=0,x[2]=0,x[3]=1,x):(nt(Vt,d,m),x[0]=Vt[0],x[1]=Vt[1],x[2]=Vt[2],x[3]=1+v,Cs(x,x))});function er(){var x=new u(2);return u!=Float32Array&&(x[0]=0,x[1]=0),x}function xt(x,d){var m=new u(2);return m[0]=x,m[1]=d,m}function Es(x,d,m){return x[0]=d,x[1]=m,x}function ur(x,d,m){return x[0]=d[0]+m[0],x[1]=d[1]+m[1],x}function Mr(x,d,m){return x[0]=d[0]-m[0],x[1]=d[1]-m[1],x}function Lr(x,d,m){return x[0]=d[0]*m,x[1]=d[1]*m,x}function fn(x){var d=x[0],m=x[1];return Math.sqrt(d*d+m*m)}function ki(x,d){var m=d[0],v=d[1],C=m*m+v*v;return C>0&&(C=1/Math.sqrt(C)),x[0]=d[0]*C,x[1]=d[1]*C,x}function Ea(x,d){return x[0]*d[0]+x[1]*d[1]}He(),He(),f();var dr,Jr,Wr=Mr;function dn(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}er();var Yr=function(){if(Jr)return dr;function x(d,m,v,C){this.cx=3*d,this.bx=3*(v-d)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*m,this.by=3*(C-m)-this.cy,this.ay=1-this.cy-this.by,this.p1x=d,this.p1y=m,this.p2x=v,this.p2y=C}return Jr=1,dr=x,x.prototype={sampleCurveX:function(d){return((this.ax*d+this.bx)*d+this.cx)*d},sampleCurveY:function(d){return((this.ay*d+this.by)*d+this.cy)*d},sampleCurveDerivativeX:function(d){return(3*this.ax*d+2*this.bx)*d+this.cx},solveCurveX:function(d,m){if(m===void 0&&(m=1e-6),d<0)return 0;if(d>1)return 1;for(var v=d,C=0;C<8;C++){var E=this.sampleCurveX(v)-d;if(Math.abs(E)E?R=v:$=v,v=.5*($-R)+R;return v},solve:function(d,m){return this.sampleCurveY(this.solveCurveX(d,m))}},dr}(),vi=dn(Yr);function pt(x,d){this.x=x,this.y=d}function ir(x,d){if(Array.isArray(x)){if(!Array.isArray(d)||x.length!==d.length)return!1;for(let m=0;m=1)return 1;const d=x*x,m=d*x;return 4*(x<.5?m:3*(x-d)+m-.75)}function Fo(x,d,m,v){const C=new vi(x,d,m,v);return function(E){return C.solve(E)}}const $t=Fo(.25,.1,.25,1);function je(x,d,m){return Math.min(m,Math.max(d,x))}function $e(x,d,m){return(m=je((m-x)/(d-x),0,1))*m*(3-2*m)}function Ye(x,d,m){const v=m-d,C=((x-d)%v+v)%v+d;return C===d?m:C}function bt(x,d,m){if(!x.length)return m(null,[]);let v=x.length;const C=new Array(x.length);let E=null;x.forEach((P,R)=>{d(P,($,G)=>{$&&(E=$),C[R]=G,--v==0&&m(E,C)})})}let gt=1;function Ft(){return gt++}function Zt(x){return x<=1?1:Math.pow(2,Math.ceil(Math.log2(x)))}function Ut(x,d){x.forEach(m=>{d[m]&&(d[m]=d[m].bind(d))})}function Xt(x,d,m){const v={};for(const C in x)v[C]=d.call(this,x[C],C,x);return v}function Ps(x,d,m){const v={};for(const C in x)d.call(this,x[C],C,x)&&(v[C]=x[C]);return v}function gs(x){return Array.isArray(x)?x.map(gs):typeof x=="object"&&x?Xt(x,gs):x}function vr(x,d){for(let m=0;m=0)return!0;return!1}const Hr={};function xr(x){Hr[x]||(typeof console<"u"&&console.warn(x),Hr[x]=!0)}function Ln(x,d,m){return(m.y-x.y)*(d.x-x.x)>(d.y-x.y)*(m.x-x.x)}function Dn(x){let d=0;for(let m,v,C=0,E=x.length,P=E-1;C@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(m,v,C,E)=>{const P=C||E;return d[v]=!P||P.toLowerCase(),""}),d["max-age"]){const m=parseInt(d["max-age"],10);isNaN(m)?delete d["max-age"]:d["max-age"]=m}return d}let il=null;function ti(x,d){return[x[4*d],x[4*d+1],x[4*d+2],x[4*d+3]]}function hl(x,d,m,v){for(;d>1;x[C]>1;x[C]<=v?d=C+1:m=C}return d}function Ia(x){return x>0?1/(1.001-x):1+x}function lo(x){return x>0?1-1/(1.001-x):-x}function Ti(x,d,m){return(x-d.min)*(m.max-m.min)/(d.max-d.min)+m.min}const ua={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(!ua.API_URL)return null;try{const x=new URL(ua.API_URL);return x.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":x.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"https://api.mapbox.com/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function co(x){return ua.API_URL_REGEX.test(x)}function Mc(x){return ua.API_SPRITE_REGEX.test(x)}let Wc,lu,Df,Fl,ch,kd;function Km(){return Wc==null&&(Wc=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),Wc}const zl={now:()=>Fl!==void 0?Fl:performance.now(),setNow(x){Fl=x},restoreNow(){Fl=void 0},frame(x){const d=requestAnimationFrame(x);return{cancel:()=>cancelAnimationFrame(d)}},getImageData(x,d=0){const{width:m,height:v}=x;ch||(ch=document.createElement("canvas"));const C=ch.getContext("2d",{willReadFrequently:!0});if(!C)throw new Error("failed to create canvas 2d context");return(m>ch.width||v>ch.height)&&(ch.width=m,ch.height=v),C.clearRect(-d,-d,m+2*d,v+2*d),C.drawImage(x,0,0,m,v),C.getImageData(-d,-d,m+2*d,v+2*d)},resolveURL:x=>(lu||(lu=document.createElement("a")),lu.href=x,lu.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(Df==null&&(Df=window.matchMedia("(prefers-reduced-motion: reduce)")),Df.matches)},hasCanvasFingerprintNoise(){if(kd!==void 0)return kd;if(!Km())return kd=!1,!1;const x=new OffscreenCanvas(85,1),d=x.getContext("2d",{willReadFrequently:!0});let m=0;for(let C=0;C0?`?${E}`:""}`}const V1="mapbox-tiles";let H1=500,W1=50;const Dp=["language","worldview","jobid"];let am,cu;function im(){try{return caches}catch{}}function $d(){const x=im();x&&am==null&&(am=x.open(V1))}let Sd=1/0;const du={supported:!1,testSupport:function(x){!Zm&&Rf&&(Ym?K0(x):Of=x)}};let Of,Rf,Zm=!1,Ym=!1;const Cd=typeof self<"u"?self:{};function K0(x){const d=x.createTexture();x.bindTexture(x.TEXTURE_2D,d);try{if(x.texImage2D(x.TEXTURE_2D,0,x.RGBA,x.RGBA,x.UNSIGNED_BYTE,Rf),x.isContextLost())return;du.supported=!0}catch{}x.deleteTexture(d),Zm=!0}Cd.document&&(Rf=Cd.document.createElement("img"),Rf.onload=function(){Of&&K0(Of),Of=null,Ym=!0},Rf.onerror=function(){Zm=!0,Of=null},Rf.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Yx={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(Yx);class Al extends Error{constructor(d,m,v){m===401&&co(v)&&(d+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(d),this.status=m,this.url=v}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const G1=_a()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,Xx=function(x,d){if(!(/^file:/.test(m=x.url)||/^file:/.test(G1())&&!/^\w+:/.test(m))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(v,C){const E=new AbortController,P=new Request(v.url,{method:v.method||"GET",body:v.body,credentials:v.credentials,headers:v.headers,referrer:G1(),referrerPolicy:v.referrerPolicy,signal:E.signal});let R=!1,$=!1;const G=(te=P.url).indexOf("sku=")>0&&co(te);var te;v.type==="json"&&P.headers.set("Accept","application/json");const se=(de,he,Se)=>{if($)return;if(de&&de.message!=="SecurityError"&&xr(de.toString()),he&&Se)return ae(he);const Fe=Date.now();fetch(P).then(Re=>{if(Re.ok){const Ke=G?Re.clone():null;return ae(Re,Ke,Fe)}return C(new Al(Re.statusText,Re.status,v.url))}).catch(Re=>{Re.name!=="AbortError"&&C(new Error(`${Re.message} ${v.url}`))})},ae=(de,he,Se)=>{(v.type==="arrayBuffer"?de.arrayBuffer():v.type==="json"?de.json():de.text()).then(Fe=>{$||(he&&Se&&function(Re,Ke,Xe){if($d(),am==null)return;const lt=vo(Ke.headers.get("Cache-Control")||"");if(lt["no-store"])return;const kt={status:Ke.status,statusText:Ke.statusText,headers:new Headers};Ke.headers.forEach((zt,qt)=>kt.headers.set(qt,zt)),lt["max-age"]&&kt.headers.set("Expires",new Date(Xe+1e3*lt["max-age"]).toUTCString());const vt=kt.headers.get("Expires");if(!vt||new Date(vt).getTime()-Xe<42e4)return;let At=yy(Re.url,{persistentParams:Dp});if(Ke.status===206){const zt=Re.headers.get("Range");if(!zt)return;kt.status=200,At=Zx(At,{range:zt})}(function(zt,qt){if(cu===void 0)try{new Response(new ReadableStream),cu=!0}catch{cu=!1}cu?qt(zt.body):zt.blob().then(qt).catch(ss=>xr(ss.message))})(Ke,zt=>{const qt=new Response((ss=Ke.status)!==200&&ss!==404&&[101,103,204,205,304].includes(ss)?null:zt,kt);var ss;$d(),am!=null&&am.then(Gt=>Gt.put(At,qt)).catch(Gt=>xr(Gt.message))})}(P,he,Se),R=!0,C(null,Fe,de.headers))}).catch(Fe=>{$||C(new Error(Fe.message))})};return G?function(de,he){if($d(),am==null)return he(null);am.then(Se=>{let Fe=yy(de.url,{persistentParams:Dp});const Re=de.headers.get("Range");Re&&(Fe=Zx(Fe,{range:Re})),Se.match(Fe).then(Ke=>{const Xe=function(lt){if(!lt)return!1;const kt=new Date(lt.headers.get("Expires")||0),vt=vo(lt.headers.get("Cache-Control")||"");return Number(kt)>Date.now()&&!vt["no-cache"]}(Ke);Se.delete(Fe).catch(he),Xe&&Se.put(Fe,Ke.clone()).catch(he),he(null,Ke,Xe)}).catch(he)}).catch(he)}(P,se):se(null,null),{cancel:()=>{$=!0,R||E.abort()}}}(x,d);if(_a(self)&&self.worker.actor)return self.worker.actor.send("getResource",x,d,void 0,!0)}var m;return function(v,C){const E=new XMLHttpRequest;E.open(v.method||"GET",v.url,!0),v.type==="arrayBuffer"&&(E.responseType="arraybuffer");for(const P in v.headers)E.setRequestHeader(P,v.headers[P]);return v.type==="json"&&(E.responseType="text",E.setRequestHeader("Accept","application/json")),E.withCredentials=v.credentials==="include",E.onerror=()=>{C(new Error(E.statusText))},E.onload=()=>{if((E.status>=200&&E.status<300||E.status===0)&&E.response!==null){let P=E.response;if(v.type==="json")try{P=JSON.parse(E.response)}catch($){return C($)}const R=new Headers;E.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach($=>{const G=$.split(": "),te=G.shift(),se=G.join(": ");R.append(te,se)}),C(null,P,R)}else C(new Al(E.statusText,E.status,v.url))},E.send(v.body),{cancel:()=>E.abort()}}(x,d)},Lh=function(x,d){return Xx(Object.assign(x,{type:"arrayBuffer"}),d)};function Hw(x){const d=document.createElement("a");return d.href=x,d.protocol===location.protocol&&d.host===location.host}const AC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Z0,La;Z0=[],La=0;const vy=function(x,d){if(du.supported&&(x.headers||(x.headers={}),x.headers.accept="image/webp,*/*"),La>=ua.MAX_PARALLEL_IMAGE_REQUESTS){const E={requestParameters:x,callback:d,cancelled:!1,cancel(){this.cancelled=!0}};return Z0.push(E),E}La++;let m=!1;const v=()=>{if(!m)for(m=!0,La--;Z0.length&&La{v(),E?d(E):P&&(self.createImageBitmap?function($,G){const te=new Blob([new Uint8Array($)],{type:"image/png"});createImageBitmap(te).then(se=>{G(null,se)}).catch(se=>{G(new Error(`Could not load image because of ${se.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(P,($,G)=>d($,G,R)):function($,G){const te=new Image;te.onload=()=>{G(null,te),URL.revokeObjectURL(te.src),te.onload=null,requestAnimationFrame(()=>{te.src=AC})},te.onerror=()=>G(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const se=new Blob([new Uint8Array($)],{type:"image/png"});te.src=$.byteLength?URL.createObjectURL(se):AC}(P,($,G)=>d($,G,R)))});return{cancel:()=>{C.cancel(),v()}}};var Ww,EC,PC,om={exports:{}},Y0={exports:{}},X0={exports:{}},Gw=function(){if(PC)return om.exports;PC=1;var x=(Ww||(Ww=1,Y0.exports=function(m,v){var C,E,P,R,$,G,te,se;for(E=m.length-(C=3&m.length),P=v,$=3432918353,G=461845907,se=0;se>>16)*$&65535)<<16)&4294967295)<<15|te>>>17))*G+(((te>>>16)*G&65535)<<16)&4294967295)<<13|P>>>19))+((5*(P>>>16)&65535)<<16)&4294967295))+((58964+(R>>>16)&65535)<<16);switch(te=0,C){case 3:te^=(255&m.charCodeAt(se+2))<<16;case 2:te^=(255&m.charCodeAt(se+1))<<8;case 1:P^=te=(65535&(te=(te=(65535&(te^=255&m.charCodeAt(se)))*$+(((te>>>16)*$&65535)<<16)&4294967295)<<15|te>>>17))*G+(((te>>>16)*G&65535)<<16)&4294967295}return P^=m.length,P=2246822507*(65535&(P^=P>>>16))+((2246822507*(P>>>16)&65535)<<16)&4294967295,P=3266489909*(65535&(P^=P>>>13))+((3266489909*(P>>>16)&65535)<<16)&4294967295,(P^=P>>>16)>>>0}),Y0.exports),d=(EC||(EC=1,X0.exports=function(m,v){for(var C,E=m.length,P=v^E,R=0;E>=4;)C=1540483477*(65535&(C=255&m.charCodeAt(R)|(255&m.charCodeAt(++R))<<8|(255&m.charCodeAt(++R))<<16|(255&m.charCodeAt(++R))<<24))+((1540483477*(C>>>16)&65535)<<16),P=1540483477*(65535&P)+((1540483477*(P>>>16)&65535)<<16)^(C=1540483477*(65535&(C^=C>>>24))+((1540483477*(C>>>16)&65535)<<16)),E-=4,++R;switch(E){case 3:P^=(255&m.charCodeAt(R+2))<<16;case 2:P^=(255&m.charCodeAt(R+1))<<8;case 1:P=1540483477*(65535&(P^=255&m.charCodeAt(R)))+((1540483477*(P>>>16)&65535)<<16)}return P=1540483477*(65535&(P^=P>>>13))+((1540483477*(P>>>16)&65535)<<16),(P^=P>>>15)>>>0}),X0.exports);return om.exports=x,om.exports.murmur3=x,om.exports.murmur2=d,om.exports}(),K1=dn(Gw);class Xm{constructor(d,...m){Object.assign(this,m[0]||{}),this.type=d}}class by extends Xm{constructor(d,m={}){super("error",Object.assign({error:d},m))}}function Kw(x,d,m){m[x]&&m[x].indexOf(d)!==-1||(m[x]=m[x]||[],m[x].push(d))}function jt(x,d,m){if(m&&m[x]){const v=m[x].indexOf(d);v!==-1&&m[x].splice(v,1)}}class As{on(d,m){return this._listeners=this._listeners||{},Kw(d,m,this._listeners),this}off(d,m){return jt(d,m,this._listeners),jt(d,m,this._oneTimeListeners),this}once(d,m){return m?(this._oneTimeListeners=this._oneTimeListeners||{},Kw(d,m,this._oneTimeListeners),this):new Promise(v=>{this.once(d,v)})}fire(d,m){const v=typeof d=="string"?new Xm(d,m):d,C=v.type;if(this.listens(C)){v.target=this;const E=this._listeners&&this._listeners[C]?this._listeners[C].slice():[];for(const $ of E)$.call(this,v);const P=this._oneTimeListeners&&this._oneTimeListeners[C]?this._oneTimeListeners[C].slice():[];for(const $ of P)jt(C,$,this._oneTimeListeners),$.call(this,v);const R=this._eventedParent;if(R){const $=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(v,$),R.fire(v)}}else v instanceof by&&console.error(v.error);return this}listens(d){return!!(this._listeners&&this._listeners[d]&&this._listeners[d].length>0||this._oneTimeListeners&&this._oneTimeListeners[d]&&this._oneTimeListeners[d].length>0||this._eventedParent&&this._eventedParent.listens(d))}setEventedParent(d,m){return this._eventedParent=d,this._eventedParentData=m,this}}class Qs{constructor(d){typeof d=="string"?this.name=d:(this.name=d.name,this.iconsetId=d.iconsetId)}static from(d){return new Qs(d)}static toString(d){return d.iconsetId?`${d.name}${d.iconsetId}`:d.name}static parse(d){const[m,v]=d.split("");return new Qs({name:m,iconsetId:v})}static isEqual(d,m){return d.name===m.name&&d.iconsetId===m.iconsetId}toString(){return Qs.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var xn,gn={},ca=function(){if(xn)return gn;xn=1;var x={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function d(E){return(E=Math.round(E))<0?0:E>255?255:E}function m(E){return d(E[E.length-1]==="%"?parseFloat(E)/100*255:parseInt(E))}function v(E){return(P=E[E.length-1]==="%"?parseFloat(E)/100:parseFloat(E))<0?0:P>1?1:P;var P}function C(E,P,R){return R<0?R+=1:R>1&&(R-=1),6*R<1?E+(P-E)*R*6:2*R<1?P:3*R<2?E+(P-E)*(2/3-R)*6:E}try{gn.parseCSSColor=function(E){var P,R=E.replace(/ /g,"").toLowerCase();if(R in x)return x[R].slice();if(R[0]==="#")return R.length===4?(P=parseInt(R.substr(1),16))>=0&&P<=4095?[(3840&P)>>4|(3840&P)>>8,240&P|(240&P)>>4,15&P|(15&P)<<4,1]:null:R.length===7&&(P=parseInt(R.substr(1),16))>=0&&P<=16777215?[(16711680&P)>>16,(65280&P)>>8,255&P,1]:null;var $=R.indexOf("("),G=R.indexOf(")");if($!==-1&&G+1===R.length){var te=R.substr(0,$),se=R.substr($+1,G-($+1)).split(","),ae=1;switch(te){case"rgba":if(se.length!==4)return null;ae=v(se.pop());case"rgb":return se.length!==3?null:[m(se[0]),m(se[1]),m(se[2]),ae];case"hsla":if(se.length!==4)return null;ae=v(se.pop());case"hsl":if(se.length!==3)return null;var de=(parseFloat(se[0])%360+360)%360/360,he=v(se[1]),Se=v(se[2]),Fe=Se<=.5?Se*(he+1):Se+he-Se*he,Re=2*Se-Fe;return[d(255*C(Re,Fe,de+1/3)),d(255*C(Re,Fe,de)),d(255*C(Re,Fe,de-1/3)),ae];default:return null}}return null}}catch{}return gn}();class Ur{constructor(d,m,v,C=1){this.r=d,this.g=m,this.b=v,this.a=C}static parse(d){if(!d)return;if(d instanceof Ur)return d;if(typeof d!="string")return;const m=ca.parseCSSColor(d);return m?new Ur(m[0]/255,m[1]/255,m[2]/255,m[3]):void 0}toString(){const[d,m,v,C]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*d)},${Math.round(255*m)},${Math.round(255*v)},${C})`}toNonPremultipliedRenderColor(d){const{r:m,g:v,b:C,a:E}=this;return new Qx(d,m,v,C,E)}toPremultipliedRenderColor(d){const{r:m,g:v,b:C,a:E}=this;return new Op(d,m*E,v*E,C*E,E)}clone(){return new Ur(this.r,this.g,this.b,this.a)}}class uo{constructor(d,m,v,C,E,P=!1){if(this.premultiplied=!1,this.premultiplied=P,d){const R=d.image.height,$=R*R;this.premultiplied?(m=E===0?0:m/E*(R-1),v=E===0?0:v/E*(R-1),C=E===0?0:C/E*(R-1)):(m*=R-1,v*=R-1,C*=R-1);const G=Math.floor(m),te=Math.floor(v),se=Math.floor(C),ae=Math.ceil(m),de=Math.ceil(v),he=Math.ceil(C),Se=m-G,Fe=v-te,Re=C-se,Ke=d.image.data,Xe=4*(G+te*$+se*R),lt=4*(G+te*$+he*R),kt=4*(G+de*$+se*R),vt=4*(G+de*$+he*R),At=4*(ae+te*$+se*R),zt=4*(ae+te*$+he*R),qt=4*(ae+de*$+se*R),ss=4*(ae+de*$+he*R);if(Xe<0||ss>=Ke.length)throw new Error("out of range");this.r=Zr(Zr(Zr(Ke[Xe],Ke[lt],Re),Zr(Ke[kt],Ke[vt],Re),Fe),Zr(Zr(Ke[At],Ke[zt],Re),Zr(Ke[qt],Ke[ss],Re),Fe),Se)/255*(this.premultiplied?E:1),this.g=Zr(Zr(Zr(Ke[Xe+1],Ke[lt+1],Re),Zr(Ke[kt+1],Ke[vt+1],Re),Fe),Zr(Zr(Ke[At+1],Ke[zt+1],Re),Zr(Ke[qt+1],Ke[ss+1],Re),Fe),Se)/255*(this.premultiplied?E:1),this.b=Zr(Zr(Zr(Ke[Xe+2],Ke[lt+2],Re),Zr(Ke[kt+2],Ke[vt+2],Re),Fe),Zr(Zr(Ke[At+2],Ke[zt+2],Re),Zr(Ke[qt+2],Ke[ss+2],Re),Fe),Se)/255*(this.premultiplied?E:1),this.a=E}else this.r=m,this.g=v,this.b=C,this.a=E}toArray(){const{r:d,g:m,b:v,a:C}=this;return[255*d,255*m,255*v,C]}toHslaArray(){let{r:d,g:m,b:v,a:C}=this;if(this.premultiplied){if(C===0)return[0,0,0,0];const he=1/C;d*=he,m*=he,v*=he}const E=Math.min(Math.max(d,0),1),P=Math.min(Math.max(m,0),1),R=Math.min(Math.max(v,0),1),$=Math.min(E,P,R),G=Math.max(E,P,R),te=G-$,se=.5*($+G);if(te===0)return[0,0,100*se,C];const ae=se>.5?te/(2-G-$):te/(G+$);let de;switch(G){case E:de=60*((P-R)/te+(PZr(v,d[C],m))}Ur.black=new Ur(0,0,0,1),Ur.white=new Ur(1,1,1,1),Ur.transparent=new Ur(0,0,0,0),Ur.red=new Ur(1,0,0,1),Ur.blue=new Ur(0,0,1,1);var J0=Object.freeze({__proto__:null,array:Q0,color:function(x,d,m){return new Ur(Zr(x.r,d.r,m),Zr(x.g,d.g,m),Zr(x.b,d.b,m),Zr(x.a,d.a,m))},number:Zr});class Qm extends Error{constructor(d,m){super(m),this.message=m,this.key=d}}class Z1{constructor(d,m=[]){this.parent=d,this.bindings={};for(const[v,C]of m)this.bindings[v]=C}concat(d){return new Z1(this,d)}get(d){if(this.bindings[d])return this.bindings[d];if(this.parent)return this.parent.get(d);throw new Error(`${d} not found in scope.`)}has(d){return!!this.bindings[d]||!!this.parent&&this.parent.has(d)}}const Rp={kind:"null"},$r={kind:"number"},Da={kind:"string"},Si={kind:"boolean"},dh={kind:"color"},Ff={kind:"object"},pi={kind:"value"},IC={kind:"collator"},Zw={kind:"formatted"},Yw={kind:"resolvedImage"};function qd(x,d){return{kind:"array",itemType:x,N:d}}function _l(x){if(x.kind==="array"){const d=_l(x.itemType);return typeof x.N=="number"?`array<${d}, ${x.N}>`:x.itemType.kind==="value"?"array":`array<${d}>`}return x.kind}const jme=[Rp,$r,Da,Si,dh,Zw,Ff,qd(pi),Yw];function _y(x,d){if(d.kind==="error")return null;if(x.kind==="array"){if(d.kind==="array"&&(d.N===0&&d.itemType.kind==="value"||!_y(x.itemType,d.itemType))&&(typeof x.N!="number"||x.N===d.N))return null}else{if(x.kind===d.kind)return null;if(x.kind==="value"){for(const m of jme)if(!_y(m,d))return null}}return`Expected ${_l(x)} but found ${_l(d)} instead.`}function FE(x,d){return d.some(m=>m.kind===x.kind)}function Xw(x,d){return d.some(m=>m==="null"?x===null:m==="array"?Array.isArray(x):m==="object"?x&&!Array.isArray(x)&&typeof x=="object":m===typeof x)}function LC(x,d){return x.kind==="array"&&d.kind==="array"?x.N===d.N&&LC(x.itemType,d.itemType):x.kind===d.kind}class zE{constructor(d,m,v){this.sensitivity=d?m?"variant":"case":m?"accent":"base",this.locale=v,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(d,m){return this.collator.compare(d,m)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class DC{constructor(d,m,v,C,E){this.text=d.normalize?d.normalize():d,this.image=m,this.scale=v,this.fontStack=C,this.textColor=E}}class Du{constructor(d){this.sections=d}static fromString(d){return new Du([new DC(d,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(d=>d.text.length!==0||!!d.image&&d.image.hasPrimary())}static factory(d){return d instanceof Du?d:Du.fromString(d)}toString(){return this.sections.length===0?"":this.sections.map(d=>d.text).join("")}serialize(){const d=["format"];for(const m of this.sections){if(m.image){const C=m.image.getPrimary().id.toString();d.push(["image",C]);continue}d.push(m.text);const v={};m.fontStack&&(v["text-font"]=["literal",m.fontStack.split(",")]),m.scale&&(v["font-scale"]=m.scale),m.textColor&&(v["text-color"]=["rgba"].concat(m.textColor.toNonPremultipliedRenderColor(null).toArray())),d.push(v)}return d}}class Jx{constructor(d,m={}){this.id=Qs.from(d),this.params=m.params,this.sx=m.sx||1,this.sy=m.sy||1}toString(){return JSON.stringify(this)}static parse(d){let m,v,C,E;try{({id:m,params:v,sx:C,sy:E}=JSON.parse(d)||{})}catch{return null}return m?new Jx(m,{params:v,sx:C,sy:E}):null}scaleSelf(d,m=d){return this.sx*=d,this.sy*=m,this}}class Ou{constructor(d,m,v,C,E=!1){this.primaryId=Qs.from(d),this.primaryOptions=m,v&&(this.secondaryId=Qs.from(v)),this.secondaryOptions=C,this.available=E}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new Jx(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new Jx(this.secondaryId,this.secondaryOptions):null}static from(d){return typeof d=="string"?Ou.build({name:d}):d}static build(d,m,v,C){return!d||typeof d=="object"&&!("name"in d)?null:new Ou(d,v,m,C)}}function ev(x,d,m,v){return typeof x=="number"&&x>=0&&x<=255&&typeof d=="number"&&d>=0&&d<=255&&typeof m=="number"&&m>=0&&m<=255?v===void 0||typeof v=="number"&&v>=0&&v<=1?null:`Invalid rgba value [${[x,d,m,v].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof v=="number"?[x,d,m,v]:[x,d,m]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Y1(x){if(x===null||typeof x=="string"||typeof x=="boolean"||typeof x=="number"||x instanceof Ur||x instanceof zE||x instanceof Du||x instanceof Ou)return!0;if(Array.isArray(x)){for(const d of x)if(!Y1(d))return!1;return!0}if(typeof x=="object"){for(const d in x)if(!Y1(x[d]))return!1;return!0}return!1}function Tc(x){if(x===null)return Rp;if(typeof x=="string")return Da;if(typeof x=="boolean")return Si;if(typeof x=="number")return $r;if(x instanceof Ur)return dh;if(x instanceof zE)return IC;if(x instanceof Du)return Zw;if(x instanceof Ou)return Yw;if(Array.isArray(x)){const d=x.length;let m;for(const v of x){const C=Tc(v);if(m){if(m===C)continue;m=pi;break}m=C}return qd(m||pi,d)}return Ff}function Jm(x){const d=typeof x;return x===null?"":d==="string"||d==="number"||d==="boolean"?String(x):x instanceof Du||x instanceof Ou||x instanceof Ur?x.toString():JSON.stringify(x)}class eg{constructor(d,m){this.type=d,this.value=m}static parse(d,m){if(d.length!==2)return m.error(`'literal' expression requires exactly one argument, but found ${d.length-1} instead.`);if(!Y1(d[1]))return m.error("invalid value");const v=d[1];let C=Tc(v);const E=m.expectedType;return C.kind!=="array"||C.N!==0||!E||E.kind!=="array"||typeof E.N=="number"&&E.N!==0||(C=E),new eg(C,v)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Ur?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Du?this.value.serialize():this.value}}class cc{constructor(d){this.name="ExpressionEvaluationError",this.message=d}toJSON(){return this.message}}const BE={string:Da,number:$r,boolean:Si,object:Ff};class Fp{constructor(d,m){this.type=d,this.args=m}static parse(d,m){if(d.length<2)return m.error("Expected at least one argument.");let v,C=1;const E=d[0];if(E==="array"){let R,$;if(d.length>2){const G=d[1];if(typeof G!="string"||!(G in BE)||G==="object")return m.error('The item type argument of "array" must be one of string, number, boolean',1);R=BE[G],C++}else R=pi;if(d.length>3){if(d[2]!==null&&(typeof d[2]!="number"||d[2]<0||d[2]!==Math.floor(d[2])))return m.error('The length argument to "array" must be a positive integer literal',2);$=d[2],C++}v=qd(R,$)}else v=BE[E];const P=[];for(;Cd.outputDefined())}serialize(){const d=this.type,m=[d.kind];if(d.kind==="array"){const v=d.itemType;if(v.kind==="string"||v.kind==="number"||v.kind==="boolean"){m.push(v.kind);const C=d.N;(typeof C=="number"||this.args.length>1)&&m.push(C)}}return m.concat(this.args.map(v=>v.serialize()))}}class zf{constructor(d){this.type=Zw,this.sections=d}static parse(d,m){if(d.length<2)return m.error("Expected at least one argument.");const v=d[1];if(!Array.isArray(v)&&typeof v=="object")return m.error("First argument must be an image or text section.");const C=[];let E=!1;for(let P=1;P<=d.length-1;++P){const R=d[P];if(E&&typeof R=="object"&&!Array.isArray(R)){E=!1;let $=null;if(R["font-scale"]&&($=m.parseObjectValue(R["font-scale"],P,"font-scale",$r),!$))return null;let G=null;if(R["text-font"]&&(G=m.parseObjectValue(R["text-font"],P,"text-font",qd(Da)),!G))return null;let te=null;if(R["text-color"]&&(te=m.parseObjectValue(R["text-color"],P,"text-color",dh),!te))return null;const se=C[C.length-1];se.scale=$,se.font=G,se.textColor=te}else{const $=m.parse(d[P],P,pi);if(!$)return null;const G=$.type.kind;if(G!=="string"&&G!=="value"&&G!=="null"&&G!=="resolvedImage")return m.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");E=!0,C.push({content:$,scale:null,font:null,textColor:null})}}return new zf(C)}evaluate(d){return new Du(this.sections.map(m=>{const v=m.content.evaluate(d);return LC(Tc(v),Yw)?new DC("",v,null,null,null):new DC(Jm(v),null,m.scale?m.scale.evaluate(d):null,m.font?m.font.evaluate(d).join(","):null,m.textColor?m.textColor.evaluate(d):null)}))}eachChild(d){for(const m of this.sections)d(m.content),m.scale&&d(m.scale),m.font&&d(m.font),m.textColor&&d(m.textColor)}outputDefined(){return!1}serialize(){const d=["format"];for(const m of this.sections){d.push(m.content.serialize());const v={};m.scale&&(v["font-scale"]=m.scale.serialize()),m.font&&(v["text-font"]=m.font.serialize()),m.textColor&&(v["text-color"]=m.textColor.serialize()),d.push(v)}return d}}class Hn{constructor(d,m,v,C){this._imageWarnHistory={},this.type=Yw,this.namePrimary=d,this.nameSecondary=m,v&&(this.paramsPrimary=v.params,this.iconsetIdPrimary=v.iconset?v.iconset.id:void 0),C&&(this.paramsSecondary=C.params,this.iconsetIdSecondary=C.iconset?C.iconset.id:void 0)}static parse(d,m){if(d.length<2)return m.error("Expected two or more arguments.");let v=1;const C=[];function E(){if(vQs.isEqual(P,E)),C.available){const P=C.getSecondary()?C.getSecondary().id:null;P&&(C.available=d.availableImages.some(R=>Qs.isEqual(R,P)))}}return C}eachChild(d){if(d(this.namePrimary),this.paramsPrimary)for(const m in this.paramsPrimary)this.paramsPrimary[m]&&d(this.paramsPrimary[m]);if(this.nameSecondary&&(d(this.nameSecondary),this.paramsSecondary))for(const m in this.paramsSecondary)this.paramsSecondary[m]&&d(this.paramsSecondary[m])}outputDefined(){return!1}serializeOptions(d,m){const v={};if(m&&(v.iconset={id:m}),d){v.params={};for(const C in d)d[C]&&(v.params[C]=d[C].serialize())}return Object.keys(v).length>0?v:void 0}serialize(){const d=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const m=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);m&&d.push(m)}if(this.nameSecondary&&(d.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const m=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);m&&d.push(m)}return d}}function Fr(x){return yn(x)?"string":X1(x)?"number":RC(x)?"boolean":Array.isArray(x)?"array":x===null?"null":OC(x)?"object":typeof x}function OC(x){return x!=null&&!Array.isArray(x)&&typeof x!="function"&&!(x instanceof String||x instanceof Number||x instanceof Boolean)&&typeof x=="object"}function yn(x){return typeof x=="string"||x instanceof String}function X1(x){return typeof x=="number"||x instanceof Number}function RC(x){return typeof x=="boolean"||x instanceof Boolean}const mn={"to-boolean":Si,"to-color":dh,"to-number":$r,"to-string":Da};class Bf{constructor(d,m){this.type=d,this.args=m}static parse(d,m){if(d.length<2)return m.error("Expected at least one argument.");const v=d[0],C=[];let E=Rp;if(v==="to-array"){if(!Array.isArray(d[1]))return null;const P=d[1].length;if(m.expectedType){if(m.expectedType.kind!=="array")return m.error(`Expected ${m.expectedType.kind} but found array.`);E=qd(m.expectedType.itemType,P)}else{if(!(P>0&&Y1(d[1][0])))return null;E=qd(Tc(d[1][0]),P)}for(let R=0;R4?`Invalid rbga value ${JSON.stringify(m)}: expected an array containing either three or four numeric values.`:ev(m[0],m[1],m[2],m[3]),!v))return new Ur(m[0]/255,m[1]/255,m[2]/255,m[3])}throw new cc(v||`Could not parse color from value '${typeof m=="string"?m:String(JSON.stringify(m))}'`)}if(this.type.kind==="number"){let m=null;for(const v of this.args){if(m=v.evaluate(d),m===null)return 0;const C=Number(m);if(!isNaN(C))return C}throw new cc(`Could not convert ${JSON.stringify(m)} to number.`)}return this.type.kind==="formatted"?Du.fromString(Jm(this.args[0].evaluate(d))):this.type.kind==="resolvedImage"?Ou.build(Jm(this.args[0].evaluate(d))):this.type.kind==="array"?this.args.map(m=>m.evaluate(d)):Jm(this.args[0].evaluate(d))}eachChild(d){this.args.forEach(d)}outputDefined(){return this.args.every(d=>d.outputDefined())}serialize(){if(this.type.kind==="formatted")return new zf([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Hn(this.args[0]).serialize();const d=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(m=>{d.push(m.serialize())}),d}}const $E=["Unknown","Point","LineString","Polygon"];class FC{constructor(d,m,v){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=d,this.options=m,this.iconImageUseTheme=v}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?$E[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(d){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const d=this.featureDistanceData.center,m=this.featureDistanceData.scale,{x:v,y:C}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(v*m-d[0])+this.featureDistanceData.bearing[1]*(C*m-d[1])}return 0}parseColor(d){let m=this._parseColorCache[d];return m||(m=this._parseColorCache[d]=Ur.parse(d)),m}getConfig(d){return this.options?this.options.get(d):null}}class Ru{constructor(d,m,v,C,E){this.name=d,this.type=m,this._evaluate=v,this.args=C,this._overloadIndex=E}evaluate(d){if(!this._evaluate){const m=Ru.definitions[this.name];this._evaluate=Array.isArray(m)?m[2]:m.overloads[this._overloadIndex][1]}return this._evaluate(d,this.args)}eachChild(d){this.args.forEach(d)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(d=>d.serialize()))}static parse(d,m){const v=d[0],C=Ru.definitions[v];if(!C)return m.error(`Unknown expression "${v}". If you wanted a literal array, use ["literal", [...]].`,0);const E=Array.isArray(C)?C[0]:C.type,P=Array.isArray(C)?[[C[1],C[2]]]:C.overloads,R=[];let $=null,G=-1;for(const[te,se]of P){if(Array.isArray(te)&&te.length!==d.length-1)continue;R.push(te),G++,$=new YC(m.registry,m.path,null,m.scope,void 0,m._scope,m.options,m.iconImageUseTheme);const ae=[];let de=!1;for(let he=1;heae)).map(zC).join(" | "),se=[];for(let ae=1;aem;){if(v-m>600){const $=v-m+1,G=d-m+1,te=Math.log($),se=.5*Math.exp(2*te/3),ae=.5*Math.sqrt(te*se*($-se)/$)*(G-$/2<0?-1:1);BC(x,d,Math.max(m,Math.floor(d-G*se/$+ae)),Math.min(v,Math.floor(d+($-G)*se/$+ae)),C)}const E=x[d];let P=m,R=v;for(zp(x,m,d),C(x[v],E)>0&&zp(x,m,v);P0;)R--}C(x[m],E)===0?zp(x,m,R):(R++,zp(x,R,v)),R<=d&&(m=R+1),d<=R&&(v=R-1)}}function zp(x,d,m){const v=x[d];x[d]=x[m],x[m]=v}function qE(x,d){return xd?1:0}function wy(x){let d=0;for(let m,v,C=0,E=x.length,P=E-1;C=d[2]||x[1]<=d[1]||x[3]>=d[3])}function Nme(x,d,m){const v=x[0]-d[0],C=x[1]-d[1],E=x[0]-m[0],P=x[1]-m[1];return v*P-E*C==0&&v*E<=0&&C*P<=0}function Q1(x,d,m=!1){let v=!1;for(let R=0,$=d.length;R<$;R++){const G=d[R];for(let te=0,se=G.length,ae=se-1;te(C=x)[1]!=(P=he)[1]>C[1]&&C[0]<(P[0]-E[0])*(C[1]-E[1])/(P[1]-E[1])+E[0]&&(v=!v)}}var C,E,P;return v}function Jw(x,d,m,v){const C=v[0]-m[0],E=v[1]-m[1],P=(x[0]-m[0])*E-C*(x[1]-m[1]),R=(d[0]-m[0])*E-C*(d[1]-m[1]);return P>0&&R<0||P<0&&R>0}function e2(x,d,m,v){return(C=[v[0]-m[0],v[1]-m[1]])[0]*(E=[d[0]-x[0],d[1]-x[1]])[1]-C[1]*E[0]!=0&&!(!Jw(x,d,m,v)||!Jw(m,v,x,d));var C,E}function tg(x){const d=new pt(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),m=new pt(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const v of x[0])d.x>v.x&&(d.x=v.x),d.y>v.y&&(d.y=v.y),m.xm[2]){const C=.5*v;let E=x[0]-m[0]>C?-v:m[0]-x[0]>C?v:0;E===0&&(E=x[0]-m[2]>C?-v:m[2]-x[0]>C?v:0),x[0]+=E}ep(d,x)}function TR(x,d,m,v){const C=Math.pow(2,v.z)*jy,E=[v.x*jy,v.y*jy],P=[];if(!x)return P;for(const R of x)for(const $ of R){const G=[$.x+E[0],$.y+E[1]];MR(G,d,m,C),P.push(G)}return P}function $C(x,d,m,v){const C=Math.pow(2,v.z)*jy,E=[v.x*jy,v.y*jy],P=[];if(!x)return P;for(const $ of x){const G=[];for(const te of $){const se=[te.x+E[0],te.y+E[1]];ep(d,se),G.push(se)}P.push(G)}if(d[2]-d[0]<=C/2){(R=d)[0]=R[1]=1/0,R[2]=R[3]=-1/0;for(const $ of P)for(const G of $)MR(G,d,m,C)}var R;return P}class ky{constructor(d,m){this.type=Si,this.geojson=d,this.geometries=m}static parse(d,m){if(d.length!==2)return m.error(`'within' expression requires exactly one argument, but found ${d.length-1} instead.`);if(Y1(d[1])){const v=d[1];if(v.type==="FeatureCollection")for(let C=0;Cm)return qC(E,P,(m-(v-R))/R)}return d[d.length-1]}pointToSegmentDistance(d,m,v){let[C,E]=m,P=lm(v[0]-C)*this.kx,R=(v[1]-E)*this.ky;if(P!==0||R!==0){const $=(lm(d[0]-C)*this.kx*P+(d[1]-E)*this.ky*R)/(P*P+R*R);$>1?(C=v[0],E=v[1]):$>0&&(C+=P/this.kx*$,E+=R/this.ky*$)}return P=lm(d[0]-C)*this.kx,R=(d[1]-E)*this.ky,Math.sqrt(P*P+R*R)}pointOnLine(d,m){let v=1/0,C=d[0][0],E=d[0][1],P=0,R=0;for(let $=0;$1?(G=d[$+1][0],te=d[$+1][1]):de>0&&(G+=se/this.kx*de,te+=ae/this.ky*de)),se=lm(m[0]-G)*this.kx,ae=(m[1]-te)*this.ky;const he=se*se+ae*ae;heE.index||C.index===E.index&&C.t>E.t){const G=C;C=E,E=G}const P=[C.point],R=C.index+1,$=E.index;!HE(v[R],P[0])&&R<=$&&P.push(v[R]);for(let G=R+1;G<=$;G++)P.push(v[G]);return HE(v[$],E.point)||P.push(E.point),P}lineSliceAlong(d,m,v){let C=0;const E=[];for(let P=0;Pd&&E.length===0&&E.push(qC(R,$,(d-(C-G))/G)),C>=m)return E.push(qC(R,$,(m-(C-G))/G)),E;C>d&&E.push($)}return E}bufferPoint(d,m){const v=m/this.ky,C=m/this.kx;return[d[0]-C,d[1]-v,d[0]+C,d[1]+v]}bufferBBox(d,m){const v=m/this.ky,C=m/this.kx;return[d[0]-C,d[1]-v,d[2]+C,d[3]+v]}insideBBox(d,m){return lm(d[0]-m[0])>=0&&lm(d[0]-m[2])<=0&&d[1]>=m[1]&&d[1]<=m[3]}}function HE(x,d){return x[0]===d[0]&&x[1]===d[1]}function qC(x,d,m){const v=lm(d[0]-x[0]);return[x[0]+v*m,x[1]+(d[1]-x[1])*m]}function lm(x){for(;x<-180;)x+=360;for(;x>180;)x-=360;return x}class UC{constructor(d=[],m=(v,C)=>vC?1:0){if(this.data=d,this.length=this.data.length,this.compare=m,this.length>0)for(let v=(this.length>>1)-1;v>=0;v--)this._down(v)}push(d){this.data.push(d),this._up(this.length++)}pop(){if(this.length===0)return;const d=this.data[0],m=this.data.pop();return--this.length>0&&(this.data[0]=m,this._down(0)),d}peek(){return this.data[0]}_up(d){const{data:m,compare:v}=this,C=m[d];for(;d>0;){const E=d-1>>1,P=m[E];if(v(C,P)>=0)break;m[d]=P,d=E}m[d]=C}_down(d){const{data:m,compare:v}=this,C=this.length>>1,E=m[d];for(;d=0)break;m[d]=m[P],d=P}m[d]=E}}var tr=8192;function WE(x,d){return d.dist-x.dist}const VC=100,HC=50;function GE(x){const d=[1/0,1/0,-1/0,-1/0];if(d.length!==x.length)return!1;for(let m=0;m=x[0]&&x[1]x[1])return[null,null];const m=s2(x);if(d){if(m===2)return[x,null];const v=Math.floor(m/2);return[[x[0],x[0]+v],[x[0]+v,x[1]]]}{if(m===1)return[x,null];const v=Math.floor(m/2)-1;return[[x[0],x[0]+v],[x[0]+v+1,x[1]]]}}function tv(x,d){const m=[1/0,1/0,-1/0,-1/0];if(!$f(d,x.length))return m;for(let v=d[0];v<=d[1];++v)ep(m,x[v]);return m}function sv(x){const d=[1/0,1/0,-1/0,-1/0];for(let m=0;md[2]&&(v=x[0]-d[2]),x[1]>d[3]&&(C=x[1]-d[3]),x[3]=v)return v;if(Qw(C,E)){if(YE(x,d))return 0}else if(YE(d,x))return 0;let P=v;for(const R of x)for(let $=0,G=R.length,te=G-1;$=E)continue;const te=G.range1;if(s2(te)<=R){if(!$f(te,x.length))return NaN;if(d){const se=Ame(x,te,m,v);if((E=Math.min(E,se))===0)return E}else for(let se=te[0];se<=te[1];++se){const ae=Tme(x[se],m,v);if((E=Math.min(E,ae))===0)return E}}else{const se=KE(te,d);if(se[0]!==null){const ae=Sy(tv(x,se[0]),$,v);ae=P)continue;const se=te.range1,ae=te.range2;if(s2(se)<=$&&s2(ae)<=G){if(!$f(se,x.length)||!$f(ae,m.length))return NaN;if(d&&v?P=Math.min(P,Fa(x,se,m,ae,C)):d||v?d&&!v?P=Math.min(P,ZE(m,ae,x,se,C)):!d&&v&&(P=Math.min(P,ZE(x,se,m,ae,C))):P=Math.min(P,Mme(x,se,m,ae,C)),P===0)return P}else{const de=KE(se,d),he=KE(ae,v);ho(R,P,C,x,m,de[0],he[0]),ho(R,P,C,x,m,de[0],he[1]),ho(R,P,C,x,m,de[1],he[0]),ho(R,P,C,x,m,de[1],he[1])}}return P}function XE(x,d,m,v,C=1/0){let E=C;const P=tv(x,[0,x.length-1]);for(const R of m)if(!(E!==1/0&&Sy(P,tv(R,[0,R.length-1]),v)>=E)&&(E=Math.min(E,IR(x,d,R,!0,v,E)),E===0))return E;return E}function KC(x,d,m,v,C=1/0){let E=C;const P=tv(x,[0,x.length-1]);for(const R of m){if(E!==1/0&&Sy(P,sv(R),v)>=E)continue;const $=Pme(x,d,R,v,E);if(isNaN($))return $;if((E=Math.min(E,$))===0)return E}return E}function QE(x){return x==="Point"||x==="MultiPoint"||x==="LineString"||x==="MultiLineString"||x==="Polygon"||x==="MultiPolygon"}class rv{constructor(d,m){this.type=$r,this.geojson=d,this.geometries=m}static parse(d,m){if(d.length!==2)return m.error(`'distance' expression requires either one argument, but found ' ${d.length-1} instead.`);if(Y1(d[1])){const v=d[1];if(v.type==="FeatureCollection"){for(let C=0;C{d&&!tb(m)&&(d=!1)}),d}function r2(x){if(x instanceof Ru&&x.name==="feature-state")return!1;let d=!0;return x.eachChild(m=>{d&&!r2(m)&&(d=!1)}),d}function sb(x,d){if(x instanceof Ru&&d.indexOf(x.name)>=0)return!1;let m=!0;return x.eachChild(v=>{m&&!sb(v,d)&&(m=!1)}),m}function LR(x,d,m){return[x,d,m].filter(Boolean).join("")}function JE(x,d){switch(x){case"string":return Jm(d);case"number":return+d;case"boolean":return!!d;case"color":return Ur.parse(d);case"formatted":return Du.fromString(Jm(d));case"resolvedImage":return Ou.build(Jm(d))}return d}function DR(x,d,m,v){return v!==void 0&&(x=v*Math.round(x/v)),d!==void 0&&xm&&(x=m),x}class rb{constructor(d,m,v,C=!1){this.type=d,this.key=m,this.scope=v,this.featureConstant=C}static parse(d,m){let v=m.expectedType;if(v==null&&(v=pi),d.length<2||d.length>3)return m.error("Invalid number of arguments for 'config' expression.");const C=m.parse(d[1],1);if(!(C instanceof eg))return m.error("Key name of 'config' expression must be a string literal.");let E,P=!0;const R=Jm(C.value);if(d.length>=3){const $=m.parse(d[2],2);if(!($ instanceof eg))return m.error("Scope of 'config' expression must be a string literal.");E=Jm($.value)}if(m.options){const $=LR(R,E,m._scope),G=m.options.get($);G&&(P=tb(G.value||G.default))}return new rb(v,R,E,P)}evaluate(d){const m=LR(this.key,this.scope,d.scope),v=d.getConfig(m);if(!v)return null;const{type:C,value:E,values:P,minValue:R,maxValue:$,stepValue:G}=v,te=v.default.evaluate(d);let se=te;if(E){const ae=d.scope;d.scope=(ae||"").split("").slice(1).join(""),se=E.evaluate(d),d.scope=ae}return C&&(se=JE(C,se)),se===void 0||R===void 0&&$===void 0&&G===void 0||(typeof se=="number"?se=DR(se,R,$,G):Array.isArray(se)&&(se=se.map(ae=>typeof ae=="number"?DR(ae,R,$,G):ae))),E!==void 0&&se!==void 0&&P&&!P.includes(se)&&(se=te,C&&(se=JE(C,se))),(C&&C!==this.type||se!==void 0&&!LC(Tc(se),this.type))&&(se=JE(this.type.kind,se)),se}eachChild(){}outputDefined(){return!1}serialize(){const d=["config",this.key];return this.scope&&d.concat(this.scope),d}}class ZC{constructor(d,m){this.type=m.type,this.name=d,this.boundExpression=m}static parse(d,m){if(d.length!==2||typeof d[1]!="string")return m.error("'var' expression requires exactly one string literal argument.");const v=d[1];return m.scope.has(v)?new ZC(v,m.scope.get(v)):m.error(`Unknown variable "${v}". Make sure "${v}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(d){return this.boundExpression.evaluate(d)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class YC{constructor(d,m=[],v,C=new Z1,E=[],P,R,$){this.registry=d,this.path=m,this.key=m.map(G=>typeof G=="string"?`['${G}']`:`[${G}]`).join(""),this.scope=C,this.errors=E,this.expectedType=v,this._scope=P,this.options=R,this.iconImageUseTheme=$}parse(d,m,v,C,E={}){return m||v?this.concat(m,null,v,C)._parse(d,E):this._parse(d,E)}parseObjectValue(d,m,v,C,E,P={}){return this.concat(m,v,C,E)._parse(d,P)}_parse(d,m){function v(C,E,P){return P==="assert"?new Fp(E,[C]):P==="coerce"?new Bf(E,[C]):C}if(d!==null&&typeof d!="string"&&typeof d!="boolean"&&typeof d!="number"||(d=["literal",d]),Array.isArray(d)){if(d.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const C=typeof d[0]=="string"?this.registry[d[0]]:void 0;if(C){let E=C.parse(d,this);if(!E)return null;if(this.expectedType){const P=this.expectedType,R=E.type;if(P.kind!=="string"&&P.kind!=="number"&&P.kind!=="boolean"&&P.kind!=="object"&&P.kind!=="array"||R.kind!=="value")if(P.kind!=="color"&&P.kind!=="formatted"&&P.kind!=="resolvedImage"||R.kind!=="value"&&R.kind!=="string"){if(this.checkSubtype(P,R))return null}else E=v(E,P,m.typeAnnotation||"coerce");else E=v(E,P,m.typeAnnotation||"assert")}if(!(E instanceof eg)&&E.type.kind!=="resolvedImage"&&e6(E)){const P=new FC(this._scope,this.options,this.iconImageUseTheme);try{E=new eg(E.type,E.evaluate(P))}catch(R){return this.error(R.message),null}}return E}return Bf.parse(["to-array",d],this)}return this.error(d===void 0?"'undefined' value invalid. Use null instead.":typeof d=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof d} instead.`)}concat(d,m,v,C){let E=typeof d=="number"?this.path.concat(d):this.path;E=typeof m=="string"?E.concat(m):E;const P=C?this.scope.concat(C):this.scope;return new YC(this.registry,E,v||null,P,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(d,...m){const v=`${this.key}${m.map(C=>`[${C}]`).join("")}`;this.errors.push(new Qm(v,d))}checkSubtype(d,m){const v=_y(d,m);return v&&this.error(v),v}}function e6(x){if(x instanceof ZC)return e6(x.boundExpression);if(x instanceof Ru&&x.name==="error"||x instanceof Gc||x instanceof ky||x instanceof rv||x instanceof rb)return!1;const d=x instanceof Bf||x instanceof Fp;let m=!0;return x.eachChild(v=>{m=d?m&&e6(v):m&&v instanceof eg}),!!m&&tb(x)&&sb(x,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function XC(x,d){const m=x.length-1;let v,C,E=0,P=m,R=0;for(;E<=P;)if(R=Math.floor((E+P)/2),v=x[R],C=x[R+1],v<=d){if(R===m||dd))throw new cc("Input is not a number.");P=R-1}return 0}class n2{constructor(d,m,v){this.type=d,this.input=m,this.labels=[],this.outputs=[];for(const[C,E]of v)this.labels.push(C),this.outputs.push(E)}static parse(d,m){if(d.length-1<4)return m.error(`Expected at least 4 arguments, but found only ${d.length-1}.`);if((d.length-1)%2!=0)return m.error("Expected an even number of arguments.");const v=m.parse(d[1],1,$r);if(!v)return null;const C=[];let E=null;m.expectedType&&m.expectedType.kind!=="value"&&(E=m.expectedType);for(let P=1;P=R)return m.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',G);const se=m.parse($,te,E);if(!se)return null;E=E||se.type,C.push([R,se])}return new n2(E,v,C)}evaluate(d){const m=this.labels,v=this.outputs;if(m.length===1)return v[0].evaluate(d);const C=this.input.evaluate(d);if(C<=m[0])return v[0].evaluate(d);const E=m.length;return C>=m[E-1]?v[E-1].evaluate(d):v[XC(m,C)].evaluate(d)}eachChild(d){d(this.input);for(const m of this.outputs)d(m)}outputDefined(){return this.outputs.every(d=>d.outputDefined())}serialize(){const d=["step",this.input.serialize()];for(let m=0;m0&&d.push(this.labels[m]),d.push(this.outputs[m].serialize());return d}}const OR=.95047,RR=1.08883,FR=4/29,nb=6/29,zR=3*nb*nb,Ime=nb*nb*nb,Lme=Math.PI/180,Dme=180/Math.PI;function t6(x){return x>Ime?Math.pow(x,1/3):x/zR+FR}function s6(x){return x>nb?x*x*x:zR*(x-FR)}function r6(x){return 255*(x<=.0031308?12.92*x:1.055*Math.pow(x,1/2.4)-.055)}function n6(x){return(x/=255)<=.04045?x/12.92:Math.pow((x+.055)/1.055,2.4)}function BR(x){const d=n6(x.r),m=n6(x.g),v=n6(x.b),C=t6((.4124564*d+.3575761*m+.1804375*v)/OR),E=t6((.2126729*d+.7151522*m+.072175*v)/1);return{l:116*E-16,a:500*(C-E),b:200*(E-t6((.0193339*d+.119192*m+.9503041*v)/RR)),alpha:x.a}}function QC(x){let d=(x.l+16)/116,m=isNaN(x.a)?d:d+x.a/500,v=isNaN(x.b)?d:d-x.b/200;return d=1*s6(d),m=OR*s6(m),v=RR*s6(v),new Ur(r6(3.2404542*m-1.5371385*d-.4985314*v),r6(-.969266*m+1.8760108*d+.041556*v),r6(.0556434*m-.2040259*d+1.0572252*v),x.alpha)}function JC(x,d,m){const v=d-x;return x+m*(v>180||v<-180?v-360*Math.round(v/360):v)}const ab={forward:BR,reverse:QC,interpolate:function(x,d,m){return{l:Zr(x.l,d.l,m),a:Zr(x.a,d.a,m),b:Zr(x.b,d.b,m),alpha:Zr(x.alpha,d.alpha,m)}}},a2={forward:function(x){const{l:d,a:m,b:v}=BR(x),C=Math.atan2(v,m)*Dme;return{h:C<0?C+360:C,c:Math.sqrt(m*m+v*v),l:d,alpha:x.a}},reverse:function(x){const d=x.h*Lme,m=x.c;return QC({l:x.l,a:Math.cos(d)*m,b:Math.sin(d)*m,alpha:x.alpha})},interpolate:function(x,d,m){return{h:JC(x.h,d.h,m),c:Zr(x.c,d.c,m),l:Zr(x.l,d.l,m),alpha:Zr(x.alpha,d.alpha,m)}}};var $R=Object.freeze({__proto__:null,hcl:a2,lab:ab});class cm{constructor(d,m,v,C,E){this.type=d,this.operator=m,this.interpolation=v,this.input=C,this.labels=[],this.outputs=[];for(const[P,R]of E)this.labels.push(P),this.outputs.push(R)}static interpolationFactor(d,m,v,C){let E=0;if(d.name==="exponential")E=e3(m,d.base,v,C);else if(d.name==="linear")E=e3(m,1,v,C);else if(d.name==="cubic-bezier"){const P=d.controlPoints;E=new vi(P[0],P[1],P[2],P[3]).solve(e3(m,1,v,C))}return E}static parse(d,m){let[v,C,E,...P]=d;if(!Array.isArray(C)||C.length===0)return m.error("Expected an interpolation type expression.",1);if(C[0]==="linear")C={name:"linear"};else if(C[0]==="exponential"){const G=C[1];if(typeof G!="number")return m.error("Exponential interpolation requires a numeric base.",1,1);C={name:"exponential",base:G}}else{if(C[0]!=="cubic-bezier")return m.error(`Unknown interpolation type ${String(C[0])}`,1,0);{const G=C.slice(1);if(G.length!==4||G.some(te=>typeof te!="number"||te<0||te>1))return m.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);C={name:"cubic-bezier",controlPoints:G}}}if(d.length-1<4)return m.error(`Expected at least 4 arguments, but found only ${d.length-1}.`);if(d.length-1>3&&(d.length-1)%2!=0)return m.error("Expected an even number of arguments.");if(E=m.parse(E,2,$r),!E)return null;const R=[];let $=null;v==="interpolate-hcl"||v==="interpolate-lab"?$=dh:m.expectedType&&m.expectedType.kind!=="value"&&($=m.expectedType);for(let G=0;G=te)return m.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',ae);const he=m.parse(se,de,$);if(!he)return null;$=$||he.type,R.push([te,he])}return $.kind==="number"||$.kind==="color"||$.kind==="array"&&$.itemType.kind==="number"&&typeof $.N=="number"?new cm($,v,C,E,R):m.error(`Type ${_l($)} is not interpolatable.`)}evaluate(d){const m=this.labels,v=this.outputs;if(m.length===1)return v[0].evaluate(d);const C=this.input.evaluate(d);if(C<=m[0])return v[0].evaluate(d);const E=m.length;if(C>=m[E-1])return v[E-1].evaluate(d);const P=XC(m,C),R=cm.interpolationFactor(this.interpolation,C,m[P],m[P+1]),$=v[P].evaluate(d),G=v[P+1].evaluate(d);return this.operator==="interpolate"?J0[this.type.kind.toLowerCase()]($,G,R):this.operator==="interpolate-hcl"?a2.reverse(a2.interpolate(a2.forward($),a2.forward(G),R)):ab.reverse(ab.interpolate(ab.forward($),ab.forward(G),R))}eachChild(d){d(this.input);for(const m of this.outputs)d(m)}outputDefined(){return this.outputs.every(d=>d.outputDefined())}serialize(){let d;d=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const m=[this.operator,d,this.input.serialize()];for(let v=0;v_y(C,R.type));return new i2(P?pi:v,E)}evaluate(d){let m,v=null,C=0;for(const E of this.args){if(C++,v=E.evaluate(d),v&&v instanceof Ou&&!v.available&&(m||(m=v),v=null,C===this.args.length))return m;if(v!==null)break}return v}eachChild(d){this.args.forEach(d)}outputDefined(){return this.args.every(d=>d.outputDefined())}serialize(){const d=["coalesce"];return this.eachChild(m=>{d.push(m.serialize())}),d}}class sg{constructor(d,m){this.type=m.type,this.bindings=[].concat(d),this.result=m}evaluate(d){return this.result.evaluate(d)}eachChild(d){for(const m of this.bindings)d(m[1]);d(this.result)}static parse(d,m){if(d.length<4)return m.error(`Expected at least 3 arguments, but found ${d.length-1} instead.`);const v=[];for(let E=1;E=v.length)throw new cc("Array index out of bounds: index exceeds array size");if(m!==Math.floor(m))throw new cc("Array index must be an integer. Use at-interpolated for fractional indices");return v[m]}eachChild(d){d(this.index),d(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class s3{constructor(d,m,v){this.type=d,this.index=m,this.input=v}static parse(d,m){if(d.length!==3)return m.error(`Expected 2 arguments, but found ${d.length-1} instead.`);const v=m.parse(d[1],1,$r),C=m.parse(d[2],2,qd(m.expectedType||pi));return v&&C?new s3(C.type.itemType,v,C):null}evaluate(d){const m=this.index.evaluate(d),v=this.input.evaluate(d);if(m<0)throw new cc(`Array index out of bounds: ${m} < 0.`);if(m>v.length-1)throw new cc(`Array index out of bounds: ${m} > ${v.length-1}.`);if(m===Math.floor(m))return v[m];const C=Math.floor(m),E=Math.ceil(m),P=v[C],R=v[E];if(typeof P!="number"||typeof R!="number")throw new cc(`Cannot interpolate between non-number values at index ${m}.`);const $=m-C;return P*(1-$)+R*$}eachChild(d){d(this.index),d(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class a6{constructor(d,m){this.type=Si,this.needle=d,this.haystack=m}static parse(d,m){if(d.length!==3)return m.error(`Expected 2 arguments, but found ${d.length-1} instead.`);const v=m.parse(d[1],1,pi),C=m.parse(d[2],2,pi);return v&&C?FE(v.type,[Si,Da,$r,Rp,pi])?new a6(v,C):m.error(`Expected first argument to be of type boolean, string, number or null, but found ${_l(v.type)} instead`):null}evaluate(d){const m=this.needle.evaluate(d),v=this.haystack.evaluate(d);if(v==null)return!1;if(!Xw(m,["boolean","string","number","null"]))throw new cc(`Expected first argument to be of type boolean, string, number or null, but found ${_l(Tc(m))} instead.`);if(!Xw(v,["string","array"]))throw new cc(`Expected second argument to be of type array or string, but found ${_l(Tc(v))} instead.`);return v.indexOf(m)>=0}eachChild(d){d(this.needle),d(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class ib{constructor(d,m,v){this.type=$r,this.needle=d,this.haystack=m,this.fromIndex=v}static parse(d,m){if(d.length<=2||d.length>=5)return m.error(`Expected 3 or 4 arguments, but found ${d.length-1} instead.`);const v=m.parse(d[1],1,pi),C=m.parse(d[2],2,pi);if(!v||!C)return null;if(!FE(v.type,[Si,Da,$r,Rp,pi]))return m.error(`Expected first argument to be of type boolean, string, number or null, but found ${_l(v.type)} instead`);if(d.length===4){const E=m.parse(d[3],3,$r);return E?new ib(v,C,E):null}return new ib(v,C)}evaluate(d){const m=this.needle.evaluate(d),v=this.haystack.evaluate(d);if(!Xw(m,["boolean","string","number","null"]))throw new cc(`Expected first argument to be of type boolean, string, number or null, but found ${_l(Tc(m))} instead.`);if(!Xw(v,["string","array"]))throw new cc(`Expected second argument to be of type array or string, but found ${_l(Tc(v))} instead.`);if(this.fromIndex){const C=this.fromIndex.evaluate(d);return v.indexOf(m,C)}return v.indexOf(m)}eachChild(d){d(this.needle),d(this.haystack),this.fromIndex&&d(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const d=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),d]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class o2{constructor(d,m,v,C,E,P){this.inputType=d,this.type=m,this.input=v,this.cases=C,this.outputs=E,this.otherwise=P}static parse(d,m){if(d.length<5)return m.error(`Expected at least 4 arguments, but found only ${d.length-1}.`);if(d.length%2!=1)return m.error("Expected an even number of arguments.");let v,C;m.expectedType&&m.expectedType.kind!=="value"&&(C=m.expectedType);const E={},P=[];for(let G=2;GNumber.MAX_SAFE_INTEGER)return ae.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof he=="number"&&Math.floor(he)!==he)return ae.error("Numeric branch labels must be integer values.");if(v){if(ae.checkSubtype(v,Tc(he)))return null}else v=Tc(he);if(E[String(he)]!==void 0)return ae.error("Branch labels must be unique.");E[String(he)]=P.length}const de=m.parse(se,G,C);if(!de)return null;C=C||de.type,P.push(de)}const R=m.parse(d[1],1,pi);if(!R)return null;const $=m.parse(d[d.length-1],d.length-1,C);return $?R.type.kind!=="value"&&m.concat(1).checkSubtype(v,R.type)?null:new o2(v,C,R,E,P,$):null}evaluate(d){const m=this.input.evaluate(d);return(LC(Tc(m),this.inputType)&&this.outputs[this.cases[m]]||this.otherwise).evaluate(d)}eachChild(d){d(this.input),this.outputs.forEach(d),d(this.otherwise)}outputDefined(){return this.outputs.every(d=>d.outputDefined())&&this.otherwise.outputDefined()}serialize(){const d=["match",this.input.serialize()],m=Object.keys(this.cases).sort(),v=[],C={};for(const P of m){const R=C[this.cases[P]];R===void 0?(C[this.cases[P]]=v.length,v.push([this.cases[P],[P]])):v[R][1].push(P)}const E=P=>this.inputType.kind==="number"?Number(P):P;for(const[P,R]of v)d.push(R.length===1?E(R[0]):R.map(E)),d.push(this.outputs[P].serialize());return d.push(this.otherwise.serialize()),d}}class l2{constructor(d,m,v){this.type=d,this.branches=m,this.otherwise=v}static parse(d,m){if(d.length<4)return m.error(`Expected at least 3 arguments, but found only ${d.length-1}.`);if(d.length%2!=0)return m.error("Expected an odd number of arguments.");let v;m.expectedType&&m.expectedType.kind!=="value"&&(v=m.expectedType);const C=[];for(let P=1;Pm.outputDefined())&&this.otherwise.outputDefined()}serialize(){const d=["case"];return this.eachChild(m=>{d.push(m.serialize())}),d}}class r3{constructor(d,m,v,C){this.type=d,this.input=m,this.beginIndex=v,this.endIndex=C}static parse(d,m){if(d.length<=2||d.length>=5)return m.error(`Expected 3 or 4 arguments, but found ${d.length-1} instead.`);const v=m.parse(d[1],1,pi),C=m.parse(d[2],2,$r);if(!v||!C)return null;if(!FE(v.type,[qd(pi),Da,pi]))return m.error(`Expected first argument to be of type array or string, but found ${_l(v.type)} instead`);if(d.length===4){const E=m.parse(d[3],3,$r);return E?new r3(v.type,v,C,E):null}return new r3(v.type,v,C)}evaluate(d){const m=this.input.evaluate(d),v=this.beginIndex.evaluate(d);if(!Xw(m,["string","array"]))throw new cc(`Expected first argument to be of type array or string, but found ${_l(Tc(m))} instead.`);if(this.endIndex){const C=this.endIndex.evaluate(d);return m.slice(v,C)}return m.slice(v)}eachChild(d){d(this.input),d(this.beginIndex),this.endIndex&&d(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const d=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),d]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class i6{constructor(d,m){this.type=qd(Da),this.str=d,this.delimiter=m}static parse(d,m){if(d.length!==3)return m.error(`Expected 2 arguments, but found ${d.length-1} instead.`);const v=m.parse(d[1],1,Da),C=m.parse(d[2],2,Da);return v&&C?new i6(v,C):void 0}evaluate(d){const m=this.str.evaluate(d),v=this.delimiter.evaluate(d);return m.split(v)}eachChild(d){d(this.str),d(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function o6(x,d){return x==="=="||x==="!="?d.kind==="boolean"||d.kind==="string"||d.kind==="number"||d.kind==="null"||d.kind==="value":d.kind==="string"||d.kind==="number"||d.kind==="value"}function l6(x,d,m,v){return v.compare(d,m)===0}function ob(x,d,m){const v=x!=="=="&&x!=="!=";return class fWe{constructor(E,P,R){this.type=Si,this.lhs=E,this.rhs=P,this.collator=R,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 R=E[0];let $=P.parse(E[1],1,pi);if(!$)return null;if(!o6(R,$.type))return P.concat(1).error(`"${R}" comparisons are not supported for type '${_l($.type)}'.`);let G=P.parse(E[2],2,pi);if(!G)return null;if(!o6(R,G.type))return P.concat(2).error(`"${R}" comparisons are not supported for type '${_l(G.type)}'.`);if($.type.kind!==G.type.kind&&$.type.kind!=="value"&&G.type.kind!=="value")return P.error(`Cannot compare types '${_l($.type)}' and '${_l(G.type)}'.`);v&&($.type.kind==="value"&&G.type.kind!=="value"?$=new Fp(G.type,[$]):$.type.kind!=="value"&&G.type.kind==="value"&&(G=new Fp($.type,[G])));let te=null;if(E.length===4){if($.type.kind!=="string"&&G.type.kind!=="string"&&$.type.kind!=="value"&&G.type.kind!=="value")return P.error("Cannot use collator to compare non-string types.");if(te=P.parse(E[3],3,IC),!te)return null}return new fWe($,G,te)}evaluate(E){const P=this.lhs.evaluate(E),R=this.rhs.evaluate(E);if(v&&this.hasUntypedArgument){const $=Tc(P),G=Tc(R);if($.kind!==G.kind||$.kind!=="string"&&$.kind!=="number")throw new cc(`Expected arguments for "${x}" to be (string, string) or (number, number), but found (${$.kind}, ${G.kind}) instead.`)}if(this.collator&&!v&&this.hasUntypedArgument){const $=Tc(P),G=Tc(R);if($.kind!=="string"||G.kind!=="string")return d(E,P,R)}return this.collator?m(E,P,R,this.collator.evaluate(E)):d(E,P,R)}eachChild(E){E(this.lhs),E(this.rhs),this.collator&&E(this.collator)}outputDefined(){return!0}serialize(){const E=[x];return this.eachChild(P=>{E.push(P.serialize())}),E}}}const Ome=ob("==",function(x,d,m){return d===m},l6),Rme=ob("!=",function(x,d,m){return d!==m},function(x,d,m,v){return!l6(0,d,m,v)}),qR=ob("<",function(x,d,m){return d",function(x,d,m){return d>m},function(x,d,m,v){return v.compare(d,m)>0}),n3=ob("<=",function(x,d,m){return d<=m},function(x,d,m,v){return v.compare(d,m)<=0}),Fme=ob(">=",function(x,d,m){return d>=m},function(x,d,m,v){return v.compare(d,m)>=0});class a3{constructor(d,m,v,C,E,P){this.type=Da,this.number=d,this.locale=m,this.currency=v,this.unit=C,this.minFractionDigits=E,this.maxFractionDigits=P}static parse(d,m){if(d.length!==3)return m.error("Expected two arguments.");const v=m.parse(d[1],1,$r);if(!v)return null;const C=d[2];if(typeof C!="object"||Array.isArray(C))return m.error("NumberFormat options argument must be an object.");let E=null;if(C.locale&&(E=m.parseObjectValue(C.locale,2,"locale",Da),!E))return null;let P=null;if(C.currency&&(P=m.parseObjectValue(C.currency,2,"currency",Da),!P))return null;let R=null;if(C.unit&&(R=m.parseObjectValue(C.unit,2,"unit",Da),!R))return null;let $=null;if(C["min-fraction-digits"]&&($=m.parseObjectValue(C["min-fraction-digits"],2,"min-fraction-digits",$r),!$))return null;let G=null;return C["max-fraction-digits"]&&(G=m.parseObjectValue(C["max-fraction-digits"],2,"max-fraction-digits",$r),!G)?null:new a3(v,E,P,R,$,G)}evaluate(d){return new Intl.NumberFormat(this.locale?this.locale.evaluate(d):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(d):void 0,unit:this.unit?this.unit.evaluate(d):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(d):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(d):void 0}).format(this.number.evaluate(d))}eachChild(d){d(this.number),this.locale&&d(this.locale),this.currency&&d(this.currency),this.unit&&d(this.unit),this.minFractionDigits&&d(this.minFractionDigits),this.maxFractionDigits&&d(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const d={};return this.locale&&(d.locale=this.locale.serialize()),this.currency&&(d.currency=this.currency.serialize()),this.unit&&(d.unit=this.unit.serialize()),this.minFractionDigits&&(d["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(d["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),d]}}class c6{constructor(d){this.type=$r,this.input=d}static parse(d,m){if(d.length!==2)return m.error(`Expected 1 argument, but found ${d.length-1} instead.`);const v=m.parse(d[1],1);return v?v.type.kind!=="array"&&v.type.kind!=="string"&&v.type.kind!=="value"?m.error(`Expected argument of type string or array, but found ${_l(v.type)} instead.`):new c6(v):null}evaluate(d){const m=this.input.evaluate(d);if(typeof m=="string"||Array.isArray(m))return m.length;throw new cc(`Expected value to be of type string or array, but found ${_l(Tc(m))} instead.`)}eachChild(d){d(this.input)}outputDefined(){return!1}serialize(){const d=["length"];return this.eachChild(m=>{d.push(m.serialize())}),d}}function VR(x){return function(){x=1831565813+(x|=0)|0;let d=Math.imul(x^x>>>15,1|x);return d=d+Math.imul(d^d>>>7,61|d)^d,((d^d>>>14)>>>0)/4294967296}}const lb={"==":Ome,"!=":Rme,">":UR,"<":qR,">=":Fme,"<=":n3,array:Fp,at:t3,"at-interpolated":s3,boolean:Fp,case:l2,coalesce:i2,collator:Gc,format:zf,image:Hn,in:a6,"index-of":ib,interpolate:cm,"interpolate-hcl":cm,"interpolate-lab":cm,length:c6,let:sg,literal:eg,match:o2,number:Fp,"number-format":a3,object:Fp,slice:r3,step:n2,string:Fp,"to-boolean":Bf,"to-color":Bf,"to-number":Bf,"to-string":Bf,var:ZC,within:ky,distance:rv,config:rb,split:i6};function d6(x,[d,m,v,C]){d=d.evaluate(x),m=m.evaluate(x),v=v.evaluate(x);const E=C?C.evaluate(x):1,P=ev(d,m,v,E);if(P)throw new cc(P);return new Ur(d/255,m/255,v/255,E)}function u6(x,[d,m,v,C]){d=d.evaluate(x),m=m.evaluate(x),v=v.evaluate(x);const E=C?C.evaluate(x):1,P=function(G,te,se,ae){return typeof G=="number"&&G>=0&&G<=360?typeof te=="number"&&te>=0&&te<=100&&typeof se=="number"&&se>=0&&se<=100?ae===void 0||typeof ae=="number"&&ae>=0&&ae<=1?null:`Invalid hsla value [${[G,te,se,ae].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof ae=="number"?[G,te,se,ae]:[G,te,se]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof ae=="number"?[G,te,se,ae]:[G,te,se]).join(", ")}]: 'h' must be between 0 and 360.`}(d,m,v,E);if(P)throw new cc(P);const R=`hsla(${d}, ${m}%, ${v}%, ${E})`,$=Ur.parse(R);if(!$)throw new cc(`Failed to parse HSLA color: ${R}`);return $}function HR(x,d){return x in d}function h6(x,d){const m=d[x];return m===void 0?null:m}function My(x){return{type:x}}function nv(x){if(x instanceof rb)return new Set([x.key]);let d=new Set;return x.eachChild(m=>{d=new Set([...d,...nv(m)])}),d}function i3(x){if(x instanceof Ru&&x.name==="is-active-floor")return!0;let d=!1;return x.eachChild(m=>{!d&&i3(m)&&(d=!0)}),d}function WR(x){return{result:"success",value:x}}function Ty(x){return{result:"error",value:x}}function m6(x,d){return!!x&&!!x.parameters&&x.parameters.indexOf(d)>-1}function c2(x){return x["property-type"]==="data-driven"}function GR(x){return m6(x.expression,"measure-light")}function KR(x){return m6(x.expression,"zoom")}function o3(x){return!!x.expression&&x.expression.interpolated}function l3(x){return typeof x=="object"&&x!==null&&!Array.isArray(x)}function ZR(x){return x}function YR(x,d){const m=d.type==="color",v=x.stops&&typeof x.stops[0][0]=="object",C=v||!(v||x.property!==void 0),E=x.type||(o3(d)?"exponential":"interval");if(m&&((x=Object.assign({},x)).stops&&(x.stops=x.stops.map(G=>[G[0],Ur.parse(G[1])])),x.default=Ur.parse(x.default?x.default:d.default)),x.colorSpace&&x.colorSpace!=="rgb"&&!$R[x.colorSpace])throw new Error(`Unknown color space: ${x.colorSpace}`);let P,R,$;if(E==="exponential")P=XR;else if(E==="interval")P=Bme;else if(E==="categorical"){P=zme,R=Object.create(null);for(const G of x.stops)R[G[0]]=G[1];$=typeof x.stops[0][0]}else{if(E!=="identity")throw new Error(`Unknown function type "${E}"`);P=QR}if(v){const G={},te=[];for(let de=0;dede[0]),evaluate:({zoom:de},he)=>XR({stops:se,base:x.base},d,de).evaluate(de,he)}}if(C){const G=E==="exponential"?{name:"exponential",base:x.base!==void 0?x.base:1}:null;return{kind:"camera",interpolationType:G,interpolationFactor:cm.interpolationFactor.bind(void 0,G),zoomStops:x.stops.map(te=>te[0]),evaluate:({zoom:te})=>P(x,d,te,R,$)}}return{kind:"source",evaluate(G,te){const se=te&&te.properties?te.properties[x.property]:void 0;return se===void 0?qf(x.default,d.default):P(x,d,se,R,$)}}}function qf(x,d,m){return x!==void 0?x:d!==void 0?d:m!==void 0?m:void 0}function zme(x,d,m,v,C){return qf(typeof m===C?v[m]:void 0,x.default,d.default)}function Bme(x,d,m){if(!X1(m))return qf(x.default,d.default);const v=x.stops.length;if(v===1||m<=x.stops[0][0])return x.stops[0][1];if(m>=x.stops[v-1][0])return x.stops[v-1][1];const C=XC(x.stops.map(E=>E[0]),m);return x.stops[C][1]}function XR(x,d,m){const v=x.base!==void 0?x.base:1;if(!X1(m))return qf(x.default,d.default);const C=x.stops.length;if(C===1||m<=x.stops[0][0])return x.stops[0][1];if(m>=x.stops[C-1][0])return x.stops[C-1][1];const E=XC(x.stops.map(te=>te[0]),m),P=function(te,se,ae,de){const he=de-ae,Se=te-ae;return he===0?0:se===1?Se/he:(Math.pow(se,Se)-1)/(Math.pow(se,he)-1)}(m,v,x.stops[E][0],x.stops[E+1][0]),R=x.stops[E][1],$=x.stops[E+1][1];let G=J0[d.type]||ZR;if(x.colorSpace&&x.colorSpace!=="rgb"){const te=$R[x.colorSpace];G=(se,ae)=>te.reverse(te.interpolate(te.forward(se),te.forward(ae),P))}return typeof R.evaluate=="function"?{evaluate(...te){const se=R.evaluate.apply(void 0,te),ae=$.evaluate.apply(void 0,te);if(se!==void 0&&ae!==void 0)return G(se,ae,P)}}:G(R,$,P)}function QR(x,d,m){return d.type==="color"?m=Ur.parse(m):d.type==="formatted"?m=Du.fromString(m.toString()):d.type==="resolvedImage"?m=Ou.build(m.toString()):Fr(m)===d.type||d.type==="enum"&&d.values[m]||(m=void 0),qf(m,x.default,d.default)}Ru.register(lb,{error:[{kind:"error"},[Da],(x,[d])=>{throw new cc(d.evaluate(x))}],typeof:[Da,[pi],(x,[d])=>_l(Tc(d.evaluate(x)))],"to-rgba":[qd($r,4),[dh],(x,[d])=>d.evaluate(x).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[qd($r,4),[dh],(x,[d])=>d.evaluate(x).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[dh,[$r,$r,$r],d6],rgba:[dh,[$r,$r,$r,$r],d6],hsl:[dh,[$r,$r,$r],u6],hsla:[dh,[$r,$r,$r,$r],u6],has:{type:Si,overloads:[[[Da],(x,[d])=>HR(d.evaluate(x),x.properties())],[[Da,Ff],(x,[d,m])=>HR(d.evaluate(x),m.evaluate(x))]]},get:{type:pi,overloads:[[[Da],(x,[d])=>h6(d.evaluate(x),x.properties())],[[Da,Ff],(x,[d,m])=>h6(d.evaluate(x),m.evaluate(x))]]},"feature-state":[pi,[Da],(x,[d])=>h6(d.evaluate(x),x.featureState||{})],properties:[Ff,[],x=>x.properties()],"geometry-type":[Da,[],x=>x.geometryType()],worldview:[Da,[],x=>x.globals.worldview||""],"is-active-floor":[Si,My(Da),(x,d)=>{if(!(x.globals.activeFloors&&x.globals.activeFloors.size>0))return!1;const m=x.globals.activeFloors;return d.some(v=>{const C=v.evaluate(x);return m.has(C)})}],id:[pi,[],x=>x.id()],zoom:[$r,[],x=>x.globals.zoom],pitch:[$r,[],x=>x.globals.pitch||0],"distance-from-center":[$r,[],x=>x.distanceFromCenter()],"measure-light":[$r,[Da],(x,[d])=>x.measureLight(d.evaluate(x))],"heatmap-density":[$r,[],x=>x.globals.heatmapDensity||0],"line-progress":[$r,[],x=>x.globals.lineProgress||0],"raster-value":[$r,[],x=>x.globals.rasterValue||0],"raster-particle-speed":[$r,[],x=>x.globals.rasterParticleSpeed||0],"sky-radial-progress":[$r,[],x=>x.globals.skyRadialProgress||0],accumulated:[pi,[],x=>x.globals.accumulated===void 0?null:x.globals.accumulated],"+":[$r,My($r),(x,d)=>{let m=0;for(const v of d)m+=v.evaluate(x);return m}],"*":[$r,My($r),(x,d)=>{let m=1;for(const v of d)m*=v.evaluate(x);return m}],"-":{type:$r,overloads:[[[$r,$r],(x,[d,m])=>d.evaluate(x)-m.evaluate(x)],[[$r],(x,[d])=>-d.evaluate(x)]]},"/":[$r,[$r,$r],(x,[d,m])=>d.evaluate(x)/m.evaluate(x)],"%":[$r,[$r,$r],(x,[d,m])=>d.evaluate(x)%m.evaluate(x)],ln2:[$r,[],()=>Math.LN2],pi:[$r,[],()=>Math.PI],e:[$r,[],()=>Math.E],"^":[$r,[$r,$r],(x,[d,m])=>Math.pow(d.evaluate(x),m.evaluate(x))],sqrt:[$r,[$r],(x,[d])=>Math.sqrt(d.evaluate(x))],log10:[$r,[$r],(x,[d])=>Math.log(d.evaluate(x))/Math.LN10],ln:[$r,[$r],(x,[d])=>Math.log(d.evaluate(x))],log2:[$r,[$r],(x,[d])=>Math.log2(d.evaluate(x))],sin:[$r,[$r],(x,[d])=>Math.sin(d.evaluate(x))],cos:[$r,[$r],(x,[d])=>Math.cos(d.evaluate(x))],tan:[$r,[$r],(x,[d])=>Math.tan(d.evaluate(x))],asin:[$r,[$r],(x,[d])=>Math.asin(d.evaluate(x))],acos:[$r,[$r],(x,[d])=>Math.acos(d.evaluate(x))],atan:[$r,[$r],(x,[d])=>Math.atan(d.evaluate(x))],min:[$r,My($r),(x,d)=>Math.min(...d.map(m=>m.evaluate(x)))],max:[$r,My($r),(x,d)=>Math.max(...d.map(m=>m.evaluate(x)))],abs:[$r,[$r],(x,[d])=>Math.abs(d.evaluate(x))],round:[$r,[$r],(x,[d])=>{const m=d.evaluate(x);return m<0?-Math.round(-m):Math.round(m)}],floor:[$r,[$r],(x,[d])=>Math.floor(d.evaluate(x))],ceil:[$r,[$r],(x,[d])=>Math.ceil(d.evaluate(x))],"filter-==":[Si,[Da,pi],(x,[d,m])=>x.properties()[d.value]===m.value],"filter-id-==":[Si,[pi],(x,[d])=>x.id()===d.value],"filter-type-==":[Si,[Da],(x,[d])=>x.geometryType()===d.value],"filter-<":[Si,[Da,pi],(x,[d,m])=>{const v=x.properties()[d.value],C=m.value;return typeof v==typeof C&&v{const m=x.id(),v=d.value;return typeof m==typeof v&&m":[Si,[Da,pi],(x,[d,m])=>{const v=x.properties()[d.value],C=m.value;return typeof v==typeof C&&v>C}],"filter-id->":[Si,[pi],(x,[d])=>{const m=x.id(),v=d.value;return typeof m==typeof v&&m>v}],"filter-<=":[Si,[Da,pi],(x,[d,m])=>{const v=x.properties()[d.value],C=m.value;return typeof v==typeof C&&v<=C}],"filter-id-<=":[Si,[pi],(x,[d])=>{const m=x.id(),v=d.value;return typeof m==typeof v&&m<=v}],"filter->=":[Si,[Da,pi],(x,[d,m])=>{const v=x.properties()[d.value],C=m.value;return typeof v==typeof C&&v>=C}],"filter-id->=":[Si,[pi],(x,[d])=>{const m=x.id(),v=d.value;return typeof m==typeof v&&m>=v}],"filter-has":[Si,[pi],(x,[d])=>d.value in x.properties()],"filter-has-id":[Si,[],x=>x.id()!==null&&x.id()!==void 0],"filter-type-in":[Si,[qd(Da)],(x,[d])=>d.value.indexOf(x.geometryType())>=0],"filter-id-in":[Si,[qd(pi)],(x,[d])=>d.value.indexOf(x.id())>=0],"filter-in-small":[Si,[Da,qd(pi)],(x,[d,m])=>m.value.indexOf(x.properties()[d.value])>=0],"filter-in-large":[Si,[Da,qd(pi)],(x,[d,m])=>function(v,C,E,P){for(;E<=P;){const R=E+P>>1;if(C[R]===v)return!0;C[R]>v?P=R-1:E=R+1}return!1}(x.properties()[d.value],m.value,0,m.value.length-1)],all:{type:Si,overloads:[[[Si,Si],(x,[d,m])=>d.evaluate(x)&&m.evaluate(x)],[My(Si),(x,d)=>{for(const m of d)if(!m.evaluate(x))return!1;return!0}]]},any:{type:Si,overloads:[[[Si,Si],(x,[d,m])=>d.evaluate(x)||m.evaluate(x)],[My(Si),(x,d)=>{for(const m of d)if(m.evaluate(x))return!0;return!1}]]},"!":[Si,[Si],(x,[d])=>!d.evaluate(x)],"is-supported-script":[Si,[Da],(x,[d])=>{const m=x.globals&&x.globals.isSupportedScript;return!m||m(d.evaluate(x))}],upcase:[Da,[Da],(x,[d])=>d.evaluate(x).toUpperCase()],downcase:[Da,[Da],(x,[d])=>d.evaluate(x).toLowerCase()],concat:[Da,My(pi),(x,d)=>d.map(m=>Jm(m.evaluate(x))).join("")],"resolved-locale":[Da,[IC],(x,[d])=>d.evaluate(x).resolvedLocale()],random:[$r,[$r,$r,pi],(x,d)=>{const[m,v,C]=d.map(P=>P.evaluate(x));if(m>v||m===v)return m;let E;if(typeof C=="string")E=function(P){let R=0;if(P.length===0)return R;for(let $=0;$JSON.stringify(se)).join(", ")}, but found ${JSON.stringify(te)} instead.`);return te}catch(te){const se=te;return this._warningHistory[se.message]||(this._warningHistory[se.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${se.message}`)),this._defaultValue}}}function d2(x){return Array.isArray(x)&&x.length>0&&typeof x[0]=="string"&&x[0]in lb}function Ay(x,d,m,v,C){const E=new YC(lb,[],d?function(R){const $={color:dh,string:Da,number:$r,enum:Da,boolean:Si,formatted:Zw,resolvedImage:Yw};return R.type==="array"?qd($[R.value]||pi,R.length):$[R.type]}(d):void 0,void 0,void 0,m,v,C),P=E.parse(x,void 0,void 0,void 0,d&&d.type==="string"?{typeAnnotation:"coerce"}:void 0);return P?WR(new c3(P,d,m,v,C)):Ty(E.errors)}class cb{constructor(d,m,v,C){this.kind=d,this._styleExpression=m,this.isLightConstant=v,this.isLineProgressConstant=C,this.isStateDependent=d!=="constant"&&!r2(m.expression),this.configDependencies=nv(m.expression),this.isIndoorDependent=i3(m.expression)}evaluateWithoutErrorHandling(d,m,v,C,E,P){return this._styleExpression.evaluateWithoutErrorHandling(d,m,v,C,E,P)}evaluate(d,m,v,C,E,P,R){return this._styleExpression.evaluate(d,m,v,C,E,P,void 0,void 0,R)}}class av{constructor(d,m,v,C,E,P){this.kind=d,this.zoomStops=v,this._styleExpression=m,this.isStateDependent=d!=="camera"&&!r2(m.expression),this.isIndoorDependent=i3(m.expression),this.isLightConstant=E,this.isLineProgressConstant=P,this.configDependencies=nv(m.expression),this.interpolationType=C}evaluateWithoutErrorHandling(d,m,v,C,E,P){return this._styleExpression.evaluateWithoutErrorHandling(d,m,v,C,E,P)}evaluate(d,m,v,C,E,P){return this._styleExpression.evaluate(d,m,v,C,E,P)}interpolationFactor(d,m,v){return this.interpolationType?cm.interpolationFactor(this.interpolationType,d,m,v):0}}function p6(x,d,m,v,C){if((x=Ay(x,d,m,v,C)).result==="error")return x;const E=x.value.expression,P=tb(E);if(!P&&!c2(d))return Ty([new Qm("","data expressions not supported")]);const R=sb(E,["zoom","pitch","distance-from-center"]);if(!R&&!KR(d))return Ty([new Qm("","zoom expressions not supported")]);const $=sb(E,["measure-light"]);if(!$&&!GR(d))return Ty([new Qm("","measure-light expression not supported")]);const G=sb(E,["line-progress"]);if(!G&&!function(ae){return m6(ae.expression,"line-progress")}(d))return Ty([new Qm("","line-progress expression not supported")]);const te=d.expression&&d.expression.relaxZoomRestriction,se=Bp(E);return se||R||te?se instanceof Qm?Ty([se]):se instanceof cm&&!o3(d)?Ty([new Qm("",'"interpolate" expressions cannot be used with this property')]):WR(se?new av(P&&G?"camera":"composite",x.value,se.labels,se instanceof cm?se.interpolation:void 0,$,G):new cb(P&&G?"constant":"source",x.value,$,G)):Ty([new Qm("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class d3{constructor(d,m){this._parameters=d,this._specification=m,Object.assign(this,YR(this._parameters,this._specification))}static deserialize(d){return new d3(d._parameters,d._specification)}static serialize(d){return{_parameters:d._parameters,_specification:d._specification}}}function Bp(x){let d=null;if(x instanceof sg)d=Bp(x.result);else if(x instanceof i2){for(const m of x.args)if(d=Bp(m),d)break}else(x instanceof n2||x instanceof cm)&&x.input instanceof Ru&&x.input.name==="zoom"&&(d=x);return d instanceof Qm||x.eachChild(m=>{const v=Bp(m);v instanceof Qm?d=v:d&&v&&d!==v&&(d=new Qm("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),d}var f6,JR,eF=function(){if(JR)return f6;JR=1,f6=d;var x=3;function d(m,v,C){var E=this.cells=[];if(m instanceof ArrayBuffer){this.arrayBuffer=m;var P=new Int32Array(this.arrayBuffer);m=P[0],this.d=(v=P[1])+2*(C=P[2]);for(var R=0;R=ae[Se+0]&&E>=ae[Se+1])?($[he]=!0,R.push(se[he])):$[he]=!1}}},d.prototype._forEachCell=function(m,v,C,E,P,R,$,G){for(var te=this._convertToCellCoord(m),se=this._convertToCellCoord(v),ae=this._convertToCellCoord(C),de=this._convertToCellCoord(E),he=te;he<=ae;he++)for(var Se=se;Se<=de;Se++){var Fe=this.d*Se+he;if((!G||G(this._convertFromCellCoord(he),this._convertFromCellCoord(Se),this._convertFromCellCoord(he+1),this._convertFromCellCoord(Se+1)))&&P.call(this,m,v,C,E,Fe,R,$,G))return}},d.prototype._convertFromCellCoord=function(m){return(m-this.padding)/this.scale},d.prototype._convertToCellCoord=function(m){return Math.max(0,Math.min(this.d-1,Math.floor(m*this.scale)+this.padding))},d.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var m=this.cells,v=x+this.cells.length+1+1,C=0,E=0;E=0||(C[E]=rg(x[E],d)));x instanceof Error&&(C.message=x.message)}if(C.$name)throw new Error("$name property is reserved for worker serialization logic.");return v!=="Object"&&(C.$name=v),C}throw new Error("can't serialize object of type "+typeof x)}function Ey(x){if(x==null||typeof x=="boolean"||typeof x=="number"||typeof x=="string"||x instanceof Boolean||x instanceof Number||x instanceof String||x instanceof Date||x instanceof RegExp||u2(x)||x instanceof ImageBitmap||ArrayBuffer.isView(x)||x instanceof ImageData)return x;if(Array.isArray(x))return x.map(Ey);if(typeof x=="object"){const d=x.$name||"Object";if(d==="Map"){const C=x.entries||[],E=new Map;for(let P=0;Px>=128&&x<=255,Arabic:x=>x>=1536&&x<=1791,"Arabic Supplement":x=>x>=1872&&x<=1919,"Arabic Extended-A":x=>x>=2208&&x<=2303,"Hangul Jamo":x=>x>=4352&&x<=4607,"Unified Canadian Aboriginal Syllabics":x=>x>=5120&&x<=5759,Khmer:x=>x>=6016&&x<=6143,"Unified Canadian Aboriginal Syllabics Extended":x=>x>=6320&&x<=6399,"General Punctuation":x=>x>=8192&&x<=8303,"Letterlike Symbols":x=>x>=8448&&x<=8527,"Number Forms":x=>x>=8528&&x<=8591,"Miscellaneous Technical":x=>x>=8960&&x<=9215,"Control Pictures":x=>x>=9216&&x<=9279,"Optical Character Recognition":x=>x>=9280&&x<=9311,"Enclosed Alphanumerics":x=>x>=9312&&x<=9471,"Geometric Shapes":x=>x>=9632&&x<=9727,"Miscellaneous Symbols":x=>x>=9728&&x<=9983,"Miscellaneous Symbols and Arrows":x=>x>=11008&&x<=11263,"CJK Radicals Supplement":x=>x>=11904&&x<=12031,"Kangxi Radicals":x=>x>=12032&&x<=12255,"Ideographic Description Characters":x=>x>=12272&&x<=12287,"CJK Symbols and Punctuation":x=>x>=12288&&x<=12351,Hiragana:x=>x>=12352&&x<=12447,Katakana:x=>x>=12448&&x<=12543,Bopomofo:x=>x>=12544&&x<=12591,"Hangul Compatibility Jamo":x=>x>=12592&&x<=12687,Kanbun:x=>x>=12688&&x<=12703,"Bopomofo Extended":x=>x>=12704&&x<=12735,"CJK Strokes":x=>x>=12736&&x<=12783,"Katakana Phonetic Extensions":x=>x>=12784&&x<=12799,"Enclosed CJK Letters and Months":x=>x>=12800&&x<=13055,"CJK Compatibility":x=>x>=13056&&x<=13311,"CJK Unified Ideographs Extension A":x=>x>=13312&&x<=19903,"Yijing Hexagram Symbols":x=>x>=19904&&x<=19967,"CJK Unified Ideographs":x=>x>=19968&&x<=40959,"Yi Syllables":x=>x>=40960&&x<=42127,"Yi Radicals":x=>x>=42128&&x<=42191,"Hangul Jamo Extended-A":x=>x>=43360&&x<=43391,"Hangul Syllables":x=>x>=44032&&x<=55215,"Hangul Jamo Extended-B":x=>x>=55216&&x<=55295,"Private Use Area":x=>x>=57344&&x<=63743,"CJK Compatibility Ideographs":x=>x>=63744&&x<=64255,"Arabic Presentation Forms-A":x=>x>=64336&&x<=65023,"Vertical Forms":x=>x>=65040&&x<=65055,"CJK Compatibility Forms":x=>x>=65072&&x<=65103,"Small Form Variants":x=>x>=65104&&x<=65135,"Arabic Presentation Forms-B":x=>x>=65136&&x<=65279,"Halfwidth and Fullwidth Forms":x=>x>=65280&&x<=65519,Osage:x=>x>=66736&&x<=66815,"CJK Unified Ideographs Extension B":x=>x>=131072&&x<=173791};function h2(x){for(const d of x)if(u3(d.charCodeAt(0)))return!0;return!1}function x6(x){for(const d of x)if(!tF(d.charCodeAt(0)))return!1;return!0}function tF(x){return!(en.Arabic(x)||en["Arabic Supplement"](x)||en["Arabic Extended-A"](x)||en["Arabic Presentation Forms-A"](x)||en["Arabic Presentation Forms-B"](x))}function u3(x){return!(x!==746&&x!==747&&(x<4352||!(en["Bopomofo Extended"](x)||en.Bopomofo(x)||en["CJK Compatibility Forms"](x)&&!(x>=65097&&x<=65103)||en["CJK Compatibility Ideographs"](x)||en["CJK Compatibility"](x)||en["CJK Radicals Supplement"](x)||en["CJK Strokes"](x)||!(!en["CJK Symbols and Punctuation"](x)||x>=12296&&x<=12305||x>=12308&&x<=12319||x===12336)||en["CJK Unified Ideographs Extension A"](x)||en["CJK Unified Ideographs"](x)||en["Enclosed CJK Letters and Months"](x)||en["Hangul Compatibility Jamo"](x)||en["Hangul Jamo Extended-A"](x)||en["Hangul Jamo Extended-B"](x)||en["Hangul Jamo"](x)||en["Hangul Syllables"](x)||en.Hiragana(x)||en["Ideographic Description Characters"](x)||en.Kanbun(x)||en["Kangxi Radicals"](x)||en["Katakana Phonetic Extensions"](x)||en.Katakana(x)&&x!==12540||!(!en["Halfwidth and Fullwidth Forms"](x)||x===65288||x===65289||x===65293||x>=65306&&x<=65310||x===65339||x===65341||x===65343||x>=65371&&x<=65503||x===65507||x>=65512&&x<=65519)||!(!en["Small Form Variants"](x)||x>=65112&&x<=65118||x>=65123&&x<=65126)||en["Unified Canadian Aboriginal Syllabics"](x)||en["Unified Canadian Aboriginal Syllabics Extended"](x)||en["Vertical Forms"](x)||en["Yijing Hexagram Symbols"](x)||en["Yi Syllables"](x)||en["Yi Radicals"](x))))}function h3(x){return!(u3(x)||function(d){return!!(en["Latin-1 Supplement"](d)&&(d===167||d===169||d===174||d===177||d===188||d===189||d===190||d===215||d===247)||en["General Punctuation"](d)&&(d===8214||d===8224||d===8225||d===8240||d===8241||d===8251||d===8252||d===8258||d===8263||d===8264||d===8265||d===8273)||en["Letterlike Symbols"](d)||en["Number Forms"](d)||en["Miscellaneous Technical"](d)&&(d>=8960&&d<=8967||d>=8972&&d<=8991||d>=8996&&d<=9e3||d===9003||d>=9085&&d<=9114||d>=9150&&d<=9165||d===9167||d>=9169&&d<=9179||d>=9186&&d<=9215)||en["Control Pictures"](d)&&d!==9251||en["Optical Character Recognition"](d)||en["Enclosed Alphanumerics"](d)||en["Geometric Shapes"](d)||en["Miscellaneous Symbols"](d)&&!(d>=9754&&d<=9759)||en["Miscellaneous Symbols and Arrows"](d)&&(d>=11026&&d<=11055||d>=11088&&d<=11097||d>=11192&&d<=11243)||en["CJK Symbols and Punctuation"](d)||en.Katakana(d)||en["Private Use Area"](d)||en["CJK Compatibility Forms"](d)||en["Small Form Variants"](d)||en["Halfwidth and Fullwidth Forms"](d)||d===8734||d===8756||d===8757||d>=9984&&d<=10087||d>=10102&&d<=10131||d===65532||d===65533)}(x))}function m3(x){return en.Arabic(x)||en["Arabic Supplement"](x)||en["Arabic Extended-A"](x)||en["Arabic Presentation Forms-A"](x)||en["Arabic Presentation Forms-B"](x)}function g6(x){return x>=1424&&x<=2303||en["Arabic Presentation Forms-A"](x)||en["Arabic Presentation Forms-B"](x)}function ng(x,d){return!(!d&&g6(x)||x>=2304&&x<=3583||x>=3840&&x<=4255||en.Khmer(x))}function $me(x){for(const d of x)if(g6(d.charCodeAt(0)))return!0;return!1}const Dh={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let y6=null,Fu=Dh.unavailable,ag=null;const m2=function(x){x&&typeof x=="string"&&x.indexOf("NetworkError")>-1&&(Fu=Dh.error),y6&&y6(x)};function p3(){f3.fire(new Xm("pluginStateChange",{pluginStatus:Fu,pluginURL:ag}))}const f3=new As,p2=function(){return Fu},sF=function(){if(Fu!==Dh.deferred||!ag)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Fu=Dh.loading,p3(),ag&&Lh({url:ag},x=>{x?m2(x):(Fu=Dh.loaded,p3())})},ig={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Fu===Dh.loaded||ig.applyArabicShaping!=null,isLoading:()=>Fu===Dh.loading,setState(x){Fu=x.pluginStatus,ag=x.pluginURL},isParsing:()=>Fu===Dh.parsing,isParsed:()=>Fu===Dh.parsed,getPluginURL:()=>ag};class Ki{constructor(d,m){this.zoom=d,m?(this.now=m.now,this.fadeDuration=m.fadeDuration,this.transition=m.transition,this.pitch=m.pitch,this.brightness=m.brightness,this.worldview=m.worldview,this.activeFloors=m.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(d){return function(m,v){for(const C of m)if(!ng(C.charCodeAt(0),v))return!1;return!0}(d,ig.isLoaded())}}class x3{constructor(d,m,v,C,E){this.property=d,this.value=m,this.expression=function(P,R,$,G,te){if(l3(P))return new d3(P,R);if(d2(P)||Array.isArray(P)&&P.length>0){const se=p6(P,R,$,G,te);if(se.result==="error")throw new Error(se.value.map(ae=>`${ae.key}: ${ae.message}`).join(", "));return se.value}{let se=P;return typeof P=="string"&&R.type==="color"&&(se=Ur.parse(P)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>se}}}(m===void 0?d.specification.default:m,d.specification,v,C,E)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(d,m,v,C){return this.property.possiblyEvaluate(this,d,m,v,C)}}class v6{constructor(d,m,v,C){this.property=d,this.value=new x3(d,void 0,m,v,C)}transitioned(d,m){return new nF(this.property,this.value,m,Object.assign({},d.transition,this.transition),d.now)}untransitioned(){return new nF(this.property,this.value,null,{},0)}}class rF{constructor(d,m,v,C){this._properties=d,this._values=Object.create(d.defaultTransitionablePropertyValues),this._scope=m,this._options=v,this._iconImageUseTheme=C,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(d){return gs(this._values[d].value.value)}setValue(d,m){this._values.hasOwnProperty(d)||(this._values[d]=new v6(this._values[d].property,this._scope,this._options,this._iconImageUseTheme)),this._values[d].value=new x3(this._values[d].property,m===null?void 0:gs(m),this._scope,this._options,this._iconImageUseTheme),this._values[d].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[d].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[d].value.isIndoorDependent())}setTransitionOrValue(d,m){m&&(this._options=m);const v=this._properties.properties;if(d)for(const C in d){const E=d[C];if(C.endsWith("-transition")){const P=C.slice(0,-11);v[P]&&this.setTransition(P,E)}else v.hasOwnProperty(C)&&this.setValue(C,E)}}getTransition(d){return gs(this._values[d].transition)}setTransition(d,m){this._values.hasOwnProperty(d)||(this._values[d]=new v6(this._values[d].property)),this._values[d].transition=gs(m)||void 0}serialize(){const d={};for(const m of Object.keys(this._values)){const v=this.getValue(m);v!==void 0&&(d[m]=v);const C=this.getTransition(m);C!==void 0&&(d[`${m}-transition`]=C)}return d}transitioned(d,m){const v=new aF(this._properties);for(const C of Object.keys(this._values))v._values[C]=this._values[C].transitioned(d,m._values[C]);return v}untransitioned(){const d=new aF(this._properties);for(const m of Object.keys(this._values))d._values[m]=this._values[m].untransitioned();return d}isIndoorDependent(){return this._isIndoorDependent}}class nF{constructor(d,m,v,C,E){const P=C.delay||0,R=C.duration||0;E=E||0,this.property=d,this.value=m,this.begin=E+P,this.end=this.begin+R,d.specification.transition&&(C.delay||C.duration)&&(this.prior=v)}possiblyEvaluate(d,m,v){const C=d.now||0,E=this.value.possiblyEvaluate(d,m,v),P=this.prior;if(P){if(C>this.end)return this.prior=null,E;if(this.value.isDataDriven())return this.prior=null,E;if(C":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*"}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective"}},"colorTheme":{"data":{"type":"string","expression":{}}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator"},"center":{"type":"array","length":2,"value":"number","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"flat"},"fill-extrusion-base-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"terrain"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":true},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","use-theme":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"building-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light","line-progress"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-gradient":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["line-progress"]}},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1]},"line-trim-fade-range":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-trim-color":{"type":"color","default":"transparent","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"use-theme":true,"expression":{"interpolated":true,"parameters":["heatmap-density"]}},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{}},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-value"]}},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-particle-speed"]}},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-shadow-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-accent-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"use-theme":true,"expression":{"interpolated":true,"parameters":["sky-radial-progress"]}},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":true},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":true},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"property-type":"data-driven"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"use-theme":true,"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d"},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"model-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"model-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function oF(x){return x instanceof Number||x instanceof String||x instanceof Boolean?x.valueOf():x}function g3(x){if(Array.isArray(x))return x.map(g3);if(x instanceof Object&&!(x instanceof Number||x instanceof String||x instanceof Boolean)){const d={};for(const m in x)d[m]=g3(x[m]);return d}return oF(x)}function Uf(x){if(x===!0||x===!1)return!0;if(!Array.isArray(x)||x.length===0)return!1;switch(x[0]){case"has":return x.length>=2&&x[1]!=="$id"&&x[1]!=="$type";case"in":return x.length>=3&&(typeof x[1]!="string"||Array.isArray(x[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return x.length!==3||Array.isArray(x[1])||Array.isArray(x[2]);case"any":case"all":for(const d of x.slice(1))if(!Uf(d)&&typeof d!="boolean")return!1;return!0;default:return!0}}function y3(x,d="",m=null,v="fill"){if(x==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Uf(x)||(x=v3(x));const C=x;let E=!0;try{E=function(te){if(!ub(te))return te;let se=g3(te);return lF(se),se=dv(se),se}(C)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md and paste the contents of this message in the report. Thank you! Filter Expression: ${JSON.stringify(C,null,2)} `)}let P=null,R=null;if(v!=="background"&&v!=="sky"&&v!=="slot"){R=Kt[`filter_${v}`];const te=Ay(E,R,d,m);if(te.result==="error")throw new Error(te.value.map(se=>`${se.key}: ${se.message}`).join(", "));P=(se,ae,de)=>te.value.evaluate(se,ae,{},de)}let $=null,G=null;if(E!==C){const te=Ay(C,R,d,m);if(te.result==="error")throw new Error(te.value.map(se=>`${se.key}: ${se.message}`).join(", "));$=(se,ae,de,he,Se)=>te.value.evaluate(se,ae,{},de,void 0,void 0,he,Se),G=!tb(te.value.expression)}return{filter:P,dynamicFilter:$||void 0,needGeometry:cF(E),needFeature:!!G}}function dv(x){if(!Array.isArray(x))return x;const d=function(m){if(qme.has(m[0])){for(let v=1;vdv(m))}function lF(x){let d=!1;const m=[];if(x[0]==="case"){for(let v=1;v",">=","<","<=","to-boolean"]);function Ume(x,d){return xd?1:0}function cF(x){if(!Array.isArray(x))return!1;if(x[0]==="within"||x[0]==="distance")return!0;for(let d=1;d"||d==="<="||d===">="?b3(x[1],x[2],d):d==="any"?(m=x.slice(1),["any"].concat(m.map(v3))):d==="all"?["all"].concat(x.slice(1).map(v3)):d==="none"?["all"].concat(x.slice(1).map(v3).map(f2)):d==="in"?_3(x[1],x.slice(2)):d==="!in"?f2(_3(x[1],x.slice(2))):d==="has"?w3(x[1]):d!=="!has"||f2(w3(x[1]));var m}function b3(x,d,m){switch(x){case"$type":return[`filter-type-${m}`,d];case"$id":return[`filter-id-${m}`,d];default:return[`filter-${m}`,x,d]}}function _3(x,d){if(d.length===0)return!1;switch(x){case"$type":return["filter-type-in",["literal",d]];case"$id":return["filter-id-in",["literal",d]];default:return d.length>200&&!d.some(m=>typeof m!=typeof d[0])?["filter-in-large",x,["literal",d.sort(Ume)]]:["filter-in-small",x,["literal",d]]}}function w3(x){switch(x){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",x]}}function f2(x){return["!",x]}const uv="";function $p(x,d){return d?`${x}${uv}${d}`:x}let dF;const uF=()=>dF||(dF=new Io({"icon-size":new ar(Kt.layout_symbol["icon-size"]),"icon-image":new ar(Kt.layout_symbol["icon-image"]),"icon-rotate":new ar(Kt.layout_symbol["icon-rotate"]),"icon-offset":new ar(Kt.layout_symbol["icon-offset"]),"text-size":new ar(Kt.layout_symbol["text-size"]),"text-rotate":new ar(Kt.layout_symbol["text-rotate"]),"text-offset":new ar(Kt.layout_symbol["text-offset"])}));class hF{constructor(d,m,v,C,E,P){const R=Ay(d,Kt.appearance.condition);if(R.result==="success"&&(this.condition=R.value),this.name=m,v){this.properties=new lv(uF()),this.unevaluatedLayout=new iF(uF(),C,E,P);for(const $ in v)this.unevaluatedLayout.setValue($,v[$])}}isActive(d){return!(this.condition||!d.isHidden||this.name!=="hidden")||this.condition.evaluate(d.globals,d.feature,d.featureState,d.canonical)}getCondition(){return this.condition}getName(){return this.name}getProperty(d){return this.properties.get(d)}getUnevaluatedProperties(){return this.unevaluatedLayout}getUnevaluatedProperty(d){return this.unevaluatedLayout._values[d]}recalculate(d,m,v){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(d,void 0,m,v))}serialize(){const d={};return d.condition=this.condition.expression.serialize(),this.name&&(d.name=this.name),this.unevaluatedLayout&&(d.properties=this.unevaluatedLayout.serialize()),d}hasIconProperties(){const d=this.hasProperty("icon-image"),m=this.hasProperty("icon-size"),v=this.hasProperty("icon-offset"),C=this.hasProperty("icon-rotate");return d||m||v||C}hasTextProperties(){const d=this.hasProperty("text-size"),m=this.hasProperty("text-offset"),v=this.hasProperty("text-rotate");return d||m||v}hasProperty(d){return this.getUnevaluatedProperty(d).value!==void 0}}const mF="-transition",Vf=new Set(["fill","line","background","hillshade","raster"]);class zu extends As{constructor(d,m,v,C,E,P){if(super(),this.id=d.id,this.fqid=$p(this.id,v),this.type=d.type,this.scope=v,this.lut=C,this.options=E,this.iconImageUseTheme=P,this.appearances=new Array,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},d.type!=="custom"){if(this.metadata=d.metadata,this.minzoom=d.minzoom,this.maxzoom=d.maxzoom,d.type&&d.type!=="background"&&d.type!=="sky"&&d.type!=="slot"){this.source=d.source,this.sourceLayer=d["source-layer"],this.filter=d.filter;const R=Ay(this.filter,Kt[`filter_${d.type}`]);R.result!=="error"&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...R.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||R.value.isIndoorDependent)}if(d.slot&&(this.slot=d.slot),d.appearances&&this.setAppearances(d.appearances),m.layout&&(this._unevaluatedLayout=new iF(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 rF(m.paint,this.scope,E);for(const R in d.paint)this.setPaintProperty(R,d.paint[R]);for(const R in d.layout)this.setLayoutProperty(R,d.layout[R]);this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new lv(m.paint)}}}onAdd(d){}onRemove(d){}isDraped(d){return!this.is3D(!0)&&Vf.has(this.type)}getLayoutProperty(d){return d==="visibility"?this.visibility:this._unevaluatedLayout.getValue(d)}setLayoutProperty(d,m){if(this.type==="custom"&&d==="visibility")return void(this.visibility=m);const v=this._unevaluatedLayout;v._properties.properties[d]&&(v.setValue(d,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...v.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||v.isIndoorDependent(),d==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(d){this.appearances=[],d.forEach(m=>{this.appearances.push(new hF(m.condition,m.name,m.properties,this.scope,this.options,this.iconImageUseTheme))})}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(d){return d.endsWith(mF)?this._transitionablePaint.getTransition(d.slice(0,-11)):this._transitionablePaint.getValue(d)}isPaintProperty(d){return!!this._transitionablePaint._properties.properties[d]}setPaintProperty(d,m){const v=this._transitionablePaint,C=v._properties.properties;if(d.endsWith(mF)){const se=d.slice(0,-11);return C[se]&&v.setTransition(se,m||void 0),!1}if(!C[d])return!1;const E=v._values[d],P=E.value.isDataDriven(),R=E.value;v.setValue(d,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...v.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||v.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(d);const $=v._values[d].value,G=$.isDataDriven(),te=d.endsWith("pattern")||d==="line-dasharray";return G||P||te||this._handleOverridablePaintPropertyUpdate(d,R,$)}_handleSpecialPaintPropertyUpdate(d){}getProgramIds(){return null}getDefaultProgramParams(d,m,v){return null}_handleOverridablePaintPropertyUpdate(d,m,v){return!1}isHidden(d){return!!(this.minzoom&&d=this.maxzoom)||this.visibility==="none"}updateTransitions(d){this._transitioningPaint=this._transitionablePaint.transitioned(d,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(d,m){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(d,void 0,m,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(d,void 0,m)}serialize(){const d={id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.appearances.length!==0&&(d.appearances=this.appearances.map(m=>m.serialize())),Ps(d,(m,v)=>!(m===void 0||v==="layout"&&!Object.keys(m).length||v==="paint"&&!Object.keys(m).length))}is3D(d){return!1}hasElevation(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(const d in this.paint._values){const m=this.paint.get(d);if(m instanceof ov&&c2(m.property.specification)&&(m.value.kind==="source"||m.value.kind==="composite")&&m.value.isStateDependent)return!0}for(const d of this.appearances)if(!r2(d.condition.expression))return!0;return!1}compileFilter(d){this._filterCompiled||(this._featureFilter=y3(this.filter,this.scope,d),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(d){this._stats&&(d.renderPass==="shadow"?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(d,m,v){return{}}queryRadius(d){}queryIntersectsFeature(d,m,v,C,E,P,R,$,G){}}const pF={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class x2{constructor(d,m){this._structArray=d,this._pos1=m*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const Vme=new ArrayBuffer(0);class ro{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(d,m){return d._trim(),m&&d.arrayBuffer&&m.add(d.arrayBuffer),{length:d.length,arrayBuffer:d.arrayBuffer}}static deserialize(d){const m=Object.create(this.prototype);return m.arrayBuffer=d.arrayBuffer,m.length=d.length,d.arrayBuffer?m.capacity=d.arrayBuffer.byteLength/m.bytesPerElement:(m.capacity=0,m.arrayBuffer=Vme),m._refreshViews(),m}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(d){this.reserve(d),this.length=d}reserve(d){if(d>this.capacity){this._reallocCount++,this.capacity=Math.max(d,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const m=this.uint8;this._refreshViews(),m&&this.uint8.set(m)}}reserveForAdditional(d){this.reserve(this.length+d)}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...d){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...d){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function fa(x,d=1){let m=0,v=0;return{members:x.map(C=>{const E=pF[C.type].BYTES_PER_ELEMENT,P=m=fF(m,Math.max(d,E)),R=C.components||1;return v=Math.max(v,E),m+=E*R,{name:C.name,type:C.type,components:R,offset:P}}),size:fF(m,Math.max(v,d)),alignment:d}}function fF(x,d){return Math.ceil(x/d)*d}class Py extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m){const v=this.length;return this.resize(v+1),this.emplace(v,d,m)}emplace(d,m,v){const C=2*d;return this.int16[C+0]=m,this.int16[C+1]=v,d}}Py.prototype.bytesPerElement=4,kr(Py,"StructArrayLayout2i4");class hb extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,v)}emplace(d,m,v,C){const E=3*d;return this.int16[E+0]=m,this.int16[E+1]=v,this.int16[E+2]=C,d}}hb.prototype.bytesPerElement=6,kr(hb,"StructArrayLayout3i6");class mb extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,C)}emplace(d,m,v,C,E){const P=4*d;return this.int16[P+0]=m,this.int16[P+1]=v,this.int16[P+2]=C,this.int16[P+3]=E,d}}mb.prototype.bytesPerElement=8,kr(mb,"StructArrayLayout4i8");class og extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.float32[1*d+0]=m,d}}og.prototype.bytesPerElement=4,kr(og,"StructArrayLayout1f4");class b6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,v)}emplace(d,m,v,C){const E=4*d,P=2*d;return this.int16[E+0]=m,this.int16[E+1]=v,this.float32[P+1]=C,d}}b6.prototype.bytesPerElement=8,kr(b6,"StructArrayLayout2i1f8");class _6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,v)}emplace(d,m,v,C){const E=4*d;return this.int16[E+0]=m,this.int16[E+1]=v,this.int16[E+2]=C,d}}_6.prototype.bytesPerElement=8,kr(_6,"StructArrayLayout3i8");class w6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,C,E)}emplace(d,m,v,C,E,P){const R=5*d;return this.int16[R+0]=m,this.int16[R+1]=v,this.int16[R+2]=C,this.int16[R+3]=E,this.int16[R+4]=P,d}}w6.prototype.bytesPerElement=10,kr(w6,"StructArrayLayout5i10");class j3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R){const $=this.length;return this.resize($+1),this.emplace($,d,m,v,C,E,P,R)}emplace(d,m,v,C,E,P,R,$){const G=6*d,te=12*d,se=3*d;return this.int16[G+0]=m,this.int16[G+1]=v,this.uint8[te+4]=C,this.uint8[te+5]=E,this.uint8[te+6]=P,this.uint8[te+7]=R,this.float32[se+2]=$,d}}j3.prototype.bytesPerElement=12,kr(j3,"StructArrayLayout2i4ub1f12");class dm extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,v)}emplace(d,m,v,C){const E=3*d;return this.float32[E+0]=m,this.float32[E+1]=v,this.float32[E+2]=C,d}}dm.prototype.bytesPerElement=12,kr(dm,"StructArrayLayout3f12");class uh extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,C,E)}emplace(d,m,v,C,E,P){const R=6*d,$=3*d;return this.uint16[R+0]=m,this.uint16[R+1]=v,this.uint16[R+2]=C,this.uint16[R+3]=E,this.float32[$+2]=P,d}}uh.prototype.bytesPerElement=12,kr(uh,"StructArrayLayout4ui1f12");class hv extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,C)}emplace(d,m,v,C,E){const P=4*d;return this.uint16[P+0]=m,this.uint16[P+1]=v,this.uint16[P+2]=C,this.uint16[P+3]=E,d}}hv.prototype.bytesPerElement=8,kr(hv,"StructArrayLayout4ui8");class N3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P){const R=this.length;return this.resize(R+1),this.emplace(R,d,m,v,C,E,P)}emplace(d,m,v,C,E,P,R){const $=6*d;return this.int16[$+0]=m,this.int16[$+1]=v,this.int16[$+2]=C,this.int16[$+3]=E,this.int16[$+4]=P,this.int16[$+5]=R,d}}N3.prototype.bytesPerElement=12,kr(N3,"StructArrayLayout6i12");class j6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R,$,G,te,se,ae){const de=this.length;return this.resize(de+1),this.emplace(de,d,m,v,C,E,P,R,$,G,te,se,ae)}emplace(d,m,v,C,E,P,R,$,G,te,se,ae,de){const he=12*d;return this.int16[he+0]=m,this.int16[he+1]=v,this.int16[he+2]=C,this.int16[he+3]=E,this.uint16[he+4]=P,this.uint16[he+5]=R,this.uint16[he+6]=$,this.uint16[he+7]=G,this.int16[he+8]=te,this.int16[he+9]=se,this.int16[he+10]=ae,this.int16[he+11]=de,d}}j6.prototype.bytesPerElement=24,kr(j6,"StructArrayLayout4i4ui4i24");class N6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P){const R=this.length;return this.resize(R+1),this.emplace(R,d,m,v,C,E,P)}emplace(d,m,v,C,E,P,R){const $=10*d,G=5*d;return this.int16[$+0]=m,this.int16[$+1]=v,this.int16[$+2]=C,this.float32[G+2]=E,this.float32[G+3]=P,this.float32[G+4]=R,d}}N6.prototype.bytesPerElement=20,kr(N6,"StructArrayLayout3i3f20");class Iy extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,C)}emplace(d,m,v,C,E){const P=4*d;return this.float32[P+0]=m,this.float32[P+1]=v,this.float32[P+2]=C,this.float32[P+3]=E,d}}Iy.prototype.bytesPerElement=16,kr(Iy,"StructArrayLayout4f16");class k3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.uint32[1*d+0]=m,d}}k3.prototype.bytesPerElement=4,kr(k3,"StructArrayLayout1ul4");class um extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m){const v=this.length;return this.resize(v+1),this.emplace(v,d,m)}emplace(d,m,v){const C=2*d;return this.uint16[C+0]=m,this.uint16[C+1]=v,d}}um.prototype.bytesPerElement=4,kr(um,"StructArrayLayout2ui4");class S3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R,$,G,te,se,ae,de){const he=this.length;return this.resize(he+1),this.emplace(he,d,m,v,C,E,P,R,$,G,te,se,ae,de)}emplace(d,m,v,C,E,P,R,$,G,te,se,ae,de,he){const Se=20*d,Fe=10*d;return this.int16[Se+0]=m,this.int16[Se+1]=v,this.int16[Se+2]=C,this.int16[Se+3]=E,this.int16[Se+4]=P,this.float32[Fe+3]=R,this.float32[Fe+4]=$,this.float32[Fe+5]=G,this.float32[Fe+6]=te,this.int16[Se+14]=se,this.uint32[Fe+8]=ae,this.uint16[Se+18]=de,this.uint16[Se+19]=he,d}}S3.prototype.bytesPerElement=40,kr(S3,"StructArrayLayout5i4f1i1ul2ui40");class C3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R){const $=this.length;return this.resize($+1),this.emplace($,d,m,v,C,E,P,R)}emplace(d,m,v,C,E,P,R,$){const G=8*d;return this.int16[G+0]=m,this.int16[G+1]=v,this.int16[G+2]=C,this.int16[G+4]=E,this.int16[G+5]=P,this.int16[G+6]=R,this.int16[G+7]=$,d}}C3.prototype.bytesPerElement=16,kr(C3,"StructArrayLayout3i2i2i16");class M3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,C,E)}emplace(d,m,v,C,E,P){const R=4*d,$=8*d;return this.float32[R+0]=m,this.float32[R+1]=v,this.float32[R+2]=C,this.int16[$+6]=E,this.int16[$+7]=P,d}}M3.prototype.bytesPerElement=16,kr(M3,"StructArrayLayout2f1f2i16");class k6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P){const R=this.length;return this.resize(R+1),this.emplace(R,d,m,v,C,E,P)}emplace(d,m,v,C,E,P,R){const $=20*d,G=5*d;return this.uint8[$+0]=m,this.uint8[$+1]=v,this.float32[G+1]=C,this.float32[G+2]=E,this.float32[G+3]=P,this.float32[G+4]=R,d}}k6.prototype.bytesPerElement=20,kr(k6,"StructArrayLayout2ub4f20");class Bl extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,v)}emplace(d,m,v,C){const E=3*d;return this.uint16[E+0]=m,this.uint16[E+1]=v,this.uint16[E+2]=C,d}}Bl.prototype.bytesPerElement=6,kr(Bl,"StructArrayLayout3ui6");class pb extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke,Xe,lt,kt){const vt=this.length;return this.resize(vt+1),this.emplace(vt,d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke,Xe,lt,kt)}emplace(d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke,Xe,lt,kt,vt){const At=30*d,zt=15*d,qt=60*d;return this.int16[At+0]=m,this.int16[At+1]=v,this.int16[At+2]=C,this.float32[zt+2]=E,this.float32[zt+3]=P,this.uint16[At+8]=R,this.uint16[At+9]=$,this.uint32[zt+5]=G,this.uint32[zt+6]=te,this.uint32[zt+7]=se,this.uint16[At+16]=ae,this.uint16[At+17]=de,this.uint16[At+18]=he,this.float32[zt+10]=Se,this.float32[zt+11]=Fe,this.uint8[qt+48]=Re,this.uint8[qt+49]=Ke,this.uint8[qt+50]=Xe,this.uint32[zt+13]=lt,this.int16[At+28]=kt,this.uint8[qt+58]=vt,d}}pb.prototype.bytesPerElement=60,kr(pb,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class S6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke,Xe,lt,kt,vt,At,zt,qt,ss,Gt,ds,js,Ns,Fs,Bs,Ls){const Os=this.length;return this.resize(Os+1),this.emplace(Os,d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke,Xe,lt,kt,vt,At,zt,qt,ss,Gt,ds,js,Ns,Fs,Bs,Ls)}emplace(d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke,Xe,lt,kt,vt,At,zt,qt,ss,Gt,ds,js,Ns,Fs,Bs,Ls,Os){const ls=20*d,rs=40*d,Rs=80*d;return this.float32[ls+0]=m,this.float32[ls+1]=v,this.int16[rs+4]=C,this.int16[rs+5]=E,this.int16[rs+6]=P,this.int16[rs+7]=R,this.int16[rs+8]=$,this.int16[rs+9]=G,this.int16[rs+10]=te,this.int16[rs+11]=se,this.int16[rs+12]=ae,this.uint16[rs+13]=de,this.uint16[rs+14]=he,this.uint16[rs+15]=Se,this.uint16[rs+16]=Fe,this.uint16[rs+17]=Re,this.uint16[rs+18]=Ke,this.uint16[rs+19]=Xe,this.uint16[rs+20]=lt,this.uint16[rs+21]=kt,this.uint16[rs+22]=vt,this.uint16[rs+23]=At,this.uint16[rs+24]=zt,this.uint16[rs+25]=qt,this.uint16[rs+26]=ss,this.uint16[rs+27]=Gt,this.uint32[ls+14]=ds,this.float32[ls+15]=js,this.float32[ls+16]=Ns,this.float32[ls+17]=Fs,this.float32[ls+18]=Bs,this.uint8[Rs+76]=Ls,this.uint16[rs+39]=Os,d}}S6.prototype.bytesPerElement=80,kr(S6,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class C6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P){const R=this.length;return this.resize(R+1),this.emplace(R,d,m,v,C,E,P)}emplace(d,m,v,C,E,P,R){const $=6*d;return this.float32[$+0]=m,this.float32[$+1]=v,this.float32[$+2]=C,this.float32[$+3]=E,this.float32[$+4]=P,this.float32[$+5]=R,d}}C6.prototype.bytesPerElement=24,kr(C6,"StructArrayLayout6f24");class mv extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,C,E)}emplace(d,m,v,C,E,P){const R=5*d;return this.float32[R+0]=m,this.float32[R+1]=v,this.float32[R+2]=C,this.float32[R+3]=E,this.float32[R+4]=P,d}}mv.prototype.bytesPerElement=20,kr(mv,"StructArrayLayout5f20");class M6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R){const $=this.length;return this.resize($+1),this.emplace($,d,m,v,C,E,P,R)}emplace(d,m,v,C,E,P,R,$){const G=7*d;return this.float32[G+0]=m,this.float32[G+1]=v,this.float32[G+2]=C,this.float32[G+3]=E,this.float32[G+4]=P,this.float32[G+5]=R,this.float32[G+6]=$,d}}M6.prototype.bytesPerElement=28,kr(M6,"StructArrayLayout7f28");class T6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R,$,G,te,se){const ae=this.length;return this.resize(ae+1),this.emplace(ae,d,m,v,C,E,P,R,$,G,te,se)}emplace(d,m,v,C,E,P,R,$,G,te,se,ae){const de=11*d;return this.float32[de+0]=m,this.float32[de+1]=v,this.float32[de+2]=C,this.float32[de+3]=E,this.float32[de+4]=P,this.float32[de+5]=R,this.float32[de+6]=$,this.float32[de+7]=G,this.float32[de+8]=te,this.float32[de+9]=se,this.float32[de+10]=ae,d}}T6.prototype.bytesPerElement=44,kr(T6,"StructArrayLayout11f44");class fb extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R,$,G){const te=this.length;return this.resize(te+1),this.emplace(te,d,m,v,C,E,P,R,$,G)}emplace(d,m,v,C,E,P,R,$,G,te){const se=9*d;return this.float32[se+0]=m,this.float32[se+1]=v,this.float32[se+2]=C,this.float32[se+3]=E,this.float32[se+4]=P,this.float32[se+5]=R,this.float32[se+6]=$,this.float32[se+7]=G,this.float32[se+8]=te,d}}fb.prototype.bytesPerElement=36,kr(fb,"StructArrayLayout9f36");class Hf extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m){const v=this.length;return this.resize(v+1),this.emplace(v,d,m)}emplace(d,m,v){const C=2*d;return this.float32[C+0]=m,this.float32[C+1]=v,d}}Hf.prototype.bytesPerElement=8,kr(Hf,"StructArrayLayout2f8");class hh extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,C)}emplace(d,m,v,C,E){const P=6*d;return this.uint32[3*d+0]=m,this.uint16[P+2]=v,this.uint16[P+3]=C,this.uint16[P+4]=E,d}}hh.prototype.bytesPerElement=12,kr(hh,"StructArrayLayout1ul3ui12");class Ly extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.uint16[1*d+0]=m,d}}Ly.prototype.bytesPerElement=2,kr(Ly,"StructArrayLayout1ui2");class A6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe){const Re=this.length;return this.resize(Re+1),this.emplace(Re,d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe)}emplace(d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re){const Ke=16*d;return this.float32[Ke+0]=m,this.float32[Ke+1]=v,this.float32[Ke+2]=C,this.float32[Ke+3]=E,this.float32[Ke+4]=P,this.float32[Ke+5]=R,this.float32[Ke+6]=$,this.float32[Ke+7]=G,this.float32[Ke+8]=te,this.float32[Ke+9]=se,this.float32[Ke+10]=ae,this.float32[Ke+11]=de,this.float32[Ke+12]=he,this.float32[Ke+13]=Se,this.float32[Ke+14]=Fe,this.float32[Ke+15]=Re,d}}A6.prototype.bytesPerElement=64,kr(A6,"StructArrayLayout16f64");class T3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R){const $=this.length;return this.resize($+1),this.emplace($,d,m,v,C,E,P,R)}emplace(d,m,v,C,E,P,R,$){const G=10*d,te=5*d;return this.uint16[G+0]=m,this.uint16[G+1]=v,this.uint16[G+2]=C,this.uint16[G+3]=E,this.float32[te+2]=P,this.float32[te+3]=R,this.float32[te+4]=$,d}}T3.prototype.bytesPerElement=20,kr(T3,"StructArrayLayout4ui3f20");class E6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.int16[1*d+0]=m,d}}E6.prototype.bytesPerElement=2,kr(E6,"StructArrayLayout1i2");class A3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.uint8[1*d+0]=m,d}}A3.prototype.bytesPerElement=1,kr(A3,"StructArrayLayout1ub1");class E3 extends x2{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]}}E3.prototype.size=40;class xF extends S3{get(d){return new E3(this,d)}}kr(xF,"CollisionBoxArray");class P3 extends x2{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(d){this._structArray.uint8[this._pos1+49]=d}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(d){this._structArray.uint8[this._pos1+50]=d}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(d){this._structArray.uint32[this._pos4+13]=d}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(d){this._structArray.uint8[this._pos1+58]=d}}P3.prototype.size=60;class gF extends pb{get(d){return new P3(this,d)}}kr(gF,"PlacedSymbolArray");class yF extends x2{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(d){this._structArray.uint32[this._pos4+14]=d}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(d){this._structArray.float32[this._pos4+18]=d}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}yF.prototype.size=80;class P6 extends S6{get(d){return new yF(this,d)}}kr(P6,"SymbolInstanceArray");class I3 extends og{getoffsetX(d){return this.float32[1*d+0]}}kr(I3,"GlyphOffsetArray");class vF extends Py{getx(d){return this.int16[2*d+0]}gety(d){return this.int16[2*d+1]}}kr(vF,"SymbolLineVertexArray");class I6 extends x2{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}I6.prototype.size=12;class L6 extends hh{get(d){return new I6(this,d)}}kr(L6,"FeatureIndexArray");class bF extends um{geta_centroid_pos0(d){return this.uint16[2*d+0]}geta_centroid_pos1(d){return this.uint16[2*d+1]}}kr(bF,"FillExtrusionCentroidArray");class L3 extends x2{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]}}L3.prototype.size=6;class g2 extends hb{get(d){return new L3(this,d)}}kr(g2,"FillExtrusionWallArray");const _F=fa([{name:"a_pos",components:2,type:"Int16"}],4),Hme=fa([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),wF=fa([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class bo{constructor(d=[]){this.segments=d}_prepareSegment(d,m,v,C){let E=this.segments[this.segments.length-1];return d>bo.MAX_VERTEX_ARRAY_LENGTH&&xr(`Max vertices per segment is ${bo.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${d}`),(!E||E.vertexLength+d>bo.MAX_VERTEX_ARRAY_LENGTH||E.sortKey!==C)&&(E={vertexOffset:m,primitiveOffset:v,vertexLength:0,primitiveLength:0},C!==void 0&&(E.sortKey=C),this.segments.push(E)),E}prepareSegment(d,m,v,C){return this._prepareSegment(d,m.length,v.length,C)}get(){return this.segments}destroy(){for(const d of this.segments)for(const m in d.vaos)d.vaos[m].destroy()}static simpleSegment(d,m,v,C){return new bo([{vertexOffset:d,primitiveOffset:m,vertexLength:v,primitiveLength:C,vaos:{},sortKey:0}])}}function D3(x,d){return 256*(x=je(Math.floor(x),0,255))+je(Math.floor(d),0,255)}bo.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,kr(bo,"SegmentVector");const Wme=fa([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Gme=fa([{name:"a_pattern_b",components:4,type:"Uint16"}]),Kme=fa([{name:"a_dash",components:4,type:"Uint16"}]);class y2{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(d,m,v,C){this.ids.push(D6(d)),this.positions.push(m,v,C)}eachPosition(d,m){const v=D6(d);let C=0,E=this.ids.length-1;for(;C>1;this.ids[P]>=v?E=P:C=P+1}for(;this.ids[C]===v;)m(this.positions[3*C],this.positions[3*C+1],this.positions[3*C+2]),C++}static serialize(d,m){const v=new Float64Array(d.ids),C=new Uint32Array(d.positions);return O6(v,C,0,v.length-1),m&&(m.add(v.buffer),m.add(C.buffer)),{ids:v,positions:C}}static deserialize(d){const m=new y2;let v;m.ids=d.ids,m.positions=d.positions;for(const C of m.ids)C!==v&&m.uniqueIds.push(C),v=C;return m.indexed=!0,m}}function D6(x){const d=+x;return Number.isSafeInteger(d)?d:K1(String(x))}function O6(x,d,m,v){for(;m>1];let E=m-1,P=v+1;for(;;){do E++;while(x[E]C);if(E>=P)break;O3(x,E,P),O3(d,3*E,3*P),O3(d,3*E+1,3*P+1),O3(d,3*E+2,3*P+2)}P-m`u_${E}`),this.type=v,this.context=C}setUniform(d,m,v,C,E){const P=C.constantOr(this.value);m.set(d,E,P instanceof Ur?P.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):P)}getBinding(d,m){return this.type==="color"?new b2(d):new $l(d)}}class xb{constructor(d,m){this.uniformNames=m.map(v=>`u_${v}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(d,m){this.pixelRatio=d.pixelRatio||1,this.pattern=d.tl.concat(d.br),this.patternTransition=m?m.tl.concat(m.br):this.pattern}setUniform(d,m,v,C,E){let P=null;E!=="u_pattern"&&E!=="u_dash"||(P=this.pattern),E==="u_pattern_b"&&(P=this.patternTransition),E==="u_pixel_ratio"&&(P=this.pixelRatio),P&&m.set(d,E,P)}getBinding(d,m){return m==="u_pattern"||m==="u_pattern_b"||m==="u_dash"?new F3(d):new $l(d)}}class cg{constructor(d,m,v,C){this.expression=d,this.type=v,this.maxValue=0,this.paintVertexAttributes=m.map(E=>({name:`a_${E}`,type:"Float32",components:v==="color"?2:1,offset:0})),this.paintVertexArray=new C}populatePaintArray(d,m,v,C,E,P,R,$){const G=this.paintVertexArray.length,te=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Ki(0,{brightness:P,worldview:$}),m,{},E,C,R):this.expression.kind==="constant"&&this.expression.value,se=w2(this.lutExpression,m,{},C,E,P,R,$);this.paintVertexArray.resize(d),this._setPaintValue(G,d,te,se?null:this.context.lut)}updatePaintArray(d,m,v,C,E,P,R,$){const G=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:R,worldview:$},v,C,void 0,E):this.expression.kind==="constant"&&this.expression.value,te=w2(this.lutExpression,v,C,E,void 0,R,void 0,$);this._setPaintValue(d,m,G,te?null:this.context.lut)}_setPaintValue(d,m,v,C){if(this.type==="color"){const E=R6(v.toPremultipliedRenderColor(C));for(let P=d;P`u_${R}_t`),this.type=v,this.useIntegerZoom=C,this.context=E,this.maxValue=0,this.paintVertexAttributes=m.map(R=>({name:`a_${R}`,type:"Float32",components:v==="color"?4:2,offset:0})),this.paintVertexArray=new P}populatePaintArray(d,m,v,C,E,P,R,$){const G=this.expression.evaluate(new Ki(this.context.zoom,{brightness:P,worldview:$}),m,{},E,C,R),te=this.expression.evaluate(new Ki(this.context.zoom+1,{brightness:P,worldview:$}),m,{},E,C,R),se=w2(this.lutExpression,m,{},C,E,P,R,$),ae=this.paintVertexArray.length;this.paintVertexArray.resize(d),this._setPaintValue(ae,d,G,te,se?null:this.context.lut)}updatePaintArray(d,m,v,C,E,P,R,$){const G=this.expression.evaluate({zoom:this.context.zoom,brightness:R,worldview:$},v,C,void 0,E),te=this.expression.evaluate({zoom:this.context.zoom+1,brightness:R,worldview:$},v,C,void 0,E),se=w2(this.lutExpression,v,C,E,void 0,R,void 0,$);this._setPaintValue(d,m,G,te,se?null:this.context.lut)}_setPaintValue(d,m,v,C,E){if(this.type==="color"){const P=R6(v.toPremultipliedRenderColor(E)),R=R6(v.toPremultipliedRenderColor(E));for(let $=d;$!0){this.binders={},this._buffers=[],this.context=m;const C=[];for(const E in d.paint._values){const P=d.paint.get(E);if(E.endsWith("-use-theme")||!v(E)||!(P instanceof ov&&c2(P.property.specification)))continue;const R=Qme(E,d.type),$=P.value,G=P.property.specification.type,te=!!P.property.useIntegerZoom,se=E==="line-dasharray"||E.endsWith("pattern"),ae=d.paint.get(`${E}-use-theme`),de=E==="line-dasharray"&&d.layout.get("line-cap").value.kind!=="constant"||ae&&ae.value.kind!=="constant";if($.kind!=="constant"||de)if($.kind==="source"||de||se){const he=F6(E,G,"source");this.binders[E]=se?new ug($,R,G,he,d.id):new cg($,R,G,he),C.push(`/a_${E}`)}else{const he=F6(E,G,"composite");this.binders[E]=new dg($,R,G,te,m,he),C.push(`/z_${E}`)}else this.binders[E]=se?new xb($.value,R):new j2($.value,R,G,m),C.push(`/u_${E}`);ae&&(this.binders[E].lutExpression=ae.value)}this.cacheKey=C.sort().join("")}getMaxValue(d){const m=this.binders[d];return m instanceof cg||m instanceof dg?m.maxValue:0}populatePaintArrays(d,m,v,C,E,P,R,$){for(const G in this.binders){const te=this.binders[G];te.context=this.context,(te instanceof cg||te instanceof dg||te instanceof ug)&&te.populatePaintArray(d,m,v,C,E,P,R,$)}}setConstantPatternPositions(d,m){for(const v in this.binders){const C=this.binders[v];C instanceof xb&&C.setConstantPatternPositions(d,m)}}getPatternTransitionVertexBuffer(d){const m=this.binders[d];return m instanceof ug?m.paintTransitionVertexBuffer:null}updatePaintArrays(d,m,v,C,E,P,R,$,G,te){let se=!1;const ae=Object.keys(d),de=ae.length!==0&&!$,he=de?ae:m.uniqueIds;this.context.lut=E.lut;for(const Se in this.binders){const Fe=this.binders[Se];if(Fe.context=this.context,(Fe instanceof cg||Fe instanceof dg||Fe instanceof ug)&&Fe.expression&&Fe.expression.kind&&Fe.expression.kind!=="constant"&&(Fe.expression.isStateDependent===!0||Fe.expression.isLightConstant===!1)){const Re=E.paint.get(Se);Fe.expression=Re.value;for(const Ke of he){const Xe=d[Ke.toString()];m.eachPosition(Ke,(lt,kt,vt)=>{const At=C.feature(lt);Fe.updatePaintArray(kt,vt,At,Xe,P,R,G,te)})}if(!de)for(const Ke of v.uniqueIds){const Xe=d[Ke.toString()];v.eachPosition(Ke,(lt,kt,vt)=>{const At=C.feature(lt);Fe.updatePaintArray(kt,vt,At,Xe,P,R,G,te)})}se=!0}}return se}defines(){const d=[];for(const m in this.binders){const v=this.binders[m];(v instanceof j2||v instanceof xb)&&d.push(...v.uniformNames.map(C=>`#define HAS_UNIFORM_${C}`))}return d}getPaintVertexBuffers(){return this._buffers}getUniforms(d){const m=[];for(const v in this.binders){const C=this.binders[v];if(C instanceof j2||C instanceof xb||C instanceof dg)for(const E of C.uniformNames)m.push({name:E,property:v,binding:C.getBinding(d,E)})}return m}setUniforms(d,m,v,C,E){for(const{name:P,property:R,binding:$}of v)this.binders[R].setUniform(d,$,E,C.get(R),P)}updatePaintBuffers(){this._buffers=[];for(const d in this.binders){const m=this.binders[d];(m instanceof cg||m instanceof dg||m instanceof ug)&&m.paintVertexBuffer&&this._buffers.push(m.paintVertexBuffer),m instanceof ug&&m.paintTransitionVertexBuffer&&this._buffers.push(m.paintTransitionVertexBuffer)}}upload(d){for(const m in this.binders){const v=this.binders[m];(v instanceof cg||v instanceof dg||v instanceof ug)&&v.upload(d)}this.updatePaintBuffers()}destroy(){for(const d in this.binders){const m=this.binders[d];(m instanceof cg||m instanceof dg||m instanceof ug)&&m.destroy()}}}class qp{constructor(d,m,v=()=>!0){this.programConfigurations={};for(const C of d)this.programConfigurations[C.id]=new Dy(C,m,v);this.needsUpload=!1,this._featureMap=new y2,this._featureMapWithoutIds=new y2,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(d,m,v,C,E,P,R,$,G){for(const te in this.programConfigurations)this.programConfigurations[te].populatePaintArrays(d,m,C,E,P,R,$,G);m.id!==void 0?this._featureMap.add(m.id,v,this._bufferOffset,d):(this._featureMapWithoutIds.add(this._idlessCounter,v,this._bufferOffset,d),this._idlessCounter+=1),this._bufferOffset=d,this.needsUpload=!0}updatePaintArrays(d,m,v,C,E,P,R,$){for(const G of v)this.needsUpload=this.programConfigurations[G.id].updatePaintArrays(d,this._featureMap,this._featureMapWithoutIds,m,G,C,E,P,R||0,$)||this.needsUpload}get(d){return this.programConfigurations[d]}upload(d){if(this.needsUpload){for(const m in this.programConfigurations)this.programConfigurations[m].upload(d);this.needsUpload=!1}}destroy(){for(const d in this.programConfigurations)this.programConfigurations[d].destroy()}}const Xme={"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 Qme(x,d){return Xme[x]||[x.replace(`${d}-`,"").replace(/-/g,"_")]}const Jme={"line-pattern":{source:uh,composite:uh},"fill-pattern":{source:uh,composite:uh},"fill-extrusion-pattern":{source:uh,composite:uh},"line-dasharray":{source:hv,composite:hv}},epe={color:{source:Hf,composite:Iy},number:{source:og,composite:Hf}};function F6(x,d,m){const v=Jme[x];return v&&v[m]||epe[d][m]}kr(j2,"ConstantBinder"),kr(xb,"PatternConstantBinder"),kr(cg,"SourceExpressionBinder"),kr(ug,"PatternCompositeBinder"),kr(dg,"CompositeExpressionBinder"),kr(Dy,"ProgramConfiguration",{omit:["_buffers"]}),kr(qp,"ProgramConfigurationSet");const Ud=tr/Math.PI/2,sp=5,$3=6,tpe=16383,gb=64,z6=[gb,32,16],rp=-Ud,np=Ud;function pv(x,d,m,v=Ud){return m=jr(m),[x*Math.sin(m)*v,-d*v,x*Math.cos(m)*v]}function yb(x,d,m){return pv(Math.cos(jr(x)),Math.sin(jr(x)),d,m)}const T=63710088e-1,h=2*Math.PI*T;class y{constructor(d,m){if(isNaN(d)||isNaN(m))throw new Error(`Invalid LngLat object: (${d}, ${m})`);if(this.lng=+d,this.lat=+m,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new y(Ye(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(d){const m=Math.PI/180,v=this.lat*m,C=d.lat*m,E=Math.sin(v)*Math.sin(C)+Math.cos(v)*Math.cos(C)*Math.cos((d.lng-this.lng)*m);return T*Math.acos(Math.min(E,1))}toBounds(d=0){const m=360*d/40075017,v=m/Math.cos(Math.PI/180*this.lat);return new A({lng:this.lng-v,lat:this.lat-m},{lng:this.lng+v,lat:this.lat+m})}toEcef(d){return yb(this.lat,this.lng,Ud+d*Ud/T)}static convert(d){if(d instanceof y)return d;if(Array.isArray(d)&&(d.length===2||d.length===3))return new y(Number(d[0]),Number(d[1]));if(!Array.isArray(d)&&typeof d=="object"&&d!==null)return new y(Number("lng"in d?d.lng:d.lon),Number(d.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class A{constructor(d,m){d&&(m?this.setSouthWest(d).setNorthEast(m):Array.isArray(d)&&d.length===4?this.setSouthWest([d[0],d[1]]).setNorthEast([d[2],d[3]]):this.setSouthWest(d[0]).setNorthEast(d[1]))}setNorthEast(d){return this._ne=d instanceof y?new y(d.lng,d.lat):y.convert(d),this}setSouthWest(d){return this._sw=d instanceof y?new y(d.lng,d.lat):y.convert(d),this}extend(d){const m=this._sw,v=this._ne;let C,E;if(d instanceof y)C=d,E=d;else{if(!(d instanceof A))return Array.isArray(d)?d.length===4||d.every(Array.isArray)?this.extend(A.convert(d)):this.extend(y.convert(d)):typeof d=="object"&&d!==null&&d.hasOwnProperty("lat")&&(d.hasOwnProperty("lon")||d.hasOwnProperty("lng"))?this.extend(y.convert(d)):this;if(C=d._sw,E=d._ne,!C||!E)return this}return m||v?(m.lng=Math.min(C.lng,m.lng),m.lat=Math.min(C.lat,m.lat),v.lng=Math.max(E.lng,v.lng),v.lat=Math.max(E.lat,v.lat)):(this._sw=new y(C.lng,C.lat),this._ne=new y(E.lng,E.lat)),this}getCenter(){return new y((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new y(this.getWest(),this.getNorth())}getSouthEast(){return new y(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(d){const{lng:m,lat:v}=y.convert(d);let C=this._sw.lng<=m&&m<=this._ne.lng;return this._sw.lng>this._ne.lng&&(C=this._sw.lng>=m&&m>=this._ne.lng),this._sw.lat<=v&&v<=this._ne.lat&&C}static convert(d){if(d)return d instanceof A?d:new A(d)}}const D=0,F=25.5;function z(x){return h*Math.cos(x*Math.PI/180)}function W(x){return(180+x)/360}function J(x){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+x*Math.PI/360)))/360}function ne(x,d){return x/z(d)}function le(x){return 360*x-180}function _e(x){return 360/Math.PI*Math.atan(Math.exp((180-360*x)*Math.PI/180))-90}function ye(x,d){return x*z(_e(d))}const we=85.051129;function Le(x){return Math.cos(jr(je(x,-we,we)))}function Ie(x,d){const m=je(d,D,F),v=Math.pow(2,m);return Le(x)*h/(512*v)}function We(x){return 1/Math.cos(x*Math.PI/180)}function Ue(x,d=0){const m=Math.exp(Math.PI*(1-(x.y+d/tr)/(1<=$?(ut(x,d,m,G,te,E,se,R,$),ut(x,G,te,v,C,se,P,R,$)):x.push(P)}function ot(x,d,m){let v=x[0],C=v.x,E=v.y;d(v);const P=[v];for(let R=1;Rx.x+1||vx.y+1)&&xr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),x}function Ot(x,d,m){const v=x.loadGeometry(),C=x.extent,E=tr/C;if(d&&m&&m.projection.isReprojectedInTileSpace){const P=1<{const de=le((d.x+ae.x/C)/P),he=_e((d.y+ae.y/C)/P),Se=te.project(de,he);ae.x=(Se.x*R-$)*C,ae.y=(Se.y*R-G)*C};for(let ae=0;ae=C||he.y<0||he.y>=C||(se(he),de.push(he));v[ae]=de}}for(const P of v)for(const R of P)yt(R,E);return v}function Wt(x,d){return{type:x.type,id:x.id,properties:x.properties,geometry:d?Ot(x):[]}}class Ht{constructor(d,m,v,C,E){this.properties={},this.extent=v,this.type=0,this.id=void 0,this._pbf=d,this._geometry=-1,this._keys=C,this._values=E,d.readFields(es,this,m)}loadGeometry(){const d=this._pbf;d.pos=this._geometry;const m=d.readVarint()+d.pos,v=[];let C,E=1,P=0,R=0,$=0;for(;d.pos>3}if(P--,E===1||E===2)R+=d.readSVarint(),$+=d.readSVarint(),E===1&&(C&&v.push(C),C=[]),C&&C.push(new pt(R,$));else{if(E!==7)throw new Error(`unknown command ${E}`);C&&C.push(C[0].clone())}}return C&&v.push(C),v}bbox(){const d=this._pbf;d.pos=this._geometry;const m=d.readVarint()+d.pos;let v=1,C=0,E=0,P=0,R=1/0,$=-1/0,G=1/0,te=-1/0;for(;d.pos>3}if(C--,v===1||v===2)E+=d.readSVarint(),P+=d.readSVarint(),E$&&($=E),Pte&&(te=P);else if(v!==7)throw new Error(`unknown command ${v}`)}return[R,G,$,te]}toGeoJSON(d,m,v){const C=this.extent*Math.pow(2,v),E=this.extent*d,P=this.extent*m,R=this.loadGeometry();function $(ae){return[360*(ae.x+E)/C-180,360/Math.PI*Math.atan(Math.exp((1-2*(ae.y+P)/C)*Math.PI))-90]}function G(ae){return ae.map($)}let te;if(this.type===1){const ae=[];for(const he of R)ae.push(he[0]);const de=G(ae);te=ae.length===1?{type:"Point",coordinates:de[0]}:{type:"MultiPoint",coordinates:de}}else if(this.type===2){const ae=R.map(G);te=ae.length===1?{type:"LineString",coordinates:ae[0]}:{type:"MultiLineString",coordinates:ae}}else{if(this.type!==3)throw new Error("unknown feature type");{const ae=function(he){const Se=he.length;if(Se<=1)return[he];const Fe=[];let Re,Ke;for(let Xe=0;Xe=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[d];const m=this._pbf.readVarint()+this._pbf.pos;return new Ht(this._pbf,m,this.extent,this._keys,this._values)}}function qs(x,d,m){x===15?d.version=m.readVarint():x===1?d.name=m.readString():x===5?d.extent=m.readVarint():x===2?d._features.push(m.pos):x===3?d._keys.push(m.readString()):x===4&&d._values.push(function(v){let C=null;const E=v.readVarint()+v.pos;for(;v.pos>3;C=P===1?v.readString():P===2?v.readFloat():P===3?v.readDouble():P===4?v.readVarint64():P===5?v.readVarint():P===6?v.readSVarint():P===7?v.readBoolean():null}if(C==null)throw new Error("unknown feature value");return C}(m))}class Yt{constructor(d,m){this.layers=d.readFields(Bt,{},m)}}function Bt(x,d,m){if(x===3){const v=new xs(m,m.readVarint()+m.pos);v.length&&(d[v.name]=v)}}const as="3d_elevation_id",Jt="level";class Is{constructor(){this._valid=!1}reset(d){return this.feature=d,this._valid=!0,this._geometry=d.loadGeometry(),this._geometry.length!==0&&this._geometry[0].length!==0||(this._valid=!1),this}geometry(d,m){return this._valid&&d(m(this._geometry)),this}require(d,m,v){return this.get(d,!0,m,v)}optional(d,m,v){return this.get(d,!1,m,v)}success(){return this._valid}get(d,m,v,C){const E=this.feature.properties.hasOwnProperty(d)?+this.feature.properties[d]:void 0;return this._valid&&E!==void 0&&!Number.isNaN(E)?v(C?C(E):E):m&&(this._valid=!1),this}}class rr{constructor(d,m){this.featureFunc=d,this.vertexFunc=m}parseFeature(d,m,v){return this.featureFunc(d,m,v)}parseVertex(d,m,v){return this.vertexFunc(d,m,v)}}const yr=new rr((x,d,m)=>x.reset(d).require(as,v=>{m.id=v}).optional("fixed_height_relative",v=>{m.constantHeight=v},Us.decodeRelativeHeight).geometry(v=>{m.bounds=v},tg).success(),(x,d,m)=>x.reset(d).require(as,v=>{m.id=v}).require("elevation_idx",v=>{m.idx=v}).require("extent",v=>{m.extent=v}).require("height_relative",v=>{m.height=v},Us.decodeRelativeHeight).geometry(v=>{m.position=v},Us.getPoint).success()),Js=new rr((x,d,m)=>x.reset(d).require(as,v=>{m.id=v}).optional("fixed_height",v=>{m.constantHeight=v},Us.decodeMetricHeight).geometry(v=>{m.bounds=v},tg).success(),(x,d,m)=>x.reset(d).require(as,v=>{m.id=v}).require("elevation_idx",v=>{m.idx=v}).require("extent",v=>{m.extent=v}).require("height",v=>{m.height=v},Us.decodeMetricHeight).geometry(v=>{m.position=v},Us.getPoint).success());class Us{static getPoint(d){return xt(d[0][0].x,d[0][0].y)}static decodeRelativeHeight(d){return 1e-4*d*5}static decodeMetricHeight(d){return 1e-4*d}static getVersionSchema(d){return d?d==="1.0.1"?Js:void 0:yr}static parse(d){const m=[],v=[],C=d.length,E=new Is;for(let P=0;P=0);if(E===0)return 0;E!==d.length&&(m=!1)}return m?2:1}function Pn(x,d){for(const m of x.projections){const v=br(d,x.points[0],m.axis);if(m.projection[1]v[1])return 0}return 1}function wa(x,d){let m=0;const v=[0,0,0,0];for(let P=0;P=0&&m++;var C,E;return m}class si{constructor(d,m){this.points=d||new Array(8).fill([0,0,0]),this.planes=m||new Array(6).fill([0,0,0,0]),this.bounds=Or.fromPoints(this.points),this.projections=[],this.frustumEdges=[Ce([],this.points[2],this.points[3]),Ce([],this.points[0],this.points[3]),Ce([],this.points[4],this.points[0]),Ce([],this.points[5],this.points[1]),Ce([],this.points[6],this.points[2]),Ce([],this.points[7],this.points[3])];for(const v of this.frustumEdges){const C=[0,-v[2],v[1]],E=[v[2],0,-v[0]];this.projections.push({axis:C,projection:br(this.points,this.points[0],C)}),this.projections.push({axis:E,projection:br(this.points,this.points[0],E)})}}static fromInvProjectionMatrix(d,m,v,C){const E=Math.pow(2,v),P=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(G=>{const te=Qe([],G,d),se=1/te[3]/m*E;return(ae=te)[0]=(de=te)[0]*(he=[se,se,C?1/te[3]:se,se])[0],ae[1]=de[1]*he[1],ae[2]=de[2]*he[2],ae[3]=de[3]*he[3],ae;var ae,de,he}),R=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(G=>{const te=ke([],nt([],Ce([],P[G[0]],P[G[1]]),Ce([],P[G[2]],P[G[1]]))),se=-Be(te,P[G[1]]);return te.concat(se)}),$=[];for(let G=0;GG[1]||G[0]>$[1])return 0}return 1}containsPoint(d){for(const m of this.planes){const v=m[3];if(Be([m[0],m[1],m[2]],d)+v<0)return!1}return!0}}class Or{static fromPoints(d){const m=[1/0,1/0,1/0],v=[-1/0,-1/0,-1/0];for(const C of d)ue(m,m,C),pe(v,v,C);return new Or(m,v)}static fromTileIdAndHeight(d,m,v){const C=1<d.max[m]||d.min[m]>this.max[m])return!1;return!0}intersectsAabbXY(d){return!(this.min[0]>d.max[0]||d.min[0]>this.max[0]||this.min[1]>d.max[1]||d.min[1]>this.max[1])}encapsulate(d){for(let m=0;m<3;m++)this.min[m]=Math.min(this.min[m],d.min[m]),this.max[m]=Math.max(this.max[m],d.max[m])}encapsulatePoint(d){for(let m=0;m<3;m++)this.min[m]=Math.min(this.min[m],d[m]),this.max[m]=Math.max(this.max[m],d[m])}closestPoint(d){return[Math.max(Math.min(this.max[0],d[0]),this.min[0]),Math.max(Math.min(this.max[1],d[1]),this.min[1]),Math.max(Math.min(this.max[2],d[2]),this.min[2])]}}kr(Or,"Aabb");class Ka{constructor(d,m){this.feature=d,this.metersToTile=m,this.index=0}get(){const d=this.feature.vertices[this.index],m=this.feature.vertexProps[this.index].dir,v=m[1],C=-m[0],E=(d.extent+1)*this.metersToTile;return[new pt(Math.trunc(d.position[0]+v*E),Math.trunc(d.position[1]+C*E)),new pt(Math.trunc(d.position[0]-v*E),Math.trunc(d.position[1]-C*E))]}next(){this.index++}valid(){return this.index{return R.a0?be($,$,1/G):oe($,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(d){if(this.edges.length===0)return;let m=0,v=Number.POSITIVE_INFINITY,C=0;const[E,P,R,$,G,te,se]=this._tmpVec2;Es(se,d.x,d.y);const ae=new Pr(se,null);for(let de=0;de0?Ea($,R)/lt:0,vt=je(kt,0,1),At=Math.abs((kt-vt)*this.edgeProps[de].len);Mr(G,se,Fe),Es(te,Se[1],-Se[0]);const zt=At+Math.abs(Ea(G,te));zt=0;--P){const R=this.edges[P].a,$=this.edges[P].b,{position:G,height:te,extent:se}=this.vertices[R],{position:ae,height:de,extent:he}=this.vertices[$],Se=this.vertexProps[R].dir,Fe=this.vertexProps[$].dir;if(oe(m,G[0]/d,G[1]/d,te),oe(v,ae[0]/d,ae[1]/d,de),oe(C,Se[1],-Se[0],0),be(C,C,se),oe(E,Fe[1],-Fe[0],0),be(E,E,he),this.distSqLines(re(m[0]+.5*C[0],m[1]+.5*C[1],m[2]+.5*C[2]),re(v[0]-.5*E[0],v[1]-.5*E[1],v[2]-.5*E[2]),re(m[0]-.5*C[0],m[1]-.5*C[1],m[2]-.5*C[2]),re(v[0]+.5*E[0],v[1]+.5*E[1],v[2]+.5*E[2]))<=.0025000000000000005)continue;const Re=this.vertices.length,Ke=ur(er(),G,ae);this.vertices.push({position:Lr(Ke,Ke,.5),height:.5*(te+de),extent:.5*(se+he)});const Xe=ur(er(),Se,Fe);this.vertexProps.push({dir:ki(Xe,Xe)}),this.edges.splice(P,1),this.edgeProps.splice(P,1),this.edges.push({a:R,b:Re}),this.edges.push({a:Re,b:$});const lt=Mr(er(),this.vertices[Re].position,G),kt=fn(lt),vt={vec:lt,dir:Lr(er(),lt,1/kt),len:kt};this.edgeProps.push(vt),this.edgeProps.push(vt)}}distSqLines(d,m,v,C){const E=xe(ee(),m,d),P=xe(ee(),C,v),R=xe(ee(),d,v),$=Be(E,E),G=Be(E,P),te=Be(E,R),se=Be(P,P),ae=Be(P,R),de=$*se-G*G;if(de===0)return Pe(Ae(E,v,C,Be(R,P)/Be(P,P)),d);const he=($*ae-G*te)/de;return Pe(Ae(E,d,m,(G*ae-te*se)/de),Ae(P,v,C,he))}}class di{static parseFrom(d,m){const v=Us.parse(d);if(!v)return[];let{vertices:C,features:E}=v;const P=1/Ue(m);E.sort((te,se)=>te.id-se.id),C.sort((te,se)=>te.id-se.id||te.idx-se.idx),C=C.filter((te,se,ae)=>se===ae.findIndex(de=>de.id===te.id&&de.idx===te.idx));const R=new Array;let $=0;const G=C.length;for(const te of E){if(te.constantHeight){R.push(new Cn(te.id,te.bounds,te.constantHeight));continue}for(;$!==G&&C[$].idC.id===v)}}class Ci{constructor(d,m){this.zScale=1,this.xOffset=0,this.yOffset=0,d.equals(m)||(this.zScale=Math.pow(2,m.z-d.z),this.xOffset=(d.x*this.zScale-m.x)*tr,this.yOffset=(d.y*this.zScale-m.y)*tr)}constantElevation(d,m){if(d.constantHeight!=null)return this.computeBiasedHeight(d.constantHeight,m)}pointElevation(d,m,v){const C=this.constantElevation(m,v);return C??(d.x=d.x*this.zScale+this.xOffset,d.y=d.y*this.zScale+this.yOffset,this.computeBiasedHeight(m.pointElevation(d),v))}computeBiasedHeight(d,m){return m<=0?d:d+m*$e(0,m,d>=0?d:Math.abs(.5*d))}}kr(Cn,"ElevationFeature");class bi{constructor(d){this.zoom=d.zoom,this.overscaling=d.overscaling,this.layers=d.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=d.index,this.hasPattern=!1,this.projection=d.projection,this.layoutVertexArray=new Py,this.indexArray=new Bl,this.segments=new bo,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut}),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,this.elevationMode!=="none"&&(this.elevatedLayoutVertexArray=new og),this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,C){}populate(d,m,v,C){const E=this.layers[0],P=[];let R=null;E.type==="circle"&&(R=E.layout.get("circle-sort-key"));for(const{feature:G,id:te,index:se,sourceLayerIndex:ae}of d){const de=this.layers[0]._featureFilter.needGeometry,he=Wt(G,de);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),he,v))continue;const Se=R?R.evaluate(he,{},v):void 0,Fe={id:te,properties:G.properties,type:G.type,sourceLayerIndex:ae,index:se,geometry:de?he.geometry:Ot(G,v,C),patterns:{},sortKey:Se};P.push(Fe)}R&&P.sort((G,te)=>G.sortKey-te.sortKey);let $=null;C.projection.name==="globe"&&(this.globeExtVertexArray=new N3,$=C.projection);for(const G of P){const{geometry:te,index:se,sourceLayerIndex:ae}=G,de=d[se].feature;this.addFeature(G,te,se,m.availableImages,v,$,m.brightness,m.elevationFeatures),m.featureIndex.insert(de,te,se,ae,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(d,m,v,C,E,P,R){this.programConfigurations.updatePaintArrays(d,m,E,v,C,P,R,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,_F.members),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=d.createVertexBuffer(this.globeExtVertexArray,wF.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=d.createVertexBuffer(this.elevatedLayoutVertexArray,Hme.members))),this.programConfigurations.upload(d),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy())}addFeature(d,m,v,C,E,P,R,$){let G;this.elevationMode!=="none"&&(G=di.getElevationFeature(d,$));for(const te of m)for(const se of te){const ae=se.x,de=se.y;if(ae<0||ae>=tr||de<0||de>=tr)continue;if(P){const Fe=P.projectTilePoint(ae,de,E),Re=P.upVector(E,ae,de);this.addGlobeExtVertex(Fe,Re),this.addGlobeExtVertex(Fe,Re),this.addGlobeExtVertex(Fe,Re),this.addGlobeExtVertex(Fe,Re)}const he=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,d.sortKey),Se=he.vertexLength;if(this.addCircleVertex(ae,de,-1,-1),this.addCircleVertex(ae,de,1,-1),this.addCircleVertex(ae,de,1,1),this.addCircleVertex(ae,de,-1,1),this.elevationMode!=="none"){const Fe=G?G.pointElevation(new pt(ae,de)):0;this.hasElevation=this.hasElevation||Fe!==0;for(let Re=0;Re<4;Re++)this.elevatedLayoutVertexArray.emplaceBack(Fe)}this.indexArray.emplaceBack(Se,Se+1,Se+2),this.indexArray.emplaceBack(Se,Se+2,Se+3),he.vertexLength+=4,he.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,v,{},C,E,R,void 0,this.worldview)}addCircleVertex(d,m,v,C){this.layoutVertexArray.emplaceBack(2*d+(v+1)/2,2*m+(C+1)/2)}addGlobeExtVertex(d,m){this.globeExtVertexArray.emplaceBack(d.x,d.y,d.z,m[0]*16384,m[1]*16384,m[2]*16384)}}function Ga(x,d){for(let m=0;m1){if(no(x,d))return!0;for(let v=0;v1?m:m.sub(d)._mult(C)._add(d))}function _o(x,d){let m,v,C,E=!1;for(let P=0;Pd.y!=C.y>d.y&&d.x<(C.x-v.x)*(d.y-v.y)/(C.y-v.y)+v.x&&(E=!E)}return E}function Di(x,d){let m=!1;for(let v=0,C=x.length-1;vd.y!=P.y>d.y&&d.x<(P.x-E.x)*(d.y-E.y)/(P.y-E.y)+E.x&&(m=!m)}return m}function Bu(x,d,m,v,C){for(const P of x)if(d<=P.x&&m<=P.y&&v>=P.x&&C>=P.y)return!0;const E=[new pt(d,m),new pt(d,C),new pt(v,C),new pt(v,m)];if(x.length>2){for(const P of E)if(Di(x,P))return!0}for(let P=0;PC.x&&d.x>C.x||x.yC.y&&d.y>C.y)return!1;const E=Ln(x,d,m[0]);return E!==Ln(x,d,m[1])||E!==Ln(x,d,m[2])||E!==Ln(x,d,m[3])}function ql(x,d,m,v,C,E){let P=d.y-x.y,R=x.x-d.x;if(E=E||0){const $=P*P+R*R;if($===0)return!0;const G=Math.sqrt($);P/=G,R/=G}return!((m.x-x.x)*P+(m.y-x.y)*R-E<0||(v.x-x.x)*P+(v.y-x.y)*R-E<0||(C.x-x.x)*P+(C.y-x.y)*R-E<0)}function Vd(x,d,m,v,C,E,P){return!(ql(x,d,v,C,E,P)||ql(d,m,v,C,E,P)||ql(m,x,v,C,E,P)||ql(v,C,x,d,m,P)||ql(C,E,x,d,m,P)||ql(E,v,x,d,m,P))}function Hd(x,d,m){const v=d.paint.get(x).value;return v.kind==="constant"?v.value:m.programConfigurations.get(d.id).getMaxValue(x)}function id(x){return Math.sqrt(x[0]*x[0]+x[1]*x[1])}function hm(x,d,m,v,C){if(!d[0]&&!d[1])return x;const E=pt.convert(d)._mult(C);m==="viewport"&&E._rotate(-v);const P=[];for(let R=0;R>m&&d.y===this.y>>m}url(d,m){const v=function(E,P,R){var $=Jo(256*E,256*(P=Math.pow(2,R)-P-1),R),G=Jo(256*(E+1),256*(P+1),R);return $[0]+","+$[1]+","+G[0]+","+G[1]}(this.x,this.y,this.z),C=function(E,P,R){let $,G="";for(let te=E;te>0;te--)$=1<this.canonical.z?new Co(d,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Co(d,this.wrap,d,this.canonical.x>>m,this.canonical.y>>m)}calculateScaledKey(d,m=!0){if(this.overscaledZ===d&&m)return this.key;if(d>this.canonical.z)return wo(this.wrap*+m,d,this.canonical.z,this.canonical.x,this.canonical.y);{const v=this.canonical.z-d;return wo(this.wrap*+m,d,d,this.canonical.x>>v,this.canonical.y>>v)}}isChildOf(d){if(d.wrap!==this.wrap)return!1;const m=this.canonical.z-d.canonical.z;return d.overscaledZ===0||d.overscaledZ>m&&d.canonical.y===this.canonical.y>>m}children(d){if(this.overscaledZ>=d)return[new Co(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const m=this.canonical.z+1,v=2*this.canonical.x,C=2*this.canonical.y;return[new Co(m,this.wrap,m,v,C),new Co(m,this.wrap,m,v+1,C),new Co(m,this.wrap,m,v,C+1),new Co(m,this.wrap,m,v+1,C+1)]}isLessThan(d){return this.wrapd.wrap)&&(this.overscaledZd.overscaledZ)&&(this.canonical.xd.canonical.x)&&this.canonical.y{let d=x.canonical.x-1,m=x.wrap;return d<0&&(d=(1<{let d=x.canonical.x+1,m=x.wrap;return d===1<new Co(x.overscaledZ,x.wrap,x.canonical.z,x.canonical.x,(x.canonical.y===0?1<new Co(x.overscaledZ,x.wrap,x.canonical.z,x.canonical.x,x.canonical.y===(1<1?null:function(v,C,E,P){const R=Math.sin(E);return v*(Math.sin((1-P)*E)/R)+C*(Math.sin(P*E)/R)}(x.a[d],x.b[d],x.angle,je(m,0,1))+x.center[d]}function Vp(x){if(x.z<=1)return hg[x.z+2*x.y+x.x];const d=spe(jF(x));return Or.fromPoints(d)}function pg(x,d,m){return be(x,x,1-m),Me(x,x,d,m)}function gCe(x,d,m){for(const v of x)ft(v,v,d),be(v,v,m)}function yCe(x,d,m,v){const C=d/x.worldSize,E=x.globeMatrix;if(m.z<=1){const qt=Vp(m).getCorners();return gCe(qt,E,C),Or.fromPoints(qt)}const P=jF(m,v),R=spe(P,Ud+Gf(x._tileCoverLift));gCe(R,E,C);const $=Number.MAX_VALUE,G=[-$,-$,-$],te=[$,$,$];if(P.contains(x.center)){for(const Gt of R)ue(te,te,Gt),pe(G,G,Gt);G[2]=0;const qt=x.point,ss=[qt.x*C,qt.y*C,0];return ue(te,te,ss),pe(G,G,ss),new Or(te,G)}if(x._tileCoverLift>0){for(const qt of R)ue(te,te,qt),pe(G,G,qt);return new Or(te,G)}const se=[E[12]*C,E[13]*C,E[14]*C],ae=P.getCenter(),de=je(x.center.lat,-we,we),he=je(ae.lat,-we,we),Se=W(x.center.lng),Fe=J(de);let Re=Se-W(ae.lng);const Ke=Fe-J(he);Re>.5?Re-=1:Re<-.5&&(Re+=1);let Xe=0;Math.abs(Re)>Math.abs(Ke)?Xe=Re>=0?1:3:(Xe=Ke>=0?0:2,Me(se,se,[E[4]*C,E[5]*C,E[6]*C],-Math.sin(jr(Ke>=0?P.getSouth():P.getNorth()))*Ud));const lt=R[Xe],kt=R[(Xe+1)%4],vt=new Oy(lt,kt,se),At=[mg(vt,0)||lt[0],mg(vt,1)||lt[1],mg(vt,2)||lt[2]],zt=_b(x.zoom);if(zt>0){const qt=function({x:Gt,y:ds,z:js},Ns,Fs,Bs,Ls){const Os=1/(1<.5?Vs=-1:zr<-.5&&(Vs=1),ls=((ls+Vs)*Ns-(Bs*=Ns))*Fs+Bs,rs=((rs+Vs)*Ns-Bs)*Fs+Bs,Rs=(Rs*Ns-(Ls*=Ns))*Fs+Ls,sr=(sr*Ns-Ls)*Fs+Ls,[[ls,sr,0],[rs,sr,0],[rs,Rs,0],[ls,Rs,0]]}(m,d,x._pixelsPerMercatorPixel,Se,Fe);for(let Gt=0;GtMath.PI/2*1.01}const jCe=jr(85),Tct=Math.cos(jCe),Act=Math.sin(jCe),Ect=_(),NCe=x=>{const d=[];return x.paint.get("circle-pitch-alignment")==="map"&&d.push("PITCH_WITH_MAP"),x.paint.get("circle-pitch-scale")==="map"&&d.push("SCALE_WITH_MAP"),d};function kCe(x,d,m,v,C,E,P,R,$){if(E&&x.queryGeometry.isAboveHorizon)return!1;E&&($*=x.pixelToTileUnitsFactor);const G=x.tileID.canonical,te=m.projection.upVectorScale(G,m.center.lat,m.worldSize).metersToTile;for(const se of d)for(const ae of se){const de=ae.add(R),he=C&&m.elevation?m.elevation.exaggeration()*C.getElevationAt(de.x,de.y,!0):0,Se=m.projection.projectTilePoint(de.x,de.y,G);if(he>0){const Xe=m.projection.upVector(G,de.x,de.y);Se.x+=Xe[0]*te*he,Se.y+=Xe[1]*te*he,Se.z+=Xe[2]*te*he}const Fe=E?de:Pct(Se.x,Se.y,Se.z,v),Re=E?x.tilespaceRays.map(Xe=>Lct(Xe,he)):x.queryGeometry.screenGeometry,Ke=Qe([],[Se.x,Se.y,Se.z,1],v);if(!P&&E?$*=Ke[3]/m.cameraToCenterDistance:P&&!E&&($*=m.cameraToCenterDistance/Ke[3]),E){const Xe=_e((ae.y/tr+G.y)/(1<x.width||C.height>x.height||m.x>x.width-C.width||m.y>x.height-C.height)throw new RangeError("out of range source coordinates for image copy");if(C.width>d.width||C.height>d.height||v.x>d.width-C.width||v.y>d.height-C.height)throw new RangeError("out of range destination coordinates for image copy");const $=x.data,G=d.data,te=E===4&&R;for(let se=0;se{d[x.evaluationKey]=$;const G=x.expression.evaluate(d),te=G?G.toNonPremultipliedRenderColor(null):null;te&&(C.data[P+R+0]=Math.floor(255*te.r),C.data[P+R+1]=Math.floor(255*te.g),C.data[P+R+2]=Math.floor(255*te.b),C.data[P+R+3]=Math.floor(255*te.a))};if(x.clips)for(let P=0,R=0;P80*m){R=x[0],$=x[1];let te=R,se=$;for(let ae=m;aete&&(te=de),he>se&&(se=he)}G=Math.max(te-R,se-$),G=G!==0?32767/G:0}return q6(E,P,m,R,$,G,0),P}function DCe(x,d,m,v,C){let E;if(C===function(P,R,$,G){let te=0;for(let se=R,ae=$-G;se<$;se+=G)te+=(P[ae]-P[se])*(P[se+1]+P[ae+1]),ae=se;return te}(x,d,m,v)>0)for(let P=d;P=d;P-=v)E=zCe(P/v|0,x[P],x[P+1],E);return E&&U3(E,E.next)&&(H6(E),E=E.next),E}function S2(x,d){if(!x)return x;d||(d=x);let m,v=x;do if(m=!1,v.steiner||!U3(v,v.next)&&Kc(v.prev,v,v.next)!==0)v=v.next;else{if(H6(v),v=d=v.prev,v===v.next)break;m=!0}while(m||v!==d);return d}function q6(x,d,m,v,C,E,P){if(!x)return;!P&&E&&function($,G,te,se){let ae=$;do ae.z===0&&(ae.z=ope(ae.x,ae.y,G,te,se)),ae.prevZ=ae.prev,ae.nextZ=ae.next,ae=ae.next;while(ae!==$);ae.prevZ.nextZ=null,ae.prevZ=null,function(de){let he,Se=1;do{let Fe,Re=de;de=null;let Ke=null;for(he=0;Re;){he++;let Xe=Re,lt=0;for(let vt=0;vt0||kt>0&&Xe;)lt!==0&&(kt===0||!Xe||Re.z<=Xe.z)?(Fe=Re,Re=Re.nextZ,lt--):(Fe=Xe,Xe=Xe.nextZ,kt--),Ke?Ke.nextZ=Fe:de=Fe,Fe.prevZ=Ke,Ke=Fe;Re=Xe}Ke.nextZ=null,Se*=2}while(he>1)}(ae)}(x,v,C,E);let R=x;for(;x.prev!==x.next;){const $=x.prev,G=x.next;if(E?Bct(x,v,C,E):zct(x))d.push($.i,x.i,G.i),H6(x),x=G.next,R=G.next;else if((x=G)===R){P?P===1?q6(x=$ct(S2(x),d),d,m,v,C,E,2):P===2&&qct(x,d,m,v,C,E):q6(S2(x),d,m,v,C,E,1);break}}}function zct(x){const d=x.prev,m=x,v=x.next;if(Kc(d,m,v)>=0)return!1;const C=d.x,E=m.x,P=v.x,R=d.y,$=m.y,G=v.y,te=Math.min(C,E,P),se=Math.min(R,$,G),ae=Math.max(C,E,P),de=Math.max(R,$,G);let he=v.next;for(;he!==d;){if(he.x>=te&&he.x<=ae&&he.y>=se&&he.y<=de&&U6(C,R,E,$,P,G,he.x,he.y)&&Kc(he.prev,he,he.next)>=0)return!1;he=he.next}return!0}function Bct(x,d,m,v){const C=x.prev,E=x,P=x.next;if(Kc(C,E,P)>=0)return!1;const R=C.x,$=E.x,G=P.x,te=C.y,se=E.y,ae=P.y,de=Math.min(R,$,G),he=Math.min(te,se,ae),Se=Math.max(R,$,G),Fe=Math.max(te,se,ae),Re=ope(de,he,d,m,v),Ke=ope(Se,Fe,d,m,v);let Xe=x.prevZ,lt=x.nextZ;for(;Xe&&Xe.z>=Re&<&<.z<=Ke;){if(Xe.x>=de&&Xe.x<=Se&&Xe.y>=he&&Xe.y<=Fe&&Xe!==C&&Xe!==P&&U6(R,te,$,se,G,ae,Xe.x,Xe.y)&&Kc(Xe.prev,Xe,Xe.next)>=0||(Xe=Xe.prevZ,lt.x>=de&<.x<=Se&<.y>=he&<.y<=Fe&<!==C&<!==P&&U6(R,te,$,se,G,ae,lt.x,lt.y)&&Kc(lt.prev,lt,lt.next)>=0))return!1;lt=lt.nextZ}for(;Xe&&Xe.z>=Re;){if(Xe.x>=de&&Xe.x<=Se&&Xe.y>=he&&Xe.y<=Fe&&Xe!==C&&Xe!==P&&U6(R,te,$,se,G,ae,Xe.x,Xe.y)&&Kc(Xe.prev,Xe,Xe.next)>=0)return!1;Xe=Xe.prevZ}for(;lt&<.z<=Ke;){if(lt.x>=de&<.x<=Se&<.y>=he&<.y<=Fe&<!==C&<!==P&&U6(R,te,$,se,G,ae,lt.x,lt.y)&&Kc(lt.prev,lt,lt.next)>=0)return!1;lt=lt.nextZ}return!0}function $ct(x,d){let m=x;do{const v=m.prev,C=m.next.next;!U3(v,C)&&RCe(v,m,m.next,C)&&V6(v,C)&&V6(C,v)&&(d.push(v.i,m.i,C.i),H6(m),H6(m.next),m=x=C),m=m.next}while(m!==x);return S2(m)}function qct(x,d,m,v,C,E){let P=x;do{let R=P.next.next;for(;R!==P.prev;){if(P.i!==R.i&&Gct(P,R)){let $=FCe(P,R);return P=S2(P,P.next),$=S2($,$.next),q6(P,d,m,v,C,E,0),void q6($,d,m,v,C,E,0)}R=R.next}P=P.next}while(P!==x)}function Uct(x,d){let m=x.x-d.x;return m===0&&(m=x.y-d.y,m===0)&&(m=(x.next.y-x.y)/(x.next.x-x.x)-(d.next.y-d.y)/(d.next.x-d.x)),m}function Vct(x,d){const m=function(C,E){let P=E;const R=C.x,$=C.y;let G,te=-1/0;if(U3(C,P))return P;do{if(U3(C,P.next))return P.next;if($<=P.y&&$>=P.next.y&&P.next.y!==P.y){const Se=P.x+($-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(Se<=R&&Se>te&&(te=Se,G=P.x=P.x&&P.x>=ae&&R!==P.x&&OCe($G.x||P.x===G.x&&Hct(G,P)))&&(G=P,he=Se)}P=P.next}while(P!==se);return G}(x,d);if(!m)return d;const v=FCe(m,x);return S2(v,v.next),S2(m,m.next)}function Hct(x,d){return Kc(x.prev,x,d.prev)<0&&Kc(d.next,x,x.next)<0}function ope(x,d,m,v,C){return(x=1431655765&((x=858993459&((x=252645135&((x=16711935&((x=(x-m)*C|0)|x<<8))|x<<4))|x<<2))|x<<1))|(d=1431655765&((d=858993459&((d=252645135&((d=16711935&((d=(d-v)*C|0)|d<<8))|d<<4))|d<<2))|d<<1))<<1}function Wct(x){let d=x,m=x;do(d.x=(x-P)*(E-R)&&(x-P)*(v-R)>=(m-P)*(d-R)&&(m-P)*(E-R)>=(C-P)*(v-R)}function U6(x,d,m,v,C,E,P,R){return!(x===P&&d===R)&&OCe(x,d,m,v,C,E,P,R)}function Gct(x,d){return x.next.i!==d.i&&x.prev.i!==d.i&&!function(m,v){let C=m;do{if(C.i!==m.i&&C.next.i!==m.i&&C.i!==v.i&&C.next.i!==v.i&&RCe(C,C.next,m,v))return!0;C=C.next}while(C!==m);return!1}(x,d)&&(V6(x,d)&&V6(d,x)&&function(m,v){let C=m,E=!1;const P=(m.x+v.x)/2,R=(m.y+v.y)/2;do C.y>R!=C.next.y>R&&C.next.y!==C.y&&P<(C.next.x-C.x)*(R-C.y)/(C.next.y-C.y)+C.x&&(E=!E),C=C.next;while(C!==m);return E}(x,d)&&(Kc(x.prev,x,d.prev)||Kc(x,d.prev,d))||U3(x,d)&&Kc(x.prev,x,x.next)>0&&Kc(d.prev,d,d.next)>0)}function Kc(x,d,m){return(d.y-x.y)*(m.x-d.x)-(d.x-x.x)*(m.y-d.y)}function U3(x,d){return x.x===d.x&&x.y===d.y}function RCe(x,d,m,v){const C=CF(Kc(x,d,m)),E=CF(Kc(x,d,v)),P=CF(Kc(m,v,x)),R=CF(Kc(m,v,d));return C!==E&&P!==R||!(C!==0||!SF(x,m,d))||!(E!==0||!SF(x,v,d))||!(P!==0||!SF(m,x,v))||!(R!==0||!SF(m,d,v))}function SF(x,d,m){return d.x<=Math.max(x.x,m.x)&&d.x>=Math.min(x.x,m.x)&&d.y<=Math.max(x.y,m.y)&&d.y>=Math.min(x.y,m.y)}function CF(x){return x>0?1:x<0?-1:0}function V6(x,d){return Kc(x.prev,x,x.next)<0?Kc(x,d,x.next)>=0&&Kc(x,x.prev,d)>=0:Kc(x,d,x.prev)<0||Kc(x,x.next,d)<0}function FCe(x,d){const m=lpe(x.i,x.x,x.y),v=lpe(d.i,d.x,d.y),C=x.next,E=d.prev;return x.next=d,d.prev=x,m.next=C,C.prev=m,v.next=m,m.prev=v,E.next=v,v.prev=E,v}function zCe(x,d,m,v){const C=lpe(x,d,m);return v?(C.next=v.next,C.prev=v,v.next.prev=C,v.next=C):(C.prev=C,C.next=C),C}function H6(x){x.next.prev=x.prev,x.prev.next=x.next,x.prevZ&&(x.prevZ.nextZ=x.nextZ),x.nextZ&&(x.nextZ.prevZ=x.prevZ)}function lpe(x,d,m){return{i:x,x:d,y:m,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function W6(x,d){const m=x.length;if(m<=1)return[x];const v=[];let C,E;for(let P=0;P1)for(let P=0;P=tr&&m>=tr}static evaluate(d){if(d.length===0)return new fv;let m=[];for(const $ of d)m.push(...$.portals);if(m.length===0)return new fv;for(const $ of m){const G=$.va,te=$.vb;(fv.isOnBorder(G.x,te.x)||fv.isOnBorder(G.y,te.y))&&($.type="border")}const v=m.filter($=>$.type!=="unevaluated"),C=m.filter($=>$.type==="unevaluated");if(C.length===0)return new fv;C.sort(($,G)=>$.hash===G.hash?$.isTunnel===G.isTunnel?0:$.isTunnel?-1:1:$.hash$.hashE!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new qp(m,{zoom:v,lut:C},E=>E!=="fill-bridge-guard-rail-color")}addVertices(d,m){const v=this.unevalVertices.length;for(let C=0;C=E.min.x&&se.x<=E.max.x&&se.y>=E.min.y&&se.y<=E.max.y||ae.x>=E.min.x&&ae.x<=E.max.x&&ae.y>=E.min.y&&ae.y<=E.max.y||Md(se,ae,R))||this.isOnBorder(se.x,ae.x)||this.isOnBorder(se.y,ae.y))continue;const de=mm.computeEdgeHash(this.unevalVertices[G],this.unevalVertices[te]);let he,Se=this.vertexHashLookup.get(mm.computePosHash(se));Se!=null?he=Se.next:(Se=this.vertexHashLookup.get(mm.computePosHash(ae)),he=Se!=null?Se.prev:de),this.unevalEdges.push({polygonIdx:d,a:G,b:te,hash:de,portalHash:he,isTunnel:C,type:"unevaluated",featureInfo:P})}}addPortalCandidates(d,m,v,C,E){if(m.length===0)return;this.portalPolygons.add(d,{geometry:m,zLevel:E});const P=m[0];this.vertexHashLookup.clear();let R=mm.computeEdgeHash(P[P.length-2],P[P.length-1]);for(let $=0;$({vertexOffset:0,primitiveOffset:this.indexArray.length}),v=ae=>{ae.primitiveLength=this.indexArray.length-ae.primitiveOffset},C=new Zct(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(d.portals,this.unevalEdges);const E=m(),P=m(),R=m(),$=(ae,de)=>{ae.sort((Se,Fe)=>Se.type===de&&Fe.type!==de?-1:Se.type!==de&&Fe.type===de?1:0);const he=ae.findIndex(Se=>Se.type!==de);return he>=0?he:ae.length};let G=0;this.unevalEdges.length>0&&(G=$(this.unevalEdges,"none"),this.constructBridgeStructures(C,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:G},this.tileToMeters)),v(R);const te=m(),se=m();if(this.unevalEdges.length>0){const ae=this.unevalEdges.splice(G),de=$(ae,"tunnel")+G;this.unevalEdges.push(...ae),this.constructTunnelStructures(C,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:G},{min:G,max:de})}v(te),C.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),v(se),C.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),v(P),C.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),v(E),this.maskSegments=bo.simpleSegment(0,se.primitiveOffset,0,se.primitiveLength),this.depthSegments=bo.simpleSegment(0,P.primitiveOffset,0,P.primitiveLength),this.renderableBridgeSegments=bo.simpleSegment(0,R.primitiveOffset,0,R.primitiveLength),this.renderableTunnelSegments=bo.simpleSegment(0,te.primitiveOffset,0,te.primitiveLength),this.shadowCasterSegments=bo.simpleSegment(0,E.primitiveOffset,0,E.primitiveLength)}update(d,m,v,C,E,P,R,$){this.bridgeProgramConfigurations.updatePaintArrays(d,m,E,v,C,P,R,$),this.tunnelProgramConfigurations.updatePaintArrays(d,m,E,v,C,P,R,$)}upload(d){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=d.createVertexBuffer(this.vertexPositions,Rct.members),this.vertexBufferNormal=d.createVertexBuffer(this.vertexNormals,Fct.members),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(d),this.tunnelProgramConfigurations.upload(d))}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy()}populatePaintArrays(d,m,v,C,E){const P=(R,$)=>{for(let G=0;G<$.length-1;G++){const te=$[G].featureIndex,se=$[G+1].vertexStart,ae=d.feature(te);R.populatePaintArrays(se,ae,te,{},v,m,C,void 0,E)}};P(this.bridgeProgramConfigurations,this.bridgeFeatureSections),P(this.tunnelProgramConfigurations,this.tunnelFeatureSections)}computeVertexConnections(d,m,v,C,E){const P=new Map;for(let R=C;Roe(Fs,m[Bs].x,m[Bs].y,v[Bs]*$),se=ee(),ae=ee(),de=ee(),he=ee(),Se=ee(),Fe=(Fs,Bs)=>{const Ls=R.get(mm.computePosHash(m[Bs])),Os=Ls.from,ls=Ls.to;if(!Os||!ls)return;te(se,Os),te(ae,Bs),te(de,ls),at(he),et(se,ae)||(Ce(Se,ae,se),ke(he,Se)),et(de,ae)||(Ce(Se,de,ae),ce(he,he,ke(Se,Se)));const rs=Ge(he);return rs>0?be(Fs,he,1/rs):void 0};let Re=Number.POSITIVE_INFINITY;this.sortSubarray(C,E.min,E.max,(Fs,Bs)=>Fs.featureInfo.featureIndex-Bs.featureInfo.featureIndex);const Ke=ee(),Xe=ee(),lt=ee(),kt=ee(),vt=ee(),At=ee(),zt=ee(),qt=ee(),ss=ee(),Gt=[ee(),ee(),ee(),ee()],ds=[ee(),ee(),ee(),ee()],js=[{coord:new pt(0,0),height:0},{coord:new pt(0,0),height:0}],Ns=(Fs,Bs)=>Fs>Bs;for(let Fs=E.min;FsRe.featureInfo.featureIndex-Ke.featureInfo.featureIndex;this.sortSubarray(C,E.min,E.max,$),this.sortSubarray(C,P.min,P.max,$);const G=Re=>ke(Re,Re),te=[{coord:new pt(0,0),height:0},{coord:new pt(0,0),height:0}],se=(Re,Ke)=>ReR.hash===$.hash?$.polygonIdx-R.polygonIdx:$.hash>R.hash?1:-1);let v=0,C=0,E=0,P=m[v].polygonIdx;do C++,(C===m.length||m[v].hash!==m[C].hash)&&((C-v==1||m[C-1].polygonIdx!==P)&&(EG.portalHashte.hash?R++:te.hash>G.portalHash?$++:(G.type=te.type,R++)}}}isOnBorder(d,m){return d<=0&&m<=0||d>=tr&&m>=tr}addFeatureSection(d,m,v,C){return d!==m&&(m=d,v.push({featureIndex:d,vertexStart:C.getVertexCount()}),C.clearVertexLookup()),m}sortSubarray(d,m,v,C){const E=d.slice(m,v);E.sort(C),d.splice(m,E.length,...E)}static computeEdgeHash(d,m){return(d.y===m.y&&d.x>m.x||d.y>m.y)&&([d,m]=[m,d]),BigInt(mm.computePosHash(d))<<32n|BigInt(mm.computePosHash(m))}static computePosHash(d){return((65535&d.x)<<16|65535&d.y)>>>0}}var qCe,UCe={exports:{}},VCe=(qCe||(qCe=1,function(x){function d(_t,Ct){return _t>Ct?1:_t0){var Br=zs+Math.floor(lr/2),Vr={key:Ct[Br],data:us[Br],parent:_t};return Vr.left=C(Vr,Ct,us,zs,Br),Vr.right=C(Vr,Ct,us,Br+1,or),Vr}return null}function E(_t,Ct,us,zs,or){if(!(us>=zs)){for(var lr=_t[us+zs>>1],Br=us-1,Vr=zs+1;;){do Br++;while(or(_t[Br],lr)<0);do Vr--;while(or(_t[Vr],lr)>0);if(Br>=Vr)break;var In=_t[Br];_t[Br]=_t[Vr],_t[Vr]=In,In=Ct[Br],Ct[Br]=Ct[Vr],Ct[Vr]=In}E(_t,Ct,us,Vr,or),E(_t,Ct,Vr+1,zs,or)}}m.prototype.rotateLeft=function(_t){var Ct=_t.right;Ct&&(_t.right=Ct.left,Ct.left&&(Ct.left.parent=_t),Ct.parent=_t.parent),_t.parent?_t===_t.parent.left?_t.parent.left=Ct:_t.parent.right=Ct:this._root=Ct,Ct&&(Ct.left=_t),_t.parent=Ct},m.prototype.rotateRight=function(_t){var Ct=_t.left;Ct&&(_t.left=Ct.right,Ct.right&&(Ct.right.parent=_t),Ct.parent=_t.parent),_t.parent?_t===_t.parent.left?_t.parent.left=Ct:_t.parent.right=Ct:this._root=Ct,Ct&&(Ct.right=_t),_t.parent=Ct},m.prototype._splay=function(_t){for(;_t.parent;){var Ct=_t.parent;Ct.parent?Ct.left===_t&&Ct.parent.left===Ct?(this.rotateRight(Ct.parent),this.rotateRight(Ct)):Ct.right===_t&&Ct.parent.right===Ct?(this.rotateLeft(Ct.parent),this.rotateLeft(Ct)):Ct.left===_t&&Ct.parent.right===Ct?(this.rotateRight(Ct),this.rotateLeft(Ct)):(this.rotateLeft(Ct),this.rotateRight(Ct)):Ct.left===_t?this.rotateRight(Ct):this.rotateLeft(Ct)}},m.prototype.splay=function(_t){for(var Ct,us,zs,or,lr;_t.parent;)(us=(Ct=_t.parent).parent)&&us.parent?((zs=us.parent).left===us?zs.left=_t:zs.right=_t,_t.parent=zs):(_t.parent=null,this._root=_t),or=_t.left,lr=_t.right,_t===Ct.left?(us&&(us.left===Ct?(Ct.right?(us.left=Ct.right,us.left.parent=us):us.left=null,Ct.right=us,us.parent=Ct):(or?(us.right=or,or.parent=us):us.right=null,_t.left=us,us.parent=_t)),lr?(Ct.left=lr,lr.parent=Ct):Ct.left=null,_t.right=Ct,Ct.parent=_t):(us&&(us.right===Ct?(Ct.left?(us.right=Ct.left,us.right.parent=us):us.right=null,Ct.left=us,us.parent=Ct):(lr?(us.left=lr,lr.parent=us):us.left=null,_t.right=us,us.parent=_t)),or?(Ct.right=or,or.parent=Ct):Ct.right=null,_t.left=Ct,Ct.parent=_t)},m.prototype.replace=function(_t,Ct){_t.parent?_t===_t.parent.left?_t.parent.left=Ct:_t.parent.right=Ct:this._root=Ct,Ct&&(Ct.parent=_t.parent)},m.prototype.minNode=function(_t){if(_t===void 0&&(_t=this._root),_t)for(;_t.left;)_t=_t.left;return _t},m.prototype.maxNode=function(_t){if(_t===void 0&&(_t=this._root),_t)for(;_t.right;)_t=_t.right;return _t},m.prototype.insert=function(_t,Ct){var us=this._root,zs=null,or=this._compare;if(this._noDuplicates)for(;us;){if(zs=us,or(us.key,_t)===0)return;us=or(us.key,_t)<0?us.right:us.left}else for(;us;)zs=us,us=or(us.key,_t)<0?us.right:us.left;return us={key:_t,data:Ct,left:null,right:null,parent:zs},zs?or(zs.key,us.key)<0?zs.right=us:zs.left=us:this._root=us,this.splay(us),this._size++,us},m.prototype.find=function(_t){for(var Ct=this._root,us=this._compare;Ct;){var zs=us(Ct.key,_t);if(zs<0)Ct=Ct.right;else{if(!(zs>0))return Ct;Ct=Ct.left}}return null},m.prototype.contains=function(_t){for(var Ct=this._root,us=this._compare;Ct;){var zs=us(_t,Ct.key);if(zs===0)return!0;Ct=zs<0?Ct.left:Ct.right}return!1},m.prototype.remove=function(_t){var Ct=this.find(_t);if(!Ct)return!1;if(this.splay(Ct),Ct.left)if(Ct.right){var us=this.minNode(Ct.right);us.parent!==Ct&&(this.replace(us,us.right),us.right=Ct.right,us.right.parent=us),this.replace(Ct,us),us.left=Ct.left,us.left.parent=us}else this.replace(Ct,Ct.left);else this.replace(Ct,Ct.right);return this._size--,!0},m.prototype.removeNode=function(_t){if(!_t)return!1;if(this.splay(_t),_t.left)if(_t.right){var Ct=this.minNode(_t.right);Ct.parent!==_t&&(this.replace(Ct,Ct.right),Ct.right=_t.right,Ct.right.parent=Ct),this.replace(_t,Ct),Ct.left=_t.left,Ct.left.parent=Ct}else this.replace(_t,_t.left);else this.replace(_t,_t.right);return this._size--,!0},m.prototype.erase=function(_t){var Ct=this.find(_t);if(Ct){this.splay(Ct);var us=Ct.left,zs=Ct.right,or=null;us&&(us.parent=null,or=this.maxNode(us),this.splay(or),this._root=or),zs&&(us?or.right=zs:this._root=zs,zs.parent=or),this._size--}},m.prototype.pop=function(){var _t=this._root,Ct=null;if(_t){for(;_t.left;)_t=_t.left;Ct={key:_t.key,data:_t.data},this.remove(_t.key)}return Ct},m.prototype.next=function(_t){var Ct=_t;if(Ct)if(Ct.right)for(Ct=Ct.right;Ct&&Ct.left;)Ct=Ct.left;else for(Ct=_t.parent;Ct&&Ct.right===_t;)_t=Ct,Ct=Ct.parent;return Ct},m.prototype.prev=function(_t){var Ct=_t;if(Ct)if(Ct.left)for(Ct=Ct.left;Ct&&Ct.right;)Ct=Ct.right;else for(Ct=_t.parent;Ct&&Ct.left===_t;)_t=Ct,Ct=Ct.parent;return Ct},m.prototype.forEach=function(_t){for(var Ct=this._root,us=[],zs=!1,or=0;!zs;)Ct?(us.push(Ct),Ct=Ct.left):us.length>0?(_t(Ct=us.pop(),or++),Ct=Ct.right):zs=!0;return this},m.prototype.range=function(_t,Ct,us,zs){for(var or=[],lr=this._compare,Br=this._root;or.length!==0||Br;)if(Br)or.push(Br),Br=Br.left;else{if(lr((Br=or.pop()).key,Ct)>0)break;if(lr(Br.key,_t)>=0&&us.call(zs,Br))return this;Br=Br.right}return this},m.prototype.keys=function(){for(var _t=this._root,Ct=[],us=[],zs=!1;!zs;)_t?(Ct.push(_t),_t=_t.left):Ct.length>0?(_t=Ct.pop(),us.push(_t.key),_t=_t.right):zs=!0;return us},m.prototype.values=function(){for(var _t=this._root,Ct=[],us=[],zs=!1;!zs;)_t?(Ct.push(_t),_t=_t.left):Ct.length>0?(_t=Ct.pop(),us.push(_t.data),_t=_t.right):zs=!0;return us},m.prototype.at=function(_t){for(var Ct=this._root,us=[],zs=!1,or=0;!zs;)if(Ct)us.push(Ct),Ct=Ct.left;else if(us.length>0){if(Ct=us.pop(),or===_t)return Ct;or++,Ct=Ct.right}else zs=!0;return null},m.prototype.load=function(_t,Ct,us){if(_t===void 0&&(_t=[]),Ct===void 0&&(Ct=[]),us===void 0&&(us=!1),this._size!==0)throw new Error("bulk-load: tree is not empty");var zs=_t.length;return us&&E(_t,Ct,0,zs-1,this._compare),this._root=C(null,_t,Ct,0,zs),this._size=zs,this},m.prototype.min=function(){var _t=this.minNode(this._root);return _t?_t.key:null},m.prototype.max=function(){var _t=this.maxNode(this._root);return _t?_t.key:null},m.prototype.isEmpty=function(){return this._root===null},v.size.get=function(){return this._size},m.createTree=function(_t,Ct,us,zs,or){return new m(us,or).load(_t,Ct,zs)},Object.defineProperties(m.prototype,v);var P=0,R=1,$=2,G=3,te=0,se=1,ae=2,de=3;function he(_t,Ct,us){Ct===null?(_t.inOut=!1,_t.otherInOut=!0):(_t.isSubject===Ct.isSubject?(_t.inOut=!Ct.inOut,_t.otherInOut=Ct.otherInOut):(_t.inOut=!Ct.otherInOut,_t.otherInOut=Ct.isVertical()?!Ct.inOut:Ct.inOut),Ct&&(_t.prevInResult=!Se(Ct,us)||Ct.isVertical()?Ct.prevInResult:Ct));var zs=Se(_t,us);_t.resultTransition=zs?function(or,lr){var Br,Vr=!or.inOut,In=!or.otherInOut;switch(lr){case te:Br=Vr&&In;break;case se:Br=Vr||In;break;case de:Br=Vr^In;break;case ae:Br=or.isSubject?Vr&&!In:In&&!Vr}return Br?1:-1}(_t,us):0}function Se(_t,Ct){switch(_t.type){case P:switch(Ct){case te:return!_t.otherInOut;case se:return _t.otherInOut;case ae:return _t.isSubject&&_t.otherInOut||!_t.isSubject&&!_t.otherInOut;case de:return!0}break;case $:return Ct===te||Ct===se;case G:return Ct===ae;case R:return!1}return!1}var Fe=function(_t,Ct,us,zs,or){this.left=Ct,this.point=_t,this.otherEvent=us,this.isSubject=zs,this.type=or||P,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0},Re={inResult:{configurable:!0}};function Ke(_t,Ct){return _t[0]===Ct[0]&&_t[1]===Ct[1]}Fe.prototype.isBelow=function(_t){var Ct=this.point,us=this.otherEvent.point;return this.left?(Ct[0]-_t[0])*(us[1]-_t[1])-(us[0]-_t[0])*(Ct[1]-_t[1])>0:(us[0]-_t[0])*(Ct[1]-_t[1])-(Ct[0]-_t[0])*(us[1]-_t[1])>0},Fe.prototype.isAbove=function(_t){return!this.isBelow(_t)},Fe.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},Re.inResult.get=function(){return this.resultTransition!==0},Fe.prototype.clone=function(){var _t=new Fe(this.point,this.left,this.otherEvent,this.isSubject,this.type);return _t.contourId=this.contourId,_t.resultTransition=this.resultTransition,_t.prevInResult=this.prevInResult,_t.isExteriorRing=this.isExteriorRing,_t.inOut=this.inOut,_t.otherInOut=this.otherInOut,_t},Object.defineProperties(Fe.prototype,Re);var Xe=11102230246251565e-32,lt=134217729,kt=(3+8*Xe)*Xe;function vt(_t,Ct,us,zs,or){var lr,Br,Vr,In,Kn=Ct[0],Qn=zs[0],xa=0,an=0;Qn>Kn==Qn>-Kn?(lr=Kn,Kn=Ct[++xa]):(lr=Qn,Qn=zs[++an]);var vn=0;if(xa<_t&&anKn==Qn>-Kn?(Vr=lr-((Br=Kn+lr)-Kn),Kn=Ct[++xa]):(Vr=lr-((Br=Qn+lr)-Qn),Qn=zs[++an]),lr=Br,Vr!==0&&(or[vn++]=Vr);xa<_t&&anKn==Qn>-Kn?(Vr=lr-((Br=lr+Kn)-(In=Br-lr))+(Kn-In),Kn=Ct[++xa]):(Vr=lr-((Br=lr+Qn)-(In=Br-lr))+(Qn-In),Qn=zs[++an]),lr=Br,Vr!==0&&(or[vn++]=Vr);for(;xa<_t;)Vr=lr-((Br=lr+Kn)-(In=Br-lr))+(Kn-In),Kn=Ct[++xa],lr=Br,Vr!==0&&(or[vn++]=Vr);for(;an0!=xa>0)return an;var vn=Math.abs(Qn+xa);return Math.abs(an)>=zt*vn?an:-function(Va,Za,Ya,_i,Ri,Ei,ri){var hi,Zn,Sa,mo,sn,ga,Li,Ui,Zi,el,Hi,rn,jo,wi,ao,Ul,Ec,wl,jl=Va-Ri,uc=Ya-Ri,ph=Za-Ei,Wi=_i-Ei;Gt[0]=(ao=(Ui=jl-(Li=(ga=lt*jl)-(ga-jl)))*(el=Wi-(Zi=(ga=lt*Wi)-(ga-Wi)))-((wi=jl*Wi)-Li*Zi-Ui*Zi-Li*el))-((Hi=ao-(Ec=(Ui=ph-(Li=(ga=lt*ph)-(ga-ph)))*(el=uc-(Zi=(ga=lt*uc)-(ga-uc)))-((Ul=ph*uc)-Li*Zi-Ui*Zi-Li*el)))+(sn=ao-Hi))+(sn-Ec),Gt[1]=(jo=wi-((rn=wi+Hi)-(sn=rn-wi))+(Hi-sn))-((Hi=jo-Ul)+(sn=jo-Hi))+(sn-Ul),Gt[2]=rn-((wl=rn+Hi)-(sn=wl-rn))+(Hi-sn),Gt[3]=wl;var Wo=function(zy,Td){for(var $u=Td[0],fm=1;fm<4;fm++)$u+=Td[fm];return $u}(0,Gt),tl=qt*ri;if(Wo>=tl||-Wo>=tl||(hi=Va-(jl+(sn=Va-jl))+(sn-Ri),Sa=Ya-(uc+(sn=Ya-uc))+(sn-Ri),Zn=Za-(ph+(sn=Za-ph))+(sn-Ei),mo=_i-(Wi+(sn=_i-Wi))+(sn-Ei),hi===0&&Zn===0&&Sa===0&&mo===0)||(tl=ss*ri+kt*Math.abs(Wo),(Wo+=jl*mo+Wi*hi-(ph*Sa+uc*Zn))>=tl||-Wo>=tl))return Wo;Fs[0]=(ao=(Ui=hi-(Li=(ga=lt*hi)-(ga-hi)))*(el=Wi-(Zi=(ga=lt*Wi)-(ga-Wi)))-((wi=hi*Wi)-Li*Zi-Ui*Zi-Li*el))-((Hi=ao-(Ec=(Ui=Zn-(Li=(ga=lt*Zn)-(ga-Zn)))*(el=uc-(Zi=(ga=lt*uc)-(ga-uc)))-((Ul=Zn*uc)-Li*Zi-Ui*Zi-Li*el)))+(sn=ao-Hi))+(sn-Ec),Fs[1]=(jo=wi-((rn=wi+Hi)-(sn=rn-wi))+(Hi-sn))-((Hi=jo-Ul)+(sn=jo-Hi))+(sn-Ul),Fs[2]=rn-((wl=rn+Hi)-(sn=wl-rn))+(Hi-sn),Fs[3]=wl;var Oh=vt(4,Gt,4,Fs,ds);Fs[0]=(ao=(Ui=jl-(Li=(ga=lt*jl)-(ga-jl)))*(el=mo-(Zi=(ga=lt*mo)-(ga-mo)))-((wi=jl*mo)-Li*Zi-Ui*Zi-Li*el))-((Hi=ao-(Ec=(Ui=ph-(Li=(ga=lt*ph)-(ga-ph)))*(el=Sa-(Zi=(ga=lt*Sa)-(ga-Sa)))-((Ul=ph*Sa)-Li*Zi-Ui*Zi-Li*el)))+(sn=ao-Hi))+(sn-Ec),Fs[1]=(jo=wi-((rn=wi+Hi)-(sn=rn-wi))+(Hi-sn))-((Hi=jo-Ul)+(sn=jo-Hi))+(sn-Ul),Fs[2]=rn-((wl=rn+Hi)-(sn=wl-rn))+(Hi-sn),Fs[3]=wl;var Vl=vt(Oh,ds,4,Fs,js);Fs[0]=(ao=(Ui=hi-(Li=(ga=lt*hi)-(ga-hi)))*(el=mo-(Zi=(ga=lt*mo)-(ga-mo)))-((wi=hi*mo)-Li*Zi-Ui*Zi-Li*el))-((Hi=ao-(Ec=(Ui=Zn-(Li=(ga=lt*Zn)-(ga-Zn)))*(el=Sa-(Zi=(ga=lt*Sa)-(ga-Sa)))-((Ul=Zn*Sa)-Li*Zi-Ui*Zi-Li*el)))+(sn=ao-Hi))+(sn-Ec),Fs[1]=(jo=wi-((rn=wi+Hi)-(sn=rn-wi))+(Hi-sn))-((Hi=jo-Ul)+(sn=jo-Hi))+(sn-Ul),Fs[2]=rn-((wl=rn+Hi)-(sn=wl-rn))+(Hi-sn),Fs[3]=wl;var Zf=vt(Vl,js,4,Fs,Ns);return Ns[Zf-1]}(or,lr,Br,Vr,In,Kn,vn)}(_t[0],_t[1],Ct[0],Ct[1],us[0],us[1]);return zs>0?-1:zs<0?1:0}function Ls(_t,Ct){var us=_t.point,zs=Ct.point;return us[0]>zs[0]?1:us[0]zs[1]?1:-1:function(or,lr,Br,Vr){return or.left!==lr.left?or.left?1:-1:Bs(Br,or.otherEvent.point,lr.otherEvent.point)!==0?or.isBelow(lr.otherEvent.point)?-1:1:!or.isSubject&&lr.isSubject?1:-1}(_t,Ct,us)}function Os(_t,Ct,us){var zs=new Fe(Ct,!1,_t,_t.isSubject),or=new Fe(Ct,!0,_t.otherEvent,_t.isSubject);return Ke(_t.point,_t.otherEvent.point)&&console.warn("what is that, a collapsed segment?",_t),zs.contourId=or.contourId=_t.contourId,Ls(or,_t.otherEvent)>0&&(_t.otherEvent.left=!0,or.left=!1),_t.otherEvent.otherEvent=or,_t.otherEvent=zs,us.push(or),us.push(zs),us}function ls(_t,Ct){return _t[0]*Ct[1]-_t[1]*Ct[0]}function rs(_t,Ct){return _t[0]*Ct[0]+_t[1]*Ct[1]}function Rs(_t,Ct,us){var zs=function(In,Kn,Qn,xa,an){var vn=[Kn[0]-In[0],Kn[1]-In[1]],Va=[xa[0]-Qn[0],xa[1]-Qn[1]];function Za(ga,Li,Ui){return[ga[0]+Li*Ui[0],ga[1]+Li*Ui[1]]}var Ya=[Qn[0]-In[0],Qn[1]-In[1]],_i=ls(vn,Va),Ri=_i*_i,Ei=rs(vn,vn);if(Ri>0){var ri=ls(Ya,Va)/_i;if(ri<0||ri>1)return null;var hi=ls(Ya,vn)/_i;return hi<0||hi>1?null:ri===0||ri===1?[Za(In,ri,vn)]:hi===0||hi===1?[Za(Qn,hi,Va)]:[Za(In,ri,vn)]}if((Ri=(_i=ls(Ya,vn))*_i)>0)return null;var Zn=rs(vn,Ya)/Ei,Sa=Zn+rs(vn,Va)/Ei,mo=Math.min(Zn,Sa),sn=Math.max(Zn,Sa);return mo<=1&&sn>=0?mo===1?[Za(In,mo>0?mo:0,vn)]:sn===0?[Za(In,sn<1?sn:1,vn)]:[Za(In,mo>0?mo:0,vn),Za(In,sn<1?sn:1,vn)]:null}(_t.point,_t.otherEvent.point,Ct.point,Ct.otherEvent.point),or=zs?zs.length:0;if(or===0||or===1&&(Ke(_t.point,Ct.point)||Ke(_t.otherEvent.point,Ct.otherEvent.point))||or===2&&_t.isSubject===Ct.isSubject)return 0;if(or===1)return Ke(_t.point,zs[0])||Ke(_t.otherEvent.point,zs[0])||Os(_t,zs[0],us),Ke(Ct.point,zs[0])||Ke(Ct.otherEvent.point,zs[0])||Os(Ct,zs[0],us),1;var lr=[],Br=!1,Vr=!1;return Ke(_t.point,Ct.point)?Br=!0:Ls(_t,Ct)===1?lr.push(Ct,_t):lr.push(_t,Ct),Ke(_t.otherEvent.point,Ct.otherEvent.point)?Vr=!0:Ls(_t.otherEvent,Ct.otherEvent)===1?lr.push(Ct.otherEvent,_t.otherEvent):lr.push(_t.otherEvent,Ct.otherEvent),Br&&Vr||Br?(Ct.type=R,_t.type=Ct.inOut===_t.inOut?$:G,Br&&!Vr&&Os(lr[1].otherEvent,lr[0].point,us),2):Vr?(Os(lr[0],lr[1].point,us),3):lr[0]!==lr[3].otherEvent?(Os(lr[0],lr[1].point,us),Os(lr[1],lr[2].point,us),3):(Os(lr[0],lr[1].point,us),Os(lr[3].otherEvent,lr[2].point,us),3)}function sr(_t,Ct){if(_t===Ct)return 0;if(Bs(_t.point,_t.otherEvent.point,Ct.point)!==0||Bs(_t.point,_t.otherEvent.point,Ct.otherEvent.point)!==0)return Ke(_t.point,Ct.point)?_t.isBelow(Ct.otherEvent.point)?-1:1:_t.point[0]===Ct.point[0]?_t.point[1]Ct.contourId?1:-1:Ls(_t,Ct)===1?1:-1}var Vs=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function zr(_t,Ct,us,zs){var or,lr=_t+1,Br=Ct[_t].point,Vr=Ct.length;for(lrzs;)lr--;return lr}Vs.prototype.isExterior=function(){return this.holeOf==null};var mr=Tr,_r=Tr;function Tr(_t,Ct){if(!(this instanceof Tr))return new Tr(_t,Ct);if(this.data=_t||[],this.length=this.data.length,this.compare=Ct||ta,this.length>0)for(var us=(this.length>>1)-1;us>=0;us--)this._down(us)}function ta(_t,Ct){return _tCt?1:0}Tr.prototype={push:function(_t){this.data.push(_t),this.length++,this._up(this.length-1)},pop:function(){if(this.length!==0){var _t=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),_t}},peek:function(){return this.data[0]},_up:function(_t){for(var Ct=this.data,us=this.compare,zs=Ct[_t];_t>0;){var or=_t-1>>1,lr=Ct[or];if(us(zs,lr)>=0)break;Ct[_t]=lr,_t=or}Ct[_t]=zs},_down:function(_t){for(var Ct=this.data,us=this.compare,zs=this.length>>1,or=Ct[_t];_t=0)break;Ct[_t]=Vr,_t=lr}Ct[_t]=or}},mr.default=_r;var Ks=Math.max,Ar=Math.min,_n=0;function ja(_t,Ct,us,zs,or,lr){var Br,Vr,In,Kn,Qn,xa;for(Br=0,Vr=_t.length-1;Br0?xa.left=!0:Qn.left=!0;var an=In[0],vn=In[1];or[0]=Ar(or[0],an),or[1]=Ar(or[1],vn),or[2]=Ks(or[2],an),or[3]=Ks(or[3],vn),zs.push(Qn),zs.push(xa)}}var Ca=[];function $n(_t,Ct,us){typeof _t[0][0][0]=="number"&&(_t=[_t]),typeof Ct[0][0][0]=="number"&&(Ct=[Ct]);var zs=function(vn,Va,Za){var Ya=null;return vn.length*Va.length==0&&(Za===te?Ya=Ca:Za===ae?Ya=vn:Za!==se&&Za!==de||(Ya=vn.length===0?Va:vn)),Ya}(_t,Ct,us);if(zs)return zs===Ca?null:zs;var or=[1/0,1/0,-1/0,-1/0],lr=[1/0,1/0,-1/0,-1/0],Br=function(vn,Va,Za,Ya,_i){var Ri,Ei,ri,hi,Zn,Sa,mo=new mr(null,Ls);for(ri=0,hi=vn.length;riYa[2]||Ya[0]>Za[2]||Za[1]>Ya[3]||Ya[1]>Za[3])&&(_i===te?Ri=Ca:_i===ae?Ri=vn:_i!==se&&_i!==de||(Ri=vn.concat(Va))),Ri}(_t,Ct,or,lr,us))return zs===Ca?null:zs;for(var Vr=function(vn){var Va,Za,Ya=function(ri){var hi,Zn,Sa,mo,sn=[];for(Zn=0,Sa=ri.length;Zn0){var Hi=ga[el];if(Hi.holeOf!=null){var rn=Hi.holeOf;ga[rn].holeIds.push(Li),Ui.holeOf=rn,Ui.depth=ga[el].depth}else ga[el].holeIds.push(Li),Ui.holeOf=el,Ui.depth=ga[el].depth+1}else Ui.holeOf=null,Ui.depth=ga[el].depth}else Ui.holeOf=null,Ui.depth=0;return Ui}(Ya[Va],Ri,ri),Zn=function(sn){_i[sn]=!0,sn=Ya.length)&&Ya[Sa];);Ri.push(hi)}};for(Va=0,Za=Ya.length;Vamo||Ri===ae&&sn.point[0]>Ya[2])break;if(sn.left){ri=Ei=Zn.insert(sn),Ei=Ei!==(hi=Zn.minNode())?Zn.prev(Ei):null,ri=Zn.next(ri);var ga=Ei?Ei.key:null;if(he(sn,ga,Ri),ri&&Rs(sn,ri.key,vn)===2&&(he(sn,ga,Ri),he(ri.key,sn,Ri)),Ei&&Rs(Ei.key,sn,vn)===2){var Li=Ei;he(ga,(Li=Li!==hi?Zn.prev(Li):null)?Li.key:null,Ri),he(sn,ga,Ri)}}else ri=Ei=Zn.find(sn=sn.otherEvent),Ei&&ri&&(Ei=Ei!==hi?Zn.prev(Ei):null,ri=Zn.next(ri),Zn.remove(sn),ri&&Ei&&Rs(Ei.key,ri.key,vn))}return Sa}(Br,0,0,or,lr,us)),In=[],Kn=0;Kn * @license MIT * @preserve */function MF(x,d,m,v){const C=[],E=v===0?(P,R,$,G,te,se)=>{P.push(new pt(se,$+(se-R)/(G-R)*(te-$)))}:(P,R,$,G,te,se)=>{P.push(new pt(R+(se-$)/(te-$)*(G-R),se))};for(const P of x){const R=[];for(const $ of P){if($.length<=2)continue;const G=[];for(let ae=0;ae<$.length-1;ae++){const de=$[ae].x,he=$[ae].y,Se=$[ae+1].x,Fe=$[ae+1].y,Re=v===0?de:he,Ke=v===0?Se:Fe;Red&&E(G,de,he,Se,Fe,d):Re>m?Ke=d&&E(G,de,he,Se,Fe,d),Ke>m&&Re<=m&&E(G,de,he,Se,Fe,m)}let te=$[$.length-1];const se=v===0?te.x:te.y;se>=d&&se<=m&&G.push(te),G.length&&(te=G[G.length-1],G[0].x===te.x&&G[0].y===te.y||G.push(G[0]),R.push(G))}R.length&&C.push(R)}return C}function Yct(x,d){const m=upe(x),v=upe([d]),C=VCe.intersection(m,v);return C==null?[]:HCe(C)}function Xct(x,d){let v=upe(x,65536);const C=[];for(;d.valid();d.next()){const[E,P]=d.get(),R=E.x*65536,$=E.y*65536,G=P.x*65536,te=P.y*65536,se=G-R,ae=te-$,de=Math.hypot(se,ae);if(de===0)continue;const he=Math.trunc(ae/de*3),Se=-Math.trunc(se/de*3);C.push([[[R,$],[G,te],[G+he,te+Se],[R+he,$+Se],[R,$]]])}return C.length>0&&(v=VCe.diff(v,C)),HCe(v,1/65536)}function upe(x,d=1){return[x.map(m=>m.map(v=>[v.x*d,v.y*d]))]}function HCe(x,d=1){return x.map(m=>m.map((v,C)=>{const E=v.map(P=>new pt(P[0]*d,P[1]*d).round());return C>0&&E.reverse(),E}))}class hpe{constructor(d,m){this.layoutVertexArray=new Py,this.indexArray=new Bl,this.lineIndexArray=new um,this.triangleSegments=new bo,this.lineSegments=new bo,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut}),this.uploaded=!1,m&&(this.elevatedLayoutVertexArray=new og)}update(d,m,v,C,E,P,R,$){this.programConfigurations.updatePaintArrays(d,m,E,v,C,P,R,$)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,Dct.members),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.lineIndexBuffer=d.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=d.createVertexBuffer(this.elevatedLayoutVertexArray,Oct.members))),this.programConfigurations.upload(d),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(d,m,v,C,E,P,R){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,m,v,C,E,P,void 0,R)}}class mpe{constructor(d){this.zoom=d.zoom,this.pixelRatio=d.pixelRatio,this.overscaling=d.overscaling,this.layers=d.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=d.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=d.lut,this.bufferData=new hpe(d,!1),this.elevationBufferData=new hpe(d,!0),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.projection=d.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=d.sourceLayerIndex,this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,C){}populate(d,m,v,C){this.hasPattern=cpe("fill",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("fill-sort-key"),P=[];for(const{feature:R,id:$,index:G,sourceLayerIndex:te}of d){const se=this.layers[0]._featureFilter.needGeometry,ae=Wt(R,se);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ae,v))continue;const de=E?E.evaluate(ae,{},v,m.availableImages):void 0,he={id:$,properties:R.properties,type:R.type,sourceLayerIndex:te,index:G,geometry:se?ae.geometry:Ot(R,v,C),patterns:{},sortKey:de};P.push(he)}E&&P.sort((R,$)=>R.sortKey-$.sortKey);for(const R of P){const{geometry:$,index:G,sourceLayerIndex:te}=R;if(this.hasPattern){const se=dpe("fill",this.layers,R,this.zoom,this.pixelRatio,m);this.patternFeatures.push(se)}else this.addFeature(R,$,G,v,{},m.availableImages,m.brightness,m.elevationFeatures);m.featureIndex.insert(d[G].feature,$,G,te,this.index)}}update(d,m,v,C,E,P,R){this.bufferData.update(d,m,v,C,E,P,R,this.worldview),this.elevationBufferData.update(d,m,v,C,E,P,R,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(d,m,v,C,E,P,R,this.worldview)}addFeatures(d,m,v,C,E,P){for(const R of this.patternFeatures)this.addFeature(R,R.geometry,R.index,m,v,C,P,d.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(d){this.bufferData.upload(d),this.elevationBufferData.upload(d),this.elevatedStructures&&this.elevatedStructures.upload(d)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(d,m,v,C,E,P=[],R,$){const G=W6(m,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(d,G,C,v,$):this.addGeometry(G,this.bufferData),this.bufferData.populatePaintArrays(d,v,E,P,C,R,this.worldview),this.elevationBufferData.populatePaintArrays(d,v,E,P,C,R,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(d,m,v,C,E){this.elevatedStructures&&(this.elevatedStructures.construct(d),this.elevatedStructures.populatePaintArrays(m,v,C,E,this.worldview))}addElevatedRoadFeature(d,m,v,C,E){const P=new Array,R=di.getElevationFeature(d,E);if(!R)return void this.addGeometry(m,this.bufferData);{const G=this.clipPolygonsToTile(m,1);G.length>0&&P.push({polygons:G,elevationFeature:R,elevationTileID:v})}const $={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(d,{},v),featureIndex:C};for(const G of P)if(G.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new mm(G.elevationTileID,this.layers,this.zoom,this.lut));const se=G.elevationFeature.isTunnel();let ae=0;d.properties.hasOwnProperty(Jt)&&(ae=+d.properties[Jt]);for(const de of G.polygons)this.elevatedStructures.addPortalCandidates(G.elevationFeature.id,de,se,G.elevationFeature,ae)}G.elevationFeature.constantHeight==null&&(G.polygons=this.prepareElevatedPolygons(G.polygons,G.elevationFeature,G.elevationTileID));const te=new Ci(v,G.elevationTileID);this.addElevatedGeometry(G.polygons,te,G.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,C,$)}}addElevatedGeometry(d,m,v,C,E,P){const R={elevation:v,elevationSampler:m,bias:C,index:E,featureInfo:P},[$,G]=this.addGeometry(d,this.elevationBufferData,R);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:$,max:G}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,$),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,G))}addGeometry(d,m,v){let C=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY,P=null;v&&(P=v.elevationSampler.constantElevation(v.elevation,v.bias),P!=null&&(C=P,E=P));const R=($,G,te)=>{if(v!=null)if(G.push($),P!=null)m.elevatedLayoutVertexArray.emplaceBack(P),te.push(P);else{const se=v.elevationSampler.pointElevation($,v.elevation,v.bias);m.elevatedLayoutVertexArray.emplaceBack(se),te.push(se),C=Math.min(C,se),E=Math.max(E,se)}};for(const $ of d){let G=0;for(const Xe of $)G+=Xe.length;const te=m.triangleSegments.prepareSegment(G,m.layoutVertexArray,m.indexArray),se=te.vertexLength,ae=[],de=[],he=[],Se=[],Fe=[],Re=m.layoutVertexArray.length;for(const Xe of $){if(Xe.length===0)continue;Xe!==$[0]&&de.push(ae.length/2);const lt=m.lineSegments.prepareSegment(Xe.length,m.layoutVertexArray,m.lineIndexArray),kt=lt.vertexLength;v&&Fe.push(m.layoutVertexArray.length-Re),R(Xe[0],he,Se),m.layoutVertexArray.emplaceBack(Xe[0].x,Xe[0].y),m.lineIndexArray.emplaceBack(kt+Xe.length-1,kt),ae.push(Xe[0].x),ae.push(Xe[0].y);for(let vt=1;vt0&&v&&this.elevationMode==="hd-road-base"){const Xe=v.elevation.isTunnel(),lt=v.elevation.safeArea,kt=this.elevatedStructures.addVertices(he,Se);this.elevatedStructures.addTriangles(Ke,kt,Xe);const vt=Fe.length;if(vt>0){for(let At=0;At=v&&de.max.x<=E&&de.min.y>=C&&de.max.y<=P?$:G).push(ae)}if($.length===d.length)return d;const te=[new pt(v,C),new pt(E,C),new pt(E,P),new pt(v,P),new pt(v,C)],se=$;for(const ae of G)se.push(...Yct(ae,te));return se}}let WCe,GCe,KCe,ZCe;kr(mpe,"FillBucket",{omit:["layers","patternFeatures"]}),kr(hpe,"FillBufferData"),kr(mm,"ElevatedStructures");class TF{constructor(d,m,v,C){if(this.triangleCount=m.length/3,this.min=new pt(0,0),this.max=new pt(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||d.length===0)return;const[E,P]=[d[0].clone(),d[0].clone()];for(let se=1;sese.cellIdx-ae.cellIdx||se.triIdx-ae.triIdx);let te=0;for(;tethis.max.x||this.min.x>d.x||d.y>this.max.y||this.min.y>d.y)return;const v=Ry(d.x-this.min.x,this.xScale,this.cellsX),C=Ry(d.y-this.min.y,this.yScale,this.cellsY),E=this.cells[C*this.cellsX+v];if(E){this._lazyInitLookup();for(let P=0;Pthis.max.x||this.min.x>m.x||d.y>this.max.y||this.min.y>m.y)return;this._lazyInitLookup();const C=Ry(d.x-this.min.x,this.xScale,this.cellsX),E=Ry(m.x-this.min.x,this.xScale,this.cellsX),P=Ry(d.y-this.min.y,this.yScale,this.cellsY),R=Ry(m.y-this.min.y,this.yScale,this.cellsY);for(let $=P;$<=R;$++)for(let G=C;G<=E;G++){const te=this.cells[$*this.cellsX+G];if(te)for(let se=0;sem.fqid),this.index=d.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.footprints=[],this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){for(const v of this.footprints)m.push({footprint:v,id:d})}updateAppearances(d,m,v,C){}populate(d,m,v,C){const E=[];for(const{feature:P,id:R,index:$,sourceLayerIndex:G}of d){const te=this.layers[0]._featureFilter.needGeometry,se=Wt(P,te);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),se,v))continue;const ae={id:R,properties:P.properties,type:P.type,sourceLayerIndex:G,index:$,geometry:te?se.geometry:Ot(P,v,C),patterns:{}};E.push(ae)}for(const P of E){const{geometry:R,index:$,sourceLayerIndex:G}=P;this.addFeature(P,R,$,v,{},m.availableImages,m.brightness),m.featureIndex.insert(d[$].feature,R,$,G,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(d){}update(d,m,v,C,E,P,R){}destroy(){}addFeature(d,m,v,C,E,P=[],R){for(const $ of W6(m,2)){const G=[],te=[],se=[],ae=new pt(1/0,1/0),de=new pt(-1/0,-1/0);for(const Fe of $)if(Fe.length!==0){Fe!==$[0]&&se.push(te.length/2);for(let Re=0;ReP===C)===void 0}(v,x.clipScope)}function AF(x,d){return x.x-d.x||x.y-d.y}function JCe(x,d){return AF(x.min,d.min)===0&&AF(x.max,d.max)===0}function ppe(x,d){return!(x.min.x>d.max.x||x.max.xd.max.y||x.max.ynew pt(($.x+E.x*tr)*R-P.x*tr,($.y+E.y*tr)*R-P.y*tr))}return fpe(m,C,x.indices,0,x.indices.length,0,0)}function s3e(x,d,m,v){const C=Math.pow(2,v.z-m.z);return new pt((x+m.x*tr)*C-v.x*tr,(d+m.y*tr)*C-v.y*tr)}function r3e(x,d){const m=[];d.grid.queryPoint(x,m);const v=d.indices,C=d.vertices;for(let E=0;E0&&(v.length>1&&m.push(v),v=[])}return v.length>1&&m.push(v),m}const gpe=Ht.types,odt=["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"],ldt=["fill-extrusion-flood-light-ground-radius"],cdt=Math.pow(2,13),ddt=Math.pow(2,15)-1,a3e=new pt(0,1),xv=2147483648,i3e=7,o3e=450;function K6(x,d,m,v,C,E,P,R){x.emplaceBack((d<<1)+P,(m<<1)+E,(Math.floor(v*cdt)<<1)+C,Math.round(R))}function Z6(x,d,m){x.emplaceBack(d.x*tr,d.y*tr,m?1:0)}function PF(x,d,m,v,C,E){x.emplaceBack(d.x,d.y,(m.x<<1)+v,(m.y<<1)+C,E)}function Y6(x,d,m){x.emplaceBack(d.x,d.y,d.z,m[0]*16384,m[1]*16384,m[2]*16384)}class l3e{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class c3e{constructor(){this.centroidXY=new pt(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new pt(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new pt(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new pt(this.max.x-this.min.x,this.max.y-this.min.y)}}class d3e{constructor(){this.acc=new pt(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(d,m){d.min.x===Number.MAX_VALUE&&(d.min.x=d.max.x=m.x,d.min.y=d.max.y=m.y)}appendEdge(d,m,v){this.accCount++,this.acc._add(m);let C=!!this.borders;m.xd.max.x&&(d.max.x=m.x,C=!0),m.yd.max.y&&(d.max.y=m.y,C=!0),((m.x===0||m.x===tr)&&m.x===v.x)!=((m.y===0||m.y===tr)&&m.y===v.y)&&this.processBorderOverlap(m,v),C&&this.checkBorderIntersection(m,v)}checkBorderIntersection(d,m){m.x<0!=d.x<0&&this.addBorderIntersection(0,Zr(m.y,d.y,(0-m.x)/(d.x-m.x))),m.x>tr!=d.x>tr&&this.addBorderIntersection(1,Zr(m.y,d.y,(tr-m.x)/(d.x-m.x))),m.y<0!=d.y<0&&this.addBorderIntersection(2,Zr(m.x,d.x,(0-m.y)/(d.y-m.y))),m.y>tr!=d.y>tr&&this.addBorderIntersection(3,Zr(m.x,d.x,(tr-m.y)/(d.y-m.y)))}addBorderIntersection(d,m){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const v=this.borders[d];mv[1]&&(v[1]=m)}processBorderOverlap(d,m){if(d.x===m.x){if(d.y===m.y)return;const v=d.x===0?0:1;this.addBorderIntersection(v,m.y),this.addBorderIntersection(v,d.y)}else{const v=d.y===0?2:3;this.addBorderIntersection(v,m.x),this.addBorderIntersection(v,d.x)}}centroid(){return this.accCount===0?new pt(0,0):new pt(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((d,m)=>d+ +(m[0]!==Number.MAX_VALUE),0):0}}function u3e(x,d){const m=x.add(d)._unit(),v=je(x.x*m.x+x.y*m.y,-1,1);var C,E,P;return C=Math.acos(v),Math.min(4,Math.max(-4,Math.tan(C)))/4*ddt*((E=x).x*(P=d).y-E.y*P.x<0?-1:1)}const udt=[x=>x.x<0,x=>x.x>tr,x=>x.y<0,x=>x.y>tr];function hdt(x,d,m,v){const C=[4];if(v===0)return C;m._mult(v);const E=x.sub(m),P=d.sub(m),R=[x,d,E,P];for(let $=0;$<4;$++)for(const G of R)if(udt[$](G)){C.push($);break}return C}class ype{constructor(d){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new w6,this.indexArray=new Bl,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut},m=>ldt.includes(m)),this._segments=new bo,this.hiddenByLandmarkVertexArray=new A3,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new bo}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(d,m,v,C=!1){const E=d.length;if(E>2){let P=Math.max(0,this._segments.get().length-1);const R=this._segments._prepareSegment(4*E,this.vertexArray.length,2*this._segmentToGroundQuads[P].length);let $;P!==this._segments.get().length-1&&(P++,this._segmentToGroundQuads[P]=[],this._segmentToRegionTriCounts[P]=[0,0,0,0,0]);{const G=d[0],te=d[1];$=u3e(G.sub(d[E-1])._perp()._unit(),te.sub(G)._perp()._unit())}for(let G=0;GC.region-E.region);for(let v=0;v$+G,0);let R=0;for(let $=0;$<=4;$++){const G=P[$];if(G!==0){let te=this.regionSegments[$];te||(te=this.regionSegments[$]=new bo);const se={vertexOffset:E.vertexOffset,primitiveOffset:E.primitiveOffset+R,vertexLength:E.vertexLength,primitiveLength:G};te.get().push(se)}R+=G}for(let $=0;$0?this.hiddenByLandmarkVertexBuffer=d.createVertexBuffer(this.hiddenByLandmarkVertexArray,rdt.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let d=0;d<=4;d++){const m=this.regionSegments[d];m&&m.destroy()}}}}class IF{constructor(d){this.zoom=d.zoom,this.canonical=d.canonical,this.overscaling=d.overscaling,this.layers=d.layers,this.pixelRatio=d.pixelRatio,this.layerIds=this.layers.map(m=>m.fqid),this.index=d.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=d.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Bl,this.footprintVertices=new Py,this.footprintSegments=[],this.layoutVertexArray=new mb,this.centroidVertexArray=new bF,this.wallVertexArray=new g2,this.indexArray=new Bl,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut},m=>odt.includes(m)),this.segments=new bo,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.groundEffect=new ype(d),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,C){}populate(d,m,v,C){this.features=[],this.hasPattern=cpe("fill-extrusion",this.layers,this.pixelRatio,m),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=Ue(v),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1)!==0;for(const{feature:E,id:P,index:R,sourceLayerIndex:$}of d){const G=this.layers[0]._featureFilter.needGeometry,te=Wt(E,G);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),te,v))continue;const se={id:P,sourceLayerIndex:$,index:R,geometry:G?te.geometry:Ot(E,v,C),properties:E.properties,type:E.type,patterns:{}},ae=this.layoutVertexArray.length,de=gpe[se.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:E.id,feature:dpe("fill-extrusion",this.layers,se,this.zoom,this.pixelRatio,m)});else if(this.wallMode)for(const he of se.geometry)for(const Se of n3e(he,de))this.addFeature(E.id,se,[Se],R,v,{},m.availableImages,C,m.brightness);else this.addFeature(E.id,se,se.geometry,R,v,{},m.availableImages,C,m.brightness);m.featureIndex.insert(E,se.geometry,R,$,this.index,ae)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(d,m,v,C,E,P){for(const{featureId:R,feature:$}of this.features){const G=gpe[$.type]==="Polygon",{geometry:te}=$;if(this.wallMode)for(const se of te)for(const ae of n3e(se,G))this.addFeature(R,$,[ae],$.index,m,v,C,E,P);else this.addFeature(R,$,te,$.index,m,v,C,E,P)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(d,m,v,C,E,P,R){this.programConfigurations.updatePaintArrays(d,m,E,v,C,P,R,this.worldview),this.groundEffect.update(d,m,E,v,C,P,R,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,adt),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.wallVertexBuffer=d.createVertexBuffer(this.wallVertexArray,sdt.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=d.createVertexBuffer(this.layoutVertexExtArray,ndt.members,!0)),this.groundEffect.upload(d)),this.groundEffect.uploadPaintProperties(d),this.programConfigurations.upload(d),this.uploaded=!0}uploadCentroid(d){this.groundEffect.uploadHiddenByLandmark(d),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=d.createVertexBuffer(this.centroidVertexArray,tdt.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(d,m,v,C,E,P,R,$,G){const te=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(m,{})/this.tileToMeter,se=[new pt(0,0),new pt(tr,tr)],ae=$.projection,de=ae.name==="globe",he=this.wallMode||gpe[m.type]==="Polygon",Se=new d3e;Se.centroidDataIndex=this.centroidData.length;const Fe=new c3e;Fe.buildingId=d,m.properties&&m.properties.hasOwnProperty("building_id")&&(Fe.buildingId=m.properties.building_id);const Re=this.layers[0].paint.get("fill-extrusion-base").evaluate(m,{},E)<=0,Ke=this.layers[0].paint.get("fill-extrusion-height").evaluate(m,{},E);let Xe;if(Fe.height=Ke,Fe.vertexArrayOffset=this.layoutVertexArray.length,Fe.groundVertexArrayOffset=this.groundEffect.vertexArray.length,de&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new N3),this.wallMode){if(de)return void xr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(v.length!==1)return;Xe=function(Gt){const ds=Gt[0].x===Gt[Gt.length-1].x&&Gt[0].y===Gt[Gt.length-1].y;(function(_r){let Tr=0;const ta=_r.length;for(let Ks=0;Ks=0})(Gt)||(Gt=Gt.reverse());const Ns={geometry:[],joinNormals:[],indices:[]},Fs=[],Bs=[],Ls=[];let Os=Gt.length;for(;Os>=2&&Gt[Os-1].equals(Gt[Os-2]);)Os--;if(Os<(ds?3:2))return Ns;let ls,rs,Rs,sr,Vs,zr=0;for(;zr0;let _n="miter";const ja=2;_n==="miter"&&Ks>ja&&(_n="bevel"),_n==="bevel"&&(Ks>100&&(_n="flipbevel"),Ks{const us=new pt($n.x,$n.y),zs=new pt($n.x,$n.y);us.x+=Ai.x*Ct,us.y+=Ai.y*Ct,zs.x-=Ai.x*Math.max(_t,1),zs.y-=Ai.y*Math.max(_t,1),Ls.push(Ai),Fs.push(us),Bs.push(zs)};if(_n==="miter")Tr._mult(Ks),Ca(ls,Tr,0,0);else if(_n==="flipbevel")Tr=Vs.mult(-1),Ca(ls,Tr,0,0),Ca(ls,Tr.mult(-1),0,0);else{const $n=-Math.sqrt(Ks*Ks-1),Ai=Ar?$n:0,_t=Ar?0:$n;rs&&Ca(ls,sr,Ai,_t),Rs&&Ca(ls,Vs,Ai,_t)}}Ns.geometry=[...Fs,...Bs.reverse(),Fs[0]],Ns.joinNormals=[...Ls,...Ls.reverse(),Ls[Ls.length-1]];const mr=Ns.geometry.length-1;for(let _r=0;_rGt<(ds.length-1)/2||Gt===ds.length-1,kt=this.wallMode?[v]:W6(v,500);for(let Gt=kt.length-1;Gt>=0;Gt--){const ds=kt[Gt];(ds.length===0||(vt=ds[0]).every(js=>js.x<=0)||vt.every(js=>js.x>=tr)||vt.every(js=>js.y<=0)||vt.every(js=>js.y>=tr))&&kt.splice(Gt,1)}var vt;let At;if(de)At=y3e(kt,se,E);else{At=[];for(const Gt of kt)At.push({polygon:Gt,bounds:se})}const zt=he?this.edgeRadius:0,qt=zt>0&&this.zoom<17,ss=(Gt,ds)=>{if(Gt.length===0)return!1;const js=Gt[Gt.length-1];return ds.x===js.x&&ds.y===js.y};for(const{polygon:Gt,bounds:ds}of At){let js=0,Ns=0;for(const Os of Gt)he&&!Os[0].equals(Os[Os.length-1])&&Os.push(Os[0]),Ns+=he?Os.length-1:Os.length;const Fs=this.segments.prepareSegment((he?5:4)*Ns,this.layoutVertexArray,this.indexArray);Fe.footprintSegIdx<0&&(Fe.footprintSegIdx=this.footprintSegments.length),Fe.polygonSegIdx<0&&(Fe.polygonSegIdx=this.polygonSegments.length);const Bs={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Ls=new l3e;if(Ls.vertexOffset=this.footprintVertices.length,Ls.indexOffset=3*this.footprintIndices.length,Ls.ringIndices=[],he){const Os=[],ls=[];js=Fs.vertexLength;for(let Rs=0;Rs4&&f3e(ls[ls.length-2],ls[0],ls[1]),Rs=zt?mdt(ls[ls.length-2],ls[0],ls[1],zt):0;const sr=[];let Vs,zr,mr;zr=ls[1].sub(ls[0])._perp()._unit();let _r=!0;for(let Tr=1,ta=0;Tr0?1:0,Ai=Ks.dist(Ar);if(ta+Ai>32768&&(ta=0),zt){mr=_n.sub(Ar)._perp()._unit();let zs=m3e(Ks,Ar,_n,h3e(zr,mr),zt);isNaN(zs)&&(zs=0);const or=Ar.sub(Ks)._unit();Ks=Ks.add(or.mult(Rs))._round(),Ar=Ar.add(or.mult(-zs))._round(),Rs=zs,zr=mr,Re&&this.zoom>=17&&(ss(sr,Ks)||sr.push(Ks),ss(sr,Ar)||sr.push(Ar))}const _t=Fs.vertexLength,Ct=ls.length>4&&f3e(Ks,Ar,_n);let us=x3e(ta,rs,_r);if(K6(this.layoutVertexArray,Ks.x,Ks.y,Ca,$n,0,0,us),K6(this.layoutVertexArray,Ks.x,Ks.y,Ca,$n,0,1,us),this.wallMode){const zs=lt(Tr-1,ls),or=Xe.joinNormals[Tr-1];Z6(this.wallVertexArray,or,zs),Z6(this.wallVertexArray,or,zs)}if(ta+=Ai,us=x3e(ta,Ct,!_r),rs=Ct,K6(this.layoutVertexArray,Ar.x,Ar.y,Ca,$n,0,0,us),K6(this.layoutVertexArray,Ar.x,Ar.y,Ca,$n,0,1,us),this.wallMode){const zs=lt(Tr,ls),or=Xe.joinNormals[Tr];Z6(this.wallVertexArray,or,zs),Z6(this.wallVertexArray,or,zs)}if(Fs.vertexLength+=4,this.indexArray.emplaceBack(_t+0,_t+1,_t+2),this.indexArray.emplaceBack(_t+1,_t+3,_t+2),Fs.primitiveLength+=2,zt){const zs=js+(Tr===1?ls.length-2:Tr-2),or=Tr===1?js:zs+1;if(this.indexArray.emplaceBack(_t+1,zs,_t+3),this.indexArray.emplaceBack(zs,or,_t+3),Fs.primitiveLength+=2,Vs===void 0&&(Vs=_t),!vpe(_n,ls[Tr],ds)){const lr=Tr===ls.length-1?Vs:Fs.vertexLength;this.indexArray.emplaceBack(_t+2,_t+3,lr),this.indexArray.emplaceBack(_t+3,lr+1,lr),this.indexArray.emplaceBack(_t+3,or,lr+1),Fs.primitiveLength+=3}_r=!_r}if(de){const zs=this.layoutVertexExtArray,or=ae.projectTilePoint(Ks.x,Ks.y,E),lr=ae.projectTilePoint(Ar.x,Ar.y,E),Br=ae.upVector(E,Ks.x,Ks.y),Vr=ae.upVector(E,Ar.x,Ar.y);Y6(zs,or,Br),Y6(zs,or,Br),Y6(zs,lr,Vr),Y6(zs,lr,Vr)}}he&&(js+=ls.length-1),Re&&zt&&this.zoom>=17&&(sr.length!==0&&ss(sr,sr[0])&&sr.pop(),this.groundEffect.addData(sr,ds,te,zt>0))}this.footprintSegments.push(Ls),Bs.triangleCount=this.indexArray.length-Bs.triangleArrayOffset,this.polygonSegments.push(Bs),++Fe.footprintSegLen,++Fe.polygonSegLen}if(Fe.vertexCount=this.layoutVertexArray.length-Fe.vertexArrayOffset,Fe.groundVertexCount=this.groundEffect.vertexArray.length-Fe.groundVertexArrayOffset,Fe.vertexCount!==0){if(Fe.centroidXY=Se.borders?a3e:this.encodeCentroid(Se,Fe),this.centroidData.push(Fe),Se.borders){this.featuresOnBorder.push(Se);const Gt=this.featuresOnBorder.length-1;for(let ds=0;dsthis.featuresOnBorder[m].borders[d][0]-this.featuresOnBorder[v].borders[d][0])}splitToSubtiles(){const d=[];for(let R=0;Rtr),te=2*G+(+($.min.x+$.max.x>tr)^G);for(let se=0;se<$.polygonSegLen;se++){const ae=$.polygonSegIdx+se;d.push({centroidIdx:R,subtile:te,polygonSegmentIdx:ae,triangleSegmentIdx:this.polygonSegments[ae].triangleSegIdx})}}const m=new Bl;d.sort((R,$)=>R.triangleSegmentIdx===$.triangleSegmentIdx?R.subtile-$.subtile:R.triangleSegmentIdx-$.triangleSegmentIdx);let v=0,C=0,E=0;for(const R of d){if(R.triangleSegmentIdx!==v)break;E++}const P=d.length;for(;C!==d.length;){v=d[C].triangleSegmentIdx;let R=0,$=C,G=C;for(let te=$;te0&&this.triangleSubSegments.push({segment:de,min:se,max:ae}),$=G;for(let he=$;he[Se[0]*(1-Re[0])+Fe[0]*Re[0],Se[1]*(1-Re[1])+Fe[1]*Re[1]],de=[],he=[];for(const Se of this.triangleSubSegments){de[0]=Se.min.x/tr,de[1]=Se.min.y/tr,he[0]=Se.max.x/tr,he[1]=Se.max.y/tr;const Fe=ae(te,se,de),Re=ae(te,se,he);if(new Or([Fe[0],Fe[1],E],[Re[0],Re[1],P]).intersectsPrecise(v)===0){G&&(C.segments.push(G),G=void 0);continue}const Ke=Se.segment;G&&G.vertexOffset!==Ke.vertexOffset&&(C.segments.push(G),G=void 0),G?(G.vertexLength+=Ke.vertexLength,G.primitiveLength+=Ke.primitiveLength):G={vertexOffset:Ke.vertexOffset,primitiveLength:Ke.primitiveLength,vertexLength:Ke.vertexLength,primitiveOffset:Ke.primitiveOffset,sortKey:void 0,vaos:{}}}return G&&C.segments.push(G),C}encodeCentroid(d,m){const v=d.centroid(),C=m.span(),E=Math.min(7,Math.round(C.x*this.tileToMeter/10)),P=Math.min(7,Math.round(C.y*this.tileToMeter/10));return new pt(je(v.x,1,tr-1)<<3|E,je(v.y,1,tr-1)<<3|P)}encodeBorderCentroid(d){if(!d.borders)return new pt(0,0);const m=d.borders,v=Number.MAX_VALUE;if(m[0][0]!==v||m[1][0]!==v){const C=m[0][0]!==v?0:1;return new pt(6|(m[0][0]!==v?0:65528),(m[C][0]+m[C][1])/2<<3|6)}{const C=m[2][0]!==v?2:3;return new pt((m[C][0]+m[C][1])/2<<3|6,6|(m[2][0]!==v?0:65528))}}showCentroid(d){const m=this.centroidData[d.centroidDataIndex];m.flags&=2147483647,m.centroidXY.x=0,m.centroidXY.y=0,this.writeCentroidToBuffer(m)}writeCentroidToBuffer(d){this.groundEffect.updateHiddenByLandmark(d);const m=d.vertexArrayOffset,v=d.vertexCount+d.vertexArrayOffset,C=d.flags&xv?a3e:d.centroidXY,E=this.centroidVertexArray.geta_centroid_pos0(m);if(this.centroidVertexArray.geta_centroid_pos1(m)!==C.y||E!==C.x){for(let P=m;P$.max.x||$.min.x>P.max.x||P.min.y>$.max.y||$.min.y>P.max.y||P.footprint.buildingIds.has($.buildingId)&&($.flags|=xv);else for(const $ of this.centroidData)if(!($.flags&xv||P.min.x>$.max.x||$.min.x>P.max.x||P.min.y>$.max.y||$.min.y>P.max.y))for(let G=0;G<$.footprintSegLen;G++){const te=this.footprintSegments[$.footprintSegIdx+G];if(E.length=0,pdt(this.footprintVertices,te.vertexOffset,te.vertexCount,P.footprintTileId.canonical,d.canonical,E),fpe(P.footprint,E,this.footprintIndices.uint16,te.indexOffset,te.indexCount,-te.vertexOffset,-R)){$.flags|=xv;break}}}for(const P of this.centroidData)this.writeCentroidToBuffer(P);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(d,m,v){let C=!1;for(let E=0;Em!=de>m&&d<(this.footprintVertices.int16[2*(te+P.vertexOffset)+0]-se)*(m-ae)/(de-ae)+se&&(C=!C)}R=$}}return C}getHeightAtTileCoord(d,m){let v=Number.NEGATIVE_INFINITY,C=!0;const E=4*(d+tr)*tr+(m+tr);if(this.partLookup.hasOwnProperty(E)){const P=this.partLookup[E];return P?{height:P.height,hidden:!!(P.flags&xv)}:void 0}for(const P of this.centroidData)d>P.max.x||P.min.x>d||m>P.max.y||P.min.y>m||P.height<=v||this.footprintContainsPoint(d,m,P)&&(v=P.height,this.partLookup[E]=P,C=!!(P.flags&xv));if(v!==Number.NEGATIVE_INFINITY)return{height:v,hidden:C};this.partLookup[E]=void 0}}function h3e(x,d){const m=x.add(d)._unit();return x.x*m.x+x.y*m.y}function mdt(x,d,m,v){const C=d.sub(x)._perp()._unit(),E=m.sub(d)._perp()._unit();return m3e(x,d,m,h3e(C,E),v)}function m3e(x,d,m,v,C){const E=Math.sqrt(1-v*v);return Math.min(x.dist(d)/3,d.dist(m)/3,C*E/v)}function vpe(x,d,m){return x.xm[1].x&&d.x>m[1].x||x.ym[1].y&&d.y>m[1].y}function p3e(x,d){return x.xd[1].x||x.yd[1].y}function f3e(x,d,m){if(x.x<0||x.x>=tr||d.x<0||d.x>=tr||m.x<0||m.x>=tr)return!1;const v=m.sub(d),C=v.perp(),E=x.sub(d);return(v.x*E.x+v.y*E.y)/Math.sqrt((v.x*v.x+v.y*v.y)*(E.x*E.x+E.y*E.y))>-.866&&C.x*E.x+C.y*E.y<0}function x3e(x,d,m){const v=d?2|x:-3&x;return m?1|v:-2&v}function g3e(){const x=Math.PI/32,d=Math.tan(x),m=T;return m*Math.sqrt(1+2*d*d)-m}function y3e(x,d,m){const v=1<{for(const zt of vt)he.push({polygon:zt,bounds:At})},Fe=Math.ceil(Math.log2(te)),Re=Math.ceil(Math.log2(se)),Ke=Fe-Re,Xe=[];for(let vt=0;vt0?0:1);for(let vt=0;vtAt+1?kt.push({polygons:Ns,bounds:Bs,depth:At+1}):Se(Ns,Bs)}if(Fs.length){const Bs=[new pt(zt===0?js:qt.x,zt===1?js:qt.y),ss];Xe.length>At+1?kt.push({polygons:Fs,bounds:Bs,depth:At+1}):Se(Fs,Bs)}}return he}(x,d,Math.ceil((E-C)/11.25),Math.ceil((P-R)/11.25),1,($,G,te)=>{if($===0)return .5*(G+te);{const se=_e((m.y+G/tr)/v);return(J(.5*(_e((m.y+te/tr)/v)+se))*v-m.y)*tr}})}function pdt(x,d,m,v,C,E){const P=Math.pow(2,v.z-C.z);for(let R=0;R=$[P]&&(R=d,$=x),R[P]C&&w3e(R,$,P,C),R[P]E&&w3e($,R,P,E)}}function LF(x,d,m,v,C,E){const P=[];for(let R=0;R=v&&he.x>=v||(de.x>=v?de=new pt(v,de.y+(v-de.x)/(he.x-de.x)*(he.y-de.y))._round():he.x>=v&&(he=new pt(v,de.y+(v-de.x)/(he.x-de.x)*(he.y-de.y))._round()),de.y>=C&&he.y>=C||(de.y>=C?de=new pt(de.x+(C-de.y)/(he.y-de.y)*(he.x-de.x),C)._round():he.y>=C&&(he=new pt(de.x+(C-de.y)/(he.y-de.y)*(he.x-de.x),C)._round()),G&&de.equals(G[G.length-1])||(G=[de],P.push(G),E&&E.push({progress:{min:Fe+N3e(Re,Ke,de)*Se,max:1},parentIndex:R,prevPoint:Re,nextPoint:Ke})),G.push(he),E&&(E[E.length-1].progress.max=Fe+N3e(Re,Ke,he)*Se,E[E.length-1].nextPoint=Ke)))))}if(E&&se>0)for(let ae=te;aeG.t-te.t);let P=0,R=0,$=[];for(v.push($);P!==x.length;){if(R===E.length){for(;P!==x.length;)$.length!==0&&$[$.length-1].equals(x[P])||$.push(x[P]),P++;break}E[R].t<=P?($.length!==0&&$[$.length-1].equals(E[R].point)||$.push(E[R].point),Math.trunc(E[R].t),R++):($.length!==0&&$[$.length-1].equals(x[P])||$.push(x[P]),P++)}}function N3e(x,d,m){return x.x!==d.x?(m.x-x.x)/(d.x-x.x):x.y!==d.y?(m.y-x.y)/(d.y-x.y):0}function X6(x,d){return x.x*d.x+x.y*d.y}function k3e(x,d){if(x.length===1){let m=0;const v=d[m++];let C;for(;!C||v.equals(C);)if(C=d[m++],!C)return 1/0;for(;m{js[0]=Ns,js[1]=Fs,js[2]=Bs,js[3]=1},ds=g3e();de>0&&(de+=ds),he+=ds;for(const js of ae){const Ns=[],Fs=[];for(const Bs of js){const Ls=Bs.x+Se.x,Os=Bs.y+Se.y,ls=se.projection.projectTilePoint(Ls,Os,kt),rs=se.projection.upVector(kt,Bs.x,Bs.y);let Rs=de,sr=he;if(Re){const Vs=M3e(Ls,Os,de,he,Re,Ke,Xe,lt);Rs+=Vs.base,sr+=Vs.top}de!==0?Gt(qt,ls.x+rs[0]*zt*Rs,ls.y+rs[1]*zt*Rs,ls.z+rs[2]*zt*Rs):Gt(qt,ls.x,ls.y,ls.z),Gt(ss,ls.x+rs[0]*zt*sr,ls.y+rs[1]*zt*sr,ls.z+rs[2]*zt*sr),ft(qt,qt,Fe),ft(ss,ss,Fe),Ns.push(new C2(qt[0],qt[1],qt[2])),Fs.push(new C2(ss[0],ss[1],ss[2]))}vt.push(Ns),At.push(Fs)}return[vt,At]}(x,d,m,v,C,E,P,R,$,G,te):P?function(se,ae,de,he,Se,Fe,Re,Ke,Xe){const lt=[],kt=[],vt=[0,0,0,1];for(const At of se){const zt=[],qt=[];for(const ss of At){const Gt=ss.x+he.x,ds=ss.y+he.y,js=M3e(Gt,ds,ae,de,Fe,Re,Ke,Xe);vt[0]=Gt,vt[1]=ds,vt[2]=js.base,vt[3]=1,Qe(vt,vt,Se),vt[3]=Math.max(vt[3],1e-5);const Ns=new C2(vt[0]/vt[3],vt[1]/vt[3],vt[2]/vt[3]);vt[0]=Gt,vt[1]=ds,vt[2]=js.top,vt[3]=1,Qe(vt,vt,Se),vt[3]=Math.max(vt[3],1e-5);const Fs=new C2(vt[0]/vt[3],vt[1]/vt[3],vt[2]/vt[3]);zt.push(Ns),qt.push(Fs)}lt.push(zt),kt.push(qt)}return[lt,kt]}(d,m,v,C,E,P,R,$,G):function(se,ae,de,he,Se){const Fe=[],Re=[],Ke=Se[8]*ae,Xe=Se[9]*ae,lt=Se[10]*ae,kt=Se[11]*ae,vt=Se[8]*de,At=Se[9]*de,zt=Se[10]*de,qt=Se[11]*de;for(const ss of se){const Gt=[],ds=[];for(const js of ss){const Ns=js.x+he.x,Fs=js.y+he.y,Bs=Se[0]*Ns+Se[4]*Fs+Se[12],Ls=Se[1]*Ns+Se[5]*Fs+Se[13],Os=Se[2]*Ns+Se[6]*Fs+Se[14],ls=Se[3]*Ns+Se[7]*Fs+Se[15],rs=Bs+Ke,Rs=Ls+Xe,sr=Os+lt,Vs=Math.max(ls+kt,1e-5),zr=Bs+vt,mr=Ls+At,_r=Os+zt,Tr=Math.max(ls+qt,1e-5);Gt.push(new C2(rs/Vs,Rs/Vs,sr/Vs)),ds.push(new C2(zr/Tr,mr/Tr,_r/Tr))}Fe.push(Gt),Re.push(ds)}return[Fe,Re]}(d,m,v,C,E)}function M3e(x,d,m,v,C,E,P,R){const $=P*C.getElevationAt(x,d,!0,!0),G=E[0]!==0,te=G?E[1]===0?P*(E[0]/i3e-o3e):P*function(se,ae,de){const he=Math.floor(ae[0]/8),Se=Math.floor(ae[1]/8),Fe=10*(ae[0]-8*he),Re=10*(ae[1]-8*Se),Ke=se.getElevationAt(he,Se,!0,!0),Xe=se.getMeterToDEM(de),lt=Math.floor(.5*(Fe*Xe-1)),kt=Math.floor(.5*(Re*Xe-1)),vt=se.tileCoordToPixel(he,Se),At=2*lt+1,zt=2*kt+1,qt=function(Fs,Bs,Ls,Os,ls){return[Fs.getElevationAtPixel(Bs,Ls,!0),Fs.getElevationAtPixel(Bs+ls,Ls,!0),Fs.getElevationAtPixel(Bs,Ls+ls,!0),Fs.getElevationAtPixel(Bs+Os,Ls+ls,!0)]}(se,vt.x-lt,vt.y-kt,At,zt),ss=Math.abs(qt[0]-qt[1]),Gt=Math.abs(qt[2]-qt[3]),ds=Math.abs(qt[0]-qt[2])+Math.abs(qt[1]-qt[3]),js=Math.min(.25,.5*Xe*(ss+Gt)/At),Ns=Math.min(.25,.5*Xe*ds/zt);return Ke+Math.max(js*Fe,Ns*Re)}(C,E,R):$;return{base:$+(m===0?-1:m),top:G?Math.max(te+v,$+m+2):$+v}}class xdt{constructor(d){this._callback=d,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class gdt{constructor(){this.tasks={},this.taskQueue=[],Ut(["process"],this),this.invoker=new xdt(this.process),this.nextId=0}add(d,m){const v=this.nextId++,C=function({type:E,isSymbolTile:P,zoom:R}){return R=R||0,E==="message"?0:E!=="maybePrepare"||P?E!=="parseTile"||P?E==="parseTile"&&P?300-R:E==="maybePrepare"&&P?400-R:500:200-R:100-R}(m);if(C===0){try{d()}finally{}return null}return this.tasks[v]={fn:d,metadata:m,priority:C,id:v},this.taskQueue.push(v),this.invoker.trigger(),{cancel:()=>{delete this.tasks[v]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(v=>!!this.tasks[v]),!this.taskQueue.length)return;const d=this.pick();if(d===null)return;const m=this.tasks[d];if(delete this.tasks[d],this.taskQueue.length&&this.invoker.trigger(),!m)return;m.fn()}finally{}}pick(){let d=null,m=1/0;for(let C=0;C{v&&delete this.callbacks[R],this.target.postMessage({id:R,type:"",targetMapId:C,sourceMapId:this.mapId})}}}receive(d){const m=d.data;if(!m)return;const v=m.id;if(v&&(!m.targetMapId||this.mapId===m.targetMapId))if(m.type===""){const C=this.cancelCallbacks[v];delete this.cancelCallbacks[v],C&&C.cancel()}else if(m.mustQueue||_a(self)){const C=this.callbacks[v],E=this.scheduler.add(()=>this.processTask(v,m),C&&C.metadata||{type:"message"});E&&(this.cancelCallbacks[v]=E)}else this.processTask(v,m)}processTask(d,m){if(delete this.cancelCallbacks[d],m.type===""){const v=this.callbacks[d];delete this.callbacks[d],v&&(m.error?v(Ey(m.error)):v(null,Ey(m.data)))}else{const v=new Set,C=m.hasCallback?(P,R)=>{this.target.postMessage({id:d,type:"",sourceMapId:this.mapId,error:P?rg(P):null,data:rg(R,v)},v)}:()=>{},E=Ey(m.data);if(this.parent[m.type])this.parent[m.type](m.sourceMapId,E,C);else if(this.parent.getWorkerSource){const P=m.type.split("."),{source:R,scope:$}=E;this.parent.getWorkerSource(m.sourceMapId,P[0],R,$)[P[1]](E,C)}else C(new Error(`Could not find function ${m.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var Q6={workerUrl:"",workerClass:null,workerParams:void 0};const bpe="mapboxgl_preloaded_worker_pool";class M2{constructor(d){this.active={},this.name=d}acquire(d,m=M2.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{m.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[bpe]}numActive(){return Object.keys(this.active).length}}M2.workerCount=2;class V3{constructor(d,m,v="Worker",C=M2.workerCount){this.workerPool=d,this.actors=[],this.currentActor=0,this.id=Ft();const E=this.workerPool.acquire(this.id,C);for(let P=0;P{this.ready=!0})}broadcast(d,m,v){bt(this.actors,(C,E)=>{C.send(d,m,E)},v=v||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(d=>{d.remove()}),this.actors=[],this.workerPool.release(this.id)}}let J6,_pe;function DF(){return J6||(J6=new M2),J6}V3.Actor=T3e;const wpe=4096;class ydt{constructor(d){this.module=d,this.memoryStack=this.module.malloc(wpe),this.memoryStackNextFree=this.memoryStack}createIntArray(d){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=d.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>wpe?-1:(new Int32Array(this.module.heap32.buffer,m,d.length).set(d),m)}createFloatArray(d){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=d.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>wpe?-1:(new Float32Array(this.module.heapF32.buffer,m,d.length).set(d),m)}readStringBuffer(d){let m="";for(;this.module.heapU8[d]!==0;)m+=String.fromCharCode(this.module.heapU8[d]),++d;return m}setStyle(d){const m=d.normalScale;this.module.setStyle(m[0],m[1],m[2],d.tileToMeters)}setAOOptions(d,m){this.module.setAOOptions(d?1:0,m)}setMetricOptions(d,m){this.module.setMetricOptions(d?1:0,m)}setStructuralOptions(d){this.module.setStructuralOptions(d?1:0)}setFacadeOptions(d,m){this.module.setFacadeOptions(d,m?1:0)}setFauxFacadeOptions(d,m,v){this.module.setFauxFacadeOptions(d?1:0,m?1:0,v)}setFacadeClassifierOptions(d){this.module.setFacadeClassifierOptions(d)}generateMesh(d,m){this.memoryStackNextFree=this.memoryStack;for(const R of d){const $=this.createIntArray(R.ringIndices),G=this.createFloatArray(R.coordinates);if($===-1||G===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(R.id,R.sourceId,R.minHeight,R.height,R.roofType,G,$,R.ringIndices.length-1)}for(const R of m){let $;$=R.entrances?JSON.parse(R.entrances):[];const G=this.createFloatArray($),te=this.createFloatArray(R.coordinates);if(G===-1||te===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(R.sourceId,R.crossPerc,R.distanceToRoad,G,$.length,te,R.coordinates.length)}if(!this.module.generateMesh()){const R=this.module.getLastError();return this.readStringBuffer(R)}const v=this.module.getMeshCount(),C=new Array(v);for(let R=0;RC.arrayBuffer()).then(C=>{d.buffers[m]=C})}function R3e(x,d){const m=x.json.bufferViews[d];return new Uint8Array(x.buffers[m.buffer],m.byteOffset||0,m.byteLength)}function Ndt(x,d,m,v){if(x.uri){const C=O3e(x.uri,v);return fetch(C).then(E=>E.blob()).then(E=>createImageBitmap(E)).then(E=>{d.images[m]=E})}if(x.bufferView!==void 0){const C=R3e(d,x.bufferView),E=new Blob([C],{type:x.mimeType});return createImageBitmap(E).then(P=>{d.images[m]=P})}}function F3e(x,d=0,m){const v={json:null,images:[],buffers:[]};if(new Uint32Array(x,d,1)[0]===L3e){const te=new Uint32Array(x,d);let se=2;const ae=(te[se++]>>2)-3,de=te[se++]>>2;if(se++,v.json=JSON.parse(D3e.decode(te.subarray(se,se+de))),se+=de,se{const te=[],se=R&&R.includes(kpe),ae=R&&R.includes(FF);if(se&&te.push(function(){if(!fg)return eP??(eP=function(de){let he,Se=null;function Fe(){he=new Uint8Array(Se.buffer)}function Re(){throw new Error("Unexpected Draco error.")}const Ke={a:{a:Re,d:function(Xe,lt,kt){return he.copyWithin(Xe,lt,lt+kt)},c:function(Xe){const lt=he.length,kt=Math.max(Xe>>>0,Math.ceil(1.2*lt)),vt=Math.ceil((kt-lt)/65536);try{return Se.grow(vt),Fe(),!0}catch{return!1}},b:Re}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(de,Ke):de.then(Xe=>Xe.arrayBuffer()).then(Xe=>WebAssembly.instantiate(Xe,Ke))).then(Xe=>{const{Rb:lt,Qb:kt,P:vt,T:At,X:zt,Ja:qt,La:ss,Qa:Gt,Va:ds,Wa:js,eb:Ns,jb:Fs,f:Bs,e:Ls,yb:Os,zb:ls,Ab:rs,Bb:Rs,Db:sr,Gb:Vs}=Xe.instance.exports;Se=Ls;const zr=(()=>{let mr=0,_r=0,Tr=0,ta=0;return Ks=>{Tr&&(lt(ta),lt(mr),_r+=Tr,Tr=mr=0),mr||(_r+=128,mr=kt(_r));const Ar=Ks.length+7&-8;let _n=mr;Ar>=_r&&(Tr=Ar,_n=ta=kt(Ar));for(let ja=0;ja{fg=de,eP=void 0}))}()),ae&&te.push(function(){if(Npe)return;const de=function(he){let Se;const Fe=WebAssembly.instantiateStreaming(he,{}).then(Xe=>{Se=Xe.instance,Se.exports.__wasm_call_ctors()}),Re={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Ke={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:Fe,supported:!0,decodeGltfBuffer(Xe,lt,kt,vt,At,zt){(function(qt,ss,Gt,ds,js,Ns,Fs){const Bs=qt.exports.sbrk,Ls=ds+3&-4,Os=Bs(Ls*js),ls=Bs(Ns.length),rs=new Uint8Array(qt.exports.memory.buffer);rs.set(Ns,ls);const Rs=ss(Os,ds,js,ls,Ns.length);if(Rs===0&&Fs&&Fs(Os,Ls,js),Gt.set(rs.subarray(Os,Os+ds*js)),Bs(Os-Bs(0)),Rs!==0)throw new Error(`Malformed buffer data: ${Rs}`)})(Se,Se.exports[Ke[At]],Xe,lt,kt,vt,Se.exports[Re[zt]])}}}(fetch(P3e()));return de.ready.then(()=>{Npe=de})}()),E)for(let de=0;de{if(se&&P)for(const{primitives:de}of P)for(const he of de)_dt(he,v);if(ae&&P&&$)for(const de of $)wdt(de,v);return v})})}function z3e(x){return fetch(x).then(d=>d.arrayBuffer()).then(d=>F3e(d,0,x))}function Spe(x){switch(x){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Cpe(x){switch(x){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Mpe{constructor(d,m,v,C){this.context=d,this.format=v,this.useMipmap=C&&C.useMipmap,this.texture=d.gl.createTexture(),this.update(m,{premultiply:C&&C.premultiply})}update(d,m){const v=d&&d instanceof HTMLVideoElement&&d.width===0?d.videoWidth:d.width,C=d&&d instanceof HTMLVideoElement&&d.height===0?d.videoHeight:d.height,{context:E}=this,{gl:P}=E,{x:R,y:$}=m&&m.position?m.position:{x:0,y:0},G=R+v,te=$+C;!this.size||this.size[0]===G&&this.size[1]===te||(P.bindTexture(P.TEXTURE_2D,null),P.deleteTexture(this.texture),this.texture=P.createTexture(),this.size=null),P.bindTexture(P.TEXTURE_2D,this.texture),E.pixelStoreUnpackFlipY.set(!1),E.pixelStoreUnpack.set(1),E.pixelStoreUnpackPremultiplyAlpha.set(this.format===P.RGBA8&&(!m||m.premultiply!==!1));const se=d instanceof HTMLImageElement||d instanceof HTMLCanvasElement||d instanceof HTMLVideoElement||d instanceof ImageData||ImageBitmap&&d instanceof ImageBitmap;if(!this.size&&G>0&&te>0){const ae=this.useMipmap?Math.floor(Math.log2(Math.max(G,te)))+1:1;P.texStorage2D(P.TEXTURE_2D,ae,this.format,G,te),this.size=[G,te]}this.size&&(se?P.texSubImage2D(P.TEXTURE_2D,0,R,$,Spe(this.format),Cpe(this.format),d):"data"in d&&d.data&&P.texSubImage2D(P.TEXTURE_2D,0,R,$,v,C,Spe(this.format),Cpe(this.format),d.data)),this.useMipmap&&P.generateMipmap(P.TEXTURE_2D)}bind(d,m,v=!1){const{context:C}=this,{gl:E}=C;E.bindTexture(E.TEXTURE_2D,this.texture),d!==this.minFilter&&(E.texParameteri(E.TEXTURE_2D,E.TEXTURE_MAG_FILTER,d),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_MIN_FILTER,this.useMipmap&&!v?d===E.NEAREST?E.NEAREST_MIPMAP_NEAREST:E.LINEAR_MIPMAP_LINEAR:d),this.minFilter=d),m!==this.wrapS&&(E.texParameteri(E.TEXTURE_2D,E.TEXTURE_WRAP_S,m),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_WRAP_T,m),this.wrapS=m)}bindExtraParam(d,m,v,C,E){const{context:P}=this,{gl:R}=P;R.bindTexture(R.TEXTURE_2D,this.texture),m!==this.magFilter&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MAG_FILTER,m),this.magFilter=m),d!==this.minFilter&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MIN_FILTER,this.useMipmap?d===R.NEAREST?R.NEAREST_MIPMAP_NEAREST:R.LINEAR_MIPMAP_LINEAR:d),this.minFilter=d),v!==this.wrapS&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_WRAP_S,v),this.wrapS=v),C!==this.wrapT&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_WRAP_T,C),this.wrapT=C),E!==this.compareMode&&(E?(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_MODE,R.COMPARE_REF_TO_TEXTURE),R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_FUNC,E)):R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_MODE,R.NONE),this.compareMode=E)}destroy(){const{gl:d}=this.context;d.deleteTexture(this.texture),this.texture=null}}class sP{constructor(d,m){this.context=d,this.texture=m}bind(d,m){const{context:v}=this,{gl:C}=v;C.bindTexture(C.TEXTURE_2D,this.texture),d!==this.minFilter&&(C.texParameteri(C.TEXTURE_2D,C.TEXTURE_MAG_FILTER,d),C.texParameteri(C.TEXTURE_2D,C.TEXTURE_MIN_FILTER,d),this.minFilter=d),m!==this.wrapS&&(C.texParameteri(C.TEXTURE_2D,C.TEXTURE_WRAP_S,m),C.texParameteri(C.TEXTURE_2D,C.TEXTURE_WRAP_T,m),this.wrapS=m)}}const kdt=fa([{name:"a_pos_3f",components:3,type:"Float32"}]),Sdt=fa([{name:"a_color_3f",components:3,type:"Float32"}]),Cdt=fa([{name:"a_color_4f",components:4,type:"Float32"}]),Mdt=fa([{name:"a_uv_2f",components:2,type:"Float32"}]),Tdt=fa([{name:"a_normal_3f",components:3,type:"Float32"}]),Adt=fa([{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"}]),Edt=fa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function B3e(x,d){const m=zF(x.projection,x.zoom,x.width,x.height),v=function(E,P,R,$,G){const te=new y(R.lng-180*jb,R.lat),se=new y(R.lng+180*jb,R.lat),ae=E.project(te.lng,te.lat),de=E.project(se.lng,se.lat),he=-Math.atan2(de.y-ae.y,de.x-ae.x),Se=st.fromLngLat(R);Se.y=je(Se.y,-1+jb,1-jb);const Fe=Se.toLngLat(),Re=E.project(Fe.lng,Fe.lat),Ke=st.fromLngLat(Fe);Ke.x+=jb;const Xe=Ke.toLngLat(),lt=E.project(Xe.lng,Xe.lat),kt=q3e(lt.x-Re.x,lt.y-Re.y,he),vt=st.fromLngLat(Fe);vt.y+=jb;const At=vt.toLngLat(),zt=E.project(At.lng,At.lat),qt=q3e(zt.x-Re.x,zt.y-Re.y,he),ss=Math.abs(kt.x)/Math.abs(qt.y),Gt=w([]);q(Gt,Gt,-he*(1-(G?0:$)));const ds=w([]);return L(ds,ds,[1,1-(1-ss)*$,1]),ds[4]=-qt.x/qt.y*$,q(ds,ds,he),S(ds,Gt,ds),ds}(x.projection,0,x.center,m,d),C=$3e(x);return L(v,v,[C,C,1]),v}function $3e(x){const d=x.projection,m=zF(x.projection,x.zoom,x.width,x.height),v=Tpe(d,x.center),C=Tpe(d,y.convert(d.center));return Math.pow(2,v*m+(1-m)*C)}function zF(x,d,m,v,C=1/0){const E=x.range;if(!E)return 0;const P=Math.min(C,Math.max(m,v)),R=Math.log2(P/1024);return $e(E[0]+R,E[1]+R,d)}const jb=1/4e4;function Tpe(x,d){const m=je(d.lat,-we,we),v=new y(d.lng-180*jb,m),C=new y(d.lng+180*jb,m),E=x.project(v.lng,m),P=x.project(C.lng,m),R=st.fromLngLat(v),$=st.fromLngLat(C),G=P.x-E.x,te=P.y-E.y,se=$.x-R.x,ae=$.y-R.y,de=Math.sqrt((se*se+ae*ae)/(G*G+te*te));return Math.log2(de)}function q3e(x,d,m){const v=Math.cos(m),C=Math.sin(m);return{x:x*v-d*C,y:x*C+d*v}}function U3e(x,d,m){w(x),q(x,x,jr(d[2])),I(x,x,jr(d[0])),O(x,x,jr(d[1])),L(x,x,m),S(x,x,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function BF(x,d,m,v,C,E,P,R){const $=[m[0]-d[0],m[1]-d[1],0],G=[v[0]-d[0],v[1]-d[1],0];if(ie($)<1e-12||ie(G)<1e-12)return Je(x);const te=nt([],$,G);ke(te,te),xe(G,v,d),$[2]=(E-C)*R,G[2]=(P-C)*R;const se=$;return nt(se,$,G),ke(se,se),cs(x,te,se)}function $F(x,d,m=!1){const v=_b(d.zoom),C=function(E,P,R){const $=P.worldSize,G=[E[12],E[13],E[14]],te=_e(G[1]/$),se=le(G[0]/$),ae=w([]),de=ne(1,te)*$,he=ne(1,0)*$*Ie(te,P.zoom),Se=1/npe($);let Fe=he*Se;if(R){const lt=zF(P.projection,P.zoom,P.width,P.height,1024);Fe=Se*P.projection.pixelSpaceConversion(P.center.lat,$,lt)}const Re=yb(te,se);ce(Re,Re,be([],ke([],Re),de*Fe*G[2]));const Ke=function(lt){const kt=[lt[0],lt[1],lt[2]];let vt=[0,1,0];const At=nt([],vt,kt);return nt(vt,kt,At),Oe(vt)===0&&(vt=[0,1,0],nt(At,kt,vt)),ke(At,At),ke(vt,vt),ke(kt,kt),[At[0],At[1],At[2],0,vt[0],vt[1],vt[2],0,kt[0],kt[1],kt[2],0,lt[0],lt[1],lt[2],1]}(Re);L(ae,ae,[Fe,Fe,Fe*de]),M(ae,ae,[-G[0],-G[1],-G[2]]);const Xe=S([],P.globeMatrix,Ke);return S(Xe,Xe,ae),S(Xe,Xe,E),Xe}(x,d,m);if(v>0){const E=function(P,R){const $=R.worldSize,G=ne(1,0)*$*Ie(R.center.lat,R.zoom)/npe($),te=ne(1,R.center.lat)*$,se=w([]);O(se,se,jr(R.center.lng)),I(se,se,jr(R.center.lat)),M(se,se,[0,0,Ud]),L(se,se,[G,G,G*te]);const ae=R.point;return M(se,se,[-ae.x,-ae.y,0]),S(se,se,P),S(se,R.globeMatrix,se)}(x,d);return function(P,R,$){const G=(he,Se,Fe)=>{const Re=ie(he),Ke=ie(Se),Xe=pg(he,Se,Fe);return be(Xe,Xe,1/ie(Xe)*Zr(Re,Ke,Fe))},te=G([P[0],P[1],P[2]],[R[0],R[1],R[2]],$),se=G([P[4],P[5],P[6]],[R[4],R[5],R[6]],$),ae=G([P[8],P[9],P[10]],[R[8],R[9],R[10]],$),de=pg([P[12],P[13],P[14]],[R[12],R[13],R[14]],$);return[te[0],te[1],te[2],0,se[0],se[1],se[2],0,ae[0],ae[1],ae[2],0,de[0],de[1],de[2],1]}(C,E,v)}return C}function Ape(x,d,m,v){const C=Or.projectAabbCorners(v,m);let E=Number.MAX_VALUE;for(let R=0;R0||Fe===0&&he[0]*Se[0]+he[1]*Se[1]>=0&&he[0]*he[0]+he[1]*he[1]>Se[0]*Se[0]+Se[1]*Se[1])&&(te=de)}se=te}while(se!==G);return $.length>0&&$.push($[0]),$}(C);if(Ga(x,P))return E}const T2=64,K3={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function qF(x,d,m,v,C,E,P,R,$,G=!1){const te=m.zoom,se=m.project(v),ae=Ie(v.lat,te),de=1/ae;w(x),M(x,x,[se.x+P[0]*de,se.y+P[1]*de,P[2]]);let he=1,Se=1;const Fe=m.worldSize;if(G){if(m.projection.name==="mercator"){let lt=0;m.elevation&&(lt=m.elevation.getAtPointOrZero(new st(se.x/Fe,se.y/Fe),0));const kt=Qe([],[se.x,se.y,lt,1],m.projMatrix)[3]/m.cameraToCenterDistance;he=kt,Se=kt*Ie(m.center.lat,te)}else if(m.projection.name==="globe"){const lt=$F(x,m),kt=[0,0,0,1];Qe(kt,kt,S([],m.projMatrix,lt));const vt=kt[3]/m.cameraToCenterDistance,At=_b(te),zt=m.projection.pixelsPerMeter(v.lat,Fe)*Ie(v.lat,te),qt=m.projection.pixelsPerMeter(m.center.lat,Fe)*Ie(m.center.lat,te);he=vt/Zr(zt,Le(m.center.lat),At),Se=vt*ae/zt,he*=qt,Se*=qt}}else he=de;L(x,x,[he,he,Se]);const Re=[...x],Ke=d.orientation,Xe=[];if(U3e(Xe,[Ke[0]+(C?C[0]:0),Ke[1]+(C?C[1]:0),Ke[2]+(C?C[2]:0)],E),S(x,Re,Xe),R&&m.elevation){let lt=0;const kt=[];if($&&m.elevation){lt=function(At,zt,qt,ss,Gt){const ds=zt.elevation;if(!ds)return 0;const js=Or.projectAabbCorners(qt,ss),Ns=ne(1,Gt.lat)*zt.worldSize,Fs=function(_r,Tr){const ta=[0,0,1],Ks=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const Ar of Ks){const _n=_r[Ar.corners[0]],ja=_r[Ar.corners[1]],Ca=_r[Ar.corners[2]],$n=[ja[0]-_n[0],ja[1]-_n[1],Tr*(ja[2]-_n[2])],Ai=nt($n,$n,[Ca[0]-_n[0],Ca[1]-_n[1],Tr*(Ca[2]-_n[2])]);ke(Ai,Ai),Ar.dotProductWithUp=Be(Ai,ta)}return Ks.sort((Ar,_n)=>Ar.dotProductWithUp-_n.dotProductWithUp),Ks[0].corners}(js,Ns),Bs=js[Fs[0]],Ls=js[Fs[1]],Os=js[Fs[2]],ls=js[Fs[3]],rs=ds.getAtPointOrZero(new st(Bs[0]/zt.worldSize,Bs[1]/zt.worldSize),0),Rs=ds.getAtPointOrZero(new st(Ls[0]/zt.worldSize,Ls[1]/zt.worldSize),0),sr=ds.getAtPointOrZero(new st(Os[0]/zt.worldSize,Os[1]/zt.worldSize),0),Vs=ds.getAtPointOrZero(new st(ls[0]/zt.worldSize,ls[1]/zt.worldSize),0),zr=(rs+Vs)/2,mr=(Rs+sr)/2;return zr>mr?Rs=d.gl.NEAREST_MIPMAP_NEAREST}),x.uploaded=!0,x.image=null)}function Pdt(x,d,m){x.indexBuffer=d.createIndexBuffer(x.indexArray,!1,!0),x.vertexBuffer=d.createVertexBuffer(x.vertexArray,kdt.members,!1,!0),x.normalArray&&(x.normalBuffer=d.createVertexBuffer(x.normalArray,Tdt.members,!1,!0)),x.texcoordArray&&(x.texcoordBuffer=d.createVertexBuffer(x.texcoordArray,Mdt.members,!1,!0)),x.colorArray&&(x.colorBuffer=d.createVertexBuffer(x.colorArray,(x.colorArray.bytesPerElement===12?Sdt:Cdt).members,!1,!0)),x.featureArray&&(x.pbrBuffer=d.createVertexBuffer(x.featureArray,Edt.members,!0)),x.segments=bo.simpleSegment(0,0,x.vertexArray.length,x.indexArray.length);const v=x.material;v.pbrMetallicRoughness.baseColorTexture&&rP(v.pbrMetallicRoughness.baseColorTexture,d),v.pbrMetallicRoughness.metallicRoughnessTexture&&rP(v.pbrMetallicRoughness.metallicRoughnessTexture,d),v.normalTexture&&rP(v.normalTexture,d),v.occlusionTexture&&rP(v.occlusionTexture,d,m),v.emissionTexture&&rP(v.emissionTexture,d)}function Epe(x,d,m){if(x.meshes)for(const v of x.meshes)Pdt(v,d,m);if(x.children)for(const v of x.children)Epe(v,d,m)}function UF(x){if(x.meshes)for(const d of x.meshes)d.indexArray.destroy(),d.vertexArray.destroy(),d.colorArray&&d.colorArray.destroy(),d.normalArray&&d.normalArray.destroy(),d.texcoordArray&&d.texcoordArray.destroy(),d.featureArray&&d.featureArray.destroy();if(x.children)for(const d of x.children)UF(d)}function Ppe(x){if(x.meshes)for(const m of x.meshes)m.vertexBuffer&&(m.vertexBuffer.destroy(),m.indexBuffer.destroy(),m.normalBuffer&&m.normalBuffer.destroy(),m.texcoordBuffer&&m.texcoordBuffer.destroy(),m.colorBuffer&&m.colorBuffer.destroy(),m.pbrBuffer&&m.pbrBuffer.destroy(),m.segments.destroy(),m.material&&((d=m.material).pbrMetallicRoughness.baseColorTexture&&d.pbrMetallicRoughness.baseColorTexture.gfxTexture&&d.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),d.pbrMetallicRoughness.metallicRoughnessTexture&&d.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&d.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),d.normalTexture&&d.normalTexture.gfxTexture&&d.normalTexture.gfxTexture.destroy(),d.emissionTexture&&d.emissionTexture.gfxTexture&&d.emissionTexture.gfxTexture.destroy(),d.occlusionTexture&&d.occlusionTexture.gfxTexture&&d.occlusionTexture.gfxTexture.destroy()));var d;if(x.children)for(const m of x.children)Ppe(m)}function A2(x,d){const m=x.json.bufferViews[d.bufferView],v=RF[d.componentType];return new v(x.buffers[m.buffer],(d.byteOffset||0)+(m.byteOffset||0),d.count*(m.byteStride&&m.byteStride!==tP[d.type]*v.BYTES_PER_ELEMENT?m.byteStride/v.BYTES_PER_ELEMENT:tP[d.type]))}function Ipe(x,d,m,v){const C=RF[d.componentType],E=function(te){switch(te){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(C),P=x.json.bufferViews[d.bufferView],R=P.byteStride?P.byteStride/C.BYTES_PER_ELEMENT:tP[d.type],$=m.float32,G=$.length/m.capacity;for(let te=0,se=0;te0){for(let Fe=0;Fe0){E.texcoordArray=new Hf;const ae=d.json.accessors[C.TEXCOORD_0];E.texcoordArray.resize(ae.count);const de=A2(d,ae);Ipe(d,ae,E.texcoordArray,de)}if(C._FEATURE_ID_RGBA4444!==void 0){const ae=d.json.accessors[C._FEATURE_ID_RGBA4444];d.json.extensionsUsed&&d.json.extensionsUsed.includes("EXT_meshopt_compression")&&(E.featureData=A2(d,ae))}C._FEATURE_RGBA4444!==void 0&&(E.featureData=new Uint32Array(A2(d,d.json.accessors[C._FEATURE_RGBA4444]).buffer));const se=x.material;return E.material=function(ae,de){const{emissiveFactor:he=[0,0,0],alphaMode:Se="OPAQUE",alphaCutoff:Fe=.5,normalTexture:Re,occlusionTexture:Ke,emissiveTexture:Xe,doubleSided:lt,name:kt}=ae,{baseColorFactor:vt=[1,1,1,1],metallicFactor:At=1,roughnessFactor:zt=1,baseColorTexture:qt,metallicRoughnessTexture:ss}=ae.pbrMetallicRoughness||{},Gt=Ke?de[Ke.index]:void 0;if(Ke&&Ke.extensions&&Ke.extensions.KHR_texture_transform&&Gt){const ds=Ke.extensions.KHR_texture_transform;Gt.offsetScale=[ds.offset[0],ds.offset[1],ds.scale[0],ds.scale[1]]}return{name:kt,pbrMetallicRoughness:{baseColorFactor:new Ur(...vt),metallicFactor:At,roughnessFactor:zt,baseColorTexture:qt?de[qt.index]:void 0,metallicRoughnessTexture:ss?de[ss.index]:void 0},doubleSided:lt,emissiveFactor:new Ur(...he),alphaMode:Se,alphaCutoff:Fe,normalTexture:Re?de[Re.index]:void 0,occlusionTexture:Gt,emissionTexture:Xe?de[Xe.index]:void 0,defined:ae.defined===void 0}}(se!==void 0?d.json.materials[se]:{defined:!1},m),E}function H3e(x,d,m){const{matrix:v,rotation:C,translation:E,scale:P,mesh:R,extras:$,children:G,name:te}=x,se={};if(se.name=te,se.localMatrix=v||function(ae,de,he,Se){var Fe=de[0],Re=de[1],Ke=de[2],Xe=de[3],lt=Fe+Fe,kt=Re+Re,vt=Ke+Ke,At=Fe*lt,zt=Fe*kt,qt=Fe*vt,ss=Re*kt,Gt=Re*vt,ds=Ke*vt,js=Xe*lt,Ns=Xe*kt,Fs=Xe*vt,Bs=Se[0],Ls=Se[1],Os=Se[2];return ae[0]=(1-(ss+ds))*Bs,ae[1]=(zt+Fs)*Bs,ae[2]=(qt-Ns)*Bs,ae[3]=0,ae[4]=(zt-Fs)*Ls,ae[5]=(1-(At+ds))*Ls,ae[6]=(Gt+js)*Ls,ae[7]=0,ae[8]=(qt+Ns)*Os,ae[9]=(Gt-js)*Os,ae[10]=(1-(At+ss))*Os,ae[11]=0,ae[12]=he[0],ae[13]=he[1],ae[14]=he[2],ae[15]=1,ae}([],C||[0,0,0,1],E||[0,0,0],P||[1,1,1]),se.globalMatrix=j(se.localMatrix),R!==void 0){se.meshes=m[R];const ae=se.anchor=[0,0];for(const de of se.meshes){const{min:he,max:Se}=de.aabb;ae[0]+=he[0]+Se[0],ae[1]+=he[1]+Se[1]}ae[0]=Math.floor(ae[0]/se.meshes.length/2),ae[1]=Math.floor(ae[1]/se.meshes.length/2)}if($&&($.id&&(se.id=$.id),$.lights&&(se.lights=function(ae){if(!ae.length)return[];const de=function(Ke){const Xe=atob(Ke),lt=new Uint8Array(Xe.length);for(let kt=0;kt1&&v[v.length-1].equals(v[0])&&v.pop();let C=0;for(let P=0;P0&&v.reverse();const E=q3(v.flatMap(P=>[P.x,P.y]),[]);return E.length===0?null:{vertices:v,indices:E}}function Odt(x,d){const m=[],v=[];let C=0;const E=[];for(const P of x){C=m.length;const R=P.vertexArray.float32,$=P.indexArray.uint16;for(let G=0;G0&&([v[P+1],v[P+2]]=[v[P+2],v[P+1]])}return{vertices:m,indices:v}}function Lpe(x){const d=function($,G){const te=[],se=WebGL2RenderingContext;if($.json.textures)for(const ae of $.json.textures){const de={magFilter:se.LINEAR,minFilter:se.NEAREST,wrapS:se.REPEAT,wrapT:se.REPEAT};ae.sampler!==void 0&&Object.assign(de,$.json.samplers[ae.sampler]),te.push({image:G[ae.source],sampler:de,uploaded:!1})}return te}(x,x.images),m=function($,G){const te=[];for(const se of $.json.meshes){const ae=[];for(const de of se.primitives)ae.push(Idt(de,$,G));te.push(ae)}return te}(x,d),{scenes:v,scene:C,nodes:E}=x.json,P=v?v[C||0].nodes:[...E.keys()],R=[];for(const $ of P)R.push(H3e(E[$],x,m));return function($,G,te){const se={},ae=new Set;for(let de=0;de<$.length;de++){const he=te[G[de]];if(!he.extras)continue;const Se=he.extras["mapbox:footprint:version"],Fe=he.extras["mapbox:footprint:id"];(Se||Fe)&&ae.add(de),Se==="1.0.0"&&Fe&&(se[Fe]=de)}for(let de=0;de<$.length;de++){if(ae.has(de))continue;const he=$[de],Se=te[G[de]];if(!Se.extras)continue;let Fe=null;he.id in se&&(Fe=Odt($[se[he.id]].meshes,he.localMatrix)),Fe||(Fe=Ddt(Se)),Fe&&(he.footprint=Ldt(Fe))}if(ae.size>0){const de=Array.from(ae.values()).sort((he,Se)=>he-Se);for(let he=de.length-1;he>=0;he--)$.splice(de[he],1)}}(R,P,x.json.nodes),R}function Rdt(x){x.heightmap=new Float32Array(4096),x.heightmap.fill(-1);const d=x.vertexArray.float32,m=x.aabb.min[0]-1,v=x.aabb.min[1]-1,C=T2/(x.aabb.max[0]-m+2),E=T2/(x.aabb.max[1]-v+2);for(let P=0;Px.heightmap[G*T2+$]&&(x.heightmap[G*T2+$]=R)}}function W3e(x,d,m,v,C){m.reserve(m.length+4*x.length),v.reserve(v.length+10*x.length),C.reserve(C.length+10*x.length);let E=v.length;for(const P of x){const R=Math.min(10,Math.max(4,1.3*P.height))*d,$=[-P.normal[1],P.normal[0],0],G=Math.min(.29,.1*P.width/P.depth),te=P.width-2*P.depth*d*(G+.01),se=Me([],P.pos,$,te/2),ae=Me([],P.pos,$,-te/2),de=[se[0],se[1],se[2]+P.height],he=[ae[0],ae[1],ae[2]+P.height],Se=Me([],P.normal,$,G);be(Se,Se,R);const Fe=Me([],P.normal,$,-G);be(Fe,Fe,R),ce(Se,se,Se),ce(Fe,ae,Fe),se[2]+=.1,ae[2]+=.1,v.emplaceBack(Se[0],Se[1],Se[2]),v.emplaceBack(Fe[0],Fe[1],Fe[2]),v.emplaceBack(se[0],se[1],se[2]),v.emplaceBack(ae[0],ae[1],ae[2]),v.emplaceBack(de[0],de[1],de[2]),v.emplaceBack(he[0],he[1],he[2]),v.emplaceBack(se[0],se[1],se[2]),v.emplaceBack(ae[0],ae[1],ae[2]),v.emplaceBack(Se[0],Se[1],Se[2]),v.emplaceBack(Fe[0],Fe[1],Fe[2]);const Re=te/R/2;C.emplaceBack(-Re-G,-1,Re,.8),C.emplaceBack(Re+G,-1,Re,.8),C.emplaceBack(-Re,0,Re,1.3),C.emplaceBack(Re,0,Re,1.3),C.emplaceBack(Re+G,-.8,Re,.7),C.emplaceBack(Re+G,-.8,Re,.7),C.emplaceBack(0,0,Re,1.3),C.emplaceBack(0,0,Re,1.3),C.emplaceBack(Re+G,-1.2,Re,.8),C.emplaceBack(Re+G,-1.2,Re,.8),m.emplaceBack(6+E,4+E,8+E),m.emplaceBack(7+E,9+E,5+E),m.emplaceBack(0+E,1+E,2+E),m.emplaceBack(1+E,3+E,2+E),E+=10}}function Fdt(x,d){const m={};m.indexArray=new Bl,m.vertexArray=new dm,m.colorArray=new Iy,W3e(x,d,m.indexArray,m.vertexArray,m.colorArray);const v={defined:!0};v.emissiveFactor=Ur.black;const C={};return C.baseColorFactor=Ur.white,v.pbrMetallicRoughness=C,m.material=v,m.aabb=new Or([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),m}const G3e=fa([{name:"a_pos_3f",components:3,type:"Float32"}]),zdt=fa([{name:"a_normal_3",components:3,type:"Int16"}]),Bdt=fa([{name:"a_centroid_3",components:3,type:"Int16"}]),K3e=fa([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),$dt=fa([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),qdt=fa([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Udt=fa([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),Vdt=fa([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),Hdt=fa([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),Z3e=Ht.types,VF=32767;function Wdt(x,d){const m=tr+d;for(const v of x)for(const C of v)if(C.x<-d||C.x>m||C.y<-d||C.y>m)return!1;return!0}function Gdt(x){switch(x){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${x}`)}}class Dpe{constructor(){this.layoutVertexArray=new dm,this.layoutAttenuationArray=new Iy,this.layoutColorArray=new um,this.indexArray=new Bl,this.indexArrayForConflation=new Bl,this.segmentsBucket=new bo}}class Ope{constructor(d){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new bo,this.entranceBloom=new Dpe;const m=66560;this.layoutVertexArray=new dm,this.layoutVertexArray.reserve(m),this.layoutNormalArray=new hb,this.layoutNormalArray.reserve(m),this.layoutCentroidArray=new hb,this.layoutCentroidArray.reserve(m),this.layoutColorArray=new um,this.layoutColorArray.reserve(m),this.layoutFloodLightDataArray=new Ly,this.layoutFloodLightDataArray.reserve(m),this.layoutAOArray=new A3,this.layoutAOArray.reserve(m),this.indexArray=new Bl,this.indexArray.reserve(66560),this.indexArrayForConflation=new Bl,this.segmentsBucket=new bo,this.entranceBloom=new Dpe,d&&(this.layoutFacadePaintArray=new um,this.layoutFacadeDataArray=new hv,this.layoutFacadeVerticalRangeArray=new um)}reserve(d,m,v){this.layoutVertexArray.reserveForAdditional(d),this.layoutCentroidArray.reserveForAdditional(d),this.layoutFloodLightDataArray.reserveForAdditional(d),this.layoutNormalArray.reserveForAdditional(d),this.layoutAOArray.reserveForAdditional(d),this.layoutColorArray.reserveForAdditional(d),this.indexArray.reserveForAdditional(m),v&&(this.layoutFacadePaintArray.reserveForAdditional(d),this.layoutFacadeDataArray.reserveForAdditional(d),this.layoutFacadeVerticalRangeArray.reserveForAdditional(d))}}class Y3e{constructor(d){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Hf,this.footprintsIndices=new Ly,this.footprintsMin=new pt(1/0,1/0),this.footprintsMax=new pt(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Ope(!1),this.buildingWithFacade=new Ope(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=d.zoom,this.canonical=d.canonical,this.layers=d.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=d.index,this.hasPattern=!1,this.worldview=d.worldview,this.lut=d.lut,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut}),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.projection=d.projection,this.groundEffect=new ype(d),this.groundEffect.groundRadiusArray=new og,this.hasAppearances=null}updateFootprints(d,m){const v=new TF([],[],1),C={vertices:[],indices:new Uint32Array(0),grid:v,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};m.push({footprint:C,id:d})}updateAppearances(d,m,v,C){}prepare(){return function(){if(OF!=null||A3e!=null)return null;if(G3!=null)return G3;const d=fetch(ua.BUILDING_GEN_URL);return G3=function(m){let v,C,E,P,R;function $(){v=new Uint8Array(R.buffer),C=new Int16Array(R.buffer),E=new Int32Array(R.buffer),P=new Float32Array(R.buffer)}function G(){throw new Error("Unexpected BuildingGen error.")}const te=()=>{},se={a:{a:G,f:function(ae){const de=v.length,he=Math.max(ae>>>0,Math.ceil(1.2*de)),Se=Math.ceil((he-de)/65536);try{return R.grow(Se),$(),!0}catch{return!1}},g:G,b:te,c:te,d:te,e:te}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(m,se):m.then(ae=>ae.arrayBuffer()).then(ae=>WebAssembly.instantiate(ae,se))).then(ae=>{const de=ae.instance.exports;return(0,de.g)(),R=de.f,$(),new ydt({setStyle:de.h,setAOOptions:de.i,setMetricOptions:de.j,setStructuralOptions:de.k,setFacadeOptions:de.l,setFauxFacadeOptions:de.m,setFacadeClassifierOptions:de.n,addFeature:de.o,addFacade:de.p,generateMesh:de.q,getLastError:de.r,getOuterRingLength:de.s,getMeshCount:de.t,getPositionsPtr:de.u,getPositionsLength:de.v,getNormalsPtr:de.w,getNormalsLength:de.x,getAOPtr:de.y,getAOLength:de.z,getUVPtr:de.A,getUVLength:de.B,getFauxFacadePtr:de.C,getFauxFacadeLength:de.D,getIndicesPtr:de.E,getIndicesLength:de.F,getBuildingPart:de.G,getRingCount:de.H,getRingPtr:de.I,getRingLength:de.J,malloc:de.K,free:de.L,heapU8:v,heap16:C,heap32:E,heapF32:P})})}(d).then(m=>(G3=null,OF=m,OF)).catch(m=>{xr("Could not load building-gen"),G3=null,A3e=m}),G3}()}populate(d,m,v,C){const E=vdt();if(!E)return;const P=Ue(v);this.tileToMeter=P,this.brightness=m.brightness,E.setStyle({normalScale:[1,-1,P],tileToMeters:P}),E.setAOOptions(!1,.3),E.setMetricOptions(!1,16),E.setStructuralOptions(!0),E.setFacadeClassifierOptions(3);const R=new Map,$=new Map;let G=0;for(const{feature:Re}of d){if(Z3e[Re.type]!=="LineString"){R.set(Re.id,Re.properties.source_id);continue}const Ke=this.layers[0]._featureFilter.needGeometry;if(Ke&&!this.layers[0]._featureFilter.filter(new Ki(this.zoom),Re,v))continue;const Xe=Wt(Re,Ke);if(!Ke&&!this.layers[0]._featureFilter.filter(new Ki(this.zoom),Xe,v))continue;const lt=Ke?Xe.geometry:Ot(Re,v,C),kt=[];for(const qt of lt)for(const ss of qt)kt.push(ss.x),kt.push(ss.y);const vt={coordinates:kt,crossPerc:Re.properties.cross_perc,distanceToRoad:Re.properties.distance_to_road,entrances:Re.properties.entrances,sourceId:0},At=Re.properties.source_id;let zt=$.get(At);zt||(zt=[],$.set(At,zt)),zt.push(vt),++G}this.maxHeight=0;const te=new Array,se=new Set,ae=Re=>{Re!=null&&se.add(Re)},de=(Re,Ke)=>{Re!=null&&te.push({buildingId:Re,footprintIndex:Ke})},he=64*(d.length-G),Se=he/2;this.buildingWithFacade.reserve(he,Se,!0),this.buildingWithoutFacade.reserve(2*he,2*Se,!1),this.footprintsIndices.reserve(16*(d.length-G)),this.footprintsVertices.reserve(8*(d.length-G));for(const{feature:Re,id:Ke,index:Xe,sourceLayerIndex:lt}of d){if(Z3e[Re.type]==="LineString")continue;const kt=this.layers[0]._featureFilter.needGeometry;if(kt&&!this.layers[0]._featureFilter.filter(new Ki(this.zoom),Re,v))continue;let vt=null;if(Re.properties&&Re.properties.hasOwnProperty("building_id")&&(vt=Re.properties.building_id,se.has(vt)))continue;const At=Wt(Re,kt);if(!kt&&!this.layers[0]._featureFilter.filter(new Ki(this.zoom),At,v))continue;const zt=kt?At.geometry:Ot(Re,v,C),qt=W6(zt,500);let ss=!1;for(const rn of qt)if(rn.length!==1){ss=!0;break}if(ss){ae(vt);continue}if(!Wdt(zt,163)){ae(vt);continue}const Gt=this.layers[0],ds=Gdt(Gt.layout.get("building-roof-shape").evaluate(Re,{},v)),js=Gt.layout.get("building-base").evaluate(Re,{},v),Ns=Gt.layout.get("building-height").evaluate(Re,{},v),Fs=Gt.layout.get("building-flood-light-ground-radius").evaluate(Re,{},v),Bs=Gt.paint.get("building-ambient-occlusion-intensity"),Ls=Fs/this.tileToMeter;Re.properties["building-part"]="roof";const Os=Gt.paint.get("building-color").evaluate(Re,{},this.canonical).toPremultipliedRenderColor(this.lut),ls=Gt.paint.get("building-emissive-strength").evaluate(Re,{},this.canonical);Re.properties["building-part"]="wall";const rs=Gt.paint.get("building-color").evaluate(Re,{},this.canonical).toPremultipliedRenderColor(this.lut),Rs=Gt.paint.get("building-emissive-strength").evaluate(Re,{},this.canonical);Re.properties["building-part"]="window";const sr=Gt.paint.get("building-color").evaluate(Re,{},this.canonical).toPremultipliedRenderColor(this.lut),Vs=Gt.paint.get("building-emissive-strength").evaluate(Re,{},this.canonical);Re.properties["building-part"]="door";const zr=Gt.paint.get("building-color").evaluate(Re,{},this.canonical).toPremultipliedRenderColor(this.lut),mr=Gt.paint.get("building-emissive-strength").evaluate(Re,{},this.canonical);let _r=Gt.layout.get("building-flood-light-wall-radius").evaluate(Re,{},v);_r=je(_r,0,2048);const Tr=_r/2048*VF,ta=R.get(Ke),Ks=$.get(ta)||[],Ar=Ks.length!==0&&Gt.layout.get("building-facade").evaluate(Re,{},v);E.setFacadeOptions(4,!0),E.setFauxFacadeOptions(Ar,!1,1);let _n=0,ja=0,Ca=0,$n=0,Ai=0,_t=0,Ct=0,us=0,zs=0,or=0,lr=0;if(Ar){let rn=Math.round(Gt.layout.get("building-facade-floors").evaluate(Re,{},v));if(js===0){rn=Math.max(1,rn-(Ks.length>0?1:0));let wi=4;if(Ns>100){const ao=[10,13,15];wi=ao[Re.id?Re.id%ao.length:0]}else Ns<=10&&(wi=3);E.setFacadeOptions(wi,!0),Ai=(Ns<15?1.3:1.61803)*wi/P}else Ai=js/P;_t=Ns/P,Ai=Math.min(Ai,_t),Ca=Gt.layout.get("building-facade-unit-width").evaluate(Re,{},v)/P,$n=(_t-Ai)/rn,E.setFauxFacadeOptions(!0,!0,Ca);const jo=Gt.layout.get("building-facade-window").evaluate(Re,{},v);_n=jo[0],ja=jo[1],Ct=Math.floor(65535*Math.min(1,Ai/tr)),us=Math.floor(65535*Math.min(1,_t/tr)),zs=Math.floor(255*_n)<<8|Math.floor(255*ja),or=Math.floor(65535*Math.min(1,Ca/tr)),lr=Math.floor(65535*Math.min(1,$n/tr))}const Br=Array(qt.length),Vr={x:1/0,y:1/0},In={x:-1/0,y:-1/0},Kn={x:0,y:0};let Qn=0;for(let rn=0;rn0){const wi=[],ao=Array(jo.length+1);ao[0]=0;for(let Ul=0;Ultr||Vr.y<0||In.y>tr)&&this.featuresOnBorder.push({featureId:Re.id,footprintIndex:this.footprints.length});{const rn=q3(Li,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+rn.length),this.footprintsIndices.uint16.set(rn,sn),this.buildingIds.add(vt??Re.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,Ui.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,Ui.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Zi.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Zi.y);const jo={footprintVertexOffset:ga,footprintVertexLength:this.footprintsVertices.length-ga,footprintIndexOffset:sn,footprintIndexLength:this.footprintsIndices.length-sn,min:Ui,max:Zi,hiddenFlags:0,indicesOffset:hi,indicesLength:mo,bloomIndicesOffset:_i,bloomIndicesLength:Ri,groundEffectVertexOffset:el,groundEffectVertexLength:Hi,hasFauxFacade:Ar,height:Zn,promoteId:Ke,feature:At,parts:Za,buildingBloom:Ya},wi=this.footprints.length;Re.id!==void 0&&this.featureFootprintLookup.set(Re.id,wi),de(vt,wi),this.footprints.push(jo)}this.programConfigurations.populatePaintArrays(an.layoutVertexArray.length,Re,Xe,{},m.availableImages,v,m.brightness),this.groundEffect.addPaintPropertiesData(Re,Xe,{},m.availableImages,v,m.brightness),m.featureIndex.insert(Re,zt,Xe,lt,this.index,Ei)}te.forEach(({buildingId:Re,footprintIndex:Ke})=>{se.has(Re)&&(this.footprints[Ke].hiddenFlags|=4)});const Fe=new Set;this.buildingIds.forEach((Re,Ke,Xe)=>{se.has(Re)||Fe.add(Re)}),this.buildingIds=Fe,this.groundEffect.prepareBorderSegments()}update(d,m,v,C,E,P,R){this.programConfigurations.updatePaintArrays(d,m,E,v,C,P,R),this.groundEffect.update(d,m,E,v,C,P,R),this.evaluate(this.layers[0],d),this.colorBufferUploaded=!1}isEmpty(){return this.buildingWithoutFacade.layoutVertexArray.length===0&&this.buildingWithFacade.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(d){const m=v=>{v.layoutVertexBuffer=d.createVertexBuffer(v.layoutVertexArray,G3e.members),v.layoutNormalBuffer=d.createVertexBuffer(v.layoutNormalArray,zdt.members),v.layoutCentroidBuffer=d.createVertexBuffer(v.layoutCentroidArray,Bdt.members),v.layoutFloodLightDataBuffer=d.createVertexBuffer(v.layoutFloodLightDataArray,Hdt.members),v.layoutFacadeDataArray&&v.layoutFacadeDataArray.length&&(v.layoutFacadeDataBuffer=d.createVertexBuffer(v.layoutFacadeDataArray,qdt.members)),v.layoutFacadeVerticalRangeArray&&v.layoutFacadeVerticalRangeArray.length&&(v.layoutFacadeVerticalRangeBuffer=d.createVertexBuffer(v.layoutFacadeVerticalRangeArray,Udt.members)),v.entranceBloom.layoutVertexArray.length&&(v.entranceBloom.layoutVertexBuffer=d.createVertexBuffer(v.entranceBloom.layoutVertexArray,G3e.members),v.entranceBloom.layoutAttenuationBuffer=d.createVertexBuffer(v.entranceBloom.layoutAttenuationArray,Vdt.members)),this.uploadUpdatedColorBuffer(d),this.uploadUpdatedIndexBuffer(d)};this.uploaded||(m(this.buildingWithoutFacade),m(this.buildingWithFacade),this.groundEffect.upload(d)),this.groundEffect.uploadPaintProperties(d),this.programConfigurations.upload(d),this.uploaded=!0}destroy(){const d=m=>{m.layoutVertexBuffer&&(m.layoutVertexBuffer.destroy(),m.layoutNormalBuffer.destroy(),m.layoutColorBuffer.destroy(),m.segmentsBucket.destroy(),m.indexBuffer&&m.indexBuffer.destroy(),m.entranceBloom.layoutVertexBuffer&&(m.entranceBloom.layoutVertexBuffer.destroy(),m.entranceBloom.layoutColorBuffer.destroy(),m.entranceBloom.layoutAttenuationBuffer.destroy(),m.entranceBloom.indexBuffer.destroy(),m.entranceBloom.segmentsBucket.destroy()))};d(this.buildingWithoutFacade),d(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(d,m,v=!0){let C=!1;const E=v?m:0,P=0|(v?-1:~m);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const R of d){const $=this.footprints[R],G=$.hiddenFlags&P|E;$.hiddenFlags!==G&&($.hiddenFlags=G,C=!0,this.groundEffect.updateHiddenByLandmarkRange($.groundEffectVertexOffset,$.groundEffectVertexLength,$.hiddenFlags!==0))}return C&&(this.indexArrayForConflationUploaded=!1),C}uploadUpdatedIndexBuffer(d){if(this.groundEffect.uploadHiddenByLandmark(d),this.indexArrayForConflationUploaded)return;const m=C=>{C.indexArray.length!==0&&(C.indexArrayForConflation.resize(C.indexArray.length),C.indexArrayForConflation.uint16.set(C.indexArray.uint16),C.entranceBloom.indexArrayForConflation.resize(C.entranceBloom.indexArray.length),C.entranceBloom.indexArrayForConflation.uint16.set(C.entranceBloom.indexArray.uint16))};m(this.buildingWithoutFacade),m(this.buildingWithFacade);for(const C of this.footprints){const E=C.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,P=C.indicesOffset+C.indicesLength;if(C.hiddenFlags!==0){for(let $=C.indicesOffset;${C.indexArray.length!==0&&(C.indexBuffer?C.indexBuffer.updateData(C.indexArrayForConflation):C.indexBuffer=d.createIndexBuffer(C.indexArrayForConflation,!0),C.entranceBloom.indexBuffer?C.entranceBloom.indexBuffer.updateData(C.entranceBloom.indexArrayForConflation):C.entranceBloom.indexBuffer=d.createIndexBuffer(C.entranceBloom.indexArrayForConflation,!0))};v(this.buildingWithoutFacade),v(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(d){const m=v=>{v.layoutColorBuffer?v.layoutColorBuffer.updateData(v.layoutColorArray):v.layoutColorBuffer=d.createVertexBuffer(v.layoutColorArray,K3e.members,!0),v.layoutFacadePaintArray&&(v.layoutFacadePaintBuffer?v.layoutFacadePaintBuffer.updateData(v.layoutFacadePaintArray):v.layoutFacadePaintBuffer=d.createVertexBuffer(v.layoutFacadePaintArray,$dt.members,!0)),v.entranceBloom.layoutColorBuffer?v.entranceBloom.layoutColorBuffer.updateData(v.entranceBloom.layoutColorArray):v.entranceBloom.layoutColorBuffer=d.createVertexBuffer(v.entranceBloom.layoutColorArray,K3e.members,!0)};m(this.buildingWithoutFacade),m(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(d,m){const v=d.paint.get("building-ambient-occlusion-intensity");for(const C of this.footprints){if(4&C.hiddenFlags)continue;const E=m[C.promoteId],P=C.feature;P.properties["building-part"]="roof";const R=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),$=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="wall";const G=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),te=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="window";const se=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),ae=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="door";const de=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),he=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical),Se=C.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Re of C.parts){let Ke,Xe=R;Re.part===1?(Xe=R,Ke=$):Re.part===0?(Xe=G,Ke=te):Re.part===2?(Xe=se,Ke=ae):Re.part===3&&(Xe=de,Ke=he),Ke=je(Ke,0,1);for(let lt=0;ltP.max.x||$.max.xP.max.y||$.max.yR.max.x||R.min.x>d||m>R.max.y||R.min.y>m||R.height<=v||Kdt(P,this.footprintsVertices.float32.subarray(2*R.footprintVertexOffset,2*(R.footprintVertexOffset+R.footprintVertexLength)),this.footprintsIndices.uint16.subarray(R.footprintIndexOffset,R.footprintIndexOffset+R.footprintIndexLength))&&(v=R.height,this.footprintLookup[E]=R,C=R.hiddenFlags!==0);if(v!==Number.NEGATIVE_INFINITY)return{height:v,hidden:C};this.footprintLookup[E]=void 0}}function Kdt(x,d,m){for(let v=0;v1&&($=d[++R]);const te=Math.abs(G-$.left),se=Math.abs(G-$.right),ae=Math.min(te,se);let de;const he=E/v*(C+1);if($.isDash){const Se=C-Math.abs(he);de=Math.sqrt(ae*ae+Se*Se)}else de=C-Math.sqrt(ae*ae+he*he);this.image.data[P+G]=Math.max(0,Math.min(255,de+128))}}}addRegularDash(d,m){for(let $=d.length-1;$>=0;--$){const G=d[$],te=d[$+1];G.zeroLength?d.splice($,1):te&&te.isDash===G.isDash&&(te.left=G.left,d.splice($,1))}const v=d[0],C=d[d.length-1];v.isDash===C.isDash&&(v.left=C.left-this.width,C.right=v.right+this.width);const E=this.width*this.nextRow;let P=0,R=d[P];for(let $=0;$1&&(R=d[++P]);const G=Math.abs($-R.left),te=Math.abs($-R.right),se=Math.min(G,te);this.image.data[E+$]=Math.max(0,Math.min(255,(R.isDash?se:-se)+m+128))}}addDash(d,m){const v=this.getKey(d,m);if(this.positions[v])return this.positions[v];const C=m==="round",E=C?7:0,P=2*E+1;if(this.nextRow+P>this.height)return xr("LineAtlas out of space"),null;d.length===0&&d.push(1);let R=0;for(let te=0;tem.fqid),this.index=d.index,this.projection=d.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(m=>{this.gradients[m.id]={}}),this.layoutVertexArray=new j3,this.layoutVertexArray2=new dm,this.patternVertexArray=new dm,this.indexArray=new Bl,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut}),this.segments=new bo,this.maxLineLength=0,this.zOffsetVertexArray=new dm,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.tessellationStep=d.tessellationStep?d.tessellationStep:tr/64,this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,C){}populate(d,m,v,C){this.hasPattern=cpe("line",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Ue(v);const P=this.layers[0].layout.get("line-elevation-reference");if(P==="hd-road-markup")this.elevationType="road";else{const ae=this.layers[0].layout.get("line-z-offset"),de=ae.isConstant()&&!ae.constantOr(0);this.elevationType=P!=="sea"&&P!=="ground"&&de?"none":"offset",this.elevationType==="offset"&&P==="none"&&xr(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`)}const R=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&R!==void 0;const $=[];for(const{feature:ae,id:de,index:he,sourceLayerIndex:Se}of d){const Fe=this.layers[0]._featureFilter.needGeometry,Re=Wt(ae,Fe);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),Re,v))continue;const Ke=E?E.evaluate(Re,{},v):void 0,Xe={id:de,properties:ae.properties,type:ae.type,sourceLayerIndex:Se,index:he,geometry:Fe?Re.geometry:Ot(ae,v,C),patterns:{},sortKey:Ke};$.push(Xe)}E&&$.sort((ae,de)=>ae.sortKey-de.sortKey);const{lineAtlas:G,featureIndex:te}=m,se=this.addConstantDashes(G);for(const ae of $){const{geometry:de,index:he,sourceLayerIndex:Se}=ae;if(se&&this.addFeatureDashes(ae,G),this.hasPattern){const Fe=dpe("line",this.layers,ae,this.zoom,this.pixelRatio,m);this.patternFeatures.push(Fe)}else this.addFeature(ae,de,he,v,G.positions,m.availableImages,m.brightness,m.elevationFeatures);te.insert(d[he].feature,de,he,Se,this.index)}}addConstantDashes(d){let m=!1;for(const v of this.layers){const C=v.paint.get("line-dasharray").value,E=v.layout.get("line-cap").value;if(C.kind!=="constant"||E.kind!=="constant")m=!0;else{const P=E.value,R=C.value;if(!R)continue;d.addDash(R,P)}}return m}addFeatureDashes(d,m){const v=this.zoom;for(const C of this.layers){const E=C.paint.get("line-dasharray").value,P=C.layout.get("line-cap").value;if(E.kind==="constant"&&P.kind==="constant")continue;let R,$;if(E.kind==="constant"){if(R=E.value,!R)continue}else R=E.evaluate({zoom:v},d);$=P.kind==="constant"?P.value:P.evaluate({zoom:v},d),m.addDash(R,$),d.patterns[C.id]=[m.getKey(R,$)]}}update(d,m,v,C,E,P,R,$){this.programConfigurations.updatePaintArrays(d,m,E,v,C,P,R,$)}addFeatures(d,m,v,C,E,P){for(const R of this.patternFeatures)this.addFeature(R,R.geometry,R.index,m,v,C,P,d.elevationFeatures)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=d.createVertexBuffer(this.layoutVertexArray2,eut)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=d.createVertexBuffer(this.patternVertexArray,sut)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=d.createVertexBuffer(this.zOffsetVertexArray,Xdt.members,!0)),this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,Qdt),this.indexBuffer=d.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(d),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(d,m){let v,C;if(m&&m>0?(v=`mapbox_clip_start_${m}`,C=`mapbox_clip_end_${m}`):(v="mapbox_clip_start",C="mapbox_clip_end"),d.properties&&d.properties.hasOwnProperty(v)&&d.properties.hasOwnProperty(C))return{start:+d.properties[v],end:+d.properties[C]}}addFeature(d,m,v,C,E,P,R,$){const G=this.layers[0].layout,te=G.get("line-join").evaluate(d,{}),se=G.get("line-cap").evaluate(d,{}),ae=G.get("line-miter-limit"),de=G.get("line-round-limit");this.lineClips=this.lineFeatureClips(d),this.lineFeature=d;const he=!(!d.properties||!d.properties.hasOwnProperty("mapbox_line_metrics"))&&d.properties.mapbox_line_metrics;this.zOffsetValue=G.get("line-z-offset").value;const Se=this.layers[0].paint.get("line-width").value;if(Se.kind!=="constant"&&Se.isLineProgressConstant===!1&&(this.variableWidthValue=Se),this.elevationType==="road"){const Fe=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(d,m,C,$,te,se,ae,de)){const[Re,Ke]=this.clipRuntimeLinesToTile(m,1);for(let Xe=0;Xe0?kt.parentIndex:null)}this.fillNonElevatedRoadSegment(Fe)}}else for(let Fe=0;Fe0?Fe:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,v,E,P,C,R,void 0,this.worldview)}computeSegNextDir(d,m){return d.nextPoint.sub(m.at(-2)).unit()}computeSegPrevDir(d,m){return m[1].sub(d.prevPoint).unit()}clipLinesToTile(d,m){return LF(d,-m,-m,tr+m,tr+m)}clipRuntimeLinesToTile(d,m){const v=[];return[LF(d,-m,-m,tr+m,tr+m,v),v]}addElevatedRoadFeature(d,m,v,C,E,P,R,$){const G=[],te=di.getElevationFeature(d,C);if(te){const se=this.clipLinesToTile(m,1),ae=this.prepareElevatedLines(se,te,v);for(const de of ae)G.push({geometry:de,elevation:te,elevationTileID:v,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(G.length===0)return!1;for(const se of G){const ae=this.layoutVertexArray.length;this.addLine(se.geometry,d,v,E,P,R,$);const de=new Ci(v,se.elevationTileID);if(se.elevation)for(let he=ae;he>1,this.layoutVertexArray.int16[6*he+1]>>1),Fe=de.pointElevation(Se,se.elevation,.05);this.updateHeightRange(Fe),this.zOffsetVertexArray.emplaceBack(Fe,0,0)}else this.fillNonElevatedRoadSegment(ae)}return!0}prepareElevatedLines(d,m,v){if(m.constantHeight!=null)return d;const C=[],E=1/Ue(v);for(const P of d)fdt(P,new Ka(m,E),0,C);return C}fillNonElevatedRoadSegment(d){for(let m=d;m0,ae=$&&$.progress.max<1;if(this.lineClips){let qt={min:this.lineClips.start,max:this.lineClips.end},ss=1;if($){const js=this.lineClips.end-this.lineClips.start;qt=function(Ns,Fs,Bs){return{min:Ti(Ns.min,Fs,Bs),max:Ti(Ns.max,Fs,Bs)}}($.progress,{min:0,max:1},qt),js>0&&(ss=(qt.max-qt.min)/js)}const Gt=+m.properties.mapbox_clip_feature_len,ds=+m.properties.mapbox_clip_seg_len;if(Number.isNaN(Gt)||Number.isNaN(ds)){for(let Ns=0;Ns=2&&d[he-1].equals(d[he-2]);)he--;let Se=0;for(;Se0,ls=this.overscaling<=16?15*tr/(512*this.overscaling):0;if(ss&&Gt==="round"){if(FsP&&(Gt="bevel"),Gt==="bevel"&&(Fs>2&&(Gt="flipbevel"),Fs2*ls){const sr=Re.sub(Re.sub(Ke)._mult(ls/rs)._round());this.updateDistance(Ke,sr),this.addCurrentVertex(sr,lt,0,0,Fe,zt),Ke=sr}this.updateDistance(Ke,Re),js._mult(Fs),this.addCurrentVertex(Re,js,0,0,Fe,zt);const Rs=Re.dist(Xe);if(Rs>2*ls){const sr=Re.add(Xe.sub(Re)._mult(ls/Rs)._round());this.updateDistance(Re,sr),this.addCurrentVertex(sr,kt,0,0,Fe,zt),Re=sr}}else js._mult(Fs),this.addCurrentVertex(Re,js,0,0,Fe,zt);else if(Gt==="flipbevel"){if(Fs>100)js=kt.mult(-1);else{const rs=Fs*lt.add(kt).mag()/lt.sub(kt).mag();js._perp()._mult(rs*(Os?-1:1))}this.addCurrentVertex(Re,js,0,0,Fe,zt),this.addCurrentVertex(Re,js.mult(-1),0,0,Fe,zt)}else if(Gt==="bevel"||Gt==="fakeround"){zt!=null&&Ke&&this.addCurrentVertex(Re,At||lt,-1,-1,Fe,zt);const rs=Re.dist(Ke)<=2*ls&&Gt!=="bevel",Rs=js.mult(Os?1:-1);Rs._mult(Fs);const sr=kt.mult(Os?-1:1),Vs=lt.mult(Os?-1:1),zr=this.evaluateLineProgressFeatures(this.distance);if(zt==null&&(this.addHalfVertex(Re,Rs.x,Rs.y,!1,!Os,0,Fe,zr),rs||this.addHalfVertex(Re,Rs.x+2*Vs.x,Rs.y+2*Vs.y,!1,Os,0,Fe,zr)),Gt==="fakeround"){const mr=Math.round(180*Bs/Math.PI/20);this.addHalfVertex(Re,Vs.x,Vs.y,!1,Os,0,Fe,zr);for(let _r=0;_r1){this.lineSoFar=d.w;const Se=(m.x-d.x)/se,Fe=(m.y-d.y)/se,Re=(m.z-d.z)/se,Ke=(m.w-d.w)/se;for(let Xe=1;Xe=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,te),$.primitiveLength++),P?this.e2=te:this.e1=te,G!=null&&this.zOffsetVertexArray.emplaceBack(G.zOffset,G.variableWidth,G.variableWidth)}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(d,m){this.prevDistance=this.distance,this.distance+=d.dist(m),this.updateScaledDistance()}}function Fpe(x,d,m){return x.xm||x.ym}let e5e,t5e;function s5e(x,d,m){return d*(tr/(x.tileSize*Math.pow(2,m-x.tileID.overscaledZ)))}kr(Rpe,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const r5e=(x,d,m)=>(1-m)*x+m*d;function n5e(x,d){return 1/s5e(x,1,d.tileZoom)}function a5e(x,d,m,v){return x.translatePosMatrix(v||d.tileID.projMatrix,d,m.paint.get("line-translate"),m.paint.get("line-translate-anchor"))}const i5e=x=>{const d=[];o5e(x)&&d.push("RENDER_LINE_DASH"),x.paint.get("line-gradient")&&d.push("RENDER_LINE_GRADIENT");const m=x.paint.get("line-trim-offset");m[0]===0&&m[1]===0||d.push("RENDER_LINE_TRIM_OFFSET"),x.paint.get("line-border-width").constantOr(1)!==0&&d.push("RENDER_LINE_BORDER");const v=x.layout.get("line-join").constantOr("miter")==="none",C=!!x.paint.get("line-pattern").constantOr(1);return v&&C&&d.push("LINE_JOIN_NONE"),d};function o5e(x){const d=x.paint.get("line-dasharray").value;return d.kind!=="constant"||d.value}let zpe;const l5e=()=>zpe||(zpe={layout:e5e||(e5e=new Io({"line-cap":new ar(Kt.layout_line["line-cap"]),"line-join":new ar(Kt.layout_line["line-join"]),"line-miter-limit":new Ys(Kt.layout_line["line-miter-limit"]),"line-round-limit":new Ys(Kt.layout_line["line-round-limit"]),"line-sort-key":new ar(Kt.layout_line["line-sort-key"]),"line-z-offset":new ar(Kt.layout_line["line-z-offset"]),"line-elevation-reference":new Ys(Kt.layout_line["line-elevation-reference"]),"line-cross-slope":new Ys(Kt.layout_line["line-cross-slope"]),visibility:new Ys(Kt.layout_line.visibility),"line-width-unit":new Ys(Kt.layout_line["line-width-unit"])})),paint:t5e||(t5e=new Io({"line-opacity":new ar(Kt.paint_line["line-opacity"]),"line-color":new ar(Kt.paint_line["line-color"]),"line-translate":new Ys(Kt.paint_line["line-translate"]),"line-translate-anchor":new Ys(Kt.paint_line["line-translate-anchor"]),"line-width":new ar(Kt.paint_line["line-width"]),"line-gap-width":new ar(Kt.paint_line["line-gap-width"]),"line-offset":new ar(Kt.paint_line["line-offset"]),"line-blur":new ar(Kt.paint_line["line-blur"]),"line-dasharray":new ar(Kt.paint_line["line-dasharray"]),"line-pattern":new ar(Kt.paint_line["line-pattern"]),"line-pattern-cross-fade":new Ys(Kt.paint_line["line-pattern-cross-fade"]),"line-gradient":new cv(Kt.paint_line["line-gradient"]),"line-trim-offset":new Ys(Kt.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ys(Kt.paint_line["line-trim-fade-range"]),"line-trim-color":new Ys(Kt.paint_line["line-trim-color"]),"line-emissive-strength":new ar(Kt.paint_line["line-emissive-strength"]),"line-border-width":new ar(Kt.paint_line["line-border-width"]),"line-border-color":new ar(Kt.paint_line["line-border-color"]),"line-occlusion-opacity":new Ys(Kt.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"})}))},zpe);class iut extends ar{possiblyEvaluate(d,m){return m=new Ki(Math.floor(m.zoom),{now:m.now,fadeDuration:m.fadeDuration,transition:m.transition,worldview:m.worldview}),super.possiblyEvaluate(d,m)}evaluate(d,m,v,C){return m=Object.assign({},m,{zoom:Math.floor(m.zoom)}),super.evaluate(d,m,v,C)}}let nP;function c5e(x,d){return d>0?d+2*x:x}const out=fa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),lut=fa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),cut=fa([{name:"a_projected_pos",components:4,type:"Float32"}],4);fa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const dut=fa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),uut=fa([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),hut=fa([{name:"a_texb",components:2,type:"Uint16"}]),mut=fa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),put=fa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);fa([{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 d5e=fa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),fut=fa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);fa([{name:"triangle",components:3,type:"Uint16"}]),fa([{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"}]),fa([{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"}]),fa([{type:"Float32",name:"offsetX"}]),fa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ac=24;function xut(x,d,m){return x.sections.forEach(v=>{v.text=function(C,E,P){const R=E.layout.get("text-transform").evaluate(P,{});return R==="uppercase"?C=C.toLocaleUpperCase():R==="lowercase"&&(C=C.toLocaleLowerCase()),ig.applyArabicShaping&&(C=ig.applyArabicShaping(C)),C}(v.text,d,m)}),x}const aP={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function gut(x){return x==="︶"||x==="﹈"||x==="︸"||x==="﹄"||x==="﹂"||x==="︾"||x==="︼"||x==="︺"||x==="︘"||x==="﹀"||x==="︐"||x==="︓"||x==="︔"||x==="`"||x===" ̄"||x==="︑"||x==="︒"}function yut(x){return x==="︵"||x==="﹇"||x==="︷"||x==="﹃"||x==="﹁"||x==="︽"||x==="︻"||x==="︹"||x==="︗"||x==="︿"}const Bpe=4294967296,u5e=1/Bpe,h5e=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let HF=class{constructor(x=new Uint8Array(16)){this.buf=ArrayBuffer.isView(x)?x:new Uint8Array(x),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(x,d,m=this.length){for(;this.pos>3,E=this.pos;this.type=7&v,x(C,d,this),this.pos===E&&this.skip(v)}return d}readMessage(x,d){return this.readFields(x,d,this.readVarint()+this.pos)}readFixed32(){const x=this.dataView.getUint32(this.pos,!0);return this.pos+=4,x}readSFixed32(){const x=this.dataView.getInt32(this.pos,!0);return this.pos+=4,x}readFixed64(){const x=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Bpe;return this.pos+=8,x}readSFixed64(){const x=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Bpe;return this.pos+=8,x}readFloat(){const x=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,x}readDouble(){const x=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,x}readVarint(x){const d=this.buf;let m,v;return v=d[this.pos++],m=127&v,v<128?m:(v=d[this.pos++],m|=(127&v)<<7,v<128?m:(v=d[this.pos++],m|=(127&v)<<14,v<128?m:(v=d[this.pos++],m|=(127&v)<<21,v<128?m:(v=d[this.pos],m|=(15&v)<<28,function(C,E,P){const R=P.buf;let $,G;if(G=R[P.pos++],$=(112&G)>>4,G<128||(G=R[P.pos++],$|=(127&G)<<3,G<128)||(G=R[P.pos++],$|=(127&G)<<10,G<128)||(G=R[P.pos++],$|=(127&G)<<17,G<128)||(G=R[P.pos++],$|=(127&G)<<24,G<128)||(G=R[P.pos++],$|=(1&G)<<31,G<128))return Z3(C,$,E);throw new Error("Expected varint not more than 10 bytes")}(m,x,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const x=this.readVarint();return x%2==1?(x+1)/-2:x/2}readBoolean(){return!!this.readVarint()}readString(){const x=this.readVarint()+this.pos,d=this.pos;return this.pos=x,x-d>=12&&h5e?h5e.decode(this.buf.subarray(d,x)):function(m,v,C){let E="",P=v;for(;P239?4:R>223?3:R>191?2:1;if(P+ae>C)break;ae===1?R<128&&(se=R):ae===2?($=m[P+1],(192&$)==128&&(se=(31&R)<<6|63&$,se<=127&&(se=null))):ae===3?($=m[P+1],G=m[P+2],(192&$)==128&&(192&G)==128&&(se=(15&R)<<12|(63&$)<<6|63&G,(se<=2047||se>=55296&&se<=57343)&&(se=null))):ae===4&&($=m[P+1],G=m[P+2],te=m[P+3],(192&$)==128&&(192&G)==128&&(192&te)==128&&(se=(15&R)<<18|(63&$)<<12|(63&G)<<6|63&te,(se<=65535||se>=1114112)&&(se=null))),se===null?(se=65533,ae=1):se>65535&&(se-=65536,E+=String.fromCharCode(se>>>10&1023|55296),se=56320|1023&se),E+=String.fromCharCode(se),P+=ae}return E}(this.buf,d,x)}readBytes(){const x=this.readVarint()+this.pos,d=this.buf.subarray(this.pos,x);return this.pos=x,d}readPackedVarint(x=[],d){const m=this.readPackedEnd();for(;this.pos127;);else if(d===2)this.pos=this.readVarint()+this.pos;else if(d===5)this.pos+=4;else{if(d!==1)throw new Error(`Unimplemented type: ${d}`);this.pos+=8}}writeTag(x,d){this.writeVarint(x<<3|d)}realloc(x){let d=this.length||16;for(;d268435455||x<0?function(d,m){let v,C;if(d>=0?(v=d%4294967296|0,C=d/4294967296|0):(v=~(-d%4294967296),C=~(-d/4294967296),4294967295^v?v=v+1|0:(v=0,C=C+1|0)),d>=18446744073709552e3||d<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");m.realloc(10),function(E,P,R){R.buf[R.pos++]=127&E|128,E>>>=7,R.buf[R.pos++]=127&E|128,E>>>=7,R.buf[R.pos++]=127&E|128,E>>>=7,R.buf[R.pos++]=127&E|128,R.buf[R.pos]=127&(E>>>=7)}(v,0,m),function(E,P){const R=(7&E)<<4;P.buf[P.pos++]|=R|((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)))))}(C,m)}(x,this):(this.realloc(4),this.buf[this.pos++]=127&x|(x>127?128:0),x<=127||(this.buf[this.pos++]=127&(x>>>=7)|(x>127?128:0),x<=127||(this.buf[this.pos++]=127&(x>>>=7)|(x>127?128:0),x<=127||(this.buf[this.pos++]=x>>>7&127))))}writeSVarint(x){this.writeVarint(x<0?2*-x-1:2*x)}writeBoolean(x){this.writeVarint(+x)}writeString(x){x=String(x),this.realloc(4*x.length),this.pos++;const d=this.pos;this.pos=function(v,C,E){for(let P,R,$=0;$55295&&P<57344){if(!R){P>56319||$+1===C.length?(v[E++]=239,v[E++]=191,v[E++]=189):R=P;continue}if(P<56320){v[E++]=239,v[E++]=191,v[E++]=189,R=P;continue}P=R-55296<<10|P-56320|65536,R=null}else R&&(v[E++]=239,v[E++]=191,v[E++]=189,R=null);P<128?v[E++]=P:(P<2048?v[E++]=P>>6|192:(P<65536?v[E++]=P>>12|224:(v[E++]=P>>18|240,v[E++]=P>>12&63|128),v[E++]=P>>6&63|128),v[E++]=63&P|128)}return E}(this.buf,x,this.pos);const m=this.pos-d;m>=128&&m5e(d,m,this),this.pos=d-1,this.writeVarint(m),this.pos+=m}writeFloat(x){this.realloc(4),this.dataView.setFloat32(this.pos,x,!0),this.pos+=4}writeDouble(x){this.realloc(8),this.dataView.setFloat64(this.pos,x,!0),this.pos+=8}writeBytes(x){const d=x.length;this.writeVarint(d),this.realloc(d);for(let m=0;m=128&&m5e(m,v,this),this.pos=m-1,this.writeVarint(v),this.pos+=v}writeMessage(x,d,m){this.writeTag(x,2),this.writeRawMessage(d,m)}writePackedVarint(x,d){d.length&&this.writeMessage(x,vut,d)}writePackedSVarint(x,d){d.length&&this.writeMessage(x,but,d)}writePackedBoolean(x,d){d.length&&this.writeMessage(x,jut,d)}writePackedFloat(x,d){d.length&&this.writeMessage(x,_ut,d)}writePackedDouble(x,d){d.length&&this.writeMessage(x,wut,d)}writePackedFixed32(x,d){d.length&&this.writeMessage(x,Nut,d)}writePackedSFixed32(x,d){d.length&&this.writeMessage(x,kut,d)}writePackedFixed64(x,d){d.length&&this.writeMessage(x,Sut,d)}writePackedSFixed64(x,d){d.length&&this.writeMessage(x,Cut,d)}writeBytesField(x,d){this.writeTag(x,2),this.writeBytes(d)}writeFixed32Field(x,d){this.writeTag(x,5),this.writeFixed32(d)}writeSFixed32Field(x,d){this.writeTag(x,5),this.writeSFixed32(d)}writeFixed64Field(x,d){this.writeTag(x,1),this.writeFixed64(d)}writeSFixed64Field(x,d){this.writeTag(x,1),this.writeSFixed64(d)}writeVarintField(x,d){this.writeTag(x,0),this.writeVarint(d)}writeSVarintField(x,d){this.writeTag(x,0),this.writeSVarint(d)}writeStringField(x,d){this.writeTag(x,2),this.writeString(d)}writeFloatField(x,d){this.writeTag(x,5),this.writeFloat(d)}writeDoubleField(x,d){this.writeTag(x,1),this.writeDouble(d)}writeBooleanField(x,d){this.writeVarintField(x,+d)}};function Z3(x,d,m){return m?4294967296*d+(x>>>0):4294967296*(d>>>0)+(x>>>0)}function m5e(x,d,m){const v=d<=16383?1:d<=2097151?2:d<=268435455?3:Math.floor(Math.log(d)/(7*Math.LN2));m.realloc(v);for(let C=m.pos-1;C>=x;C--)m.buf[C+v]=m.buf[C]}function vut(x,d){for(let m=0;m=0&&v>=d&&WF[this.text.charCodeAt(v)];v--)m--;this.text=this.text.substring(d,m),this.sectionIndex=this.sectionIndex.slice(d,m)}substring(d,m){const v=new Y3;return v.text=this.text.substring(d,m),v.sectionIndex=this.sectionIndex.slice(d,m),v.sections=this.sections,v}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((d,m)=>Math.max(d,this.sections[m].scale),0)}addTextSection(d,m){this.text+=d.text,this.sections.push(iP.forText(d.scale,d.fontStack||m));const v=this.sections.length-1;for(let C=0;C=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function qpe(x,d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se=1){const Fe=Y3.fromFeature(x,C,Se);se===pm.vertical&&Fe.verticalizePunctuation(ae);let Re=[];const Ke=function(At,zt,qt,ss,Gt,ds){if(!At)return[];const js=[],Ns=function(Os,ls,rs,Rs,sr,Vs){let zr=0;for(let mr=0;mr=0;let Bs=0;for(let Os=0;Os0&&Ya>$n&&($n=Ya)}else{const Va=qt[zs.fontStack];if(!Va)continue;Va[lr]&&(In=Va[lr]);const Za=zt[zs.fontStack];if(!Za)continue;const Ya=Za.glyphs[lr];if(!Ya)continue;if(Vr=Ya.metrics,Qn=lr!==8203?Ac:0,Vs){const _i=Za.ascender!==void 0?Math.abs(Za.ascender):0,Ri=Za.descender!==void 0?Math.abs(Za.descender):0,Ei=(_i+Ri)*Br;Ai-m/2;){if(P--,P<0)return!1;R-=x[P].dist(E),E=x[P]}R+=x[P].dist(x[P+1]),P++;const $=[];let G=0;for(;Rv;)G-=$.shift().angleDelta;if(G>C)return!1;P++,R+=te.dist(se)}return!0}function N5e(x){let d=0;for(let m=0;mG){const he=(G-$)/de,Se=Zr(se.x,ae.x,he),Fe=Zr(se.y,ae.y,he),Re=new gv(Se,Fe,0,ae.angleTo(se),te);return!P||j5e(x,Re,R,P,d)?Re:void 0}$+=de}}function Lut(x,d,m,v,C,E,P,R,$){const G=k5e(v,E,P),te=S5e(v,C),se=te*P,ae=x[0].x===0||x[0].x===$||x[0].y===0||x[0].y===$;return d-se=0&<<$&&kt>=0&&kt<$&&ae-G>=0&&ae+G<=te){const vt=new gv(lt,kt,0,Ke,he);v&&!j5e(x,vt,E,v,C)||de.push(vt)}}se+=Re}return R||de.length||P||(de=C5e(x,se/2,m,v,C,E,P,!0,$)),de}function M5e(x){let d=0,m=0;for(const P of x)d+=P.w*P.h,m=Math.max(m,P.w);x.sort((P,R)=>R.h-P.h);const v=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(d/.95)),m),h:1/0}];let C=0,E=0;for(const P of x)for(let R=v.length-1;R>=0;R--){const $=v[R];if(!(P.w>$.w||P.h>$.h)){if(P.x=$.x,P.y=$.y,E=Math.max(E,P.y+P.h),C=Math.max(C,P.x+P.w),P.w===$.w&&P.h===$.h){const G=v.pop();G&&R1?he-1:he,Wd.copy(se.data,G,{x:0,y:0},{x:Se,y:Fe},se.data,v),Wd.copy(se.data,G,{x:0,y:Ke-he},{x:Se,y:Fe-he},{width:Re,height:he},v),Wd.copy(se.data,G,{x:0,y:0},{x:Se,y:Fe+Ke},{width:Re,height:he},v),Wd.copy(se.data,G,{x:Re-he,y:0},{x:Se-he,y:Fe},{width:he,height:Ke},v),Wd.copy(se.data,G,{x:0,y:0},{x:Se+Re,y:Fe},{width:he,height:Ke},v),Wd.copy(se.data,G,{x:Re-he,y:Ke-he},{x:Se-he,y:Fe-he},{width:he,height:he},v),Wd.copy(se.data,G,{x:0,y:Ke-he},{x:Se+Re,y:Fe-he},{width:he,height:he},v),Wd.copy(se.data,G,{x:0,y:0},{x:Se+Re,y:Fe+Ke},{width:he,height:he},v),Wd.copy(se.data,G,{x:Re-he,y:0},{x:Se-he,y:Fe+Ke},{width:he,height:he},v)}this.lut=v,this.image=G,this.iconPositions=C,this.patternPositions=E}addImages(d,m,v,C){for(const[E,P]of d.entries()){const{bin:R,imagePosition:$,imageVariant:G}=Gpe(E,P,v);m.set(E,$),C.push(R),P.hasRenderCallback&&this.haveRenderCallbacks.push(G.id)}}patchUpdatedImages(d,m,v){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(C=>d.hasImage(C,v)),d.dispatchRenderCallbacks(this.haveRenderCallbacks,v);for(const C of d.getUpdatedImages(v)){for(const E of this.iconPositions.keys()){const P=Jx.parse(E);if(Qs.isEqual(P.id,C)){const R=d.getImage(C,v);this.patchUpdatedImage(this.iconPositions.get(E),R,m,null)}}for(const E of this.patternPositions.keys()){const P=Jx.parse(E);if(Qs.isEqual(P.id,C)){const R=d.getImage(C,v);this.patchUpdatedImage(this.patternPositions.get(E),R,m,this.lut)}}}}patchUpdatedImage(d,m,v,C=null){if(!d||!m||d.version===m.version)return;d.version=m.version;const[E,P]=d.tl,R=d.sdf;if(this.lut||R){const $={width:m.data.width,height:m.data.height},G=new Wd($);Wd.copy(m.data,G,{x:0,y:0},{x:0,y:0},$,C,R),v.update(G,{position:{x:E,y:P}})}else v.update(m.data,{position:{x:E,y:P}})}}kr(oP,"ImagePosition"),kr(T5e,"ImageAtlas");const lP=1e20;function A5e(x,d,m,v,C,E,P,R,$){for(let G=d;G-1);$++,E[$]=R,P[$]=G,P[$+1]=lP}for(let R=0,$=0;R{let $=this.entries[E];$||($=this.entries[E]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let G=$.glyphs[P];if(G!==void 0)return void R(null,{stack:E,id:P,glyph:G});if(G=this._tinySDF($,E,P),G)return $.glyphs[P]=G,void R(null,{stack:E,id:P,glyph:G});const te=Math.floor(P/256);if(256*te>65535)return xr("glyphs > 65535 not supported"),void R(null,{stack:E,id:P,glyph:G});if($.ranges[te])return void R(null,{stack:E,id:P,glyph:G});let se=$.requests[te];se||(se=$.requests[te]=[],J3.loadGlyphRange(E,te,C,this.requestManager,(ae,de)=>{if(de){$.ascender=de.ascender,$.descender=de.descender;for(const he in de.glyphs)this._doesCharSupportLocalGlyph(+he)||($.glyphs[+he]=de.glyphs[+he]);$.ranges[te]=!0}for(const he of se)he(ae,de);delete $.requests[te]})),se.push((ae,de)=>{ae?R(ae):de&&R(null,{stack:E,id:P,glyph:de.glyphs[P]||null})})},(E,P)=>{if(E)m(E);else if(P){const R={};for(const{stack:$,id:G,glyph:te}of P)R[$]===void 0&&(R[$]={}),R[$].glyphs===void 0&&(R[$].glyphs={}),R[$].glyphs[G]=te&&{id:te.id,bitmap:te.bitmap.clone(),metrics:te.metrics},R[$].ascender=this.entries[$].ascender,R[$].descender=this.entries[$].descender;m(null,R)}})}_doesCharSupportLocalGlyph(d){return this.localGlyphMode!==Kpe.none&&(this.localGlyphMode===Kpe.all?!!this.localFontFamily:!!this.localFontFamily&&(en["CJK Unified Ideographs"](d)||en["Hangul Syllables"](d)||en.Hiragana(d)||en.Katakana(d)||en["CJK Symbols and Punctuation"](d)||en["CJK Unified Ideographs Extension A"](d)||en["CJK Unified Ideographs Extension B"](d)||en.Osage(d)))}_tinySDF(d,m,v){const C=this.localFontFamily;if(!C||!this._doesCharSupportLocalGlyph(v))return;let E=d.tinySDF;if(!E){let Se="400";/bold/i.test(m)?Se="900":/medium/i.test(m)?Se="500":/light/i.test(m)&&(Se="200"),E=d.tinySDF=new J3.TinySDF({fontFamily:C,fontWeight:Se,fontSize:24*gg,buffer:3*gg,radius:8*gg}),E.fontWeight=Se}if(this.localGlyphs[E.fontWeight][v])return this.localGlyphs[E.fontWeight][v];const P=String.fromCodePoint(v),{data:R,width:$,height:G,glyphWidth:te,glyphHeight:se,glyphLeft:ae,glyphTop:de,glyphAdvance:he}=E.draw(P);return this.localGlyphs[E.fontWeight][v]={id:v,bitmap:new wb({width:$,height:G},R),metrics:{width:te/gg,height:se/gg,left:ae/gg,top:de/gg-27,advance:he/gg,localGlyph:!0}}}}J3.loadGlyphRange=function(x,d,m,v,C){const E=256*d,P=E+255,R=v.transformRequest(v.normalizeGlyphsURL(m).replace("{fontstack}",x).replace("{range}",`${E}-${P}`),Yx.Glyphs);Lh(R,($,G)=>{if($)C($);else if(G){const te={},se=function(ae){return new HF(ae).readFields(Mut,{})}(G);for(const ae of se.glyphs)te[ae.id]=ae;C(null,{glyphs:te,ascender:se.ascender,descender:se.descender})}})},J3.TinySDF=class{constructor({fontSize:x=24,buffer:d=3,radius:m=8,cutoff:v=.25,fontFamily:C="sans-serif",fontWeight:E="normal",fontStyle:P="normal",lang:R=null}={}){this.buffer=d,this.cutoff=v,this.radius=m,this.lang=R;const $=this.size=x+4*d,G=this._createCanvas($),te=this.ctx=G.getContext("2d",{willReadFrequently:!0});te.font=`${P} ${E} ${x}px ${C}`,te.textBaseline="alphabetic",te.textAlign="left",te.fillStyle="black",this.gridOuter=new Float64Array($*$),this.gridInner=new Float64Array($*$),this.f=new Float64Array($),this.z=new Float64Array($+1),this.v=new Uint16Array($)}_createCanvas(x){const d=document.createElement("canvas");return d.width=d.height=x,d}draw(x){const{width:d,actualBoundingBoxAscent:m,actualBoundingBoxDescent:v,actualBoundingBoxLeft:C,actualBoundingBoxRight:E}=this.ctx.measureText(x),P=Math.ceil(m),R=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(E-C))),$=Math.min(this.size-this.buffer,P+Math.ceil(v)),G=R+2*this.buffer,te=$+2*this.buffer,se=Math.max(G*te,0),ae=new Uint8ClampedArray(se),de={data:ae,width:G,height:te,glyphWidth:R,glyphHeight:$,glyphTop:P,glyphLeft:0,glyphAdvance:d};if(R===0||$===0)return de;const{ctx:he,buffer:Se,gridInner:Fe,gridOuter:Re}=this;this.lang&&(he.lang=this.lang),he.clearRect(Se,Se,R,$),he.fillText(x,Se,Se+P);const Ke=he.getImageData(Se,Se,R,$);Re.fill(lP,0,se),Fe.fill(0,0,se);for(let Xe=0;Xe<$;Xe++)for(let lt=0;lt0?At*At:0,Fe[vt]=At<0?At*At:0}}A5e(Re,0,0,G,te,G,this.f,this.v,this.z),A5e(Fe,Se,Se,R,$,G,this.f,this.v,this.z);for(let Xe=0;Xe{const Fs=ZF(Gt.stretch-Ke,Xe,te,x.left*C),Bs=YF(Gt.fixed-vt,At,Gt.stretch,he),Ls=ZF(ds.stretch-lt,kt,se,x.top*C),Os=YF(ds.fixed-zt,qt,ds.stretch,Se),ls=ZF(js.stretch-Ke,Xe,te,x.left*C),rs=YF(js.fixed-vt,At,js.stretch,he),Rs=ZF(Ns.stretch-lt,kt,se,x.top*C),sr=YF(Ns.fixed-zt,qt,Ns.stretch,Se),Vs=new pt(Fs,Ls),zr=new pt(ls,Ls),mr=new pt(ls,Rs),_r=new pt(Fs,Rs),Tr=new pt(Bs/R,Os/R),ta=new pt(rs/R,sr/R),Ks=d*Math.PI/180;if(Ks){const Ai=Math.sin(Ks),_t=Math.cos(Ks),Ct=[_t,-Ai,Ai,_t];Vs._matMult(Ct),zr._matMult(Ct),_r._matMult(Ct),mr._matMult(Ct)}const Ar=Gt.stretch+Gt.fixed,_n=js.stretch+js.fixed,ja=ds.stretch+ds.fixed,Ca=Ns.stretch+Ns.fixed,$n=x.imageSecondary;return{tl:Vs,tr:zr,bl:_r,br:mr,texPrimary:{x:P.paddedRect.x+Fy+Ar,y:P.paddedRect.y+Fy+ja,w:_n-Ar,h:Ca-ja},texSecondary:$n?{x:$n.paddedRect.x+Fy+Ar,y:$n.paddedRect.y+Fy+ja,w:_n-Ar,h:Ca-ja}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Tr,pixelOffsetBR:ta,minFontScaleX:At/R/te,minFontScaleY:qt/R/se,isSDF:m}};if(v&&(P.stretchX||P.stretchY)){const Gt=I5e(ae,Fe,he),ds=I5e(de,Re,Se);for(let js=0;jsE)&&(E=he.x),(!de||he.y>P)&&(P=he.y)}const $=Math.min(E-v,P-C);let G=$/2;const te=new UC([],Fut);if($===0)return new pt(v,C);for(let de=v;dese.d||!se.d)&&(se=de,m&&console.log("found best %d after %d probes",Math.round(1e4*de.d)/1e4,ae)),de.max-se.d<=d||(G=de.h/2,te.push(new e5(de.p.x-G,de.p.y-G,G,x)),te.push(new e5(de.p.x+G,de.p.y-G,G,x)),te.push(new e5(de.p.x-G,de.p.y+G,G,x)),te.push(new e5(de.p.x+G,de.p.y+G,G,x)),ae+=4)}return m&&(console.log(`num probes: ${ae}`),console.log(`best distance: ${se.d}`)),se.p}function Fut(x,d){return d.max-x.max}class e5{constructor(d,m,v,C){this.p=new pt(d,m),this.h=v,this.d=function(E,P){let R=!1,$=1/0;for(let G=0;GE.y!=Se.y>E.y&&E.x<(Se.x-he.x)*(E.y-he.y)/(Se.y-he.y)+he.x&&(R=!R),$=Math.min($,Ho(E,he,Se))}}return(R?1:-1)*Math.sqrt($)}(this.p,C),this.max=this.d+this.h*Math.SQRT2}}const zut=Object.keys,Ype=Number.POSITIVE_INFINITY,But=Math.sqrt(2);function Nb(x,d,m,v,C){const E=Vpe(x)&&x.collisionPadding?x.collisionPadding:[0,0,0,0],P={top:x.top-E[1],bottom:x.bottom+E[3],left:x.left-E[0],right:x.right+E[2],scaled:!1};return v!==void 0&&function(R,$){R.top*=$,R.bottom*=$,R.left*=$,R.right*=$,R.scaled=!0}(P,v),m&&function(R,$){if(!$)return;const G=jr($),te=new pt(R.left,R.top),se=new pt(R.right,R.top),ae=new pt(R.left,R.bottom),de=new pt(R.right,R.bottom),he=new pt(0,0);te._rotateAround(G,he),se._rotateAround(G,he),ae._rotateAround(G,he),de._rotateAround(G,he),R.left=Math.min(te.x,se.x,ae.x,de.x),R.right=Math.max(te.x,se.x,ae.x,de.x),R.top=Math.min(te.y,se.y,ae.y,de.y),R.bottom=Math.max(te.y,se.y,ae.y,de.y)}(P,m),C&&(P.left+=C[0],P.right+=C[0],P.top+=C[1],P.bottom+=C[1]),d?{top:Math.min(d.top,P.top),bottom:Math.max(d.bottom,P.bottom),left:Math.min(d.left,P.left),right:Math.max(d.right,P.right),scaled:d.scaled||P.scaled}:P}function D5e(x,[d,m]){let v=0,C=0;if(m===Ype){d<0&&(d=0);const E=d/But;switch(x){case"top-right":case"top-left":C=E-7;break;case"bottom-right":case"bottom-left":C=7-E;break;case"bottom":C=7-d;break;case"top":C=d-7}switch(x){case"top-right":case"bottom-right":v=-E;break;case"top-left":case"bottom-left":v=E;break;case"left":v=d;break;case"right":v=-d}}else{switch(d=Math.abs(d),m=Math.abs(m),x){case"top-right":case"top-left":case"top":C=m-7;break;case"bottom-right":case"bottom-left":case"bottom":C=7-m}switch(x){case"top-right":case"bottom-right":case"right":v=-d;break;case"top-left":case"bottom-left":case"left":v=d}}return[v,C]}function $ut(x,d,m,v,C,E,P,R,$,G,te,se,ae,de){const he=x.layers[0],Se=he.appearances;if(Se.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Fe={iconBBox:null,iconVerticalBBox:null},Re={textBBox:null,textVerticalBBox:null},{baseIconRotate:Ke,baseTextRotate:Xe,iconScaleFactor:lt}=function(vt,At,zt){const qt=vt.get("icon-rotate").evaluate(At,{},zt),ss=vt.get("text-rotate").evaluate(At,{},zt),[Gt,ds]=vt.get("icon-size-scale-range");return{baseIconRotate:qt,baseTextRotate:ss,iconScaleFactor:je(1,Gt,ds)}}(v,C,E);d&&(Fe.iconBBox=Nb(d,Fe.iconBBox,Ke,P),m)&&(Fe.iconVerticalBBox=Nb(m,Fe.iconVerticalBBox,Ke+90,P));const kt=QF(se.horizontal);kt&&(Re.textBBox=Nb(kt,Re.textBBox,Xe,1,de)),se.vertical&&(Re.textVerticalBBox=Nb(se.vertical,Re.textVerticalBBox,Xe+90,1,de));for(const vt of Se)vt.hasIconProperties()&&qut(Fe,x,he,vt,C,E,R,Ke,P,$,d,G,lt,te),vt.hasTextProperties()&&Uut(Re,he,vt,C,E,de,Xe,ae,kt,se.vertical);return{iconBBox:Fe.iconBBox,iconVerticalBBox:Fe.iconVerticalBBox,textBBox:Re.textBBox,textVerticalBBox:Re.textVerticalBBox}}function qut(x,d,m,v,C,E,P,R,$,G,te,se,ae,de){const{appearanceIconOffset:he,appearanceIconRotate:Se,appearanceIconSize:Fe}=function(lt,kt,vt,At,zt,qt,ss,Gt){const ds=lt.hasProperty("icon-offset")?kt.getAppearanceValueAndResolveTokens(lt,"icon-offset",vt,At,[]):null,js=ds&&Array.isArray(ds)?ds:zt,Ns=lt.hasProperty("icon-rotate")?kt.getAppearanceValueAndResolveTokens(lt,"icon-rotate",vt,At,[]):null,Fs=typeof Ns=="number"?Ns:qt,Bs=lt.hasProperty("icon-size")?kt.getAppearanceValueAndResolveTokens(lt,"icon-size",vt,At,[]):null;return{appearanceIconOffset:js,appearanceIconRotate:Fs,appearanceIconSize:typeof Bs=="number"?Bs*Gt.iconScaleFactor:ss}}(v,m,C,E,P,R,$,G);let Re=null,Ke=null,Xe=null;v.hasProperty("icon-image")?Xe=function(lt,kt,vt,At,zt,qt,ss){let Gt=null;const ds=kt.getAppearanceValueAndResolveTokens(vt,"icon-image",At,zt,[]);if(ds){const js=lt.getResolvedImageFromTokens(ds),Ns=vt.getUnevaluatedProperty("icon-size"),Fs=cP(js,X3(lt.zoom,Ns,lt.worldview),Ns,zt,lt.zoom,At,lt.pixelRatio,ss,lt.worldview);Gt=qt.get(Fs.iconPrimary.toString())}return Gt}(d,m,v,C,E,se,ae):te&&(Xe=te.imagePrimary),Xe&&(Re=GF(Xe,null,he,de),d.allowVerticalPlacement&&(Ke=GF(Xe,null,he,de))),Re&&(x.iconBBox=Nb(Re,x.iconBBox,Se,Fe)),Ke&&(x.iconVerticalBBox=Nb(Ke,x.iconVerticalBBox,Se+90,Fe))}function Uut(x,d,m,v,C,E,P,R,$,G){const{appearanceTextOffset:te,appearanceTextRotate:se,appearanceTextSize:ae}=function(he,Se,Fe,Re,Ke,Xe,lt){const kt=he.hasProperty("text-offset")?Se.getAppearanceValueAndResolveTokens(he,"text-offset",Fe,Re,[]):null,vt=kt&&Array.isArray(kt)?[kt[0]*Ac,kt[1]*Ac]:Ke,At=he.hasProperty("text-rotate")?Se.getAppearanceValueAndResolveTokens(he,"text-rotate",Fe,Re,[]):null,zt=typeof At=="number"?At:Xe,qt=he.hasProperty("text-size")?Se.getAppearanceValueAndResolveTokens(he,"text-size",Fe,Re,[]):null;return{appearanceTextOffset:vt,appearanceTextRotate:zt,appearanceTextSize:typeof qt=="number"?qt:lt}}(m,d,v,C,E,P,R),de=ae/R;$&&(x.textBBox=Nb($,x.textBBox,se,de,te)),G&&(x.textVerticalBBox=Nb(G,x.textVerticalBBox,se+90,de,te))}function XF(x,d,m,v,C,E,P,R,$){if(!d||!d.usvg)return;const G=w5e(v),te=w5e(C),se=E!=="both"&&E!=="width"||!b5e(v)?1:te.width/G.width,ae=E!=="both"&&E!=="height"||!_5e(v)?1:te.height/G.height;m.scaleSelf(se,ae);const de=m.toString();P.set(de,m),R.set(de,d);const{imagePosition:he}=Gpe(de,d,E2);$.set(de,he)}function O5e(x,d,m,v,C,E,P,R,$){if(!x)return;const G=function(te,se,ae,de,he,Se){if(te.kind==="camera")return te.maxSize;if(te.kind==="composite"){const Fe=se.possiblyEvaluate(new Ki(te.maxZoom,{worldview:Se}),ae).evaluate(he,{},ae),Re=se.possiblyEvaluate(new Ki(te.minZoom,{worldview:Se}),ae).evaluate(he,{},ae);return Math.max(Fe,Re)}return se.possiblyEvaluate(new Ki(de,{worldview:Se})).evaluate(he,{},ae)}(d,m,v,C,E,$);return x.scaleSelf(G*R*P)}function cP(x,d,m,v,C,E,P,R,$){return{iconPrimary:O5e(x.getPrimary(),d,m,v,C,E,P,R,$),iconSecondary:O5e(x.getSecondary(),d,m,v,C,E,P,R,$)}}function Vut(x,d,m){if(!d)return;const v=m.get(x.toString()),C=m.get(d.toString());v&&C&&(v.paddedRect.w===C.paddedRect.w&&v.paddedRect.h===C.paddedRect.h||xr(`Mismatch in icon variant sizes: ${x.toString()} and ${d.toString()}`),v.usvg!==C.usvg&&xr(`Mismatch in icon variant image types: ${x.id} and ${d.id}`))}function R5e(x,d,m,v){if(!x)return;const C=d.get(m.toString());if(x.imagePrimary=C,v){const E=d.get(v.toString());x.imageSecondary=E}}function Hut(x,d){for(const m in x.horizontal)F5e(x.horizontal[m],d);F5e(x.vertical,d)}function F5e(x,d){if(x){for(const m of x.positionedLines)for(const v of m.positionedGlyphs)if(v.image!==null){const C=v.image.toString();v.rect=d.get(C).paddedRect}}}function Xpe(x){switch(x){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Wut(x,d,m,v,C,E,P,R,$){const G=QF(E.horizontal)||E.vertical,te=m.get("icon-text-fit-padding").evaluate(v,{},C);let se,ae=d;return d&&$!=="none"&&(x.allowVerticalPlacement&&E.vertical&&(se=Hpe(d,E.vertical,$,te,R,P)),G&&(ae=Hpe(d,G,$,te,R,P))),{defaultShapedIcon:ae,verticallyShapedIcon:se}}function Gut(x,d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke,Xe,lt,kt,vt,At){let zt=P.textMaxSize.evaluate(d,{},ae);zt===void 0?zt=R*P.textScaleFactor:zt*=P.textScaleFactor;const qt=x.layers[0].layout,ss=Ac,Gt=R*P.textScaleFactor/ss,ds=QF(m.horizontal)||m.vertical;if(Fe!=="none"&&x.appearanceFeatureData&&d.index18&&Rs>2&&(Rs>>=1),Math.max(tr/(512*Rs),1)*qt.get("symbol-spacing")),Bs=qt.get("text-padding")*x.tilePixelRatio,Ls=qt.get("icon-padding")*x.tilePixelRatio,Os=jr(qt.get("text-max-angle")),ls=qt.get("icon-rotation-alignment")==="map"&&Xe!=="point",rs=Fs/2;var Rs;x.hasAnyIconTextFit===!1&&Fe!=="none"&&(x.hasAnyIconTextFit=!0);const sr=d.properties?+d.properties[as]:null,Vs=sr&&x.elevationFeatureIdToIndex?x.elevationFeatureIdToIndex.get(sr):65535,zr=(mr,_r,Tr)=>{if(_r.x<0||_r.x>=tr||_r.y<0||_r.y>=tr)return;let ta=null;if(js){const{x:Ks,y:Ar,z:_n}=de.projectTilePoint(_r.x,_r.y,Tr);ta={anchor:new gv(Ks,Ar,_n,0,void 0),up:de.upVector(Tr,_r.x,_r.y)}}(function(Ks,Ar,_n,ja,Ca,$n,Ai,_t,Ct,us,zs,or,lr,Br,Vr,In,Kn,Qn,xa,an,vn,Va,Za,Ya,_i,Ri,Ei,ri,hi,Zn,Sa,mo,sn){const ga=Ks.addToLineVertexArray(Ar,ja);let Li,Ui,Zi,el,Hi,rn,jo,wi=0,ao=0,Ul=0,Ec=0,wl=-1,jl=-1;const uc={};let ph=K1("");const Wi=_n?_n.anchor:Ar,Wo=ri!=="none";let tl=0,Oh=0;if(Ct._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Td=Ct.layout.get("text-offset").evaluate(vn,{},_i);tl=Td[0]*Ac,Oh=Td[1]*Ac}else tl=Ct.layout.get("text-radial-offset").evaluate(vn,{},_i)*Ac,Oh=Ype;if(Ks.allowVerticalPlacement&&Ca.vertical){const Td=Ca.vertical;if(Vr)rn=Qpe(Td),_t&&(jo=Qpe(_t));else{const $u=Ct.layout.get("text-rotate").evaluate(vn,{},_i)+90;Zi=JF(us,Wi,Ar,zs,or,lr,Td,Br,$u,In,mo),_t&&(el=JF(us,Wi,Ar,zs,or,lr,_t,Qn,$u,null,Sa))}}if($n){const Td=Ks.iconSizeData,$u=Ct.layout.get("icon-rotate").evaluate(vn,{},_i),fm=Zpe($n,$u,Za,Wo,Va.iconScaleFactor),Cb=_t?Zpe(_t,$u,Za,Wo,Va.iconScaleFactor):void 0;Ui=JF(us,Wi,Ar,zs,or,lr,$n,Qn,$u,null,Zn);const o5=function(_g,CP,rTe,amt,nTe,aTe,imt,omt){const iTe=_g.layers[0],oTe=iTe.appearances;let l5=CP.length;if(rTe&&(l5=Math.max(l5,rTe.length)),oTe.length===0)return l5;const[lmt,cmt]=amt.get("icon-size-scale-range"),dmt=je(1,lmt,cmt);for(const lTe of oTe){const cTe=lTe.getUnevaluatedProperties();if(cTe._values["icon-image"].value!==void 0){const dTe=iTe.getAppearanceValueAndResolveTokens(lTe,"icon-image",nTe,aTe,[]);if(dTe){const uTe=_g.getResolvedImageFromTokens(dTe);if(uTe){const hTe=cTe._values["icon-size"],umt=cP(uTe,X3(_g.zoom,hTe,_g.worldview),hTe,aTe,_g.zoom,nTe,_g.pixelRatio,dmt,_g.worldview),hmt=imt.get(umt.iconPrimary.toString());l5=Math.max(l5,Dut(hmt,omt))}}}}return l5}(Ks,fm,Cb,Ct.layout,vn,_i,Ks.iconAtlasPositions,Wo);wi=4*o5;let bg=null;Td.kind==="source"?(bg=[xg*Ct.layout.get("icon-size").evaluate(vn,{},_i)*Va.iconScaleFactor],bg[0]>yv&&xr(`${Ks.layerIds[0]}: Value for "icon-size" is >= ${dP}. Reduce your "icon-size".`)):Td.kind==="composite"&&(bg=[xg*Va.compositeIconSizes[0].evaluate(vn,{},_i)*Va.iconScaleFactor,xg*Va.compositeIconSizes[1].evaluate(vn,{},_i)*Va.iconScaleFactor],(bg[0]>yv||bg[1]>yv)&&xr(`${Ks.layerIds[0]}: Value for "icon-size" is >= ${dP}. Reduce your "icon-size".`)),Ks.addSymbols(Ks.icon,fm,bg,an,xa,vn,void 0,_n,Ar,ga.lineStartIndex,ga.lineLength,-1,Ya,_i,Ri,Ei,Ks.symbolInstances.length,o5),wl=Ks.icon.placedSymbolArray.length-1,Cb&&(ao=4*o5,Ks.addSymbols(Ks.icon,Cb,bg,an,xa,vn,pm.vertical,_n,Ar,ga.lineStartIndex,ga.lineLength,-1,Ya,_i,Ri,Ei,Ks.symbolInstances.length,o5),jl=Ks.icon.placedSymbolArray.length-1)}for(const Td in Ca.horizontal){const $u=Td,fm=Ca.horizontal[$u];Li||(ph=K1(fm.text),Vr?Hi=Qpe(fm):Li=JF(us,Wi,Ar,zs,or,lr,fm,Br,Ct.layout.get("text-rotate").evaluate(vn,{},_i),In,mo));const Cb=fm.positionedLines.length===1;if(Ul+=z5e(Ks,_n,Ar,fm,Ai,Ct,Vr,vn,In,ga,Ca.vertical?pm.horizontal:pm.horizontalOnly,Cb?zut(Ca.horizontal):[$u],uc,wl,Va,Ya,_i,Ks.symbolInstances.length,Ri),Cb)break}Ca.vertical&&(Ec+=z5e(Ks,_n,Ar,Ca.vertical,Ai,Ct,Vr,vn,In,ga,pm.vertical,["vertical"],uc,jl,Va,Ya,_i,Ks.symbolInstances.length,Ri));let Vl=-1;const Zf=(Td,$u)=>Td?Math.max(Td,$u):$u;Vl=Zf(Hi,Vl),Vl=Zf(rn,Vl),Vl=Zf(jo,Vl);const zy=Vl>-1?1:0;Ks.glyphOffsetArray.length>=65535&&xr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),vn.sortKey!==void 0&&Ks.addToSortKeyRanges(Ks.symbolInstances.length,vn.sortKey),Ks.symbolInstances.emplaceBack(Ar.x,Ar.y,Wi.x,Wi.y,Wi.z,uc.right>=0?uc.right:-1,uc.center>=0?uc.center:-1,uc.left>=0?uc.left:-1,uc.vertical>=0?uc.vertical:-1,wl,jl,ph,Li!==void 0?Li:Ks.collisionBoxArray.length,Li!==void 0?Li+1:Ks.collisionBoxArray.length,Zi!==void 0?Zi:Ks.collisionBoxArray.length,Zi!==void 0?Zi+1:Ks.collisionBoxArray.length,Ui!==void 0?Ui:Ks.collisionBoxArray.length,Ui!==void 0?Ui+1:Ks.collisionBoxArray.length,el||Ks.collisionBoxArray.length,el?el+1:Ks.collisionBoxArray.length,zs,Ul,Ec,wi,ao,zy,0,tl,Oh,Vl,0,Wo?1:0,hi)})(x,_r,ta,mr,m,v,E,C,x.layers[0],x.collisionBoxArray,d.index,d.sourceLayerIndex,x.index,Bs,Ke,G,0,Ls,ls,Re,d,P,te,se,ae,he,Se,Fe,Vs,lt,kt,vt)};if(Xe==="line")for(const mr of LF(d.geometry,0,0,tr,tr)){const _r=Lut(mr,Fs,Os,m.vertical||ds,v,ss,Ns,x.overscaling,tr);for(const Tr of _r)ds&&Kut(x,ds.text,rs,Tr)||zr(mr,Tr,ae)}else if(Xe==="line-center"){for(const mr of d.geometry)if(mr.length>1){const _r=Iut(mr,Os,m.vertical||ds,v,ss,Ns);_r&&zr(mr,_r,ae)}}else if(d.type==="Polygon")for(const mr of W6(d.geometry,0)){const _r=Rut(mr,16);zr(mr[0],new gv(_r.x,_r.y,0,0,void 0),ae)}else if(d.type==="LineString")for(const mr of d.geometry)zr(mr,new gv(mr[0].x,mr[0].y,0,0,void 0),ae);else if(d.type==="Point")for(const mr of d.geometry)for(const _r of mr)zr([_r],new gv(_r.x,_r.y,0,0,void 0),ae)}const dP=255,yv=dP*xg;function z5e(x,d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke){const Xe=function(vt,At,zt,qt,ss,Gt,ds,js){const Ns=[];if(At.positionedLines.length===0)return Ns;const Fs=qt.layout.get("text-rotate").evaluate(Gt,{})*Math.PI/180,Bs=function(Rs){const sr=Rs[0],Vs=Rs[1],zr=sr*Vs;return zr>0?[sr,-Vs]:zr<0?[-sr,Vs]:sr===0?[Vs,sr]:[Vs,-sr]}(zt);let Ls=Math.abs(At.top-At.bottom);for(const Rs of At.positionedLines)Ls-=Rs.lineOffset;const Os=At.positionedLines.length,ls=Ls/Os;let rs=At.top-zt[1];for(let Rs=0;Rsyv&&xr(`${x.layerIds[0]}: Value for "text-size" is >= ${dP}. Reduce your "text-size".`)):lt.kind==="composite"&&(kt=[xg*he.compositeTextSizes[0].evaluate(R,{},Fe)*he.textScaleFactor,xg*he.compositeTextSizes[1].evaluate(R,{},Fe)*he.textScaleFactor],(kt[0]>yv||kt[1]>yv)&&xr(`${x.layerIds[0]}: Value for "text-size" is >= ${dP}. Reduce your "text-size".`)),x.addSymbols(x.text,Xe,kt,$,P,R,te,d,m,G.lineStartIndex,G.lineLength,de,Se,Fe,Ke,!1,Re,Xe.length);for(const vt of se)ae[vt]=x.text.placedSymbolArray.length-1;return 4*Xe.length}function QF(x){for(const d in x)return x[d];return null}function JF(x,d,m,v,C,E,P,R,$,G,te){let se,ae,de,he;if(se=te?te.top:P.top,ae=te?te.bottom:P.bottom,de=te?te.left:P.left,he=te?te.right:P.right,Vpe(P)&&P.collisionPadding){const Se=P.collisionPadding;de-=Se[0],se-=Se[1],he+=Se[2],ae+=Se[3]}if($){const Se=new pt(de,se),Fe=new pt(he,se),Re=new pt(de,ae),Ke=new pt(he,ae),Xe=jr($);let lt=new pt(0,0);G&&(lt=new pt(G[0],G[1])),Se._rotateAround(Xe,lt),Fe._rotateAround(Xe,lt),Re._rotateAround(Xe,lt),Ke._rotateAround(Xe,lt),de=Math.min(Se.x,Fe.x,Re.x,Ke.x),he=Math.max(Se.x,Fe.x,Re.x,Ke.x),se=Math.min(Se.y,Fe.y,Re.y,Ke.y),ae=Math.max(Se.y,Fe.y,Re.y,Ke.y)}return x.emplaceBack(d.x,d.y,d.z,m.x,m.y,de,se,he,ae,R,v,C,E),x.length-1}function Qpe(x){Vpe(x)&&x.collisionPadding&&(x.top-=x.collisionPadding[1],x.bottom+=x.collisionPadding[3]);const d=x.bottom-x.top;return d>0?Math.max(10,d):null}function Kut(x,d,m,v){const C=x.compareText;if(d in C){const E=C[d];for(let P=E.length-1;P>=0;P--)if(v.dist(E[P])Xe&&(lt(vt,Ns,zt,qt,ds,js),lt(Ns,At,ds,js,ss,Gt))}lt(se,ae,v,E,C,E),lt(ae,de,C,E,C,P),lt(de,he,C,P,v,P),lt(he,se,v,P,v,E),Se-=Xe,Fe-=Xe,Re+=Xe,Ke+=Xe;const kt=1/Math.max(Re-Se,Ke-Fe);return{scale:kt,x:Se*kt,y:Fe*kt,x2:Re*kt,y2:Ke*kt,projection:d}}function $5e(x,{x:d,y:m},v=0){return new pt(((d-v)*x.scale-x.x)*tr,(m*x.scale-x.y)*tr)}const Zut=w(new Float32Array(16));class kb{constructor(d){this.spec=d,this.name=d.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(d,m){return{x:0,y:0,z:0}}unproject(d,m){return new y(0,0)}projectTilePoint(d,m,v){return{x:d,y:m,z:0}}locationPoint(d,m,v,C=!0){return d._coordinatePoint(d.locationCoordinate(m,v),C)}pixelsPerMeter(d,m){return ne(1,d)*m}pixelSpaceConversion(d,m,v){return 1}farthestPixelDistance(d){return B5e(d,d.pixelsPerMeter)}pointCoordinate(d,m,v,C){const E=d.horizonLineFromTop(!1),P=new pt(m,Math.max(E,v));return d.rayIntersectionCoordinate(d.pointRayIntersection(P,C))}pointCoordinate3D(d,m,v){const C=new pt(m,v);if(d.elevation)return d.elevation.pointCoordinate(C);{const E=this.pointCoordinate(d,C.x,C.y,0);return[E.x,E.y,E.z]}}isPointAboveHorizon(d,m){if(d.elevation&&d.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(d,m.x,m.y);const v=d.horizonLineFromTop();return m.y0?m<-t5+v&&(m=-t5+v):m>t5-v&&(m=t5-v);const P=E/Math.pow(t7(m),C);let R=P*Math.sin(C*d),$=E-P*Math.cos(C*d);return R=.5*(R/Math.PI+.5),$=.5*($/Math.PI+.5),{x:R,y:this.southernCenter?$:1-$,z:0}}unproject(d,m){d=(2*d-.5)*Math.PI,this.southernCenter&&(m=1-m),m=(2*(1-m)-.5)*Math.PI;const{n:v,f:C}=this,E=C-m,P=Math.sign(E),R=Math.sign(v)*Math.sqrt(d*d+E*E);let $=Math.atan2(d,Math.abs(E))*P;E*v<0&&($-=Math.PI*Math.sign(d)*P);const G=je(ea($/v)+this.center[0],-180,180),te=je(ea(2*Math.atan(Math.pow(C/R,1/v))-t5),-we,we);return new y(G,this.southernCenter?-te:te)}}class q5e extends kb{constructor(d){super(d),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(d,m){return{x:W(d),y:J(m),z:0}}unproject(d,m){const v=le(d),C=_e(m);return new y(v,C)}}const U5e=jr(we);class eht extends kb{project(d,m){const v=(m=jr(m))*m,C=v*v;return{x:.5*((d=jr(d))*(.8707-.131979*v+C*(C*(.003971*v-.001529*C)-.013791))/Math.PI+.5),y:1-.5*(m*(1.007226+v*(.015085+C*(.028874*v-.044475-.005916*C)))/Math.PI+1),z:0}}unproject(d,m){d=(2*d-.5)*Math.PI;let v=m=(2*(1-m)-1)*Math.PI,C=25,E=0,P=v*v;do{P=v*v;const G=P*P;E=(v*(1.007226+P*(.015085+G*(.028874*P-.044475-.005916*G)))-m)/(1.007226+P*(.045255+G*(.259866*P-.311325-.005916*11*G))),v=je(v-E,-U5e,U5e)}while(Math.abs(E)>1e-6&&--C>0);P=v*v;const R=je(ea(d/(.8707+P*(P*(P*P*P*(.003971-.001529*P)-.013791)-.131979))),-180,180),$=ea(v);return new y(R,$)}}const V5e=jr(we);class tht extends kb{project(d,m){m=jr(m),d=jr(d);const v=Math.cos(m),C=2/Math.PI,E=Math.acos(v*Math.cos(d/2)),P=Math.sin(E)/E,R=.5*(d*C+2*v*Math.sin(d/2)/P)||0,$=.5*(m+Math.sin(m)/P)||0;return{x:.5*(R/Math.PI+.5),y:1-.5*($/Math.PI+1),z:0}}unproject(d,m){let v=d=(2*d-.5)*Math.PI,C=m=(2*(1-m)-1)*Math.PI,E=25;const P=1e-6;let R=0,$=0;do{const G=Math.cos(C),te=Math.sin(C),se=2*te*G,ae=te*te,de=G*G,he=Math.cos(v/2),Se=Math.sin(v/2),Fe=2*he*Se,Re=Se*Se,Ke=1-de*he*he,Xe=Ke?1/Ke:0,lt=Ke?Math.acos(G*he)*Math.sqrt(1/Ke):0,kt=.5*(2*lt*G*Se+2*v/Math.PI)-d,vt=.5*(lt*te+C)-m,At=.5*Xe*(de*Re+lt*G*he*ae)+1/Math.PI,zt=Xe*(Fe*se/4-lt*te*Se),qt=.125*Xe*(se*Se-lt*te*de*Fe),ss=.5*Xe*(ae*he+lt*Re*G)+.5,Gt=zt*qt-ss*At;R=(vt*zt-kt*ss)/Gt,$=(kt*qt-vt*At)/Gt,v=je(v-R,-Math.PI,Math.PI),C=je(C-$,-V5e,V5e)}while((Math.abs(R)>P||Math.abs($)>P)&&--E>0);return new y(ea(v),ea(C))}}class H5e extends kb{constructor(d){super(d),this.center=d.center||[0,0],this.parallels=d.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(jr(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(d,m){const{scale:v,cosPhi:C}=this;return{x:jr(d)*C*v+.5,y:-Math.sin(jr(m))/C*v+.5,z:0}}unproject(d,m){const{scale:v,cosPhi:C}=this,E=-(m-.5)/v,P=je(ea((d-.5)/v)/C,-180,180),R=Math.asin(je(E*C,-1,1)),$=je(ea(R),-we,we);return new y(P,$)}}class sht extends q5e{constructor(d){super(d),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(d,m,v){const C=B6(d,m,v);return ft(C,C,kF(Vp(v))),{x:C[0],y:C[1],z:C[2]}}locationPoint(d,m,v){const C=yb(m.lat,m.lng),E=ke([],C),P=v?d._centerAltitude+v:d.elevation?d.elevation.getAtPointOrZero(d.locationCoordinate(m),d._centerAltitude):d._centerAltitude;Me(C,C,E,ne(1,0)*tr*P);const R=w(new Float64Array(16));return S(R,d.pixelMatrix,d.globeMatrix),ft(C,C,R),new pt(C[0],C[1])}pixelsPerMeter(d,m){return ne(1,0)*m}pixelSpaceConversion(d,m,v){const C=ne(1,d)*m,E=Zr(ne(1,45)*m,C,v);return this.pixelsPerMeter(d,m)/E}createTileMatrix(d,m,v){const C=rpe(Vp(v.canonical));return S(new Float64Array(16),d.globeMatrix,C)}createInversionMatrix(d,m){const{center:v}=d,C=kF(Vp(m));return O(C,C,jr(v.lng)),I(C,C,jr(v.lat)),L(C,C,[d._pixelsPerMercatorPixel,d._pixelsPerMercatorPixel,1]),Float32Array.from(C)}pointCoordinate(d,m,v,C){return bb(d,m,v,!0)||new st(0,0)}pointCoordinate3D(d,m,v){const C=this.pointCoordinate(d,m,v,0);return[C.x,C.y,C.z]}isPointAboveHorizon(d,m){return!bb(d,m.x,m.y,!1)}farthestPixelDistance(d){const m=function(C,E){const P=C.cameraToCenterDistance,R=C._centerAltitude*E,$=C._camera,G=C._camera.forward(),te=ce([],be([],G,-P),[0,0,R]),se=C.worldSize/(2*Math.PI),ae=[0,0,-se],de=C.width/C.height,he=Math.tan(C.fovAboveCenter),Se=be([],$.up(),he),Fe=be([],$.right(),he*de),Re=ke([],ce([],ce([],G,Se),Fe)),Ke=[];let Xe;if(new Cr(te,Re).closestPointOnSphere(ae,se,Ke)){const lt=ce([],Ke,ae),kt=Ce([],lt,te);Xe=Math.cos(C.fovAboveCenter)*ie(kt)}else{const lt=Ce([],te,ae),kt=Ce([],ae,te);ke(kt,kt);const vt=ie(lt)-se;Xe=Math.sqrt(vt*(vt+2*se));const At=Math.acos(Xe/(se+vt))-Math.acos(Be(G,kt));Xe*=Math.cos(At)}return 1.01*Xe}(d,this.pixelsPerMeter(d.center.lat,d.worldSize)),v=_b(d.zoom);if(v>0){const C=B5e(d,ne(1,d.center.lat)*d.worldSize),E=d.worldSize/(2*Math.PI),P=Math.max(d.width,d.height)/d.worldSize*Math.PI;return Zr(m,C+E*(1-Math.cos(P)),Math.pow(v,10))}return m}upVector(d,m,v){return B6(m,v,d,1)}upVectorScale(d){return{metersToTile:Gf(NF(Vp(d)))}}}function W5e(x){const d=x.parallels,m=!!d&&Math.abs(d[0]+d[1])<.01;switch(x.name){case"mercator":return new q5e(x);case"equirectangular":return new Qut(x);case"naturalEarth":return new eht(x);case"equalEarth":return new Xut(x);case"winkelTripel":return new tht(x);case"albers":return m?new H5e(x):new Yut(x);case"lambertConformalConic":return m?new H5e(x):new Jut(x);case"globe":return new sht(x)}throw new Error(`Invalid projection name: ${x.name}`)}const rht=Ht.types,nht=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function xP(x,d,m,v,C,E,P,R,$,G,te,se,ae){const de=R?Math.min(yv,Math.round(R[0])):0,he=R?Math.min(yv,Math.round(R[1])):0;x.emplaceBack(d,m,Math.round(32*v),Math.round(32*C),E,P,(de<<1)+($?1:0),0+(he<<1),16*G,16*te,256*se,256*ae)}function gP(x,d,m){x.emplaceBack(d,m)}function yP(x,d,m,v,C,E,P){x.emplaceBack(d,m,v,C,E,P)}const s7=(x,d,m,v)=>{for(let C=0;C0&&(this.iconTransitioningVertexBuffer=d.createVertexBuffer(this.iconTransitioningVertexArray,hut.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=d.createVertexBuffer(this.globeExtVertexArray,lut.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||E)&&(this.zOffsetVertexBuffer=d.createVertexBuffer(this.zOffsetVertexArray,dut.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=d.createVertexBuffer(this.orientationVertexArray,uut.members,!0)),this.opacityVertexBuffer.itemSize=1),(v||C)&&this.programConfigurations.upload(d))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy())}}kr(Jpe,"SymbolBuffers");class efe{constructor(d,m,v){this.layoutVertexArray=new d,this.layoutAttributes=m,this.indexArray=new v,this.segments=new bo,this.collisionVertexArray=new k6,this.collisionVertexArrayExt=new Iy}upload(d){this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=d.createVertexBuffer(this.collisionVertexArray,mut.members,!0),this.collisionVertexBufferExt=d.createVertexBuffer(this.collisionVertexArrayExt,put.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}kr(efe,"CollisionBuffers");class r7{constructor(d){this.collisionBoxArray=d.collisionBoxArray,this.zoom=d.zoom,this.overscaling=d.overscaling,this.layers=d.layers,this.layerIds=this.layers.map(P=>P.fqid),this.index=d.index,this.pixelRatio=d.pixelRatio,this.sourceLayerIndex=d.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=w([]),this.placementViewportMatrix=w([]);const m=this.layers[0]._unevaluatedLayout._values;this.worldview=d.worldview,this.localizable=d.localizable,this.textSizeData=X3(this.zoom,m["text-size"],this.worldview),this.iconSizeData=X3(this.zoom,m["icon-size"],this.worldview);const v=this.layers[0].layout,C=v.get("symbol-sort-key"),E=v.get("symbol-z-order");this.lut=d.lut,this.canOverlap=v.get("text-allow-overlap")||v.get("icon-allow-overlap")||v.get("text-ignore-placement")||v.get("icon-ignore-placement"),this.sortFeaturesByKey=E!=="viewport-y"&&C.constantOr(1)!==void 0,this.sortFeaturesByY=(E==="viewport-y"||E==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=v.get("text-writing-mode").map(P=>pm[P]),this.stateDependentLayerIds=this.layers.filter(P=>P.isStateDependent()).map(P=>P.id),this.sourceID=d.sourceID,this.projection=d.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.lastActiveApperance=null,this.featureToAppearanceIndex={}}hasAnyAppearanceProperty(d){const m=this.layers[0].getAppearances();return!(!m||m.length===0)&&m.some(v=>v.getProperty(d)!=null)}createArrays(){this.text=new Jpe(new qp(this.layers,{zoom:this.zoom,lut:this.lut},d=>d.startsWith("text")||d.startsWith("symbol"))),this.icon=new Jpe(new qp(this.layers,{zoom:this.zoom,lut:this.lut},d=>d.startsWith("icon")||d.startsWith("symbol"))),this.glyphOffsetArray=new I3,this.lineVertexArray=new vF,this.symbolInstances=new P6}calculateGlyphDependencies(d,m,v,C,E){for(const P of d){const R=P.codePointAt(0);if(R===void 0)break;if(m[R]=!0,C&&E&&R<=65535){const $=aP[P];$&&(m[$.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(d,m,v,C,E,P){let R=1;const $=d.getUnevaluatedProperties()._values["icon-size"],G=X3(this.zoom,$,this.worldview),te=Q3(G,m);if(G.kind!=="constant"&&G.kind!=="camera"||(R=te.uSize),G.kind==="composite"){const{minZoom:se,maxZoom:ae}=G,de=$.possiblyEvaluate(new Ki(se,{worldview:this.worldview}),C),he=$.possiblyEvaluate(new Ki(ae,{worldview:this.worldview}),C),Se=de.evaluate(v,{},C,E);R=Se+(he.evaluate(v,{},C,E)-Se)*te.uSizeT}return G.kind==="source"&&(R=$.possiblyEvaluate(new Ki(this.zoom,{worldview:this.worldview}),C).evaluate(v,{},C,E)),R*P}updateFootprints(d,m){}updateReplacement(d,m){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const v=m.getReplacementRegionsForTile(d.toUnwrapped(),!0);return!EF(this.activeReplacements,v)&&(this.activeReplacements=v,!0)}getResolvedImageFromTokens(d){return typeof d=="string"?Ou.build(d):d}populate(d,m,v,C){const E=this.layers[0],P=E.layout,R=this.projection.name==="globe",$=P.get("text-font"),G=P.get("text-field"),te=P.get("icon-image"),[se,ae]=P.get("icon-size-scale-range"),de=je(m.scaleFactor||1,se,ae),he=(G.value.kind!=="constant"||G.value.value instanceof Du&&!G.value.value.isEmpty()||G.value.value.toString().length>0)&&($.value.kind!=="constant"||$.value.value.length>0),Se=te.value.kind!=="constant"||!!te.value.value||Object.keys(te.parameters).length>0,Fe=this.hasAnyAppearanceProperty("icon-image"),Re=P.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!he&&!Se&&!Fe)return;const Ke=m.iconDependencies,Xe=m.glyphDependencies,lt=m.availableImages,kt=new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),vt=At=>{const zt=At.id.toString();Ke.has(zt)?Ke.get(zt).push(At):Ke.set(zt,[At])};for(const At of d){const{feature:zt,id:qt,index:ss,sourceLayerIndex:Gt}=At,ds=E._featureFilter.needGeometry,js=Wt(zt,ds);if(!E._featureFilter.filter(kt,js,v))continue;if(ds||(js.geometry=Ot(zt,v,C)),R&&zt.type!==1&&v.z<=5){const Rs=js.geometry,sr=.98078528056,Vs=(zr,mr)=>Be(B6(zr.x,zr.y,v,1),B6(mr.x,mr.y,v,1)){if(!Rs.getProperty("icon-image"))return;const sr=this.getCombinedIconPrimary(Rs,Bs,js,v,lt,ls,de);sr&&vt(sr)}),Ns){const Rs=$.evaluate(js,{},v).join(","),sr=P.get("text-rotation-alignment")==="map"&&P.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(pm.vertical)>=0;for(const Vs of Ns.sections)if(Vs.image){const zr=Vs.image.getPrimary().scaleSelf(this.pixelRatio),mr=zr.id.toString(),_r=Ke.get(mr)||[];_r.push(zr),Ke.set(mr,_r)}else{const zr=h2(Ns.toString()),mr=Vs.fontStack||Rs,_r=Xe[mr]=Xe[mr]||{};this.calculateGlyphDependencies(Vs.text,_r,sr,this.allowVerticalPlacement,zr)}}}if(P.get("symbol-placement")==="line"&&(this.features=function(At){const zt={},qt={},ss=[];let Gt=0;function ds(Bs){ss.push(At[Bs]),Gt++}function js(Bs,Ls,Os){const ls=qt[Bs];return delete qt[Bs],qt[Ls]=ls,ss[ls].geometry[0].pop(),ss[ls].geometry[0]=ss[ls].geometry[0].concat(Os[0]),ls}function Ns(Bs,Ls,Os){const ls=zt[Ls];return delete zt[Ls],zt[Bs]=ls,ss[ls].geometry[0].shift(),ss[ls].geometry[0]=Os[0].concat(ss[ls].geometry[0]),ls}function Fs(Bs,Ls,Os){const ls=Os?Ls[0][Ls[0].length-1]:Ls[0][0];return`${Bs}:${ls.x}:${ls.y}`}for(let Bs=0;BsBs.geometry)}(this.features)),P.get("symbol-elevation-reference")==="hd-road-markup"){if(this.elevationType="road",m.elevationFeatures){!this.elevationFeatures&&m.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const At of m.elevationFeatures)this.elevationFeatureIdToIndex.set(At.id,this.elevationFeatures.length),this.elevationFeatures.push(At)}}else P.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((At,zt)=>At.sortKey-zt.sortKey)}getCombinedIconPrimary(d,m,v,C,E,P,R){let $,G;const te=d.getUnevaluatedProperties();if(te._values["icon-image"].value!==void 0){const se=m.getAppearanceValueAndResolveTokens(d,"icon-image",v,C,E);$=this.getResolvedImageFromTokens(se)}else{const se=m.getValueAndResolveTokens("icon-image",v,C,E);$=this.getResolvedImageFromTokens(se)}if($){const se=te._values["icon-size"]||m._unevaluatedLayout._values["icon-size"];G=cP($,X3(this.zoom,se,this.worldview),se,C,this.zoom,P,this.pixelRatio,R,this.worldview).iconPrimary}return G}updateAppearanceBasedIconTextures(d,m,v,C){if(!this.appearanceFeatureData||!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)return!1;const E=this.layers[0];let P=!1,R=0;const $=E.layout,[G,te]=$.get("icon-size-scale-range"),se=je(1,G,te);for(let ae=0;ae=0){const Fe=Se.id,Re=m&&Fe!==void 0?m[String(Fe)]:void 0,Ke={type:"Point",id:Se.id,properties:Se.properties,geometry:[]},Xe=this.layers[0].appearances&&this.layers[0].appearances.find(lt=>lt.isActive({globals:C,feature:Ke,canonical:d,featureState:Re}));if(Se.activeAppearance===Xe){R+=de.numIconVertices;continue}if(Xe){Se.activeAppearance=Xe;const lt=this.getCombinedIconPrimary(Xe,E,Ke,d,v,{sortKey:void 0,text:void 0,icon:null,index:de.featureIndex,sourceLayerIndex:de.featureIndex,geometry:[],properties:Se.properties,type:"Point",id:Se.id},se);if(!lt)continue;const kt=lt.toString(),vt=this.iconAtlasPositions&&this.iconAtlasPositions.get(kt);if(vt){const At=E.getAppearanceValueAndResolveTokens(Xe,"icon-offset",Ke,d,v),zt=At&&Array.isArray(At)?At:[0,0];let qt=GF(vt,void 0,zt,E.layout.get("icon-anchor").evaluate(Ke,{},d));const ss=E.getAppearanceValueAndResolveTokens(Xe,"icon-rotate",Ke,d,v),Gt=typeof ss=="number"?ss:0,ds=vt.sdf,js=E.layout.get("icon-text-fit").constantOr("none");js!=="none"&&Se.textShaping&&Se.iconTextFitPadding&&Se.fontScale&&(qt=Hpe(qt,Se.textShaping,js,Se.iconTextFitPadding,zt,Se.fontScale));const Ns=this.calculateEffectiveAppearanceIconSize(Xe,C.zoom,Ke,d,v,se),Fs=0,Bs=1+(Math.min(yv,Math.round(Ns*xg))<<1),Ls=Zpe(qt,Gt,ds,js!=="none",se);Se.isUsingAppearanceVertexData||(Se.isUsingAppearanceVertexData=!0,Se.layoutBasedVertexData=this.icon.getIconVertexData(R,de.numIconVertices));for(let ls=0;ls0&&(this.icon.updateIconVertexData(R,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(R+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(R+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(R+3,0,0,0,0,0,0,0,0,0,0,0,0),P=!0),R+=de.numIconVertices,Se.activeAppearance=null;else if(Se.isUsingAppearanceVertexData){const kt=Se.layoutBasedVertexData.length/12;for(let vt=0;vt0||ae>0,Fe=de>0,Re=this.elevationFeatures[$.elevationFeatureIndex];if(Re){const Ke=new pt($.tileAnchorX,$.tileAnchorY),Xe=.075+Re.pointElevation(Ke);$.zOffset!==Xe&&(m=!0,$.zOffset=Xe),Xe!==0&&(this.hasAnyZOffset=!0);const lt=Re.computeSlopeNormal(Ke,C),kt=cs(He(),re(0,0,1),lt);Ve(G,G,kt),Ve(te,te,kt),G[2]*=v,te[2]*=v,G[0]===1&&G[1]===0&&G[2]===0&&te[0]===0&&te[1]===1&&te[2]===0||(E=E||Se,P=P||Fe)}if(Se&&(s7(this.text.orientationVertexArray,se,G,te),s7(this.text.orientationVertexArray,ae,G,te)),Fe){const{placedIconSymbolIndex:Ke,verticalPlacedIconSymbolIndex:Xe}=$;Ke>=0&&s7(this.icon.orientationVertexArray,de,G,te),Xe>=0&&s7(this.icon.orientationVertexArray,he,G,te)}}E||(this.text.orientationVertexArray=void 0),P||(this.icon.orientationVertexArray=void 0),m&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const d=(E,P,R)=>{v+=P,v>E.length&&E.resize(v);for(let $=-P;$<0;$++)E.emplace($+v,R)},m=(E,P,R)=>{C+=P,C>E.length&&E.resize(C);for(let $=-P;$<0;$++)E.emplace($+C,R)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let v=0,C=0;for(let E=0;E0;if((R>0||$>0)&&(d(this.text.zOffsetVertexArray,R,te),d(this.text.zOffsetVertexArray,$,te)),se){const{placedIconSymbolIndex:ae,verticalPlacedIconSymbolIndex:de}=P;ae>=0&&m(this.icon.zOffsetVertexArray,G,te),de>=0&&m(this.icon.zOffsetVertexArray,P.numVerticalIconVertices,te)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(d,m,v,C,E){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(d),this.iconCollisionBox.upload(d)),this.text.upload(d,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,!1),this.hasAppearances===null&&(this.hasAppearances=this.layers.some(P=>P.appearances&&P.appearances.length>0)),this.icon.upload(d,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(d,m,v,C){return!!(d&&m&&v)&&!(!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(d,m,v,C)&&this.icon.layoutVertexBuffer&&this.icon.layoutVertexArray.arrayBuffer!==null&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray))}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=W5e(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(d,m){const v=this.lineVertexArray.length;if(d.segment!==void 0)for(const{x:C,y:E}of m)this.lineVertexArray.emplaceBack(C,E);return{lineStartIndex:v,lineLength:this.lineVertexArray.length-v}}addSymbols(d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke){const Xe=d.indexArray,lt=d.layoutVertexArray,kt=d.globeExtVertexArray,vt=d.segments.prepareSegment(4*Ke,lt,Xe,this.canOverlap?P.sortKey:void 0),At=this.glyphOffsetArray.length,zt=vt.vertexLength,qt=this.allowVerticalPlacement&&R===pm.vertical?Math.PI/2:0,ss=P.text&&P.text.sections;for(let js=0;js=0?m.rightJustifiedTextSymbolIndex:m.centerJustifiedTextSymbolIndex>=0?m.centerJustifiedTextSymbolIndex:m.leftJustifiedTextSymbolIndex>=0?m.leftJustifiedTextSymbolIndex:m.verticalPlacedTextSymbolIndex>=0?m.verticalPlacedTextSymbolIndex:C),P=Wpe(this.textSizeData,d,E)/Ac;return this.tilePixelRatio*P}getSymbolInstanceIconSize(d,m,v){const C=this.icon.placedSymbolArray.get(v),E=Wpe(this.iconSizeData,d,C);return this.tilePixelRatio*E}_commitDebugCollisionVertexUpdate(d,m,v,C){d.emplaceBack(m,-v,-v,C),d.emplaceBack(m,v,-v,C),d.emplaceBack(m,v,v,C),d.emplaceBack(m,-v,v,C)}_updateTextDebugCollisionBoxes(d,m,v,C,E,P,R){for(let $=C;$0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(d,m){const v=d.placedSymbolArray.get(m),C=v.vertexStartIndex+4*v.numGlyphs;for(let E=v.vertexStartIndex;EC[R]-C[$]||E[$]-E[R]),P}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let d=0;dthis.symbolInstances.get(m).zOffset-this.symbolInstances.get(d).zOffset)}addToSortKeyRanges(d,m){const v=this.sortKeyRanges[this.sortKeyRanges.length-1];v&&v.sortKey===m?v.symbolInstanceEnd=d+1:this.sortKeyRanges.push({sortKey:m,symbolInstanceStart:d,symbolInstanceEnd:d+1})}sortFeatures(d){if(this.sortFeaturesByY&&this.sortedAngle!==d&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(d),this.sortedAngle=d,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const m of this.symbolInstanceIndexes){const v=this.symbolInstances.get(m);this.featureSortOrder.push(v.featureIndex);const{rightJustifiedTextSymbolIndex:C,centerJustifiedTextSymbolIndex:E,leftJustifiedTextSymbolIndex:P,verticalPlacedTextSymbolIndex:R,placedIconSymbolIndex:$,verticalPlacedIconSymbolIndex:G}=v;C>=0&&this.addIndicesForPlacedSymbol(this.text,C),E>=0&&E!==C&&this.addIndicesForPlacedSymbol(this.text,E),P>=0&&P!==E&&P!==C&&this.addIndicesForPlacedSymbol(this.text,P),R>=0&&this.addIndicesForPlacedSymbol(this.text,R),$>=0&&this.addIndicesForPlacedSymbol(this.icon,$),G>=0&&this.addIndicesForPlacedSymbol(this.icon,G)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getElevationFeatureForText(d){const m=this.symbolInstances.get(this.text.symbolInstanceIndices[d]).elevationFeatureIndex;let v;return this.elevationFeatures&&mv in x?String(x[v]):"")}let K5e,Z5e,tfe;kr(r7,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),r7.addDynamicAttributes=s5;class Y5e{constructor(d){this.type=d.property.overrides?d.property.overrides.runtimeType:Rp,this.defaultValue=d}evaluate(d){if(d.formattedSection){const m=this.defaultValue.property.overrides;if(m&&m.hasOverride(d.formattedSection))return m.getOverride(d.formattedSection)}return d.feature&&d.featureState?this.defaultValue.evaluate(d.feature,d.featureState):this.defaultValue.property.specification.default}eachChild(d){this.defaultValue.isConstant()||d(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}kr(Y5e,"FormatSectionOverride",{omit:["defaultValue"]});const sfe=()=>tfe||(tfe={layout:K5e||(K5e=new Io({"symbol-placement":new Ys(Kt.layout_symbol["symbol-placement"]),"symbol-spacing":new Ys(Kt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ys(Kt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ar(Kt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ys(Kt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ys(Kt.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Ys(Kt.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Ys(Kt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ys(Kt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ys(Kt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ys(Kt.layout_symbol["icon-rotation-alignment"]),"icon-size":new ar(Kt.layout_symbol["icon-size"]),"icon-size-scale-range":new Ys(Kt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new ar(Kt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ar(Kt.layout_symbol["icon-text-fit-padding"]),"icon-image":new ar(Kt.layout_symbol["icon-image"]),"icon-image-use-theme":new Ys({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new ar(Kt.layout_symbol["icon-rotate"]),"icon-padding":new Ys(Kt.layout_symbol["icon-padding"]),"icon-keep-upright":new Ys(Kt.layout_symbol["icon-keep-upright"]),"icon-offset":new ar(Kt.layout_symbol["icon-offset"]),"icon-anchor":new ar(Kt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ys(Kt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ys(Kt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ys(Kt.layout_symbol["text-rotation-alignment"]),"text-field":new ar(Kt.layout_symbol["text-field"]),"text-font":new ar(Kt.layout_symbol["text-font"]),"text-size":new ar(Kt.layout_symbol["text-size"]),"text-size-scale-range":new Ys(Kt.layout_symbol["text-size-scale-range"]),"text-max-width":new ar(Kt.layout_symbol["text-max-width"]),"text-line-height":new ar(Kt.layout_symbol["text-line-height"]),"text-letter-spacing":new ar(Kt.layout_symbol["text-letter-spacing"]),"text-justify":new ar(Kt.layout_symbol["text-justify"]),"text-radial-offset":new ar(Kt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ys(Kt.layout_symbol["text-variable-anchor"]),"text-anchor":new ar(Kt.layout_symbol["text-anchor"]),"text-max-angle":new Ys(Kt.layout_symbol["text-max-angle"]),"text-writing-mode":new Ys(Kt.layout_symbol["text-writing-mode"]),"text-rotate":new ar(Kt.layout_symbol["text-rotate"]),"text-padding":new Ys(Kt.layout_symbol["text-padding"]),"text-keep-upright":new Ys(Kt.layout_symbol["text-keep-upright"]),"text-transform":new ar(Kt.layout_symbol["text-transform"]),"text-offset":new ar(Kt.layout_symbol["text-offset"]),"text-allow-overlap":new Ys(Kt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ys(Kt.layout_symbol["text-ignore-placement"]),"text-optional":new Ys(Kt.layout_symbol["text-optional"]),visibility:new Ys(Kt.layout_symbol.visibility)})),paint:Z5e||(Z5e=new Io({"icon-opacity":new ar(Kt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ar(Kt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ar(Kt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ar(Kt.paint_symbol["text-emissive-strength"]),"icon-color":new ar(Kt.paint_symbol["icon-color"]),"icon-halo-color":new ar(Kt.paint_symbol["icon-halo-color"]),"icon-halo-width":new ar(Kt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ar(Kt.paint_symbol["icon-halo-blur"]),"icon-translate":new Ys(Kt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ys(Kt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Ys(Kt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ar(Kt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ar(Kt.paint_symbol["text-occlusion-opacity"]),"text-color":new ar(Kt.paint_symbol["text-color"],{runtimeType:dh,getOverride:x=>x.textColor,hasOverride:x=>!!x.textColor}),"text-halo-color":new ar(Kt.paint_symbol["text-halo-color"]),"text-halo-width":new ar(Kt.paint_symbol["text-halo-width"]),"text-halo-blur":new ar(Kt.paint_symbol["text-halo-blur"]),"text-translate":new Ys(Kt.paint_symbol["text-translate"]),"text-translate-anchor":new Ys(Kt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ys(Kt.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ys(Kt.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ys(Kt.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ys(Kt.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ar(Kt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"})}))},tfe);class n7 extends zu{constructor(d,m,v,C){super(d,sfe(),m,v,C,d.layout?d.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=w([]),this.hasOcclusionOpacityProperties=d.paint!==void 0&&("icon-occlusion-opacity"in d.paint||"text-occlusion-opacity"in d.paint)}_handleSpecialPaintPropertyUpdate(d){d!=="icon-occlusion-opacity"&&d!=="text-occlusion-opacity"||(this.hasOcclusionOpacityProperties=!0)}recalculate(d,m){super.recalculate(d,m),this.appearances&&this.appearances.forEach(C=>{C.recalculate(d,m,this.iconImageUseTheme)}),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const v=this.layout.get("text-writing-mode");if(v){const C=[];for(const E of v)C.indexOf(E)<0&&C.push(E);this.layout._values["text-writing-mode"]=C}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(d,m,v,C){return this._saturation===d&&this._contrast===m&&this._brightnessMin===v&&this._brightnessMax===C||(this._colorAdjustmentMatrix=function(E,P,R,$){E=lo(E),P=Ia(P);const G=_(),te=E/3,se=1-2*te,ae=[se,te,te,0,te,se,te,0,te,te,se,0,0,0,0,1],de=.5-.5*P,he=$-R;return S(G,[he,0,0,0,0,he,0,0,0,0,he,0,R,R,R,1],[P,0,0,0,0,P,0,0,0,0,P,0,de,de,de,1]),S(G,G,ae),G}(d,m,v,C),this._saturation=d,this._contrast=m,this._brightnessMin=v,this._brightnessMax=C),this._colorAdjustmentMatrix}getValueAndResolveTokens(d,m,v,C){const E=this.layout.get(d).evaluate(m,{},v,C),P=this._unevaluatedLayout._values[d];return P.isDataDriven()||d2(P.value)||!E?E:G5e(m.properties,E)}getAppearanceValueAndResolveTokens(d,m,v,C,E){const P=d.getProperty(m);if(!P)return;const R=P.evaluate(v,{},C,E),$=d.getUnevaluatedProperties()._values[m];return $.isDataDriven()||d2($.value)||!R||typeof R!="string"?R:G5e(v.properties,R)}createBucket(d){return new r7(d)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const d of sfe().paint.overridableProperties){if(!n7.hasPaintOverride(this.layout,d))continue;const m=this.paint.get(d),v=new Y5e(m),C=new c3(v,m.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let E=null;E=m.value.kind==="constant"||m.value.kind==="source"?new cb("source",C):new av("composite",C,m.value.zoomStops,m.value.interpolationType),this.paint._values[d]=new ov(m.property,E,m.parameters)}}_handleOverridablePaintPropertyUpdate(d,m,v){return!(!this.layout||m.isDataDriven()||v.isDataDriven())&&n7.hasPaintOverride(this.layout,d)}static hasPaintOverride(d,m){const v=d.get("text-field"),C=sfe().paint.properties[m];let E=!1;const P=R=>{for(const $ of R)if(C.overrides&&C.overrides.hasOverride($))return void(E=!0)};if(v.value.kind==="constant"&&v.value.value instanceof Du)P(v.value.value.sections);else if(v.value.kind==="source"){const R=G=>{E||(G instanceof eg&&Tc(G.value)===Zw?P(G.value.sections):G instanceof zf?P(G.sections):G.eachChild(R))},$=v.value;$._styleExpression&&R($._styleExpression.expression)}return E}getProgramIds(){return["symbol"]}getDefaultProgramParams(d,m,v){return{config:new Dy(this,{zoom:m,lut:v}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let X5e,Q5e,J5e,eMe;var rfe=fa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function a7(x,d,m,v,C,E,P,R){const $=[x,d,1,m,v,1,C,E,1],G=[P,R,1],te=g([],$),[se,ae,de]=fe(G,G,te);return b($,$,[se,0,0,0,ae,0,0,0,de])}function tMe(x,d,m,v,C,E,P,R){const $=function(G,te,se,ae,de,he,Se,Fe){const Re=a7(0,0,1,0,1,1,0,1),Ke=a7(G,te,se,ae,de,he,Se,Fe);return b(Ke,Ke,g([],Re))}(x,d,m,v,C,E,P,R);return[$[2]/$[8]/tr,$[5]/$[8]/tr]}function i7(x){return[x[0],Math.min(Math.max(x[1],-we),we)]}class sMe extends As{constructor(d,m,v,C){super(),this.id=d,this.dispatcher=v,this.coordinates=m.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(C),this.options=m,this._dirty=!1}load(d,m){if(this._loaded=m||!1,this.fire(new Xm("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return d&&(this.coordinates=d),this._loaded=!0,void this._finishLoading();this._imageRequest=vy(this.map._requestManager.transformRequest(this.url,Yx.Image),(v,C)=>{this._imageRequest=null,this._loaded=!0,v?this.fire(new by(v)):C&&(this.image=C instanceof HTMLImageElement?zl.getImageData(C):C,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,d&&(this.coordinates=d),this._finishLoading())})}loaded(){return this._loaded}updateImage(d){return d.url?(this._imageRequest&&d.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=d.url,this.load(d.coordinates,this._loaded),this):this}setTexture(d){if(!(d.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new sP(this.map.painter.context,d.handle),this.width=d.dimensions[0],this.height=d.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Xm("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(d){this.map=d,this.load()}onRemove(d){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof sP||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(d){if(this.coordinates=d,this._boundsArray=void 0,this._unsupportedCoords=!1,!d.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let m=d[0][1],v=d[0][1];for(const E of d)E[1]>v&&(v=E[1]),E[1]we?this.onNorthPole=!0:C<-we&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const E=d.map(st.fromLngLat);this.tileID=function(P){let R=1/0,$=1/0,G=-1/0,te=-1/0;for(const Se of P)R=Math.min(R,Se.x),$=Math.min($,Se.y),G=Math.max(G,Se.x),te=Math.max(te,Se.y);const se=Math.max(G-R,te-$),ae=Math.max(0,Math.floor(-Math.log2(se))),de=Math.pow(2,ae);let he=Math.floor((R+G)/2*de);return he>1&&(he-=1),new Oi(ae,he,Math.floor(($+te)/2*de))}(E),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Xm("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof sP||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(d){for(const Re in this.tiles){const Ke=this.tiles[Re];Ke.state!=="loaded"&&(Ke.state="loaded",Ke.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const m=uP(new Oi(0,0,0),this.map.transform.projection),v=[m.projection.project(this.coordinates[0][0],this.coordinates[0][1]),m.projection.project(this.coordinates[1][0],this.coordinates[1][1]),m.projection.project(this.coordinates[2][0],this.coordinates[2][1]),m.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(Re){const Ke=Re[1].x-Re[0].x,Xe=Re[1].y-Re[0].y,lt=Re[2].x-Re[1].x,kt=Re[2].y-Re[1].y,vt=Re[3].x-Re[2].x,At=Re[3].y-Re[2].y,zt=Re[0].x-Re[3].x,qt=Re[0].y-Re[3].y,ss=Ke*kt-lt*Xe,Gt=lt*At-vt*kt,ds=vt*qt-zt*At,js=zt*Xe-Ke*qt;return ss>0&&Gt>0&&ds>0&&js>0||ss<0&&Gt<0&&ds<0&&js<0}(v))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const C=uP(this.tileID,this.map.transform.projection),[E,P,R,$]=this.coordinates.map(Re=>{const Ke=C.projection.project(Re[0],Re[1]);return $5e(C,Ke)._round()});this.perspectiveTransform=tMe(E.x,E.y,P.x,P.y,R.x,R.y,$.x,$.y);const G=this._boundsArray=new mb;G.emplaceBack(E.x,E.y,0,0),G.emplaceBack(P.x,P.y,tr,0),G.emplaceBack($.x,$.y,0,tr),G.emplaceBack(R.x,R.y,tr,tr),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=d.createVertexBuffer(G,rfe.members),this.boundsSegments=bo.simpleSegment(0,0,4,2);const te=[],se=[i7((ae=this.coordinates)[0]),i7(ae[1]),i7(ae[2]),i7(ae[3])];var ae;const[de,he,Se,Fe]=function(Re){let Ke=Re[0][0],Xe=Ke,lt=Re[0][1],kt=lt;for(let vt=1;vtXe&&(Xe=Re[vt][0]),Re[vt][1]kt&&(kt=Re[vt][1]);return[Ke,lt,Xe-Ke,kt-lt]}(se);{const Re=new mb,[Ke,Xe,lt,kt]=function(Ls){let Os=Ls[0].x,ls=Os,rs=Ls[0].y,Rs=rs;for(let sr=1;srls&&(ls=Ls[sr].x),Ls[sr].yRs&&(Rs=Ls[sr].y);return[Os,rs,ls-Os,Rs-rs]}(v),vt=Ls=>[(Ls.x-Ke)/lt,(Ls.y-Xe)/kt],[At,zt,qt,ss]=v.map(vt),Gt=function(Ls,Os,ls,rs,Rs,sr,Vs,zr){const mr=a7(0,0,1,0,1,1,0,1);return b(mr,mr,g([],a7(Ls,Os,ls,rs,Rs,sr,Vs,zr)))}(At[0],At[1],zt[0],zt[1],qt[0],qt[1],ss[0],ss[1]);this.elevatedGlobePerspectiveTransform=tMe(At[0],At[1],zt[0],zt[1],qt[0],qt[1],ss[0],ss[1]);const ds=(Ls,Os)=>{te.push(Ls.lng);const ls=Math.round((Ls.lng-de)/Se*tr),rs=Math.round((Ls.lat-he)/Fe*tr),Rs=vt(Os),sr=fe([],[Rs[0],Rs[1],1],Gt),Vs=Math.round(sr[0]/sr[2]*tr),zr=Math.round(sr[1]/sr[2]*tr);Re.emplaceBack(ls,rs,Vs,zr)},js=v[3].x-v[0].x,Ns=v[3].y-v[0].y,Fs=v[2].x-v[1].x,Bs=v[2].y-v[1].y;for(let Ls=0;Ls<65;Ls++){const Os=Ls/64,ls=[v[0].x+Os*js,v[0].y+Os*Ns],rs=[v[1].x+Os*Fs,v[1].y+Os*Bs],Rs=rs[0]-ls[0],sr=rs[1]-ls[1];for(let Vs=0;Vs<65;Vs++){const zr=Vs/64,mr={x:ls[0]+Rs*zr,y:ls[1]+sr*zr};ds(m.projection.unproject(mr.x,mr.y),mr)}}this.elevatedGlobeVertexBuffer=d.createVertexBuffer(Re,rfe.members)}{this.maxLongitudeTriangleSize=0;let Re=[],Ke=new Bl;const Xe=(lt,kt,vt)=>{Ke.emplaceBack(lt,kt,vt);const At=te[lt],zt=te[kt],qt=te[vt],ss=Math.min(Math.min(At,zt),qt),Gt=Math.max(Math.max(At,zt),qt)-ss;Gt>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Gt),Re.push(ss+Gt/2)};for(let lt=0;lt<64;lt++)for(let kt=0;kt<64;kt++){const vt=65*lt+kt,At=vt+1,zt=vt+65,qt=zt+1;Xe(vt,zt,At),Xe(At,zt,qt)}[Re,Ke]=function(lt,kt){const vt=Array.from({length:lt.length},(qt,ss)=>ss);vt.sort((qt,ss)=>lt[qt]-lt[ss]);const At=[],zt=new Bl;for(let qt=0;qt{P.segments.push({vertexOffset:0,primitiveOffset:se,vertexLength:m.segments[0].vertexLength,primitiveLength:ae,sortKey:void 0,vaos:{}})},$=.51*this.maxLongitudeTriangleSize;if(Math.abs(v[0]-C)<=$){const se=oo(v,0,v.length,C+$);return se===v.length||R(se,hl(v,se+1,v.length,C+360-$)-se),P}Ctr?C-tr:C,new pt(Math.trunc(C),Math.trunc(v[m+1]))}translationForInstance(d){const m=16*d,v=this.instancedDataArray.float32;return[v[m+4],v[m+5],v[m+6]]}rotationScaleForInstance(d){const m=16*d,v=this.instancedDataArray.float32;return[v[m+7],v[m+8],v[m+9],v[m+10],v[m+11],v[m+12],v[m+13],v[m+14],v[m+15]]}transformForInstance(d){const m=16*d,v=this.instancedDataArray.float32;return[v[m+7],v[m+8],v[m+9],v[m+4],v[m+10],v[m+11],v[m+12],v[m+5],v[m+13],v[m+14],v[m+15],v[m+6],0,0,0,1]}}class ife{constructor(d){this.zoom=d.zoom,this.canonical=d.canonical,this.overscaledZ=this.canonical.z+Math.log2(d.overscaling),this.layers=d.layers,this.layerIds=this.layers.map(m=>m.fqid),this.projection=d.projection,this.index=d.index,this.worldview=d.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=d.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,C){}populate(d,m,v,C){this.tileToMeter=Ue(v);const E=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:P,id:R,index:$,sourceLayerIndex:G}of d){const te=R??(P.properties&&P.properties.hasOwnProperty("id")?P.properties.id:void 0),se=Wt(P,E);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),se,v))continue;const ae={id:te,sourceLayerIndex:G,index:$,geometry:E?se.geometry:Ot(P,v,C),properties:P.properties,type:P.type,patterns:{}},de=this.addFeature(ae,ae.geometry,se);de&&m.featureIndex.insert(P,ae.geometry,$,G,this.index,this.instancesPerModel[de].instancedDataArray.length,tr/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const d=this.layers[0].modelManager,m=this.layers[0].scope;let v=0;for(const C of this.modelUris){const E=d.getModel(C,m);if(!E)continue;const P=this.instancesPerModel[C];if(P){const R=.5*Ne(E.aabb.max,E.aabb.min)*P.maxScale+P.maxXYTranslationDistance,$=Math.min(tr,Math.max(R/this.tileToMeter,tr/32));v=Math.max($,v)}}return v}update(d,m,v,C){for(const E in this.instancesPerModel){const P=this.instancesPerModel[E];for(const R in d)P.idToFeaturesIndex.hasOwnProperty(R)&&(this.evaluate(P.features[P.idToFeaturesIndex[R]],d[R],P,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let d=!1;for(const m in this.instancesPerModel){const v=this.instancesPerModel[m];for(const C of v.features){const E=this.layers[0],P=C.feature,R=this.canonical,$=E.paint.get("model-rotation").evaluate(P,{},R),G=E.paint.get("model-scale").evaluate(P,{},R),te=E.paint.get("model-translation").evaluate(P,{},R);et(C.rotation,$)&&et(C.scale,G)&&et(C.translation,te)||(this.evaluate(C,C.featureStates,v,!0),d=!0)}}return d}updateReplacement(d,m,v,C){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const E=m.getReplacementRegionsForTile(d.toUnwrapped(),!0);if(EF(this.activeReplacements,E))return!1;this.activeReplacements=E;let P=!1;for(const R in this.instancesPerModel){const $=this.instancesPerModel[R],G=$.instancedDataArray;for(const te of $.features){const se=te.instancedDataOffset,ae=te.instancedDataCount;for(let de=0;detr;Se=Fe?Se-tr:Se;const Re=Math.floor(Se),Ke=Math.floor(G.float32[he+1]);let Xe=!1;for(const lt of this.activeReplacements)if(!QCe(lt,v,dMe.Model,C)&&!(lt.min.x>Re||Re>lt.max.x||lt.min.y>Ke||Ke>lt.max.y)&&(Xe=r3e(s3e(Re,Ke,d.canonical,lt.footprintTileId.canonical),lt.footprint),Xe))break;G.float32[he]=Xe?Se+tr:Se,P=P||Xe!==Fe}}}return P}isEmpty(){for(const d in this.instancesPerModel)if(this.instancesPerModel[d].instancedDataArray.length!==0)return!1;return!0}uploadPending(){return!this.uploaded}upload(d){if(!this.uploaded)for(const m in this.instancesPerModel){const v=this.instancesPerModel[m];v.instancedDataArray.length<0||v.instancedDataArray.length===0||(v.instancedDataBuffer?v.instancedDataBuffer.updateData(v.instancedDataArray):v.instancedDataBuffer=d.createVertexBuffer(v.instancedDataArray,Adt.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(d){for(const v in this.instancesPerModel){const C=this.instancesPerModel[v];C.instancedDataArray.length!==0&&C.instancedDataBuffer&&C.instancedDataBuffer.destroy()}const m=this.layers[0].modelManager;if(d&&m&&this.modelUris&&this.modelsRequested)for(const v of this.modelUris)m.removeModel(v,"",!0)}addFeature(d,m,v){const C=this.layers[0],E=C.layout.get("model-id").evaluate(v,{},this.canonical);if(!E)return xr(`modelId is not evaluated for layer ${C.id} and it is not going to get rendered.`),E;(afe(E,!1)||this.styleDefinedModelURLs[E]!==void 0)&&(this.modelUris.includes(E)||this.modelUris.push(E)),this.instancesPerModel[E]||(this.instancesPerModel[E]=new hMe);const P=this.instancesPerModel[E],R=P.instancedDataArray,$=new uMe(v,R.length);for(const G of m)for(const te of G){if(te.x<0||te.x>=tr||te.y<0||te.y>=tr)continue;if(this.lookupDim!==0){const ae=(this.lookupDim-1)/tr,de=this.lookupDim*(te.y*ae|0)+te.x*ae|0;if(this.lookup){if(this.lookup[de]!==0)continue;this.lookup[de]=1}}this.instanceCount++;const se=R.length;R.resize(se+1),P.instancesEvaluatedElevation.push(0),R.float32[16*se]=te.x,R.float32[16*se+1]=te.y}return $.instancedDataCount=P.instancedDataArray.length-$.instancedDataOffset,$.instancedDataCount>0&&(d.id&&(P.idToFeaturesIndex[d.id]=P.features.length),P.features.push($),this.evaluate($,{},P,!1)),E}getModelUris(){return this.modelUris}evaluate(d,m,v,C){const E=this.layers[0],P=d.feature,R=this.canonical,$=d.rotation=E.paint.get("model-rotation").evaluate(P,m,R),G=d.scale=E.paint.get("model-scale").evaluate(P,m,R),te=d.translation=E.paint.get("model-translation").evaluate(P,m,R),se=Object.assign({},E.paint.get("model-color").evaluate(P,m,R));se.a=E.paint.get("model-color-mix-intensity").evaluate(P,m,R);const ae=[];this.maxVerticalOffset0?Math.sqrt(de):0;v.maxScale=Math.max(Math.max(v.maxScale,G[0]),Math.max(G[1],G[2])),v.maxXYTranslationDistance=Math.max(v.maxXYTranslationDistance,he),this.maxScale=Math.max(Math.max(this.maxScale,G[0]),Math.max(G[1],G[2])),U3e(ae,$,G);const Se=Math.round(100*se.a)+se.b/1.05;for(let Fe=0;Fe10?this.tileToMeter:Ue(R,kt)),Xe[Ke+4]=te[0],Xe[Ke+5]=te[1],Xe[Ke+6]=te[2]+lt,Xe[Ke+7]=ae[0],Xe[Ke+8]=ae[1],Xe[Ke+9]=ae[2],Xe[Ke+10]=ae[4],Xe[Ke+11]=ae[5],Xe[Ke+12]=ae[6],Xe[Ke+13]=ae[8],Xe[Ke+14]=ae[9],Xe[Ke+15]=ae[10],v.instancesEvaluatedElevation[Re]=te[2]}}}let mMe,pMe;kr(ife,"ModelBucket",{omit:["layers"]}),kr(hMe,"PerModelAttributes"),kr(uMe,"ModelFeature");class r5{constructor(d,m,v){this._demTile=d,this._dem=this._demTile.dem,this._scale=m,this._offset=v}static create(d,m,v){const C=v||d.findDEMTileFor(m);if(!C||!C.dem)return;const E=C.dem,P=C.tileID,R=1<G.fqid),this.stateDependentLayerIds=this.layers.filter(G=>G.isStateDependent()).map(G=>G.id),this.modelTraits|=K3.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,C&&(this.modelTraits|=K3.HasMapboxMeshFeatures),E&&(this.modelTraits|=K3.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=P,this.worldview=$,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const G of m)this.nodesInfo.push(new yMe(G)),xMe(G,R.featureIndexArray.length,R.grid),R.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,R.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(d,m){for(const v of this.getNodesInfo()){const C=v.node;C.footprint&&m.push({footprint:C.footprint,id:d})}}updateAppearances(d,m,v,C){}update(d){const m=Object.keys(d).length!==0;if(m&&!this.stateDependentLayers.length)return;const v=m?this.stateDependentLayers:this.layers;if(!ir(d,this.states))for(const C of v)this.evaluate(C,d);this.states=structuredClone(d)}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(d){if(!this.needsUpload)return;const m=this.getNodesInfo();for(const v of m){const C=v.node;this.uploaded?this.updatePbrBuffer(C):Epe(C,d,!0)}for(const v of m)UF(v.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(d){let m=!1;if(!d.meshes)return m;for(const v of d.meshes)v.pbrBuffer&&(v.pbrBuffer.updateData(v.featureArray),m=!0);return m}needsReEvaluation(d,m,v){const C=d.transform.projectionOptions,E=d.style.getBrightness(),P=this.brightness!==E;if(!this.uploaded||this.dirty||C.name!==this.projection.name||vP(v.paint.get("model-color").value,P)||vP(v.paint.get("model-color-mix-intensity").value,P)||vP(v.paint.get("model-roughness").value,P)||vP(v.paint.get("model-emissive-strength").value,P)||vP(v.paint.get("model-height-based-emissive-strength-multiplier").value,P)){this.projection=C,this.brightness=E;const R=this.getNodesInfo();for(const $ of R)$.state=null;return!0}return!1}evaluateTransform(d,m){if(d.transform.zoom===this.zoom)return;this.zoom=d.transform.zoom;const v=this.getNodesInfo(),C=this.id.canonical;for(const E of v){const P=E.feature;E.evaluatedTranslation=m.paint.get("model-translation").evaluate(P,{},C),E.evaluatedScale=m.paint.get("model-scale").evaluate(P,{},C)}}evaluate(d,m){const v=this.getNodesInfo();for(const C of v){if(!C.node.meshes)continue;const E=C.feature,P=m&&m[E.id];if(ir(P,C.state))continue;C.state=structuredClone(P);const R=C.node.meshes&&C.node.meshes[0].featureData,$=C.evaluatedColor[2],G=C.evaluatedRMEA[2],te=this.id.canonical;if(C.hasTranslucentParts=!1,R){for(let se=0;se=vt)continue;const Ls=ofe[Bs],Os=Math.abs(Ls);Os>Gt&&(ss=Ls,Gt=Os,ds=Fs,js=Ns)}if(Gt>.1){const Ns=1-(vt+.5*Math.abs(ds*js))/he;let Fs=m._dem.get(zt,At)+ss*Ns;const Bs=m._dem.get(zt+ds,At+js),Ls=m._dem.get(zt-ds,At-js,!0);(Fs-Bs)*(Fs-Ls)>0&&(Fs=(Bs+Ls)/2),ofe[qt]=m._dem.set(zt,At,Fs),P2[qt]=vt}}}}}R&&(m._demTile.needsDEMTextureUpload=!0,m._dem._timestamp=zl.now())}setFilter(d){this.filter=d?y3(d):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(d=>this.filter.filter(new Ki(this.id.overscaledZ,{worldview:this.worldview}),d.feature,this.id.canonical)):this.nodesInfo}destroy(){const d=this.getNodesInfo();for(const m of d)UF(m.node),Ppe(m.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(d,m){if(m.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=m.updateTime;const v=m.getReplacementRegionsForTile(d.toUnwrapped());for(const C of this.getNodesInfo()){const E=C.node.footprint;C.hiddenByReplacement=!!E&&!v.find(P=>P.footprint===E)}}getHeightAtTileCoord(d,m){const v=[],C=[0,0,0],E=w([]);for(const P of this.getNodesInfo()){const R=P.node.meshes[0],$=R.transformedAabb;if(d<$.min[0]||m<$.min[1]||d>$.max[0]||m>$.max[1])continue;if(P.node.hidden===!0)return{height:1/0,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};k(E,P.node.globalMatrix),C[0]=d,C[1]=m,ft(C,C,E);const G=(C[0]-R.aabb.min[0])/(R.aabb.max[0]-R.aabb.min[0])*T2|0,te=Math.min(63,(C[1]-R.aabb.min[1])/(R.aabb.max[1]-R.aabb.min[1])*T2|0)*T2+Math.min(63,G),se=R.heightmap[te];if(!(se<0&&P.node.footprint))return P.hiddenByReplacement?void 0:{height:se,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};if(P.node.footprint.grid.query(new pt(d,m),new pt(d,m),v),v.length>0)return{height:void 0,maxHeight:P.feature.properties.height,hidden:P.hiddenByReplacement,verticalScale:P.evaluatedScale[2]}}}}function vP(x,d){return x instanceof cb&&!x.isLightConstant&&d}function lht(x,d,m,v,C,E,P,R){let $=(61440&d|(61440&d)>>4)>>8,G=(3840&d|(3840&d)>>4)>>4,te=240&d|(240&d)>>4;m[3]>0&&($=Zr($,255*m[0],m[3]),G=Zr(G,255*m[1],m[3]),te=Zr(te,255*m[2],m[3]));const se=$<<8|G,ae=te<<8|Math.floor(255*v[3]),de=function(vt){const At=je(vt,0,2);return Math.min(Math.round(.5*At*255),255)}(v[2])<<8|15*v[0]<<4|15*v[1],he=je(C[0],0,1),Se=je(C[1],0,1),Fe=je(C[2],0,1),Re=je(C[3],0,1);let Ke,Xe,lt,kt;if(he!==Se&&P!==E&&Se!==he){const vt=P-E;Xe=1/(vt*(Se-he)),lt=-(E+vt*he)/(vt*(Se-he));const At=je(C[4],-1,1);kt=Math.pow(10,At),Ke=255*Fe<<8|255*Re}else Ke=65535,Xe=0,lt=1,kt=1;if(x.emplaceBack(se,ae,de,Ke,Xe,lt,kt),R){const vt=R.length;R.clear();for(let At=0;At>16&65535,te=E?$>>16&65535:65535&$,se=(15&te)<8?15&te:0,ae=x.evaluatedRMEA[se],de=x.evaluatedColor[se],he=x.emissionHeightBasedParams[se];let Se;if(R&&se===2&&v.lights&&(Se=new T3,Se.resize(10*v.lights.length)),lht(P.featureArray,G,de,ae,he,P.aabb.min[2],P.aabb.max[2],Se),Se&&R){R=!1;const Fe=v.meshes[v.lightMeshIndex];Fe.featureArray=Se,Fe.featureArray._trim()}}P.featureArray._trim(),C++}}kr(l7,"Tiled3dModelBucket",{omit:["layers"]}),kr(yMe,"Tiled3dModelFeature");const dht=["id","tile","layer","source","sourceLayer","state"];class I2{constructor(d,m,v,C,E){this.type="Feature",this._vectorTileFeature=d,this._z=m,this._x=v,this._y=C,this.properties=d?d.properties:{},this.id=E}clone(){const d=new I2(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(d.state=Object.assign({},this.state)),this.layer&&(d.layer=Object.assign({},this.layer)),this.source&&(d.source=this.source),this.sourceLayer&&(d.sourceLayer=this.sourceLayer),d}get geometry(){return this._geometry===void 0&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(d){this._geometry=d}toJSON(){const d={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const m of dht)this[m]!==void 0&&(d[m]=this[m]);return d}}class L2 extends As{constructor(d,m,v,C){super(),this.id=d,this.type="model",this.models=[],this._loaded=!1,this._options=m,this._modelsInfo=new Map}load(){const d=[];for(const m in this._options.models){const v=this._options.models[m],C=this._modelsInfo.get(m);if(C){const E=C.model;E.position=v.position!=null?new y(v.position[0],v.position[1]):new y(0,0),E.orientation=v.orientation!=null?v.orientation:[0,0,0],C.modelSpec=v,L2.applyModelSpecification(E,v),E.computeBoundsAndApplyParent(),this.models.push(E)}else{const E=z3e(this.map._requestManager.transformRequest(v.uri,Yx.Model).url).then(P=>{if(!P)return;const R=Lpe(P),$=new V3e(m,v.uri,v.position,v.orientation,R);L2.applyModelSpecification($,v),$.computeBoundsAndApplyParent(),this.models.push($),this._modelsInfo.set(m,{modelSpec:v,model:$})}).catch(P=>{this.fire(new by(new Error(`Could not load model ${m} from ${v.uri}: ${P.message}`)))});d.push(E)}}Promise.allSettled(d).then(()=>{this._loaded=!0,this.fire(new Xm("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(m=>{this._loaded=!0,this.fire(new by(new Error(`Could not load models: ${m.message}`)))})}static applyModelSpecification(d,m){m.nodeOverrides&&L2.convertNodeOverrides(d,m.nodeOverrides),m.materialOverrides&&L2.convertMaterialOverrides(d,m.materialOverrides),m.nodeOverrideNames&&(d.nodeOverrideNames=[...m.nodeOverrideNames]),m.materialOverrideNames&&(d.materialOverrideNames=[...m.materialOverrideNames]),m.featureProperties&&(d.featureProperties=m.featureProperties)}static convertNodeOverrides(d,m){if(Array.isArray(m)&&m.every(v=>typeof v=="string")){d.nodeOverrideNames=[];for(const v of m)d.nodeOverrideNames.push(v)}else Object.entries(m).forEach(([v,C])=>{const E={orientation:[0,0,0]};if(C.hasOwnProperty("orientation")){const P=C.orientation;P&&(E.orientation=P)}d.nodeOverrides.set(v,E)})}static convertMaterialOverrides(d,m){if(Array.isArray(m)&&m.every(v=>typeof v=="string")){d.materialOverrideNames=[];for(const v of m)d.materialOverrideNames.push(v)}else Object.entries(m).forEach(([v,C])=>{const E={color:new Ur(1,1,1),colorMix:0,emissionStrength:0,opacity:1},P=C["model-color"];P!==void 0&&(E.color.r=P[0],E.color.g=P[1],E.color.b=P[2]);const R=C["model-color-mix-intensity"];R!==void 0&&(E.colorMix=R);const $=C["model-emissive-strength"];$!==void 0&&(E.emissionStrength=$);const G=C["model-opacity"];G!==void 0&&(E.opacity=G),d.materialOverrides.set(v,E)})}onAdd(d){this.map=d,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(d,m){}serialize(){return this._options}setProperty(d,m){return!1}reload(){const d=$p(this.id,this.scope);this.map.style.clearSource(d),this.models=[],this._modelsInfo.clear(),this._loaded=!1,this.load()}setModels(d){this.models=[];const m=new Map;for(const v in d){const C=d[v];if(this._modelsInfo.has(v)){const E=this._modelsInfo.get(v);E&&E.modelSpec.uri===C.uri&&m.set(v,E)}}this._modelsInfo=m,this._options.models=d,this._loaded=!1,this.load()}}function lfe(x,d,m,v){const C=1<lt.polygon).flat());const Fe=de?R:null,[Re,Ke]=C3e(E,v,se,te,G,P,Fe,ae,he,E.center.lat,x.tileID.canonical),Xe=x.queryGeometry;return S3e(Re,Ke,Xe.isPointQuery()?Xe.screenBounds:Xe.screenGeometry)}},building:class extends zu{constructor(x,d,m,v){super(x,{layout:X3e||(X3e=new Io({visibility:new Ys(Kt.layout_building.visibility),"building-facade":new ar(Kt.layout_building["building-facade"]),"building-facade-floors":new ar(Kt.layout_building["building-facade-floors"]),"building-facade-unit-width":new ar(Kt.layout_building["building-facade-unit-width"]),"building-facade-window":new ar(Kt.layout_building["building-facade-window"]),"building-roof-shape":new ar(Kt.layout_building["building-roof-shape"]),"building-height":new ar(Kt.layout_building["building-height"]),"building-base":new ar(Kt.layout_building["building-base"]),"building-flood-light-wall-radius":new ar(Kt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new ar(Kt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new ar(Kt.layout_building["building-flip-roof-orientation"])})),paint:Q3e||(Q3e=new Io({"building-opacity":new Ys(Kt.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Ys(Kt.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Ys(Kt.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Ys(Kt.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Ys(Kt.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Ys(Kt.paint_building["building-vertical-scale"]),"building-cast-shadows":new Ys(Kt.paint_building["building-cast-shadows"]),"building-color":new ar(Kt.paint_building["building-color"]),"building-emissive-strength":new ar(Kt.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Ys(Kt.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Ys(Kt.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new Ys(Kt.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Ys(Kt.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Ys(Kt.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"})}))},d,m,v),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(x){return new Y3e(x)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(x){return!0}queryRadius(x){return 0}queryIntersectsFeature(x,d,m,v,C,E,P,R,$){let G=this.layout.get("building-height").evaluate(d,m);const te=this.layout.get("building-base").evaluate(d,m),se=x.tile.getBucket(this).getFootprint(d);if(se){if(se.hiddenFlags!==0)return!1;G=se.height}const[ae,de]=C3e(E,v,te,G,new pt(0,0),P,null,[0,0],1,E.center.lat,x.tileID.canonical),he=x.queryGeometry;return S3e(ae,de,he.isPointQuery()?he.screenBounds:he.screenGeometry)}},line:class extends zu{constructor(x,d,m,v){const C=l5e();super(x,C,d,m,v),C.layout&&(this.layout=new lv(C.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(x){if(x==="line-gradient"){const d=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=d._styleExpression&&d._styleExpression.expression instanceof n2,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(x,d){super.recalculate(x,d),this.paint._values["line-floorwidth"]=(()=>{if(nP)return nP;const m=l5e();return nP=new iut(m.paint.properties["line-width"].specification),nP.useIntegerZoom=!0,nP})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,x)}createBucket(x){return new Rpe(x)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(x,d,m){const v=i5e(this);return{config:new Dy(this,{zoom:d,lut:m}),defines:v,overrideFog:!1}}queryRadius(x){const d=x,m=c5e(Hd("line-width",this,d),Hd("line-gap-width",this,d)),v=Hd("line-offset",this,d);return m/2+Math.abs(v)+id(this.paint.get("line-translate"))}queryIntersectsFeature(x,d,m,v,C,E){if(x.queryGeometry.isAboveHorizon)return!1;const P=hm(x.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),E.angle,x.pixelToTileUnitsFactor),R=x.pixelToTileUnitsFactor/2*c5e(this.paint.get("line-width").evaluate(d,m),this.paint.get("line-gap-width").evaluate(d,m)),$=this.paint.get("line-offset").evaluate(d,m);return $&&(v=function(G,te){const se=[],ae=new pt(0,0);for(let de=0;de=3){for(let he=0;he>16&255)/255,(x>>8&255)/255,(255&x)/255,1)}function kht(x,d,m){x===1?(d.rgb_color=h7(m.readVarint()),d.paint="rgb_color"):x===2?(d.linear_gradient_idx=m.readVarint(),d.paint="linear_gradient_idx"):x===3?(d.radial_gradient_idx=m.readVarint(),d.paint="radial_gradient_idx"):x===5?m.readPackedFloat(d.dasharray):x===6?d.dashoffset=m.readFloat():x===7?d.miterlimit=m.readFloat():x===8?d.opacity=m.readVarint():x===9?d.width=m.readFloat():x===10?d.linecap=m.readVarint():x===11&&(d.linejoin=m.readVarint())}function Sht(x,d,m){x===1?d.transform=u7(m,m.readVarint()+m.pos):x===2?d.spread_method=m.readVarint():x===3?d.stops.push(wMe(m,m.readVarint()+m.pos)):x===4?d.x1=m.readFloat():x===5?d.y1=m.readFloat():x===6?d.x2=m.readFloat():x===7&&(d.y2=m.readFloat())}function wMe(x,d){return x.readFields(Cht,{offset:0,opacity:255,rgb_color:cfe},d)}function Cht(x,d,m){x===1?d.offset=m.readFloat():x===2?d.opacity=m.readVarint():x===3&&(d.rgb_color=h7(m.readVarint()))}function Mht(x,d,m){x===1?d.transform=u7(m,m.readVarint()+m.pos):x===2?d.spread_method=m.readVarint():x===3?d.stops.push(wMe(m,m.readVarint()+m.pos)):x===4?d.cx=m.readFloat():x===5?d.cy=m.readFloat():x===6?d.r=m.readFloat():x===7?d.fx=m.readFloat():x===8?d.fy=m.readFloat():x===9&&(d.fr=m.readFloat())}function Tht(x,d,m){x===1?d.transform=u7(m,m.readVarint()+m.pos):x===2?d.clip_path_idx=m.readVarint():x===3&&d.children.push(d7(m,m.readVarint()+m.pos))}function Aht(x,d,m){x===1?d.left=d.top=m.readFloat():x===2?d.width=d.height=m.readFloat():x===3?d.top=m.readFloat():x===4?d.height=m.readFloat():x===5?d.mask_type=m.readVarint():x===6?d.mask_idx=m.readVarint():x===7&&d.children.push(d7(m,m.readVarint()+m.pos))}class Eht{static calculate(d={},m=[]){const v=new Map,C=new Map;if(Object.keys(d).length===0)return v;m.forEach(E=>{C.set(E.name,E.rgb_color||new Ur(0,0,0))});for(const[E,P]of Object.entries(d))C.has(E)?v.set(C.get(E).toString(),P):console.warn(`Ignoring unknown image variable "${E}"`);return v}}function n5(x,d=255,m){const v=d/255,C=x.toString(),E=m.has(C)?m.get(C).clone():x.clone();return E.a*=v,E.toString()}function _P(x,d){if(!Km()){const m=document.createElement("canvas");return m.width=x,m.height=d,m}return new OffscreenCanvas(x,d)}let hfe,wP=null;function mfe(x,d,m,v,C){for(const E of v.children)jMe(x,d,m,E,C)}function jMe(x,d,m,v,C){v.group?(x.save(),function(E,P,R,$,G){const te=$.mask_idx!=null?R.masks[$.mask_idx]:null,se=$.clip_path_idx!=null?R.clip_paths[$.clip_path_idx]:null;if($.transform&&(P=a5($.transform).preMultiplySelf(P)),!function(he,Se,Fe){return he.opacity!==255||Se||Fe}($,se!=null,te!=null))return void mfe(E,P,R,$,G);const ae=_P(E.canvas.width,E.canvas.height),de=ae.getContext("2d");mfe(de,P,R,$,G),se&&AMe(de,P,R,se),te&&EMe(de,P,R,te,G),E.globalAlpha=$.opacity/255,E.drawImage(ae,0,0)}(x,d,m,v.group,C),x.restore()):v.path&&(x.save(),function(E,P,R,$,G){E.setTransform(P),$.paint_order===mht.PAINT_ORDER_FILL_AND_STROKE?(NMe(E,R,$,G),SMe(E,R,$,G)):(SMe(E,R,$,G),NMe(E,R,$,G))}(x,d,m,v.path,C),x.restore())}function NMe(x,d,m,v){const C=m.fill;if(!C)return;const E=C.opacity/255;switch(x.save(),x.beginPath(),PMe(m,x),C.paint){case"rgb_color":x.fillStyle=n5(C.rgb_color,C.opacity,v);break;case"linear_gradient_idx":{const P=d.linear_gradients[C.linear_gradient_idx];P.transform&&x.setTransform(a5(P.transform).preMultiplySelf(x.getTransform())),x.fillStyle=CMe(x,P,E,v);break}case"radial_gradient_idx":{const P=d.radial_gradients[C.radial_gradient_idx];P.transform&&x.setTransform(a5(P.transform).preMultiplySelf(x.getTransform())),x.fillStyle=MMe(x,P,E,v)}}x.fill(kMe(m)),x.restore()}function kMe(x){return x.rule===dfe.PATH_RULE_NON_ZERO?"nonzero":x.rule===dfe.PATH_RULE_EVEN_ODD?"evenodd":void 0}function SMe(x,d,m,v){const C=m.stroke;if(!C)return;const E=IMe(m);x.lineWidth=C.width,x.miterLimit=C.miterlimit,x.setLineDash(C.dasharray),x.lineDashOffset=C.dashoffset;const P=C.opacity/255;switch(C.paint){case"rgb_color":x.strokeStyle=n5(C.rgb_color,C.opacity,v);break;case"linear_gradient_idx":x.strokeStyle=CMe(x,d.linear_gradients[C.linear_gradient_idx],P,v,!0);break;case"radial_gradient_idx":x.strokeStyle=MMe(x,d.radial_gradients[C.radial_gradient_idx],P,v,!0)}switch(C.linejoin){case c7.LINE_JOIN_MITER_CLIP:case c7.LINE_JOIN_MITER:x.lineJoin="miter";break;case c7.LINE_JOIN_ROUND:x.lineJoin="round";break;case c7.LINE_JOIN_BEVEL:x.lineJoin="bevel"}switch(C.linecap){case ufe.LINE_CAP_BUTT:x.lineCap="butt";break;case ufe.LINE_CAP_ROUND:x.lineCap="round";break;case ufe.LINE_CAP_SQUARE:x.lineCap="square"}x.stroke(E)}function CMe(x,d,m,v,C=!1){if(d.stops.length===1){const ae=d.stops[0];return n5(ae.rgb_color,ae.opacity*m,v)}const{x1:E,y1:P,x2:R,y2:$}=d;let G=new DOMPoint(E,P),te=new DOMPoint(R,$);if(C){const ae=a5(d.transform);G=ae.transformPoint(G),te=ae.transformPoint(te)}const se=x.createLinearGradient(G.x,G.y,te.x,te.y);for(const ae of d.stops)se.addColorStop(ae.offset,n5(ae.rgb_color,ae.opacity*m,v));return se}function MMe(x,d,m,v,C=!1){if(d.stops.length===1){const Re=d.stops[0];return n5(Re.rgb_color,Re.opacity*m,v)}const E=a5(d.transform),{fx:P,fy:R,fr:$,cx:G,cy:te,r:se}=d;let ae=new DOMPoint(P,R),de=new DOMPoint(G,te),he=$,Se=se;if(C){ae=E.transformPoint(ae),de=E.transformPoint(de);const Re=(E.a+E.d)/2;he=$*Re,Se=d.r*Re}const Fe=x.createRadialGradient(ae.x,ae.y,he,de.x,de.y,Se);for(const Re of d.stops)Fe.addColorStop(Re.offset,n5(Re.rgb_color,Re.opacity*m,v));return Fe}function TMe(x,d,m,v){const C=v.transform?a5(v.transform).preMultiplySelf(d):d,E=_P(x.canvas.width,x.canvas.height),P=E.getContext("2d");for(const $ of v.children)if($.group)TMe(P,C,m,$.group);else if($.path){const G=$.path,te=new Path2D;te.addPath(IMe(G),C),P.fill(te,kMe(G))}const R=v.clip_path_idx!=null?m.clip_paths[v.clip_path_idx]:null;R&&AMe(P,C,m,R),x.globalCompositeOperation="source-over",x.drawImage(E,0,0)}function AMe(x,d,m,v){const C=_P(x.canvas.width,x.canvas.height);TMe(C.getContext("2d"),d,m,v),x.globalCompositeOperation="destination-in",x.drawImage(C,0,0)}function EMe(x,d,m,v,C){if(v.children.length===0)return;const E=v.mask_idx!=null?m.masks[v.mask_idx]:null;E&&EMe(x,d,m,E,C);const P=x.canvas.width,R=x.canvas.height,$=_P(P,R),G=$.getContext("2d"),te=v.width,se=v.height,ae=v.left,de=v.top,he=new Path2D,Se=new Path2D;Se.rect(ae,de,te,se),he.addPath(Se,d),G.clip(he);for(const Ke of v.children)jMe(G,d,m,Ke,C);const Fe=G.getImageData(0,0,P,R),Re=Fe.data;if(v.mask_type===vMe.MASK_TYPE_LUMINANCE)for(let Ke=0;Ked[P])return null}else{const R=1/v[P];let $=(x[P]-m[P])*R,G=(d[P]-m[P])*R;if($>G){const te=$;$=G,G=te}if($>C&&(C=$),GE)return null}return C}function OMe(x,d,m,v,C,E,P,R,$,G,te){const se=v-x,ae=C-d,de=E-m,he=P-x,Se=R-d,Fe=$-m,Re=te[1]*Fe-te[2]*Se,Ke=te[2]*he-te[0]*Fe,Xe=te[0]*Se-te[1]*he,lt=se*Re+ae*Ke+de*Xe;if(Math.abs(lt)<1e-15)return null;const kt=1/lt,vt=G[0]-x,At=G[1]-d,zt=G[2]-m,qt=(vt*Re+At*Ke+zt*Xe)*kt;if(qt<0||qt>1)return null;const ss=At*de-zt*ae,Gt=zt*se-vt*de,ds=vt*ae-At*se,js=(te[0]*ss+te[1]*Gt+te[2]*ds)*kt;return js<0||qt+js>1?null:(he*ss+Se*Gt+Fe*ds)*kt}function RMe(x,d,m){return(x-d)/(m-d)}function FMe(x,d,m,v,C,E,P,R,$){const G=1<{const Ke=Fe?1:0,Xe=(de+1)*Se-Ke,lt=he*Se,kt=(he+1)*Se-Ke;Re[0]=de*Se,Re[1]=lt,Re[2]=Xe,Re[3]=kt};let se=new LMe($);const ae=[];for(let de=0;de<$*$;de++){te(de%$,Math.floor(de/$),G,!1,ae);const he=Sb(ae[0],ae[1],E),Se=Sb(ae[2],ae[1],E),Fe=Sb(ae[2],ae[3],E),Re=Sb(ae[0],ae[3],E);se.minimums.push(Math.min(he,Se,Fe,Re)),se.maximums.push(Math.max(he,Se,Fe,Re)),se.leaves.push(1)}for(R.push(se),$/=2;$>=1;$/=2){const de=R[R.length-1];se=new LMe($);for(let he=0;he<$*$;he++){te(he%$,Math.floor(he/$),2,!0,ae);const Se=de.getElevation(ae[0],ae[1]),Fe=de.getElevation(ae[2],ae[1]),Re=de.getElevation(ae[2],ae[3]),Ke=de.getElevation(ae[0],ae[3]),Xe=de.isLeaf(ae[0],ae[1]),lt=de.isLeaf(ae[2],ae[1]),kt=de.isLeaf(ae[2],ae[3]),vt=de.isLeaf(ae[0],ae[3]),At=Math.min(Se.min,Fe.min,Re.min,Ke.min),zt=Math.max(Se.max,Fe.max,Re.max,Ke.max),qt=Xe&<&&kt&&vt;se.maximums.push(zt),se.minimums.push(At),se.leaves.push(zt-At<=5&&qt?1:0)}R.push(se)}return R}(this.dem),v=m.length-1,C=m[v];this._addNode(C.minimums[0],C.maximums[0],C.leaves[0]),this._construct(m,0,0,v,0)}raycastRoot(d,m,v,C,E,P,R=1){return DMe([d,m,-100],[v,C,this.maximums[0]*R],E,P)}raycast(d,m,v,C,E,P,R=1){if(!this.nodeCount)return null;const $=this.raycastRoot(d,m,v,C,E,P,R);if($==null)return null;const G=[],te=[],se=[],ae=[],de=[{idx:0,t:$,nodex:0,nodey:0,depth:0}];for(;de.length>0;){const{idx:he,t:Se,nodex:Fe,nodey:Re,depth:Ke}=de.pop();if(this.leaves[he]){FMe(Fe,Re,Ke,d,m,v,C,se,ae);const lt=1<=Bs[2])return Se}continue}let Xe=0;for(let lt=0;lt=G[te[zt]]&&(te.splice(zt,0,lt),At=!0);At||(te[Xe]=lt),Xe++}}for(let lt=0;lt=this.dim+1||m<-1||m>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(m+1)*this.stride+(d+1)}static pack(d,m){const v=[0,0,0,0],C=p7.getUnpackVector(m);let E=Math.floor((d+C[3])/C[2]);return v[2]=E%256,E=Math.floor(E/256),v[1]=E%256,E=Math.floor(E/256),v[0]=E,v}getPixels(){return new LCe({width:this.stride,height:this.stride},this.pixels)}backfillBorder(d,m,v){if(this.dim!==d.dim)throw new Error("dem dimension mismatch");let C=m*this.dim,E=m*this.dim+this.dim,P=v*this.dim,R=v*this.dim+this.dim;switch(m){case-1:C=E-1;break;case 1:E=C+1}switch(v){case-1:P=R-1;break;case 1:R=P+1}const $=-m*this.dim,G=-v*this.dim;for(let te=P;te=1;v--){const C=v===1?1:0,E=v===2?1:0;for(let P=0;P>>1^-(1&x[d]);return x}function Hht(x,d){switch(d){case"uint32":return x;case"uint16":for(let m=0;m>4|(61440&v)>>8|(240&C)<<4|61440&C,x[m+1]=15&v|(3840&v)>>4|(15&C)<<8|(3840&C)<<4}return x;case"uint8":for(let m=0;m>6|(192&C)>>4|(192&E)>>2|192&P,x[m+1]=(48&v)>>4|(48&C)>>2|48&E|(48&P)<<2,x[m+2]=(12&v)>>2|12&C|(12&E)<<2|(12&P)<<4,x[m+3]=3&v|(3&C)<<2|(3&E)<<4|(3&P)<<6}return x;default:throw new Error(`Invalid pixel format, "${d}"`)}}kr(p7,"DEMData"),kr(zMe,"DemMinMaxQuadTree",{omit:["dem"]});var Hp=Uint8Array,jP=Uint16Array,Wht=Int32Array,$Me=new Hp([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),qMe=new Hp([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ght=new Hp([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),UMe=function(x,d){for(var m=new jP(31),v=0;v<31;++v)m[v]=d+=1<>1|(21845&dc)<<1;WMe[dc]=((65280&(i5=(61680&(i5=(52428&i5)>>2|(13107&i5)<<2))>>4|(3855&i5)<<4))>>8|(255&i5)<<8)>>1}var NP=function(x,d,m){for(var v=x.length,C=0,E=new jP(d);C>$]=G;return P},kP=new Hp(288);for(dc=0;dc<144;++dc)kP[dc]=8;for(dc=144;dc<256;++dc)kP[dc]=9;for(dc=256;dc<280;++dc)kP[dc]=7;for(dc=280;dc<288;++dc)kP[dc]=8;var GMe=new Hp(32);for(dc=0;dc<32;++dc)GMe[dc]=5;var Yht=NP(kP,9),Xht=NP(GMe,5),ffe=function(x){for(var d=x[0],m=1;md&&(d=x[m]);return d},yg=function(x,d,m){var v=d/8|0;return(x[v]|x[v+1]<<8)>>(7&d)&m},xfe=function(x,d){var m=d/8|0;return(x[m]|x[m+1]<<8|x[m+2]<<16)>>(7&d)},Qht=["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"],vg=function(x,d,m){var v=new Error(d||Qht[x]);if(v.code=x,Error.captureStackTrace&&Error.captureStackTrace(v,vg),!m)throw v;return v},Jht=new Hp(0),emt=typeof TextDecoder<"u"&&new TextDecoder;try{emt.decode(Jht,{stream:!0})}catch{}const tmt={gzip_data:"gzip"};class Kf extends Error{constructor(d){super(d),this.name="MRTError"}}const smt={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},KMe={uint32:1,uint16:2,uint8:4},rmt={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let gfe;class f7{constructor(d=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=d}getLayer(d){const m=this.layers[d];if(!m)throw new Kf(`Layer '${d}' not found`);return m}getHeaderLength(d){const m=new Uint8Array(d),v=new DataView(d);if(m[0]!==13)throw new Kf("File is not a valid MRT.");return v.getUint32(1,!0)}parseHeader(d){const m=new Uint8Array(d),v=this.getHeaderLength(d);if(m.length= ${v} but got buffer of length ${m.length}`);const C=new gfe(m.subarray(0,v)).readFields(Dht,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==C.x||this.y!==C.y||this.z!==C.z))throw new Kf(`Invalid attempt to parse header ${C.z}/${C.x}/${C.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=C.x,this.y=C.y,this.z=C.z;for(const E of C.layers)this.layers[E.name]=new ZMe(E,{cacheSize:this._cacheSize});return this}createDecodingTask(d){const m=[],v=this.getLayer(d.layerName);for(let C of d.blockIndices){const E=v.dataIndex[C],P=E.firstByte-d.firstByte,R=E.lastByte-d.firstByte;if(v._blocksInProgress.has(C))continue;const $={layerName:v.name,firstByte:P,lastByte:R,pixelFormat:v.pixelFormat,blockIndex:C,blockShape:[E.bands.length].concat(v.bandShape),buffer:v.buffer,codec:E.codec.codec,filters:E.filters.map(G=>G.filter)};v._blocksInProgress.add(C),m.push($)}return new YMe(m,()=>{m.forEach(C=>v._blocksInProgress.delete(C.blockIndex))},(C,E)=>{if(m.forEach(P=>v._blocksInProgress.delete(P.blockIndex)),C)throw C;E.forEach(P=>{this.getLayer(P.layerName).processDecodedData(P)})})}}class ZMe{constructor({version:d,name:m,units:v,tileSize:C,pixelFormat:E,buffer:P,dataIndex:R},$){if(this.version=d,this.version!==1)throw new Kf(`Cannot parse raster layer encoded with MRT version ${d}`);this.name=m,this.units=v,this.tileSize=C,this.buffer=P,this.pixelFormat=smt[E],this.dataIndex=R,this.bandShape=[C+2*P,C+2*P,KMe[this.pixelFormat]],this._decodedBlocks=new m7($?$.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return KMe[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:d})=>d).flat()}processDecodedData(d){const m=d.blockIndex.toString();this._decodedBlocks.get(m)||this._decodedBlocks.put(m,d.data)}getBlockForBand(d){let m=0;switch(typeof d){case"string":for(const[v,C]of this.dataIndex.entries()){for(const[E,P]of C.bands.entries())if(P===d)return{bandIndex:m+E,blockIndex:v,blockBandIndex:E};m+=C.bands.length}break;case"number":for(const[v,C]of this.dataIndex.entries()){if(d>=m&&dthis.cacheSize)throw new Kf(`Number of blocks to decode (${E.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:m,lastByte:v,blockIndices:C}}hasBand(d){const{blockIndex:m}=this.getBlockForBand(d);return m>=0}hasDataForBand(d){const{blockIndex:m}=this.getBlockForBand(d);return m>=0&&!!this._decodedBlocks.get(m.toString())}getBandView(d){const{blockIndex:m,blockBandIndex:v}=this.getBlockForBand(d);if(m<0)throw new Kf(`Band not found: ${JSON.stringify(d)}`);const C=this._decodedBlocks.get(m.toString());if(!C)throw new Kf(`Data for band ${JSON.stringify(d)} of layer "${this.name}" not decoded.`);const E=this.dataIndex[m],P=this.bandShape.reduce((G,te)=>G*te,1),R=v*P,$=C.subarray(R,R+P);return{data:$,bytes:new Uint8Array($.buffer).subarray($.byteOffset,$.byteOffset+$.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:E.offset,scale:E.scale}}}f7.setPbf=function(x){gfe=x};class YMe{constructor(d,m,v){this.tasks=d,this._onCancel=m,this._onComplete=v,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(d,m){this._finalized||(this._onComplete(d,m),this._finalized=!0)}}f7.performDecoding=function(x,d){const m=new Uint8Array(x);return Promise.all(d.tasks.map(v=>{const{layerName:C,firstByte:E,lastByte:P,pixelFormat:R,blockShape:$,blockIndex:G,filters:te,codec:se}=v,ae=m.subarray(E,P+1),de=new Uint32Array($[0]*$[1]*$[2]);let he;if(se!=="gzip_data")throw new Kf(`Unhandled codec: ${se}`);return he=function(Se,Fe){if(!globalThis.DecompressionStream&&Fe==="gzip_data")return Promise.resolve(((lt=function(At){At[0]==31&&At[1]==139&&At[2]==8||vg(6,"invalid gzip data");var zt=At[3],qt=10;4&zt&&(qt+=2+(At[10]|At[11]<<8));for(var ss=(zt>>3&1)+(zt>>4&1);ss>0;ss-=!At[qt++]);return qt+(2&zt)}(Xe=Se))+8>Xe.length&&vg(6,"invalid gzip data"),function(At,zt,qt,ss){var Gt=At.length;if(!Gt||zt.f&&!zt.l)return qt||new Hp(0);var ds=!qt,js=ds||zt.i!=2,Ns=zt.i;ds&&(qt=new Hp(3*Gt));var Fs,Bs,Ls=function(Ei){var ri=qt.length;if(Ei>ri){var hi=new Hp(Math.max(2*ri,Ei));hi.set(qt),qt=hi}},Os=zt.f||0,ls=zt.p||0,rs=zt.b||0,Rs=zt.l,sr=zt.d,Vs=zt.m,zr=zt.n,mr=8*Gt;do{if(!Rs){Os=yg(At,ls,1);var _r=yg(At,ls+1,3);if(ls+=3,!_r){var Tr=At[(us=4+((ls+7)/8|0))-4]|At[us-3]<<8,ta=us+Tr;if(ta>Gt){Ns&&vg(0);break}js&&Ls(rs+Tr),qt.set(At.subarray(us,ta),rs),zt.b=rs+=Tr,zt.p=ls=8*ta,zt.f=Os;continue}if(_r==1)Rs=Yht,sr=Xht,Vs=9,zr=5;else if(_r==2){var Ks=yg(At,ls,31)+257,Ar=yg(At,ls+10,15)+4,_n=Ks+yg(At,ls+5,31)+1;ls+=14;for(var ja=new Hp(_n),Ca=new Hp(19),$n=0;$n>4)<16)ja[$n++]=us;else{var or=0,lr=0;for(us==16?(lr=3+yg(At,ls,3),ls+=2,or=ja[$n-1]):us==17?(lr=3+yg(At,ls,7),ls+=3):us==18&&(lr=11+yg(At,ls,127),ls+=7);lr--;)ja[$n++]=or}}var Br=ja.subarray(0,Ks),Vr=ja.subarray(Ks);Vs=ffe(Br),zr=ffe(Vr),Rs=NP(Br,Vs),sr=NP(Vr,zr)}else vg(1);if(ls>mr){Ns&&vg(0);break}}js&&Ls(rs+131072);for(var In=(1<>4;if((ls+=15&or)>mr){Ns&&vg(0);break}if(or||vg(2),xa<256)qt[rs++]=xa;else{if(xa==256){Qn=ls,Rs=null;break}var an=xa-254;xa>264&&(an=yg(At,ls,(1<<(Za=$Me[$n=xa-257]))-1)+HMe[$n],ls+=Za);var vn=sr[xfe(At,ls)&Kn],Va=vn>>4;if(vn||vg(3),ls+=15&vn,Vr=Zht[Va],Va>3){var Za=qMe[Va];Vr+=xfe(At,ls)&(1<mr){Ns&&vg(0);break}js&&Ls(rs+131072);var Ya=rs+an;if(rsFs.length)&&(Bs=Fs.length),new Hp(Fs.subarray(0,Bs))):qt.subarray(0,rs)}(Xe.subarray(lt,-8),{i:2},new Hp(((Re=Xe)[(Ke=Re.length)-4]|Re[Ke-3]<<8|Re[Ke-2]<<16|Re[Ke-1]<<24)>>>0))));var Re,Ke,Xe,lt;const kt=tmt[Fe];if(!kt)throw new Error(`Unhandled codec: ${Fe}`);const vt=new globalThis.DecompressionStream(kt);return new Response(new Blob([Se]).stream().pipeThrough(vt)).arrayBuffer().then(At=>new Uint8Array(At))}(ae,se).then(Se=>(function(Fe,Re){Fe.readFields($ht,Re)}(new gfe(Se),de),new rmt[R](de.buffer))),he.then(Se=>{for(let Fe=te.length-1;Fe>=0;Fe--)switch(te[Fe]){case"delta_filter":Uht(Se,$);break;case"zigzag_filter":Vht(Se);break;case"bitshuffle_filter":Hht(Se,R);break;default:throw new Kf(`Unhandled filter "${te[Fe]}"`)}return{layerName:C,blockIndex:G,data:Se}}).catch(Se=>{throw Se})}))},kr(YMe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),kr(f7,"MapboxRasterTile"),kr(ZMe,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class XMe{constructor(d){this._stringToNumber={},this._numberToString=[];for(let m=0;m=0&&ae[3]>=0&&G.insert($,ae[0],ae[1],ae[2],ae[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yt(new HF(this.rawTileData)).layers,this.sourceLayerCoder=new XMe(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const d in this.vtLayers)this.vtFeatures[d]=[]}return this.vtLayers}query(d,m){const{tilespaceGeometry:v,transform:C,tileTransform:E,pixelPosMatrix:P,availableImages:R,worldview:$}=m;this.loadVTLayers(),this.serializedLayersCache.clear();const G=m.queryRadius?m.queryRadius:0,te=v.bufferedTilespaceBounds,se=this.grid.query(te.min.x,te.min.y,te.max.x,te.max.y,(Se,Fe,Re,Ke)=>Bu(v.bufferedTilespaceGeometry,Se-G,Fe-G,Re+G,Ke+G));se.sort(nmt);let ae=null;C.elevation&&se.length>0&&(ae=r5.create(C.elevation,this.tileID));const de={};let he;for(let Se=0;Se(Ke||(Ke=Ot(Xe,this.tileID.canonical,E)),lt.queryIntersectsFeature(v,Xe,kt,Ke,this.z,C,P,ae,vt)))}return de}loadMatchingFeature(d,m,v,C,E,P){const{featureIndex:R,bucketIndex:$,sourceLayerIndex:G,layoutVertexArrayOffset:te}=m,se=this.bucketLayerIDs[$],ae=v.layers,de=Object.keys(ae);if(de.length&&!vr(de,se))return;const he=v.sourceCache,Se=this.sourceLayerCoder.decode(G),Fe=this.vtLayers[Se].feature(R),Re=this.getId(Fe,Se);for(let Ke=0;Ke`${R.key}: ${R.message}`).join(", ");return void xr(`Failed to create expression for promoteId: ${P}`)}this.promoteIdExpression=E.value}v=this.promoteIdExpression.evaluate({zoom:0},d)}else v=d.properties[C];typeof v=="boolean"&&(v=Number(v))}return v}}function JMe(x,d,m,v,C){return Xt(x,(E,P)=>{const R=d instanceof lv?d.get(P):null;return R&&R.evaluate?R.evaluate(m,v,void 0,C):R})}function nmt(x,d){return d-x}kr(QMe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const eTe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class yfe{static from(d){if(!(d instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[m,v]=new Uint8Array(d,0,2);if(m!==219)throw new Error("Data does not appear to be in a KDBush format.");const C=v>>4;if(C!==1)throw new Error(`Got v${C} data when expected v1.`);const E=eTe[15&v];if(!E)throw new Error("Unrecognized array type.");const[P]=new Uint16Array(d,2,1),[R]=new Uint32Array(d,4,1);return new yfe(R,P,E,d)}constructor(d,m=64,v=Float64Array,C){if(isNaN(d)||d<0)throw new Error(`Unpexpected numItems value: ${d}.`);this.numItems=+d,this.nodeSize=Math.min(Math.max(+m,2),65535),this.ArrayType=v,this.IndexArrayType=d<65536?Uint16Array:Uint32Array;const E=eTe.indexOf(this.ArrayType),P=2*d*this.ArrayType.BYTES_PER_ELEMENT,R=d*this.IndexArrayType.BYTES_PER_ELEMENT,$=(8-R%8)%8;if(E<0)throw new Error(`Unexpected typed array class: ${v}.`);C&&C instanceof ArrayBuffer?(this.data=C,this.ids=new this.IndexArrayType(this.data,8,d),this.coords=new this.ArrayType(this.data,8+R+$,2*d),this._pos=2*d,this._finished=!0):(this.data=new ArrayBuffer(8+P+R+$),this.ids=new this.IndexArrayType(this.data,8,d),this.coords=new this.ArrayType(this.data,8+R+$,2*d),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+E]),new Uint16Array(this.data,2,1)[0]=m,new Uint32Array(this.data,4,1)[0]=d)}add(d,m){const v=this._pos>>1;return this.ids[v]=v,this.coords[this._pos++]=d,this.coords[this._pos++]=m,v}finish(){const d=this._pos>>1;if(d!==this.numItems)throw new Error(`Added ${d} items when expected ${this.numItems}.`);return vfe(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(d,m,v,C){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:E,coords:P,nodeSize:R}=this,$=[0,E.length-1,0],G=[];for(;$.length;){const te=$.pop()||0,se=$.pop()||0,ae=$.pop()||0;if(se-ae<=R){for(let Fe=ae;Fe<=se;Fe++){const Re=P[2*Fe],Ke=P[2*Fe+1];Re>=d&&Re<=v&&Ke>=m&&Ke<=C&&G.push(E[Fe])}continue}const de=ae+se>>1,he=P[2*de],Se=P[2*de+1];he>=d&&he<=v&&Se>=m&&Se<=C&&G.push(E[de]),(te===0?d<=he:m<=Se)&&($.push(ae),$.push(de-1),$.push(1-te)),(te===0?v>=he:C>=Se)&&($.push(de+1),$.push(se),$.push(1-te))}return G}within(d,m,v){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:C,coords:E,nodeSize:P}=this,R=[0,C.length-1,0],$=[],G=v*v;for(;R.length;){const te=R.pop()||0,se=R.pop()||0,ae=R.pop()||0;if(se-ae<=P){for(let Fe=ae;Fe<=se;Fe++)sTe(E[2*Fe],E[2*Fe+1],d,m)<=G&&$.push(C[Fe]);continue}const de=ae+se>>1,he=E[2*de],Se=E[2*de+1];sTe(he,Se,d,m)<=G&&$.push(C[de]),(te===0?d-v<=he:m-v<=Se)&&(R.push(ae),R.push(de-1),R.push(1-te)),(te===0?d+v>=he:m+v>=Se)&&(R.push(de+1),R.push(se),R.push(1-te))}return $}}function vfe(x,d,m,v,C,E){if(C-v<=m)return;const P=v+C>>1;tTe(x,d,P,v,C,E),vfe(x,d,m,v,P-1,1-E),vfe(x,d,m,P+1,C,1-E)}function tTe(x,d,m,v,C,E){for(;C>v;){if(C-v>600){const G=C-v+1,te=m-v+1,se=Math.log(G),ae=.5*Math.exp(2*se/3),de=.5*Math.sqrt(se*ae*(G-ae)/G)*(te-G/2<0?-1:1);tTe(x,d,m,Math.max(v,Math.floor(m-te*ae/G+de)),Math.min(C,Math.floor(m+(G-te)*ae/G+de)),E)}const P=d[2*m+E];let R=v,$=C;for(SP(x,d,v,m),d[2*C+E]>P&&SP(x,d,v,C);R<$;){for(SP(x,d,R,$),R++,$--;d[2*R+E]P;)$--}d[2*v+E]===P?SP(x,d,v,$):($++,SP(x,d,$,C)),$<=m&&(v=$+1),m<=$&&(C=$-1)}}function SP(x,d,m,v){bfe(x,m,v),bfe(d,2*m,2*v),bfe(d,2*m+1,2*v+1)}function bfe(x,d,m){const v=x[d];x[d]=x[m],x[m]=v}function sTe(x,d,m,v){const C=x-m,E=d-v;return C*C+E*E}i.$=RC,i.A=Jx,i.B=$p,i.C=2,i.D=V3,i.E=As,i.F=oP,i.G=M5e,i.H=OC,i.I=Qs,i.J=oF,i.K=Fr,i.L=X1,i.M=o3,i.N=c2,i.O=KR,i.P=pt,i.Q=d2,i.R=Yx,i.S=g3,i.T=Mpe,i.U=Ay,i.V=o7,i.W=p6,i.X=sb,i.Y=tb,i.Z=r2,i._=Ru,i.a=function(x){return ua.API_CDN_URL_REGEX.test(x)},i.a$=_e,i.a0=yn,i.a1=ca,i.a2=Uf,i.a3=class extends o7{},i.a4=l3,i.a5=GR,i.a6=Kt,i.a7=function(x){const d=x.value;return d?yn(d)?afe(d,!0)?[]:[new o7(x.key,d,`invalid url "${d}"`)]:[new o7(x.key,d,`string expected, "${Fr(d)}" found`)]:[]},i.a8=rF,i.a9=Io,i.aA=je,i.aB=S,i.aC=Qe,i.aD=Ud,i.aE=Di,i.aF=W,i.aG=ot,i.aH=function(x,d){const m={};for(let v=0;v{v(E,P)},d):v(E,P),()=>{}}return C.callbacks.push(v),C.cancel||(C.cancel=m((E,P)=>{C.result=[E,P];for(const R of C.callbacks)this.scheduler?this.scheduler.add(()=>{R(E,P)},d):R(E,P);setTimeout(()=>delete this.entries[x],3e3)})),()=>{C.result||(C.callbacks=C.callbacks.filter(E=>E!==v),C.callbacks.length||(C.cancel(),delete this.entries[x]))}}},i.aL=function(x,d,m){const v=JSON.stringify(x.request);return x.data&&(this.deduped.entries[v]={result:[null,x.data]}),this.deduped.request(v,{type:"parseTile",isSymbolTile:x.isSymbolTile,zoom:x.tileZoom},C=>{const E=Lh(x.request,(P,R,$)=>{P?C(P):R&&C(null,{rawData:R,vectorTile:m?void 0:new Yt(new HF(R)),responseHeaders:new Map($.entries())})});return()=>{E.cancel(),C()}},d)},i.aM=function(x){return x?{cacheControl:x.get("Cache-Control"),expires:x.get("Expires")}:{cacheControl:void 0,expires:void 0}},i.aN=Al,i.aO=function(x){Sd++,Sd>W1&&(x.getActor().send("enforceCacheSizeLimit",H1),Sd=0)},i.aP=function(x){return x<=1?1:Math.pow(2,Math.floor(Math.log2(x)))},i.aQ=Co,i.aR=rMe,i.aS=cMe,i.aT=y,i.aU=sMe,i.aV=function(x,d){const m=document.createElement("video");m.muted=!0,m.onloadstart=function(){d(null,m)};for(let v=0;v{}}},i.aW=sP,i.aX=L2,i.aY=Ut,i.aZ=uP,i.a_=le,i.aa=Ys,i.ab=class{constructor(x){this.specification=x}possiblyEvaluate(x,d){return En(x.expression.evaluate(d))}interpolate(x,d,m){return{x:Zr(x.x,d.x,m),y:Zr(x.y,d.y,m),z:Zr(x.z,d.z,m),azimuthal:Zr(x.azimuthal,d.azimuthal,m),polar:Zr(x.polar,d.polar,m)}}},i.ac=Ki,i.ad=av,i.ae=st,i.af=ft,i.ag=ie,i.ah=$e,i.ai=lv,i.aj=_b,i.ak=Zr,i.al=tr,i.am=Q0,i.an=jr,i.ao=Ur,i.ap=class{constructor(x){this.specification=x}possiblyEvaluate(x,d){return function([m,v]){const C=En([1,m,v]);return{x:C.x,y:C.y,z:C.z}}(x.expression.evaluate(d))}interpolate(x,d,m){return{x:Zr(x.x,d.x,m),y:Zr(x.y,d.y,m),z:Zr(x.z,d.z,m)}}},i.aq=function(x,d,m=0,v=!0){const C=new pt(m,m),E=x.sub(C),P=d.add(C),R=[E,new pt(P.x,E.y),P,new pt(E.x,P.y)];return v&&R.push(E.clone()),R},i.ar=function(x,d){const m=[];for(let v=0;v1)return!1;const m=d.getSource().maxzoom,v=1<1)return d;const C=v.getSource().maxzoom,E=1<{const R=this.getAtTileOffset(x,C,E,P),$=v.upVector(x.canonical,C.x,C.y);return be($,$,R*v.upVectorScale(x.canonical,d,m).metersToTile),$}}getForTilePoints(x,d,m,v){if(this.isUsingMockSource())return!1;const C=r5.create(this,x,v);return!!C&&(d.forEach(E=>{E[2]=this.exaggeration()*C.getElevationAt(E[0],E[1],m)}),!0)}getMinMaxForTile(x){if(this.isUsingMockSource())return null;const d=this.findDEMTileFor(x);if(!d||!d.dem)return null;const m=d.dem.tree,v=d.tileID,C=1<0&&(v+=(x[C]-0)*(x[C]-0)),d[C]<0&&(v+=(0-d[C])*(0-d[C]));return v},i.c0=r3e,i.c1=Upe,i.c2=D5e,i.c3=Xpe,i.c4=yfe,i.c5=be,i.c6=Ge,i.c7=Je,i.c8=function(x,d,m){m*=.5;var v=d[0],C=d[1],E=d[2],P=d[3],R=Math.sin(m),$=Math.cos(m);return x[0]=v*$+C*R,x[1]=C*$-v*R,x[2]=E*$+P*R,x[3]=P*$-E*R,x},i.c9=it,i.cA=ee,i.cB=si,i.cC=$3e,i.cD=Oi,i.cE=yCe,i.cF=function(x,d,m,v,C,E,P,R,$){if($.name==="globe")return yCe(x,d,new Oi(m,v,C),!1);const G=uP({z:m,x:v,y:C},$);return new Or([(E+G.x/G.scale)*d,d*(G.y/G.scale),P],[(E+G.x2/G.scale)*d,d*(G.y2/G.scale),R])},i.cG=function(x,d,m){return x[0]=Math.min(d[0],m[0]),x[1]=Math.min(d[1],m[1]),x[2]=Math.min(d[2],m[2]),x[3]=Math.min(d[3],m[3]),x},i.cH=function(x,d,m){return x[0]=Math.max(d[0],m[0]),x[1]=Math.max(d[1],m[1]),x[2]=Math.max(d[2],m[2]),x[3]=Math.max(d[3],m[3]),x},i.cI=function(x){const d=Math.round((x+45+360)%360/90)%4;return Pa[d]},i.cJ=we,i.cK=qe,i.cL=$3,i.cM=function(x){const d=w(new Float64Array(16));S(d,x.pixelMatrix,x.globeMatrix);const m=[0,rp,0],v=[0,np,0];return ft(m,m,d),ft(v,v,d),[m[0]>0&&m[0]<=x.width&&m[1]>0&&m[1]<=x.height&&!ape(x,new y(x.center.lat,90)),v[0]>0&&v[0]<=x.width&&v[1]>0&&v[1]<=x.height&&!ape(x,new y(x.center.lat,-90))]},i.cN=function(x,d){const{scale:m}=x.tileTransform,v=m*tr/(x.tileSize*Math.pow(2,d.zoom-x.tileID.overscaledZ+x.tileID.canonical.z));return function(C,E,P){var R=E[1],$=E[2],G=E[3],te=P[0],se=P[1];return C[0]=E[0]*te,C[1]=R*te,C[2]=$*se,C[3]=G*se,C}(new Float32Array(4),d.inverseAdjustmentMatrix,[v,v])},i.cO=zF,i.cP=X,i.cQ=B3e,i.cR=function(x){const d=B3e(x,!0);return p([],[d[0],d[1],d[4],d[5]])},i.cS=L,i.cT=hr,i.cU=I,i.cV=function(x){const{x:d,y:m}=x.point,{lng:v,lat:C}=x._center;return _Ce(d,m,x.worldSize,v,C)},i.cW=ge,i.cX=ea,i.cY=wo,i.cZ=Md,i.c_=sp,i.ca=ti,i.cb=function(x,d){return x[0]=-d[0],x[1]=-d[1],x[2]=-d[2],x[3]=d[3],x},i.cc=Z,i.cd=function(x,d,m,v,C){var E=1/Math.tan(d/2);if(x[0]=E/m,x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=E,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[11]=-1,x[12]=0,x[13]=0,x[15]=0,C!=null&&C!==1/0){var P=1/(v-C);x[10]=(C+v)*P,x[14]=2*C*v*P}else x[10]=-1,x[14]=-2*v;return x},i.ce=function(x,d,m,v,C,E,P){var R=1/(d-m),$=1/(v-C),G=1/(E-P);return x[0]=-2*R,x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=-2*$,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=2*G,x[11]=0,x[12]=(d+m)*R,x[13]=(C+v)*$,x[14]=(P+E)*G,x[15]=1,x},i.cf=ne,i.cg=function(x,d,m){x[4*d+0]=m[0],x[4*d+1]=m[1],x[4*d+2]=m[2],x[4*d+3]=m[3]},i.ch=R3,i.ci=v2,i.cj=$l,i.ck=Wf,i.cl=_2,i.cm=W5e,i.cn=function(){var x=new u(4);return u!=Float32Array&&(x[1]=0,x[2]=0),x[0]=1,x[3]=1,x},i.co=function(x,d,m){var v=d[0],C=d[1],E=d[2],P=d[3],R=Math.sin(m),$=Math.cos(m);return x[0]=v*$+E*R,x[1]=C*$+P*R,x[2]=v*-R+E*$,x[3]=C*-R+P*$,x},i.cp=function(x,d){return x[0]===d[0]&&x[1]===d[1]&&x[2]===d[2]&&x[3]===d[3]},i.cq=et,i.cr=function(x){var d=x[0],m=x[1],v=x[2],C=x[3];return Math.sqrt(d*d+m*m+v*v+C*C)},i.cs=Cs,i.ct=Ve,i.cu=ml,i.cv=3,i.cw=2,i.cx=7,i.cy=6,i.cz=Ae,i.d=function(x){return ua.API_TILEJSON_REGEX.test(x)},i.d$=class{constructor(x,d,m,v){this.context=x,this.format=v,this.size=m,this.texture=x.gl.createTexture();const[C,E,P]=this.size,{gl:R}=x;R.bindTexture(R.TEXTURE_3D,this.texture),x.pixelStoreUnpackFlipY.set(!1),x.pixelStoreUnpack.set(1),x.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in d&&d.data&&R.texImage3D(R.TEXTURE_3D,0,this.format,C,E,P,0,Spe(this.format),Cpe(this.format),d.data)}bind(x,d){const{context:m}=this,{gl:v}=m;v.bindTexture(v.TEXTURE_3D,this.texture),x!==this.minFilter&&(v.texParameteri(v.TEXTURE_3D,v.TEXTURE_MAG_FILTER,x),v.texParameteri(v.TEXTURE_3D,v.TEXTURE_MIN_FILTER,x),this.minFilter=x),d!==this.wrapS&&(v.texParameteri(v.TEXTURE_3D,v.TEXTURE_WRAP_S,d),v.texParameteri(v.TEXTURE_3D,v.TEXTURE_WRAP_T,d),this.wrapS=d)}destroy(){const{gl:x}=this.context;x.deleteTexture(this.texture),this.texture=null}},i.d0=function(x){return x*x*x*x*x},i.d1=z,i.d2=45,i.d3=F3,i.d4=function(x,d,m){const v=Math.sqrt(x*x+d*d+m*m),C=v>0?Math.acos(m/v)*Sr:0;let E=x!==0||d!==0?Math.atan2(-d,-x)*Sr+90:0;return E<0&&(E+=360),[v,E,C]},i.d5=re,i.d6=En,i.d7=Ue,i.d8=ce,i.d9=Or,i.dA=function(x){return x({pluginStatus:Fu,pluginURL:ag}),f3.on("pluginStateChange",x),x},i.dB=b2,i.dC=class extends lg{constructor(x){super(x),this.current=z3}set(x,d,m){if(this.fetchUniformLocation(x,d)){for(let v=0;v<9;v++)if(m[v]!==this.current[v]){this.current=m,this.gl.uniformMatrix3fv(this.location,!1,m);break}}}},i.dD=Ii,i.dE=function(x,d,m){const v=_b(m.zoom),C=x.style.map._antialias,E=x.terrain&&x.terrain.exaggeration()>0;return v===0&&!C&&!E},i.dF=function(x){const d=x.pixelsPerMeter,m=d/ne(1,x.center.lat),v=w(new Float64Array(16));return M(v,v,[x.point.x,x.point.y,0]),L(v,v,[m,m,d]),Float32Array.from(v)},i.dG=jF,i.dH=function(x){const d=we-5;x=je(x,-d,d)/d*90;const m=Math.pow(Math.abs(Math.sin(jr(x))),3);return Math.round(m*(z6.length-1))},i.dI=function(x,d,m,v){const C=d.getNorth(),E=d.getSouth(),P=d.getWest(),R=d.getEast(),$=1<0){const he=180/v;b(de,de,[he/G+1,0,0,0,he/te+1,0,-.5*he/se,.5*he/ae,1])}return de[2]=$,de[5]=x.x,de[8]=x.y,de},i.dJ=Vp,i.dK=function(x,d,m){const v=w(new Float64Array(16)),C=(d/(1<({u_matrix:new _2(x),u_texsize:new Wf(x),u_pixels_to_tile_units:new B3(x),u_device_pixel_ratio:new $l(x),u_width_scale:new $l(x),u_floor_width_scale:new $l(x),u_image:new R3(x),u_units_to_pixels:new Wf(x),u_tile_units_to_pixels:new $l(x),u_alpha_discard_threshold:new $l(x),u_trim_offset:new Wf(x),u_trim_fade_range:new Wf(x),u_trim_color:new F3(x),u_zbias_factor:new $l(x),u_tile_to_meter:new $l(x),u_ground_shadow_factor:new v2(x),u_pattern_transition:new $l(x)}),i.dX=x=>({u_matrix:new _2(x),u_pixels_to_tile_units:new B3(x),u_device_pixel_ratio:new $l(x),u_width_scale:new $l(x),u_floor_width_scale:new $l(x),u_units_to_pixels:new Wf(x),u_dash_image:new R3(x),u_gradient_image:new R3(x),u_image_height:new $l(x),u_texsize:new Wf(x),u_tile_units_to_pixels:new $l(x),u_alpha_discard_threshold:new $l(x),u_trim_offset:new Wf(x),u_trim_fade_range:new Wf(x),u_trim_color:new F3(x),u_zbias_factor:new $l(x),u_tile_to_meter:new $l(x),u_ground_shadow_factor:new v2(x)}),i.dY=x=>({u_camera_to_center_distance:new $l(x),u_extrude_scale:new B3(x),u_device_pixel_ratio:new $l(x),u_matrix:new _2(x),u_inv_rot_matrix:new _2(x),u_merc_center:new Wf(x),u_tile_id:new v2(x),u_zoom_transition:new $l(x),u_up_dir:new v2(x),u_emissive_strength:new $l(x)}),i.dZ=M3,i.d_=fut,i.da=xe,i.db=function(x){return[Math.pow(x[0],1/2.2),Math.pow(x[1],1/2.2),Math.pow(x[2],1/2.2)]},i.dc=z3e,i.dd=Lpe,i.de=V3e,i.df=afe,i.dg=function(x,d){return x.readFields(pht,{icons:[]},d)},i.dh=DF,i.di=J3,i.dj=Kpe,i.dk=G1,i.dl=m2,i.dm=yy,i.dn=K1,i.dp=gs,i.dq=function(x){const d=x.indexOf(uv);return d>=0?x.slice(0,d):x},i.dr=function(x){return x.indexOf(uv)>=0},i.ds=function(x){const d=x.lastIndexOf(uv);return d>=0?x.slice(d+1):""},i.dt=function(x){const d=[],m=x.id;return m===void 0&&d.push({message:`layers.${m}: missing required property "id"`}),x.render===void 0&&d.push({message:`layers.${m}: missing required method "render"`}),x.renderingMode&&x.renderingMode!=="2d"&&x.renderingMode!=="3d"&&d.push({message:`layers.${m}: property "renderingMode" must be either "2d" or "3d"`}),d},i.du=function(x,d,m,v){return x.type==="custom"?new oht(x,d):new hht[x.type](x,d,m,v)},i.dv=Ps,i.dw=function(x){const d=x.indexOf(uv);return d>=0?x.slice(d+1):""},i.dx=class extends I2{constructor(x,d){super(x._vectorTileFeature,x._z,x._x,x._y,x.id),x.state&&(this.state=Object.assign({},x.state)),this.target=d.target,this.namespace=d.namespace,d.properties&&(this.properties=d.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=x.source,this.sourceLayer=x.sourceLayer,this.layer=x.layer)}toJSON(){const x=super.toJSON();return x.target=this.target,x.namespace=this.namespace,x}},i.dy=f3,i.dz=Xx,i.e=ua,i.e$=oe,i.e0=NCe,i.e1=(x,d,m,v,C,E)=>{const P=x.transform,R=P.projection.name==="globe";let $;if(E.paint.get("circle-pitch-alignment")==="map")if(R){const te=bCe(P.zoom,d.canonical)*P._pixelsPerMercatorPixel;$=Float32Array.from([te,0,0,te])}else $=P.calculatePixelsToTileUnitsMatrix(m);else $=new Float32Array([P.pixelsToGLUnits[0],0,0,P.pixelsToGLUnits[1]]);const G={u_camera_to_center_distance:x.transform.getCameraToCenterDistance(P.projection),u_matrix:x.translatePosMatrix(d.projMatrix,m,E.paint.get("circle-translate"),E.paint.get("circle-translate-anchor")),u_device_pixel_ratio:zl.devicePixelRatio,u_extrude_scale:$,u_inv_rot_matrix:Ect,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:E.paint.get("circle-emissive-strength")};if(R){G.u_inv_rot_matrix=v,G.u_merc_center=C,G.u_tile_id=[d.canonical.x,d.canonical.y,1<{const te=x.transform,se=te.pitch<15?r5e(.07,.7,je((14-te.zoom)/5,0,1)):.07,ae=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:a5e(x,d,m,v),u_texsize:d.imageAtlasTexture?d.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:te.calculatePixelsToTileUnitsMatrix(d),u_device_pixel_ratio:C,u_width_scale:E,u_floor_width_scale:P,u_image:0,u_tile_units_to_pixels:n5e(d,te),u_units_to_pixels:[1/te.pixelsToGLUnits[0],1/te.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:R,u_trim_fade_range:m.paint.get("line-trim-fade-range"),u_trim_color:m.paint.get("line-trim-color").toPremultipliedRenderColor(ae?null:m.lut).toArray01(),u_zbias_factor:se,u_tile_to_meter:Ue(d.tileID.canonical,0),u_ground_shadow_factor:$,u_pattern_transition:G}},i.e5=(x,d,m,v,C,E,P,R,$,G)=>{const te=x.transform,se=te.calculatePixelsToTileUnitsMatrix(d),ae=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none",de=te.pitch<15?r5e(.07,.7,je((14-te.zoom)/5,0,1)):.07;return{u_matrix:a5e(x,d,m,v),u_pixels_to_tile_units:se,u_device_pixel_ratio:E,u_width_scale:P,u_floor_width_scale:R,u_units_to_pixels:[1/te.pixelsToGLUnits[0],1/te.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:C,u_texsize:o5e(m)&&d.lineAtlasTexture?d.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:n5e(d,x.transform),u_alpha_discard_threshold:0,u_trim_offset:$,u_trim_fade_range:m.paint.get("line-trim-fade-range"),u_trim_color:m.paint.get("line-trim-color").toPremultipliedRenderColor(ae?null:m.lut).toArray01(),u_zbias_factor:de,u_tile_to_meter:Ue(d.tileID.canonical,0),u_ground_shadow_factor:G}},i.e6=Zt,i.e7=$6,i.e8=ye,i.e9=ip,i.eA=function(x,d){var m=2*Math.acos(d[3]),v=Math.sin(m/2);return v>c?(x[0]=d[0]/v,x[1]=d[1]/v,x[2]=d[2]/v):(x[0]=1,x[1]=0,x[2]=0),m},i.eB=lfe,i.eC=qF,i.eD=$F,i.eE=[1,1,1],i.eF=r5,i.eG=ct,i.eH=function(x,d,m,v){var C=d[0],E=d[1],P=d[2],R=d[3];return x[0]=C+v*(m[0]-C),x[1]=E+v*(m[1]-E),x[2]=P+v*(m[2]-P),x[3]=R+v*(m[3]-R),x},i.eI=K3,i.eJ=um,i.eK=Hf,i.eL=function(x,d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se){var Fe=new u(16);return Fe[0]=x,Fe[1]=d,Fe[2]=m,Fe[3]=v,Fe[4]=C,Fe[5]=E,Fe[6]=P,Fe[7]=R,Fe[8]=$,Fe[9]=G,Fe[10]=te,Fe[11]=se,Fe[12]=ae,Fe[13]=de,Fe[14]=he,Fe[15]=Se,Fe},i.eM=T,i.eN=fb,i.eO=T6,i.eP=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new pt(1/0,1/0),max:new pt(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(x,d=!1){const m=e3e(new pt(0,0),new pt(tr,tr),x),v=[];if(d&&!ppe(m,this._globalClipBounds))return v;for(const C of this._activeRegions){if(C.hiddenByOverlap||!ppe(m,C))continue;const E=idt(C.min,C.max,x);v.push({min:E.min,max:E.max,sourceId:this._sourceIds[C.priority],footprint:C.footprint,footprintTileId:C.tileId,order:C.order,clipMask:C.clipMask,clipScope:C.clipScope})}return v}setSources(x){this._setSources(x.map(d=>({getSourceId:()=>d.cache.id,getFootprints:()=>{const m=[];for(const v of d.cache.getVisibleCoordinates()){const C=d.cache.getTile(v).buckets[d.layer];C&&C.updateFootprints(v.toUnwrapped(),m)}return m},getOrder:()=>d.order,getClipMask:()=>d.clipMask,getClipScope:()=>d.clipScope})))}_addSource(x){const d=x.getFootprints();if(d.length===0)return;const m=x.getOrder(),v=x.getClipMask(),C=x.getClipScope();for(const E of d){if(!E.footprint)continue;const P=e3e(E.footprint.min,E.footprint.max,E.id);this._activeRegions.push({min:P.min,max:P.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:E.id,footprint:E.footprint,order:m,clipMask:v,clipScope:C})}this._sourceIds.push(x.getSourceId())}_computeReplacement(){this._activeRegions.sort((d,m)=>d.priority-m.priority||AF(d.min,m.min)||AF(d.max,m.max)||d.order-m.order||d.clipMask-m.clipMask||function(v,C){const E=(P,R)=>P+R;return v.length-C.length||v.reduce(E,"").localeCompare(C.reduce(E,""))}(d.clipScope,m.clipScope));let x=this._activeRegions.length!==this._prevRegions.length;if(!x){let d=0;for(;!x&&d!==this._activeRegions.length;){const m=this._activeRegions[d],v=this._prevRegions[d];x=m.priority!==v.priority||!JCe(m,v)||m.order!==v.order||m.clipMask!==v.clipMask||!ir(m.clipScope,v.clipScope),this._activeRegions[d].hiddenByOverlap=v.hiddenByOverlap,++d}}if(x){++this._updateTime;for(const m of this._activeRegions)m.order!==G6&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,m.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,m.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,m.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,m.max.y));const d=m=>{const v=this._activeRegions;if(m>=v.length)return m;const C=v[m].priority;for(;m1){let m=0,v=d(m);for(;m!==v;){let C=m;const E=m;for(;C!==v;){const P=this._activeRegions[C];P.hiddenByOverlap=!1;for(let R=0;R=0;d--)this._addSource(x[d]);this._computeReplacement()}},i.eQ=G6,i.eR=class{constructor(x){this._createGrid(x),this._createPoles(x)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const x of this._poleSegments)x.destroy();for(const x of this._gridSegments)x.withSkirts.destroy(),x.withoutSkirts.destroy()}_fillGridMeshWithLods(x,d){const m=new Py,v=new Bl,C=[],E=x+1+2,P=d[0]+1,R=d[0]+1+(1+d.length),$=(G,te,se)=>{let ae=G===E-1?G-2:G===0?G:G-1;return ae+=se?24575:0,[ae,te]};for(let G=0;G0?(Fe=2*Math.sqrt(Se+1),x[3]=.25*Fe,x[0]=(se-de)/Fe,x[1]=(ae-$)/Fe,x[2]=(R-G)/Fe):P>te&&P>he?(Fe=2*Math.sqrt(1+P-te-he),x[3]=(se-de)/Fe,x[0]=.25*Fe,x[1]=(R+G)/Fe,x[2]=(ae+$)/Fe):te>he?(Fe=2*Math.sqrt(1+te-P-he),x[3]=(ae-$)/Fe,x[0]=(R+G)/Fe,x[1]=.25*Fe,x[2]=(se+de)/Fe):(Fe=2*Math.sqrt(1+he-P-te),x[3]=(R-G)/Fe,x[0]=(ae+$)/Fe,x[1]=(se+de)/Fe,x[2]=.25*Fe),x},i.f=function(x){return btoa(encodeURIComponent(x).replace(/%([0-9A-F]{2})/g,(d,m)=>String.fromCharCode(+("0x"+m))))},i.f0=function([x,d,m]){const v=Math.hypot(x,d,m),C=Math.atan2(x,m),E=.5*Math.PI-Math.acos(-d/v);return new y(ea(C),ea(E))},i.f1=Ze,i.f2=Tpe,i.f3=function(x){const d=x.navigator?x.navigator.userAgent:null;return!!function(m){if(il==null){const v=m.navigator?m.navigator.userAgent:null;il=!!m.safari||!(!v||!(/\b(iPad|iPhone|iPod)\b/.test(v)||v.match("Safari")&&!v.match("Chrome")))}return il}(x)&&!(!d||!(d.match("Version/15.4")||d.match("Version/15.5")||d.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/)))},i.f4=function(x,d){H1=x,W1=d},i.f5=ape,i.f6=wCe,i.f7=function(x){const d=[0,0,0],m=w(new Float64Array(16));return S(m,x.pixelMatrix,x.globeMatrix),ft(d,d,m),new pt(d[0],d[1])},i.f8=function(){const x=J6;x&&(x.isPreloaded()&&x.numActive()===1?(x.release(bpe),J6=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},i.f9=function(){DF().acquire(bpe)},i.fA=p7,i.fB=Ht,i.fC=function(x){let d=0;if(new Uint32Array(x,0,1)[0]!==L3e){const m=new Uint32Array(x,0,7),[,,v,C,E,P]=m;d=m.byteLength+C+E+P+E,(v!==x.byteLength||d>=x.byteLength)&&xr("Invalid b3dm header information.")}return F3e(x,d)},i.fD=function(x,d){const m=Lpe(x);for(const v of m){for(const C of v.meshes)Rdt(C);v.lights&&(v.lightMeshIndex=v.meshes.length,v.meshes.push(Fdt(v.lights,d)))}return m},i.fE=l7,i.fF=_a,i.fG=T3e,i.fH=ig,i.fI=Dh,i.fJ=function(x){$d(),am!=null&&am.then(d=>{d.keys().then(m=>{for(let v=0;vxr(C.message))}).catch(m=>xr(m.message))}).catch(d=>xr(d.message))},i.fa=p2,i.fb=function(x,d,m=!1){if(Fu===Dh.deferred||Fu===Dh.loading||Fu===Dh.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");ag=zl.resolveURL(x),Fu=Dh.deferred,y6=d,p3(),m||sF()},i.fc=function(x){H3=zl.resolveURL(x),W3||(W3=new V3(DF(),new As)),W3.broadcast("setMeshoptUrl",H3)},i.fd=P3e,i.fe=function(x){jpe=zl.resolveURL(x),W3||(W3=new V3(DF(),new As)),W3.broadcast("setDracoUrl",jpe)},i.ff=E3e,i.fg=Q6,i.fh=function(x){const d=im();if(!d)return;const m=d.delete(V1);x&&m.then(()=>x()).catch(x)},i.fi=M2,i.fj=kr,i.fk=wb,i.fl=gg,i.fm=XMe,i.fn=QMe,i.fo=J3e,i.fp=as,i.fq="hd_road_elevation",i.fr=di,i.fs=Xt,i.ft=fv,i.fu=Gpe,i.fv=E2,i.fw=function(x,d,m,v,C,E,P,R=1,$,G,te){x.createArrays(),x.tilePixelRatio=tr/(512*x.overscaling),x.compareText={},x.iconsNeedLinear=!1;const se=x.layers[0].layout,ae=x.layers[0]._unevaluatedLayout._values,de={};de.scaleFactor=R,de.textSizeScaleRange=se.get("text-size-scale-range"),de.iconSizeScaleRange=se.get("icon-size-scale-range");const[he,Se]=de.textSizeScaleRange,[Fe,Re]=de.iconSizeScaleRange;de.textScaleFactor=je(de.scaleFactor,he,Se),de.iconScaleFactor=je(de.scaleFactor,Fe,Re);const Ke=ae["text-size"],Xe=ae["icon-size"];if(x.textSizeData.kind==="composite"){const{minZoom:qt,maxZoom:ss}=x.textSizeData;de.compositeTextSizes=[Ke.possiblyEvaluate(new Ki(qt,{worldview:te}),E),Ke.possiblyEvaluate(new Ki(ss,{worldview:te}),E)]}if(x.iconSizeData.kind==="composite"){const{minZoom:qt,maxZoom:ss}=x.iconSizeData;de.compositeIconSizes=[Xe.possiblyEvaluate(new Ki(qt,{worldview:te}),E),Xe.possiblyEvaluate(new Ki(ss,{worldview:te}),E)]}de.layoutTextSize=Ke.possiblyEvaluate(new Ki(P+1,{worldview:te}),E),de.layoutIconSize=Xe.possiblyEvaluate(new Ki(P+1,{worldview:te}),E),de.textMaxSize=Ke.possiblyEvaluate(new Ki(18,{worldview:te}),E);const lt=se.get("symbol-placement"),kt=se.get("text-rotation-alignment")==="map"&<!=="point",vt=se.get("text-size");let At=!1;const zt=[];for(const qt of x.features){const ss=se.get("text-font").evaluate(qt,{},E).join(","),Gt=vt.evaluate(qt,{},E)*de.textScaleFactor,ds=de.layoutTextSize.evaluate(qt,{},E)*de.textScaleFactor,js=de.layoutIconSize.evaluate(qt,{},E)*de.iconScaleFactor,Ns={horizontal:{},vertical:void 0},Fs=qt.text;let Bs,Ls=[0,0];if(Fs){const $n=Fs.toString(),Ai=se.get("text-letter-spacing").evaluate(qt,{},E)*Ac,_t=se.get("text-line-height").evaluate(qt,{},E)*Ac,Ct=x6($n)?Ai:0,us=se.get("text-anchor").evaluate(qt,{},E),zs=se.get("text-variable-anchor");if(!zs){const In=se.get("text-radial-offset").evaluate(qt,{},E);if(In)Ls=D5e(us,[In*Ac,Ype]);else{const Kn=se.get("text-offset").evaluate(qt,{},E);Ls=[Kn[0]*Ac,Kn[1]*Ac]}}let or=kt?"center":se.get("text-justify").evaluate(qt,{},E);const lr=lt==="point",Br=lr?se.get("text-max-width").evaluate(qt,{},E)*Ac:1/0,Vr=In=>{x.allowVerticalPlacement&&h2($n)&&(Ns.vertical=qpe(Fs,d,m,C,ss,Br,_t,us,In,Ct,Ls,pm.vertical,!0,ds,Gt,$))};if(!kt&&zs){const In=or==="auto"?zs.map(Qn=>Xpe(Qn)):[or];let Kn=!1;for(let Qn=0;Qn=0||!h2($n)){const In=qpe(Fs,d,m,C,ss,Br,_t,us,or,Ct,Ls,pm.horizontal,!1,ds,Gt,$);In&&(Ns.horizontal[or]=In)}Vr(lr?"left":or)}}let Os,ls,rs,Rs,sr,Vs,zr=!1;const mr=se.get("icon-text-fit").evaluate(qt,{},E);if(qt.icon&&qt.icon.hasPrimary()){const $n=cP(qt.icon,x.iconSizeData,ae["icon-size"],E,x.zoom,qt,$,de.iconScaleFactor,te);Os=$n.iconPrimary,rs=$n.iconSecondary;const Ai=Os.toString();if(ls=v.get(Ai),ls&&(sr=se.get("icon-offset").evaluate(qt,{},E),Vs=se.get("icon-anchor").evaluate(qt,{},E),Bs=GF(C.get(Ai),rs?C.get(rs.toString()):void 0,sr,Vs),zr=ls.sdf,x.sdfIcons===void 0?x.sdfIcons=ls.sdf:x.sdfIcons!==ls.sdf&&xr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(ls.pixelRatio!==x.pixelRatio||se.get("icon-rotate").constantOr(1)!==0)&&(x.iconsNeedLinear=!0)),rs){const _t=rs.toString();Rs=v.get(_t)}}At=At||!(!qt.icon||!qt.icon.hasSecondary());const _r=QF(Ns.horizontal)||Ns.vertical;x.iconsInText||(x.iconsInText=!!_r&&_r.iconsInText);const Tr=ds*de.textScaleFactor/Ac,{defaultShapedIcon:ta,verticallyShapedIcon:Ks}=Wut(x,Bs,se,qt,E,Ns,Tr,sr,mr);mr!=="none"&&Bs&&(b5e(Bs)||_5e(Bs))&&(XF(0,ls,Os,Bs,ta,mr,G,v,C),XF(0,Rs,rs,Bs,ta,mr,G,v,C),Ks&&(XF(0,ls,Os,Bs,Ks,mr,G,v,C),XF(0,Rs,rs,Bs,Ks,mr,G,v,C))),Bs=ta;const{iconBBox:Ar,iconVerticalBBox:_n,textBBox:ja,textVerticalBBox:Ca}=$ut(x,Bs,Ks,se,qt,E,js,sr,de,C,Vs,Ns,ds,Ls);zt.push({feature:qt,shapedTextOrientations:Ns,shapedText:_r,shapedIcon:Bs,iconPrimary:Os,iconSecondary:rs,iconOffset:sr,iconAnchor:Vs,verticallyShapedIcon:Ks,layoutTextSize:ds,layoutIconSize:js,textOffset:Ls,isSDFIcon:zr,iconTextFit:mr,iconCollisionBounds:Ar,iconVerticalCollisionBounds:_n,textCollisionBounds:ja,textVerticalCollisionBounds:Ca})}return{featureData:zt,sizes:de,hasAnySecondaryIcon:At,textAlongLine:kt,symbolPlacement:lt}},i.fx=T5e,i.fy=function(x,d,m,v,C,E,P,R,$,G){x.iconAtlasPositions=G.iconPositions;const{featureData:te,hasAnySecondaryIcon:se,sizes:ae,textAlongLine:de,symbolPlacement:he}=d;for(const Se of te){const{shapedIcon:Fe,verticallyShapedIcon:Re,feature:Ke,shapedTextOrientations:Xe,shapedText:lt,layoutTextSize:kt,textOffset:vt,isSDFIcon:At,iconPrimary:zt,iconSecondary:qt,iconTextFit:ss,iconOffset:Gt,iconCollisionBounds:ds,iconVerticalCollisionBounds:js,textCollisionBounds:Ns}=Se;R5e(Fe,G.iconPositions,zt,qt),R5e(Re,G.iconPositions,zt,qt),Hut(Xe,G.iconPositions),Vut(zt,qt,G.iconPositions),(lt||Fe)&&Gut(x,Ke,Xe,Fe,Re,$,ae,kt,0,vt,At,v,C,P,R,se,ss,Gt,de,he,ds,js,Ns)}m&&x.generateCollisionDebugBuffers(E,x.collisionBoxArray,ae.textScaleFactor)},i.fz=Yt,i.g=function(x,d){return Xx(Object.assign(x,{method:"GET"}),d)},i.h=function(x){return x.indexOf("mapbox:")===0},i.i=function(x){return ua.API_STYLE_REGEX.test(x)&&!Mc(x)},i.j=co,i.k=du,i.l=function(x){return decodeURIComponent(atob(x).split("").map(d=>"%"+("00"+d.charCodeAt(0).toString(16)).slice(-2)).join(""))},i.m=function(x,d){return Xx(Object.assign(x,{type:"json"}),d)},i.n=vy,i.o=zl,i.p=function(x,d){return Xx(Object.assign(x,{method:"POST"}),d)},i.q=Wd,i.r=Km,i.s=function(x){try{const d=self[x];return d.setItem("_mapbox_test_",1),d.removeItem("_mapbox_test_"),!0}catch{return!1}},i.t=function(){return _pe||(_pe=new M2("ImageRasterizer")),_pe},i.u=function(){return function x(d){return d?(d^Math.random()*(16>>d/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,x)}()},i.v=function(x){return!!x&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(x)},i.w=xr,i.x=pfe,i.y=by,i.z=Xm}),o(["./shared"],function(i){function c($t){const je=$t?$t.url.toString():void 0;return je?performance.getEntriesByName(je):[]}function u($t){if(typeof $t=="number"||typeof $t=="boolean"||typeof $t=="string"||$t==null)return JSON.stringify($t);if(Array.isArray($t)){let $e="[";for(const Ye of $t)$e+=`${u(Ye)},`;return`${$e}]`}let je="{";for(const $e of Object.keys($t).sort())je+=`${$e}:${u($t[$e])},`;return`${je}}`}function p($t){let je="";for(const $e of i.bx)je+=`/${u($t[$e])}`;return je}class f{constructor(je){this.keyCache={},this._layers={},this._layerConfigs={},je&&this.replace(je)}replace(je,$e){this._layerConfigs={},this._layers={},this.update(je,[],$e)}update(je,$e,Ye){this._options=Ye;for(const gt of je)this._layerConfigs[gt.id]=gt,(this._layers[gt.id]=i.du(gt,this.scope,null,this._options)).compileFilter(Ye),this.keyCache[gt.id]&&delete this.keyCache[gt.id];for(const gt of $e)delete this.keyCache[gt],delete this._layerConfigs[gt],delete this._layers[gt];this.familiesBySource={};const bt=function(gt,Ft){const Zt={};for(let Xt=0;Xtthis._layers[vr.id]),Zt=Ft[0];if(Zt.visibility==="none")continue;const Ut=Zt.source||"";let Xt=this.familiesBySource[Ut];Xt||(Xt=this.familiesBySource[Ut]={});const Ps=Zt.sourceLayer||"_geojsonTileLayer";let gs=Xt[Ps];gs||(gs=Xt[Ps]=[]),gs.push(Ft)}}}const g=1*i.fl;class b{constructor(je){const $e={},Ye=[];for(const Zt in je){const Ut=je[Zt],Xt=$e[Zt]={};for(const Ps in Ut.glyphs){const gs=Ut.glyphs[+Ps];if(!gs||gs.bitmap.width===0||gs.bitmap.height===0)continue;const vr=gs.metrics.localGlyph?g:1,Hr={x:0,y:0,w:gs.bitmap.width+2*vr,h:gs.bitmap.height+2*vr};Ye.push(Hr),Xt[Ps]=Hr}}const{w:bt,h:gt}=i.G(Ye),Ft=new i.fk({width:bt||1,height:gt||1});for(const Zt in je){const Ut=je[Zt];for(const Xt in Ut.glyphs){const Ps=Ut.glyphs[+Xt];if(!Ps||Ps.bitmap.width===0||Ps.bitmap.height===0)continue;const gs=$e[Zt][Xt],vr=Ps.metrics.localGlyph?g:1;i.fk.copy(Ps.bitmap,Ft,{x:0,y:0},{x:gs.x+vr,y:gs.y+vr},Ps.bitmap)}}this.image=Ft,this.positions=$e}}function _($t,je,$e){$t[je]?$e&&($t[je].center=$e):$t[je]={floorIds:new Set,center:$e||[0,0],floors:{}}}function j($t,je,$e,Ye){for(const bt of je)_($t,bt),$t[bt].floors[$e]=Ye,$t[bt].floorIds.add($e)}function w($t){return{id:$t.properties.id.toString(),center:$t.properties.center.toString().split(";").map(Number)}}function k($t){return{id:$t.properties.id.toString(),isDefault:!!$t.properties.is_default&&$t.properties.is_default,connections:$t.properties.connected_floor_ids?new Set($t.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:$t.properties.conflicted_floor_ids?new Set($t.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:$t.properties.building_ids?new Set($t.properties.building_ids.toString().split(";")):new Set,name:$t.properties.name.toString(),zIndex:$t.properties.z_index}}function S($t,je){return je.every($e=>$t.properties&&$t.properties[$e]!=null)}function M($t){return S($t,["type","id","name"])&&$t.properties.type==="building"}function L($t){return S($t,["type","id","name","z_index"])&&$t.properties.type==="floor"}i.fj(b,"GlyphAtlas");class I{constructor(je){this.tileID=new i.aQ(je.tileID.overscaledZ,je.tileID.wrap,je.tileID.canonical.z,je.tileID.canonical.x,je.tileID.canonical.y),this.tileZoom=je.tileZoom,this.uid=je.uid,this.zoom=je.zoom,this.lut=je.lut,this.canonical=je.tileID.canonical,this.pixelRatio=je.pixelRatio,this.tileSize=je.tileSize,this.source=je.source,this.scope=je.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=je.showCollisionBoxes,this.collectResourceTiming=!!je.request&&je.request.collectResourceTiming,this.promoteId=je.promoteId,this.isSymbolTile=je.isSymbolTile,this.tileTransform=i.aZ(je.tileID.canonical,je.projection),this.projection=je.projection,this.worldview=je.worldview,this.localizableLayerIds=je.localizableLayerIds,this.brightness=je.brightness,this.extraShadowCaster=!!je.extraShadowCaster,this.tessellationStep=je.tessellationStep,this.scaleFactor=je.scaleFactor,this.worldview=je.worldview,this.indoor=je.indoor}parse(je,$e,Ye,bt,gt,Ft){this.status="parsing",this.data=je,this.collisionBoxArray=new i.b3;const Zt=new i.fm(Object.keys(je.layers).sort()),Ut=new i.fn(this.tileID,this.promoteId);Ut.bucketLayerIDs=[];const Xt={},Ps=new i.fo(256,256),gs={featureIndex:Ut,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Ps,availableImages:Ye,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const Ln=this.indoor.indoorState.activeFloorsVisible,Dn=function(En,_a,vo){const il=function(oo,Ia){if(!oo)return i.w("No source layers defined in indoor specification"),Ia;if(oo.size===0)return Ia;const lo=oo.difference(Ia);for(const Ti of lo)i.w(`Missing source layer required in indoor specification: ${Ti}`);return Ia.intersection(Ia)}(_a.sourceLayers,new Set(Object.keys(En.layers))),ti=_a.indoorState,hl=function(oo,Ia,lo,Ti){const ua=new Set,co=new Set,Mc=new Set,Wc=new Map,lu={},Df=Fl=>{const ch=Wc.get(Fl)||new Set;for(const kd of ua)if((Wc.get(kd)||new Set).has(Fl)||ch.has(kd))return!0;return!1};for(const Fl of Ia){const ch=oo.layers[Fl];if(ch)for(let kd=0;kd=lo.maxzoom||lo.visibility==="none")continue;O(Ia,this.zoom,gs.brightness,Ye,this.worldview);const Ti=Xt[lo.id]=lo.createBucket({index:Ut.bucketLayerIDs.length,layers:Ia,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:il,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:bt,worldview:this.worldview,localizable:hl});Ut.bucketLayerIDs.push(Ia.map(co=>i.B(co.id,co.scope)));let ua=Ti.prepare?Ti.prepare():null;ua!=null?(ua=ua.then(()=>Ti.populate(ti,gs,this.tileID.canonical,this.tileTransform)),vr.push(ua)):Ti.populate(ti,gs,this.tileID.canonical,this.tileTransform)}}const xr=()=>{let Ln,Dn,En,_a,vo,il;Ps.trim();const ti={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},hl=()=>{if(Ln)return this.status="done",Ft(Ln);if(this.extraShadowCaster)this.status="done",Ft(null,{buckets:Object.values(Xt).filter(Ia=>!Ia.isEmpty()),featureIndex:Ut,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:gs.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Dn&&En&&_a){const Ia=new b(Dn),lo=new Map;for(const[co,Mc]of En.entries()){const{imagePosition:Wc}=i.fu(co,Mc,i.fv);lo.set(co,Wc)}const Ti={};for(const co in Xt){const Mc=Xt[co];Mc instanceof i.b4&&(O(Mc.layers,this.zoom,gs.brightness,Ye,this.worldview),Ti[co]=i.fw(Mc,Dn,Ia.positions,En,lo,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,vo,this.worldview))}const ua={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(gt,En,vo,()=>{ua.iconsPending=!1,oo(Ti,Ia,ua)}),this.rasterizeIfNeeded(gt,_a,il,()=>{ua.patternsPending=!1,oo(Ti,Ia,ua)})}},oo=(Ia,lo,Ti,ua)=>{if(Ti.iconsPending||Ti.patternsPending)return;const co=new i.fx(En,_a,this.lut);for(const Mc in Xt){const Wc=Xt[Mc];if(Mc in Ia)i.fy(Wc,Ia[Mc],this.showCollisionBoxes,Ye,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,En,co);else if(Wc.hasPattern&&(Wc instanceof i.ba||Wc instanceof i.bb||Wc instanceof i.ea)){O(Wc.layers,this.zoom,gs.brightness,Ye,this.worldview);const lu=Object.fromEntries(co.patternPositions);Wc.addFeatures(gs,this.tileID.canonical,lu,Ye,this.tileTransform,this.brightness)}}this.status="done",Ft(null,{buckets:Object.values(Xt).filter(Mc=>!Mc.isEmpty()),featureIndex:Ut,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:lo.image,lineAtlas:Ps,imageAtlas:co,brightness:gs.brightness})};if(!this.extraShadowCaster){const Ia=i.fs(gs.glyphDependencies,ua=>Object.keys(ua).map(Number));Object.keys(Ia).length?gt.send("getGlyphs",{uid:this.uid,stacks:Ia},(ua,co)=>{Ln||(Ln=ua,Dn=co,hl())},void 0,!1,ti):Dn={};const lo=Array.from(gs.iconDependencies.keys()).map(ua=>i.I.parse(ua));lo.length?gt.send("getImages",{images:lo,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(ua,co)=>{Ln||(Ln=ua,En=new Map,vo=this.updateImageMapAndGetImageTaskQueue(En,co,gs.iconDependencies),hl())},void 0,!1,ti):(En=new Map,vo=new Map);const Ti=Array.from(gs.patternDependencies.keys()).map(ua=>i.I.parse(ua));Ti.length?gt.send("getImages",{images:Ti,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(ua,co)=>{Ln||(Ln=ua,_a=new Map,il=this.updateImageMapAndGetImageTaskQueue(_a,co,gs.patternDependencies),hl())},void 0,!1,ti):(_a=new Map,il=new Map)}if(gs.elevationFeatures&&gs.elevationFeatures.length>0){const Ia=[];for(const Ti of Object.values(Xt))if(Ti instanceof i.bb){const ua=Ti.getUnevaluatedPortalGraph();ua&&Ia.push(ua)}const lo=i.ft.evaluate(Ia);for(const Ti of Object.values(Xt))if(Ti instanceof i.bb){const ua=je.layers[Zt.decode(Ti.sourceLayerIndex)];Ti.setEvaluatedPortalGraph(lo,ua,this.tileID.canonical,gs.availableImages,gs.brightness)}}hl()};vr.length>0?Promise.allSettled(vr).then(xr).catch(Ft):xr()}updateParameters(je){this.scaleFactor=je.scaleFactor,this.showCollisionBoxes=je.showCollisionBoxes,this.projection=je.projection,this.brightness=je.brightness,this.tileTransform=i.aZ(je.tileID.canonical,je.projection),this.extraShadowCaster=je.extraShadowCaster,this.lut=je.lut,this.worldview=je.worldview,this.indoor=je.indoor}rasterizeIfNeeded(je,$e,Ye,bt){Array.from($e.values()).some(gt=>gt.usvg)?this.rasterize(je,$e,Ye,bt):bt()}updateImageMapAndGetImageTaskQueue(je,$e,Ye){const bt=new Map;for(const gt of $e.keys()){const Ft=Ye.get(gt)||[];for(const Zt of Ft){const Ut=Zt.toString(),Xt=$e.get(Zt.id.toString());Xt.usvg?bt.has(Ut)||(bt.set(Ut,Zt),je.set(Ut,Object.assign({},Xt))):je.set(Ut,Xt)}}return bt}rasterize(je,$e,Ye,bt){this.rasterizeTask=je.send("rasterizeImages",{scope:this.scope,tasks:Ye},(gt,Ft)=>{if(!gt)for(const[Zt,Ut]of Ft.entries()){const Xt=Object.assign($e.get(Zt),{data:Ut});$e.set(Zt,Xt)}bt()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function O($t,je,$e,Ye,bt){const gt=new i.ac(je,{brightness:$e,worldview:bt});for(const Ft of $t)Ft.recalculate(gt,Ye)}class q extends i.E{constructor(je,$e,Ye,bt,gt,Ft,Zt){super(),this.actor=je,this.layerIndex=$e,this.availableImages=Ye,this.availableModels=bt,this.loadVectorData=Ft||i.aL,this.loading={},this.loaded={},this.deduped=new i.aK(je.scheduler),this.isSpriteLoaded=gt,this.scheduler=je.scheduler,this.brightness=Zt}loadTile(je,$e){const Ye=je.uid,bt=je&&je.request,gt=bt&&bt.collectResourceTiming,Ft=this.loading[Ye]=new I(je);Ft.abort=this.loadVectorData(je,(Zt,Ut)=>{const Xt=!this.loading[Ye];if(delete this.loading[Ye],Ft.cancelRasterize(),Xt||Zt||!Ut)return Ft.status="done",Xt||(this.loaded[Ye]=Ft),$e(Zt);const Ps=Ut.rawData,gs={},vr=i.aM(Ut.responseHeaders);vr&&vr.expires&&(gs.expires=vr.expires),vr&&vr.cacheControl&&(gs.cacheControl=vr.cacheControl),Ft.vectorTile=Ut.vectorTile||new i.fz(new i.bt(Ps));const Hr=()=>{Ft.parse(Ft.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(xr,Ln)=>{if(xr||!Ln)return $e(xr);const Dn={};if(gt){const En=c(bt);En.length>0&&(Dn.resourceTiming=JSON.parse(JSON.stringify(En)))}$e(null,Object.assign({rawTileData:Ps.slice(0),responseHeaders:Ut.responseHeaders},Ln,gs,Dn))})};this.isSpriteLoaded?Hr():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Hr,{type:"parseTile",isSymbolTile:je.isSymbolTile,zoom:je.tileZoom}):Hr()}),this.loaded=this.loaded||{},this.loaded[Ye]=Ft})}reloadTile(je,$e){const Ye=this.loaded,bt=je.uid;if(Ye&&Ye[bt]){const gt=Ye[bt];gt.updateParameters(je);const Ft=(Zt,Ut)=>{const Xt=gt.reloadCallback;Xt&&(delete gt.reloadCallback,gt.parse(gt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Xt)),$e(Zt,Ut)};gt.status==="parsing"?gt.reloadCallback=Ft:gt.status==="done"&&(gt.vectorTile?gt.parse(gt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Ft):Ft())}else $e(null,void 0)}abortTile(je,$e){const Ye=je.uid,bt=this.loading[Ye];bt&&(bt.abort&&bt.abort(),delete this.loading[Ye]),$e()}removeTile(je,$e){const Ye=this.loaded,bt=je.uid;Ye&&Ye[bt]&&delete Ye[bt],$e()}}class U{loadTile(je,$e){const{uid:Ye,encoding:bt,rawImageData:gt,padding:Ft}=je,Zt=ImageBitmap&> instanceof ImageBitmap?this.getImageData(gt,Ft):gt;$e(null,new i.fA(Ye,Zt,bt,Ft<1))}reloadTile(je,$e){$e(null,null)}abortTile(je,$e){$e()}removeTile(je,$e){$e()}getImageData(je,$e){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(je.width,je.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=je.width,this.offscreenCanvas.height=je.height,this.offscreenCanvasContext.drawImage(je,0,0,je.width,je.height);const Ye=this.offscreenCanvasContext.getImageData(-$e,-$e,je.width+2*$e,je.height+2*$e);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Ye}}i.bs.setPbf(i.bt);class B{constructor(je){this._mrt=new i.bs(je.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=je.uid,this.tileID=je.tileID,this.source=je.source}parse(je,$e){const Ye=this._mrt;this.status="parsing",this._entireBuffer=je;try{Ye.parseHeader(je),this._isHeaderLoaded=!0;const bt=[];for(const gt in Ye.layers){const Ft=Ye.getLayer(gt),Zt=Ft.getDataRange(Ft.getBandList()),Ut=Ye.createDecodingTask(Zt),Xt=je.slice(Zt.firstByte,Zt.lastByte+1),Ps=i.bs.performDecoding(Xt,Ut).then(gs=>Ut.complete(null,gs)).catch(gs=>Ut.complete(gs,null));bt.push(Ps)}Promise.allSettled(bt).then(()=>$e(null,Ye)).catch(gt=>$e(gt))}catch(bt){$e(bt)}}}class V{constructor(je){this.actor=je,this.loading={},this.loaded={}}loadTile(je,$e){const Ye=je.uid,bt=je.request,gt=this.loading[Ye]=new B(je),{cancel:Ft}=i.bu(bt,(Zt,Ut,Xt)=>{const Ps=!this.loading[Ye];if(delete this.loading[Ye],Ps||Zt||!Ut)return gt.status="done",Ps||(this.loaded[Ye]=gt),$e(Zt);gt.parse(Ut,(gs,vr)=>{if(gs||!vr)return $e(gs);$e(null,vr,Xt)}),this.loaded[Ye]=gt});gt.abort=Ft}reloadTile(je,$e){$e(null,void 0)}abortTile(je,$e){const Ye=je.uid,bt=this.loading[Ye];bt&&(bt.abort&&bt.abort(),delete this.loading[Ye]),$e()}removeTile(je,$e){const Ye=je.uid;this.loaded[Ye]&&delete this.loaded[Ye],$e()}decodeRasterArray(je,$e){i.bs.performDecoding(je.buffer,je.task).then(Ye=>$e(null,Ye)).catch(Ye=>$e(Ye))}}const Z=i.fB.prototype.toGeoJSON;class X{constructor(je){this._feature=je,this.extent=i.al,this.type=je.type,this.properties=je.tags,"id"in je&&!isNaN(je.id)&&(this.id=parseInt(je.id,10))}loadGeometry(){if(this._feature.type===1){const je=[];for(const $e of this._feature.geometry)je.push([new i.P($e[0],$e[1])]);return je}{const je=[];for(const $e of this._feature.geometry){const Ye=[];for(const bt of $e)Ye.push(new i.P(bt[0],bt[1]));je.push(Ye)}return je}}toGeoJSON(je,$e,Ye){return Z.call(this,je,$e,Ye)}}class ee{constructor(je,$e){this.name=je,this.extent=i.al,this.length=$e.length,this._jsonFeatures=$e}feature(je){return new X(this._jsonFeatures[je])}}class Q{constructor(je){this.layers={},this.extent=i.al;for(const $e of Object.keys(je))this.layers[$e]=new ee($e,je[$e])}}const ie=64/4096,re=128;class oe{constructor(){this.features=new Map}clear(){this.features.clear()}load(je=[],$e){for(const Ye of je){const bt=Ye.id;if(bt==null)continue;let gt=this.features.get(bt);gt&&this.updateCache(gt,$e),Ye.geometry?(gt=xe(Ye),this.updateCache(gt,$e),this.features.set(bt,gt)):this.features.delete(bt),this.updateCache(gt,$e)}}updateCache(je,$e){for(const{canonical:Ye,uid:bt}of Object.values($e)){const{z:gt,x:Ft,y:Zt}=Ye;ce(je,Math.pow(2,gt),Ft,Zt)&&delete $e[bt]}}getTile(je,$e,Ye){const bt=Math.pow(2,je),gt=[];for(const Ft of this.features.values())ce(Ft,bt,$e,Ye)&>.push(be(Ft,bt,$e,Ye));return{features:gt}}getFeatures(){return[...this.features.values()]}}function ce({minX:$t,minY:je,maxX:$e,maxY:Ye},bt,gt,Ft){return $t<(gt+1+ie)/bt&&je<(Ft+1+ie)/bt&&$e>(gt-ie)/bt&&Ye>(Ft-ie)/bt}function xe($t){const{id:je,geometry:$e,properties:Ye}=$t;if(!$e)return;if($e.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:bt,coordinates:gt}=$e,Ft={id:je,type:1,geometry:[],tags:Ye,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Zt=Ft.geometry;if(bt==="Point")ge(gt,Zt,Ft);else if(bt==="MultiPoint")for(const Ut of gt)ge(Ut,Zt,Ft);else if(bt==="LineString")Ft.type=2,ue(gt,Zt,Ft);else if(bt==="MultiLineString")Ft.type=2,pe(gt,Zt,Ft);else if(bt==="Polygon")Ft.type=3,pe(gt,Zt,Ft,!0);else{if(bt!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Ft.type=3;for(const Ut of gt)pe(Ut,Zt,Ft,!0)}return Ft}function ge([$t,je],$e,Ye){const bt=i.aF($t);let gt=i.aJ(je);gt=gt<0?0:gt>1?1:gt,$e.push(bt,gt),Ye.minX=Math.min(Ye.minX,bt),Ye.minY=Math.min(Ye.minY,gt),Ye.maxX=Math.max(Ye.maxX,bt),Ye.maxY=Math.max(Ye.maxY,gt)}function ue($t,je,$e,Ye=!1,bt=!1){const gt=[];for(const Ft of $t)ge(Ft,gt,$e);je.push(gt),Ye&&function(Ft,Zt){let Ut=0;for(let Xt=0,Ps=Ft.length,gs=Ps-2;Xt0===Zt)for(let Xt=0,Ps=Ft.length;Xt=Ft&&gs>=Ft||(Xt>=Ft?(Ps+=Math.round(xr*((Ft-Xt)/Hr)),Xt=Ft):gs>=Ft&&(vr=Ps+Math.round(xr*((Ft-Xt)/Hr)),gs=Ft),Ps>=Ft&&vr>=Ft||(Ps>=Ft?(Xt+=Math.round(Hr*((Ft-Ps)/xr)),Ps=Ft):vr>=Ft&&(gs=Xt+Math.round(Hr*((Ft-Ps)/xr)),vr=Ft),Zt&&Xt===Zt[Zt.length-1][0]&&Ps===Zt[Zt.length-1][1]||(Zt=[[Xt,Ps]],bt.push(Zt)),Zt.push([gs,vr])))))}}function Ne($t,je,$e,Ye,bt){const gt=($e-ie)/je,Ft=(Ye-ie)/je,Zt=($e+1+ie)/je,Ut=(Ye+1+ie)/je;function Xt(vr,Hr){let xr=0;return vrZt&&(xr|=2),HrUt&&(xr|=8),xr}let Ps=[];for(let vr=1;vr<=8;vr*=2){let Hr=$t[$t.length-2],xr=$t[$t.length-1],Ln=!(Xt(Hr,xr)&vr);for(let Dn=0;Dn<$t.length;Dn+=2){const En=$t[Dn],_a=$t[Dn+1],vo=!(Xt(En,_a)&vr);vo!==Ln&&(8&vr?Ps.push(Hr+(En-Hr)*(Ut-xr)/(_a-xr),Ut):4&vr?Ps.push(Hr+(En-Hr)*(Ft-xr)/(_a-xr),Ft):2&vr?Ps.push(Zt,xr+(_a-xr)*(Zt-Hr)/(En-Hr)):1&vr&&Ps.push(gt,xr+(_a-xr)*(gt-Hr)/(En-Hr))),vo&&Ps.push(En,_a),Hr=En,xr=_a,Ln=vo}if(!($t=Ps).length||vr===8)break;Ps=[]}const gs=[];for(let vr=0;vr>31}function nt($t,je){const{geometry:$e,type:Ye}=$t;let bt=0,gt=0;if(Ye===1){je.writeVarint(ke(1,$e.length));for(const Ft of $e){const Zt=Ft[0]-bt,Ut=Ft[1]-gt;je.writeVarint(Be(Zt)),je.writeVarint(Be(Ut)),bt+=Zt,gt+=Ut}}else for(const Ft of $e){je.writeVarint(ke(1,1));const Zt=Ft.length-(Ye===3?1:0);for(let Ut=0;Ut$t},fe=Math.fround||(Ve=new Float32Array(1),$t=>(Ve[0]=+$t,Ve[0]));var Ve;const at=3,et=5,Ce=6;class rt{constructor(je){this.options=Object.assign(Object.create(ft),je),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(je){const{log:$e,minZoom:Ye,maxZoom:bt}=this.options;$e&&console.time("total time");const gt=`prepare ${je.length} points`;$e&&console.time(gt),this.points=je;const Ft=[];for(let Ut=0;Ut=Ye;Ut--){const Xt=+Date.now();Zt=this.trees[Ut]=this._createTree(this._cluster(Zt,Ut)),$e&&console.log("z%d: %d clusters in %dms",Ut,Zt.numItems,+Date.now()-Xt)}return $e&&console.timeEnd("total time"),this}getClusters(je,$e){let Ye=((je[0]+180)%360+360)%360-180;const bt=Math.max(-90,Math.min(90,je[1]));let gt=je[2]===180?180:((je[2]+180)%360+360)%360-180;const Ft=Math.max(-90,Math.min(90,je[3]));if(je[2]-je[0]>=360)Ye=-180,gt=180;else if(Ye>gt){const gs=this.getClusters([Ye,bt,180,Ft],$e),vr=this.getClusters([-180,bt,gt,Ft],$e);return gs.concat(vr)}const Zt=this.trees[this._limitZoom($e)],Ut=Zt.range(qe(Ye),Ze(Ft),qe(gt),Ze(bt)),Xt=Zt.data,Ps=[];for(const gs of Ut){const vr=this.stride*gs;Ps.push(Xt[vr+et]>1?Ge(Xt,vr,this.clusterProps):this.points[Xt[vr+at]])}return Ps}getChildren(je){const $e=this._getOriginId(je),Ye=this._getOriginZoom(je),bt="No cluster with the specified id.",gt=this.trees[Ye];if(!gt)throw new Error(bt);const Ft=gt.data;if($e*this.stride>=Ft.length)throw new Error(bt);const Zt=this.options.radius/(this.options.extent*Math.pow(2,Ye-1)),Ut=gt.within(Ft[$e*this.stride],Ft[$e*this.stride+1],Zt),Xt=[];for(const Ps of Ut){const gs=Ps*this.stride;Ft[gs+4]===je&&Xt.push(Ft[gs+et]>1?Ge(Ft,gs,this.clusterProps):this.points[Ft[gs+at]])}if(Xt.length===0)throw new Error(bt);return Xt}getLeaves(je,$e,Ye){const bt=[];return this._appendLeaves(bt,je,$e=$e||10,Ye=Ye||0,0),bt}getTile(je,$e,Ye){const bt=this.trees[this._limitZoom(je)],gt=Math.pow(2,je),{extent:Ft,radius:Zt}=this.options,Ut=Zt/Ft,Xt=(Ye-Ut)/gt,Ps=(Ye+1+Ut)/gt,gs={features:[]};return this._addTileFeatures(bt.range(($e-Ut)/gt,Xt,($e+1+Ut)/gt,Ps),bt.data,$e,Ye,gt,gs),$e===0&&this._addTileFeatures(bt.range(1-Ut/gt,Xt,1,Ps),bt.data,gt,Ye,gt,gs),$e===gt-1&&this._addTileFeatures(bt.range(0,Xt,Ut/gt,Ps),bt.data,-1,Ye,gt,gs),gs.features.length?gs:null}getClusterExpansionZoom(je){let $e=this._getOriginZoom(je)-1;for(;$e<=this.options.maxZoom;){const Ye=this.getChildren(je);if($e++,Ye.length!==1)break;je=Ye[0].properties.cluster_id}return $e}_appendLeaves(je,$e,Ye,bt,gt){const Ft=this.getChildren($e);for(const Zt of Ft){const Ut=Zt.properties;if(Ut&&Ut.cluster?gt+Ut.point_count<=bt?gt+=Ut.point_count:gt=this._appendLeaves(je,Ut.cluster_id,Ye,bt,gt):gt1;let Ps,gs,vr;if(Xt)Ps=ct($e,Ut,this.clusterProps),gs=$e[Ut],vr=$e[Ut+1];else{const Ln=this.points[$e[Ut+at]];Ps=Ln.properties;const[Dn,En]=Ln.geometry.coordinates;gs=qe(Dn),vr=Ze(En)}const Hr={type:1,geometry:[[Math.round(this.options.extent*(gs*gt-Ye)),Math.round(this.options.extent*(vr*gt-bt))]],tags:Ps};let xr;xr=Xt||this.options.generateId?$e[Ut+at]:this.points[$e[Ut+at]].id,xr!==void 0&&(Hr.id=xr),Ft.features.push(Hr)}}_limitZoom(je){return Math.max(this.options.minZoom,Math.min(Math.floor(+je),this.options.maxZoom+1))}_cluster(je,$e){const{radius:Ye,extent:bt,reduce:gt,minPoints:Ft}=this.options,Zt=Ye/(bt*Math.pow(2,$e)),Ut=je.data,Xt=[],Ps=this.stride;for(let gs=0;gs$e&&(Dn+=Ut[_a+et])}if(Dn>Ln&&Dn>=Ft){let En,_a=vr*Ln,vo=Hr*Ln,il=-1;const ti=(gs/Ps<<5)+($e+1)+this.points.length;for(const hl of xr){const oo=hl*Ps;if(Ut[oo+2]<=$e)continue;Ut[oo+2]=$e;const Ia=Ut[oo+et];_a+=Ut[oo]*Ia,vo+=Ut[oo+1]*Ia,Ut[oo+4]=ti,gt&&(En||(En=this._map(Ut,gs,!0),il=this.clusterProps.length,this.clusterProps.push(En)),gt(En,this._map(Ut,oo)))}Ut[gs+4]=ti,Xt.push(_a/Dn,vo/Dn,1/0,ti,-1,Dn),gt&&Xt.push(il)}else{for(let En=0;En1)for(const En of xr){const _a=En*Ps;if(!(Ut[_a+2]<=$e)){Ut[_a+2]=$e;for(let vo=0;vo>5}_getOriginZoom(je){return(je-this.points.length)%32}_map(je,$e,Ye){if(je[$e+et]>1){const Ft=this.clusterProps[je[$e+Ce]];return Ye?Object.assign({},Ft):Ft}const bt=this.points[je[$e+at]].properties,gt=this.options.map(bt);return Ye&>===bt?Object.assign({},gt):gt}}function Ge($t,je,$e){return{type:"Feature",id:$t[je+at],properties:ct($t,je,$e),geometry:{type:"Point",coordinates:[(Ye=$t[je],360*(Ye-.5)),Qe($t[je+1])]}};var Ye}function ct($t,je,$e){const Ye=$t[je+et],bt=Ye>=1e4?`${Math.round(Ye/1e3)}k`:Ye>=1e3?Math.round(Ye/100)/10+"k":Ye,gt=$t[je+Ce],Ft=gt===-1?{}:Object.assign({},$e[gt]);return Object.assign(Ft,{cluster:!0,cluster_id:$t[je+at],point_count:Ye,point_count_abbreviated:bt})}function qe($t){return $t/360+.5}function Ze($t){const je=Math.sin($t*Math.PI/180),$e=.5-.25*Math.log((1+je)/(1-je))/Math.PI;return $e<0?0:$e>1?1:$e}function Qe($t){const je=(180-360*$t)*Math.PI/180;return 360*Math.atan(Math.exp(je))/Math.PI-90}function He($t,je,$e,Ye){let bt=Ye;const gt=je+($e-je>>1);let Ft,Zt=$e-je;const Ut=$t[je],Xt=$t[je+1],Ps=$t[$e],gs=$t[$e+1];for(let vr=je+3;vr<$e;vr+=3){const Hr=Je($t[vr],$t[vr+1],Ut,Xt,Ps,gs);if(Hr>bt)Ft=vr,bt=Hr;else if(Hr===bt){const xr=Math.abs(vr-gt);xrYe&&(Ft-je>3&&He($t,je,Ft,Ye),$t[Ft+2]=bt,$e-Ft>3&&He($t,Ft,$e,Ye))}function Je($t,je,$e,Ye,bt,gt){let Ft=bt-$e,Zt=gt-Ye;if(Ft!==0||Zt!==0){const Ut=(($t-$e)*Ft+(je-Ye)*Zt)/(Ft*Ft+Zt*Zt);Ut>1?($e=bt,Ye=gt):Ut>0&&($e+=Ft*Ut,Ye+=Zt*Ut)}return Ft=$t-$e,Zt=je-Ye,Ft*Ft+Zt*Zt}function it($t,je,$e,Ye){const bt={id:$t??null,type:je,geometry:$e,tags:Ye,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(je==="Point"||je==="MultiPoint"||je==="LineString")Lt(bt,$e);else if(je==="Polygon")Lt(bt,$e[0]);else if(je==="MultiLineString")for(const gt of $e)Lt(bt,gt);else if(je==="MultiPolygon")for(const gt of $e)Lt(bt,gt[0]);return bt}function Lt($t,je){for(let $e=0;$e0&&(Ft+=Ye?(bt*Ps-Xt*gt)/2:Math.sqrt(Math.pow(Xt-bt,2)+Math.pow(Ps-gt,2))),bt=Xt,gt=Ps}const Zt=je.length-3;je[2]=1,He(je,0,Zt,$e),je[Zt+2]=1,je.size=Math.abs(Ft),je.start=0,je.end=je.size}function Cs($t,je,$e,Ye){for(let bt=0;bt<$t.length;bt++){const gt=[];Ts($t[bt],gt,$e,Ye),je.push(gt)}}function cs($t){return $t/360+.5}function er($t){const je=Math.sin($t*Math.PI/180),$e=.5-.25*Math.log((1+je)/(1-je))/Math.PI;return $e<0?0:$e>1?1:$e}function xt($t,je,$e,Ye,bt,gt,Ft,Zt){if(Ye/=je,gt>=($e/=je)&&Ft=Ye)return null;const Ut=[];for(const Xt of $t){const Ps=Xt.geometry;let gs=Xt.type;const vr=bt===0?Xt.minX:Xt.minY,Hr=bt===0?Xt.maxX:Xt.maxY;if(vr>=$e&&Hr=Ye)continue;let xr=[];if(gs==="Point"||gs==="MultiPoint")Es(Ps,xr,$e,Ye,bt);else if(gs==="LineString")ur(Ps,xr,$e,Ye,bt,!1,Zt.lineMetrics);else if(gs==="MultiLineString")Lr(Ps,xr,$e,Ye,bt,!1);else if(gs==="Polygon")Lr(Ps,xr,$e,Ye,bt,!0);else if(gs==="MultiPolygon")for(const Ln of Ps){const Dn=[];Lr(Ln,Dn,$e,Ye,bt,!0),Dn.length&&xr.push(Dn)}if(xr.length){if(Zt.lineMetrics&&gs==="LineString"){for(const Ln of xr)Ut.push(it(Xt.id,gs,Ln,Xt.tags));continue}gs!=="LineString"&&gs!=="MultiLineString"||(xr.length===1?(gs="LineString",xr=xr[0]):gs="MultiLineString"),gs!=="Point"&&gs!=="MultiPoint"||(gs=xr.length===3?"Point":"MultiPoint"),Ut.push(it(Xt.id,gs,xr,Xt.tags))}}return Ut.length?Ut:null}function Es($t,je,$e,Ye,bt){for(let gt=0;gt<$t.length;gt+=3){const Ft=$t[gt+bt];Ft>=$e&&Ft<=Ye&&fn(je,$t[gt],$t[gt+1],$t[gt+2])}}function ur($t,je,$e,Ye,bt,gt,Ft){let Zt=Mr($t);const Ut=bt===0?ki:Ea;let Xt,Ps,gs=$t.start;for(let Dn=0;Dn<$t.length-3;Dn+=3){const En=$t[Dn],_a=$t[Dn+1],vo=$t[Dn+2],il=$t[Dn+3],ti=$t[Dn+4],hl=bt===0?En:_a,oo=bt===0?il:ti;let Ia=!1;Ft&&(Xt=Math.sqrt(Math.pow(En-il,2)+Math.pow(_a-ti,2))),hl<$e?oo>$e&&(Ps=Ut(Zt,En,_a,il,ti,$e),Ft&&(Zt.start=gs+Xt*Ps)):hl>Ye?oo=$e&&(Ps=Ut(Zt,En,_a,il,ti,$e),Ia=!0),oo>Ye&&hl<=Ye&&(Ps=Ut(Zt,En,_a,il,ti,Ye),Ia=!0),!gt&&Ia&&(Ft&&(Zt.end=gs+Xt*Ps),je.push(Zt),Zt=Mr($t)),Ft&&(gs+=Xt)}let vr=$t.length-3;const Hr=$t[vr],xr=$t[vr+1],Ln=bt===0?Hr:xr;Ln>=$e&&Ln<=Ye&&fn(Zt,Hr,xr,$t[vr+2]),vr=Zt.length-3,gt&&vr>=3&&(Zt[vr]!==Zt[0]||Zt[vr+1]!==Zt[1])&&fn(Zt,Zt[0],Zt[1],Zt[2]),Zt.length&&je.push(Zt)}function Mr($t){const je=[];return je.size=$t.size,je.start=$t.start,je.end=$t.end,je}function Lr($t,je,$e,Ye,bt,gt){for(const Ft of $t)ur(Ft,je,$e,Ye,bt,gt,!1)}function fn($t,je,$e,Ye){$t.push(je,$e,Ye)}function ki($t,je,$e,Ye,bt,gt){const Ft=(gt-je)/(Ye-je);return fn($t,gt,$e+(bt-$e)*Ft,1),Ft}function Ea($t,je,$e,Ye,bt,gt){const Ft=(gt-$e)/(bt-$e);return fn($t,je+(Ye-je)*Ft,gt,1),Ft}function dr($t,je){const $e=[];for(let Ye=0;Ye<$t.length;Ye++){const bt=$t[Ye],gt=bt.type;let Ft;if(gt==="Point"||gt==="MultiPoint"||gt==="LineString")Ft=Jr(bt.geometry,je);else if(gt==="MultiLineString"||gt==="Polygon"){Ft=[];for(const Zt of bt.geometry)Ft.push(Jr(Zt,je))}else if(gt==="MultiPolygon"){Ft=[];for(const Zt of bt.geometry){const Ut=[];for(const Xt of Zt)Ut.push(Jr(Xt,je));Ft.push(Ut)}}$e.push(it(bt.id,gt,Ft,bt.tags))}return $e}function Jr($t,je){const $e=[];$e.size=$t.size,$t.start!==void 0&&($e.start=$t.start,$e.end=$t.end);for(let Ye=0;Ye<$t.length;Ye+=3)$e.push($t[Ye]+je,$t[Ye+1],$t[Ye+2]);return $e}function Wr($t,je){if($t.transformed)return $t;const $e=1<<$t.z,Ye=$t.x,bt=$t.y;for(const gt of $t.features){const Ft=gt.geometry,Zt=gt.type;if(gt.geometry=[],Zt===1)for(let Ut=0;Ut0&&je.size<(bt?Ft:Ye))return void($e.numPoints+=je.length/3);const Zt=[];for(let Ut=0;UtFt)&&($e.numSimplified++,Zt.push(je[Ut],je[Ut+1])),$e.numPoints++;bt&&function(Ut,Xt){let Ps=0;for(let gs=0,vr=Ut.length,Hr=vr-2;gs0===Xt)for(let gs=0,vr=Ut.length;gs24)throw new Error("maxZoom should be in the 0-24 range");if($e.promoteId&&$e.generateId)throw new Error("promoteId and generateId cannot be used together.");let bt=function(gt,Ft){const Zt=[];if(gt.type==="FeatureCollection")for(let Ut=0;Ut1&&console.time("creation"),Hr=this.tiles[vr]=Yr(je,$e,Ye,bt,Xt),this.tileCoords.push({z:$e,x:Ye,y:bt}),Ps)){Ps>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",$e,Ye,bt,Hr.numFeatures,Hr.numPoints,Hr.numSimplified),console.timeEnd("creation"));const Ia=`z${$e}`;this.stats[Ia]=(this.stats[Ia]||0)+1,this.total++}if(Hr.source=je,gt==null){if($e===Xt.indexMaxZoom||Hr.numPoints<=Xt.indexMaxPoints)continue}else{if($e===Xt.maxZoom||$e===gt)continue;if(gt!=null){const Ia=gt-$e;if(Ye!==Ft>>Ia||bt!==Zt>>Ia)continue}}if(Hr.source=null,je.length===0)continue;Ps>1&&console.time("clipping");const xr=.5*Xt.buffer/Xt.extent,Ln=.5-xr,Dn=.5+xr,En=1+xr;let _a=null,vo=null,il=null,ti=null,hl=xt(je,gs,Ye-xr,Ye+Dn,0,Hr.minX,Hr.maxX,Xt),oo=xt(je,gs,Ye+Ln,Ye+En,0,Hr.minX,Hr.maxX,Xt);je=null,hl&&(_a=xt(hl,gs,bt-xr,bt+Dn,1,Hr.minY,Hr.maxY,Xt),vo=xt(hl,gs,bt+Ln,bt+En,1,Hr.minY,Hr.maxY,Xt),hl=null),oo&&(il=xt(oo,gs,bt-xr,bt+Dn,1,Hr.minY,Hr.maxY,Xt),ti=xt(oo,gs,bt+Ln,bt+En,1,Hr.minY,Hr.maxY,Xt),oo=null),Ps>1&&console.timeEnd("clipping"),Ut.push(_a||[],$e+1,2*Ye,2*bt),Ut.push(vo||[],$e+1,2*Ye,2*bt+1),Ut.push(il||[],$e+1,2*Ye+1,2*bt),Ut.push(ti||[],$e+1,2*Ye+1,2*bt+1)}}getTile(je,$e,Ye){je=+je,$e=+$e,Ye=+Ye;const bt=this.options,{extent:gt,debug:Ft}=bt;if(je<0||je>24)return null;const Zt=1<1&&console.log("drilling down to z%d-%d-%d",je,$e,Ye);let Xt,Ps=je,gs=$e,vr=Ye;for(;!Xt&&Ps>0;)Ps--,gs>>=1,vr>>=1,Xt=this.tiles[Sr(Ps,gs,vr)];return Xt&&Xt.source?(Ft>1&&(console.log("found parent tile z%d-%d-%d",Ps,gs,vr),console.time("drilling down")),this.splitTile(Xt.source,Ps,gs,vr,je,$e,Ye),Ft>1&&console.timeEnd("drilling down"),this.tiles[Ut]?Wr(this.tiles[Ut],gt):null):null}}function Sr($t,je,$e){return 32*((1<<$t)*$e+je)+$t}function jr($t,je){const $e=$t.tileID.canonical;if(!this._geoJSONIndex)return void je(null,null);const Ye=this._geoJSONIndex.getTile($e.z,$e.x,$e.y);if(!Ye)return void je(null,null);const bt=Xt=>Xt.tags&&"3d_elevation_id"in Xt.tags&&"source"in Xt.tags&&Xt.tags.source==="elevation",gt=Ye.features.filter(Xt=>bt(Xt));let Ft={_geojsonTileLayer:Ye.features};gt.length>0&&(Ft={_geojsonTileLayer:Ye.features.filter(Xt=>!bt(Xt)),hd_road_elevation:gt});const Zt=new Q(Ft),Ut=function(Xt){const Ps=new i.bt;for(const gs of Object.keys(Xt))Ps.writeMessage(3,Pe,{name:gs,features:Xt[gs]});return Ps.finish()}(Ft).buffer;je(null,{vectorTile:Zt,rawData:Ut})}class ea extends q{constructor(je,$e,Ye,bt,gt,Ft,Zt){super(je,$e,Ye,bt,gt,jr,Zt),Ft&&(this.loadGeoJSON=Ft),this._dynamicIndex=new oe}loadData(je,$e){const Ye=je&&je.request,bt=Ye&&Ye.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(je,(gt,Ft)=>{if(gt||!Ft)return $e(gt);if(typeof Ft!="object")return $e(new Error(`Input data given to '${je.source}' is not a valid GeoJSON object.`));{try{if(je.filter){const Ut=i.U(je.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(", "));Ft.features=Ft.features.filter(Xt=>Ut.value.evaluate({zoom:0},Xt))}je.dynamic?(Ft.type==="Feature"&&(Ft={type:"FeatureCollection",features:[Ft]}),je.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Ft.features,this.loaded),je.cluster&&(Ft.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=je.cluster?new rt(function({superclusterOptions:Ut,clusterProperties:Xt}){if(!Xt||!Ut)return Ut;const Ps={},gs={},vr={accumulated:null,zoom:0},Hr={properties:null},xr=Object.keys(Xt);for(const Ln of xr){const[Dn,En]=Xt[Ln],_a=i.U(En),vo=i.U(typeof Dn=="string"?[Dn,["accumulated"],["get",Ln]]:Dn);Ps[Ln]=_a.value,gs[Ln]=vo.value}return Ut.map=Ln=>{Hr.properties=Ln;const Dn={};for(const En of xr)Dn[En]=Ps[En].evaluate(vr,Hr);return Dn},Ut.reduce=(Ln,Dn)=>{Hr.properties=Dn;for(const En of xr)vr.accumulated=Ln[En],Ln[En]=gs[En].evaluate(vr,Hr)},Ut}(je)).load(Ft.features):je.dynamic?this._dynamicIndex:function(Ut,Xt){return new Vn(Ut,Xt)}(Ft,je.geojsonVtOptions)}catch(Ut){return $e(Ut)}const Zt={};if(bt){const Ut=c(Ye);Ut&&(Zt.resourceTiming={},Zt.resourceTiming[je.source]=JSON.parse(JSON.stringify(Ut)))}$e(null,Zt)}})}reloadTile(je,$e){const Ye=this.loaded;return Ye&&Ye[je.uid]?je.partial?$e(null,void 0):super.reloadTile(je,$e):this.loadTile(je,$e)}loadGeoJSON(je,$e){if(je.request)i.m(je.request,$e);else{if(typeof je.data!="string")return $e(new Error(`Input data given to '${je.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return $e(null,JSON.parse(je.data))}catch{return $e(new Error(`Input data given to '${je.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(je,$e){try{$e(null,this._geoJSONIndex.getClusterExpansionZoom(je.clusterId))}catch(Ye){$e(Ye)}}getClusterChildren(je,$e){try{$e(null,this._geoJSONIndex.getChildren(je.clusterId))}catch(Ye){$e(Ye)}}getClusterLeaves(je,$e){try{$e(null,this._geoJSONIndex.getLeaves(je.clusterId,je.limit,je.offset))}catch(Ye){$e(Ye)}}}class Pa{constructor(je,$e,Ye){this.tileID=new i.aQ(je.tileID.overscaledZ,je.tileID.wrap,je.tileID.canonical.z,je.tileID.canonical.x,je.tileID.canonical.y),this.tileZoom=je.tileZoom,this.uid=je.uid,this.zoom=je.zoom,this.canonical=je.tileID.canonical,this.pixelRatio=je.pixelRatio,this.tileSize=je.tileSize,this.source=je.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=je.projection,this.brightness=$e,this.worldview=Ye}parse(je,$e,Ye,bt){this.status="parsing";const gt=new i.aQ(Ye.tileID.overscaledZ,Ye.tileID.wrap,Ye.tileID.canonical.z,Ye.tileID.canonical.x,Ye.tileID.canonical.y),Ft=[],Zt=$e.familiesBySource[Ye.source],Ut=new i.fn(gt,Ye.promoteId);Ut.bucketLayerIDs=[],Ut.is3DTile=!0,i.fC(je).then(Xt=>{if(!Xt)return bt(new Error("Could not parse tile"));const Ps=Xt.json.extensionsUsed&&Xt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Xt.json.asset.extras&&Xt.json.asset.extras.MAPBOX_mesh_features,gs=Xt.json.extensionsUsed&&Xt.json.extensionsUsed.includes("EXT_meshopt_compression"),vr=new i.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Hr in Zt)for(const xr of Zt[Hr]){const Ln=xr[0];Ut.bucketLayerIDs.push(xr.map(_a=>i.B(_a.id,_a.scope))),Ln.recalculate(vr,[]);const Dn=i.fD(Xt,1/i.d7(Ye.tileID.canonical)),En=new i.fE(xr,Dn,gt,Ps,gs,this.brightness,Ut,this.worldview);Ps||(En.needsUpload=!0),Ft.push(En),En.evaluate(Ln)}this.status="done",bt(null,{buckets:Ft,featureIndex:Ut,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Xt=>bt(new Error(Xt.message)))}}class Ii{constructor(je,$e,Ye,bt,gt,Ft,Zt,Ut){this.actor=je,this.layerIndex=$e,this.availableImages=Ye,this.availableModels=bt,this.brightness=Zt,this.loading={},this.loaded={},this.worldview=Ut}loadTile(je,$e){const Ye=je.uid,bt=this.loading[Ye]=new Pa(je,this.brightness,this.worldview);i.bu(je.request,(gt,Ft)=>{const Zt=!this.loading[Ye];return delete this.loading[Ye],Zt||gt?(bt.status="done",Zt||(this.loaded[Ye]=bt),$e(gt)):Ft&&Ft.byteLength!==0?void bt.parse(Ft,this.layerIndex,je,(Ut,Xt)=>{bt.status="done",this.loaded=this.loaded||{},this.loaded[Ye]=bt,Ut||!Xt?$e(Ut):$e(null,Xt)}):(bt.status="done",this.loaded[Ye]=bt,$e())})}reloadTile(je,$e){const Ye=this.loaded,bt=je.uid;if(Ye&&Ye[bt]){const gt=Ye[bt];gt.projection=je.projection,gt.brightness=je.brightness;const Ft=(Zt,Ut)=>{gt.reloadCallback&&(delete gt.reloadCallback,this.loadTile(je,$e)),$e(Zt,Ut)};gt.status==="parsing"?gt.reloadCallback=Ft:gt.status==="done"&&this.loadTile(je,$e)}}abortTile(je,$e){const Ye=je.uid;this.loading[Ye]&&delete this.loading[Ye],$e()}removeTile(je,$e){const Ye=this.loaded,bt=je.uid;Ye&&Ye[bt]&&delete Ye[bt],$e()}}class Fo{constructor(je){this.self=je,this.actor=new i.fG(je,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new i.x,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=i.cm({name:"mercator"}),this.workerSourceTypes={vector:q,geojson:ea,"raster-dem":U,"raster-array":V,"batched-model":Ii},this.workerSources={},this.self.registerWorkerSource=($e,Ye)=>{if(this.workerSourceTypes[$e])throw new Error(`Worker source with name "${$e}" already registered.`);this.workerSourceTypes[$e]=Ye},this.self.registerRTLTextPlugin=$e=>{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=$e.applyArabicShaping,i.fH.processBidirectionalText=$e.processBidirectionalText,i.fH.processStyledBidirectionalText=$e.processStyledBidirectionalText;for(const Ye of this.rtlPluginParsingListeners)Ye(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(je,$e,Ye){delete this.layerIndexes[je],delete this.availableImages[je],delete this.availableModels[je],delete this.workerSources[je],Ye()}checkIfReady(je,$e,Ye){Ye()}setReferrer(je,$e){this.referrer=$e}spriteLoaded(je,$e){this.isSpriteLoaded[je]||(this.isSpriteLoaded[je]={});const{scope:Ye,isLoaded:bt}=$e;if(this.isSpriteLoaded[je][Ye]=bt,this.workerSources[je]&&this.workerSources[je][Ye])for(const gt in this.workerSources[je][Ye]){const Ft=this.workerSources[je][Ye][gt];for(const Zt in Ft){const Ut=Ft[Zt];Ut instanceof q&&(Ut.isSpriteLoaded=bt,Ut.fire(new i.z("isSpriteLoaded")))}}}setImages(je,$e,Ye){this.availableImages[je]||(this.availableImages[je]={});const{scope:bt,images:gt}=$e;if(this.availableImages[je][bt]=gt,this.workerSources[je]&&this.workerSources[je][bt]){for(const Ft in this.workerSources[je][bt]){const Zt=this.workerSources[je][bt][Ft];for(const Ut in Zt)Zt[Ut].availableImages=gt}Ye()}else Ye()}setModels(je,{scope:$e,models:Ye},bt){if(this.availableModels[je]||(this.availableModels[je]={}),this.availableModels[je][$e]=Ye,this.workerSources[je]&&this.workerSources[je][$e]){for(const gt in this.workerSources[je][$e]){const Ft=this.workerSources[je][$e][gt];for(const Zt in Ft)Ft[Zt].availableModels=Ye}bt()}else bt()}setProjection(je,$e){this.projections[je]=i.cm($e)}setBrightness(je,$e,Ye){this.brightness=$e,Ye()}setWorldview(je,$e,Ye){this.worldview=$e,Ye()}setLayers(je,$e,Ye){this.getLayerIndex(je,$e.scope).replace($e.layers,$e.options),Ye()}updateLayers(je,$e,Ye){this.getLayerIndex(je,$e.scope).update($e.layers,$e.removedIds,$e.options),Ye()}loadTile(je,$e,Ye){$e.projection=this.projections[je]||this.defaultProjection,this.getWorkerSource(je,$e.type,$e.source,$e.scope).loadTile($e,Ye)}decodeRasterArray(je,$e,Ye){this.getWorkerSource(je,$e.type,$e.source,$e.scope).decodeRasterArray($e,Ye)}reloadTile(je,$e,Ye){$e.projection=this.projections[je]||this.defaultProjection,this.getWorkerSource(je,$e.type,$e.source,$e.scope).reloadTile($e,Ye)}abortTile(je,$e,Ye){this.getWorkerSource(je,$e.type,$e.source,$e.scope).abortTile($e,Ye)}removeTile(je,$e,Ye){this.getWorkerSource(je,$e.type,$e.source,$e.scope).removeTile($e,Ye)}removeSource(je,$e,Ye){if(!(this.workerSources[je]&&this.workerSources[je][$e.scope]&&this.workerSources[je][$e.scope][$e.type]&&this.workerSources[je][$e.scope][$e.type][$e.source]))return;const bt=this.workerSources[je][$e.scope][$e.type][$e.source];delete this.workerSources[je][$e.scope][$e.type][$e.source],bt.removeSource!==void 0?bt.removeSource($e,Ye):Ye()}loadWorkerSource(je,$e,Ye){try{this.self.importScripts($e.url),Ye()}catch(bt){Ye(bt)}}syncRTLPluginState(je,$e,Ye){if(i.fH.isParsed())Ye(null,!0);else if(i.fH.isParsing())this.rtlPluginParsingListeners.push(Ye);else try{i.fH.setState($e);const bt=i.fH.getPluginURL();!i.fH.isLoaded()||i.fH.isParsed()||i.fH.isParsing()||bt==null||(i.fH.setState({pluginStatus:i.fI.parsing,pluginURL:i.fH.getPluginURL()}),this.self.importScripts(bt),i.fH.isParsed()?Ye(null,!0):this.rtlPluginParsingListeners.push(Ye))}catch(bt){Ye(bt)}}setDracoUrl(je,$e){this.dracoUrl=$e}getAvailableImages(je,$e){this.availableImages[je]||(this.availableImages[je]={});let Ye=this.availableImages[je][$e];return Ye||(Ye=[]),Ye}getAvailableModels(je,$e){this.availableModels[je]||(this.availableModels[je]={});let Ye=this.availableModels[je][$e];return Ye||(Ye={}),Ye}getLayerIndex(je,$e){this.layerIndexes[je]||(this.layerIndexes[je]={});let Ye=this.layerIndexes[je][$e];return Ye||(Ye=this.layerIndexes[je][$e]=new f,Ye.scope=$e),Ye}getWorkerSource(je,$e,Ye,bt){const gt=this.workerSources;return gt[je]||(gt[je]={}),gt[je][bt]||(gt[je][bt]={}),gt[je][bt][$e]||(gt[je][bt][$e]={}),this.isSpriteLoaded[je]||(this.isSpriteLoaded[je]={}),gt[je][bt][$e][Ye]||(gt[je][bt][$e][Ye]=new this.workerSourceTypes[$e]({send:(Ft,Zt,Ut,Xt,Ps,gs)=>this.actor.send(Ft,Zt,Ut,je,Ps,gs),scheduler:this.actor.scheduler},this.getLayerIndex(je,bt),this.getAvailableImages(je,bt),this.getAvailableModels(je,bt),this.isSpriteLoaded[je][bt],void 0,this.brightness,this.worldview)),gt[je][bt][$e][Ye]}rasterizeImagesWorker(je,$e,Ye){const bt=new Map;for(const[gt,{image:Ft,imageVariant:Zt}]of $e.tasks.entries()){const Ut=this.imageRasterizer.rasterize(Zt,Ft,$e.scope,je);bt.set(gt,Ut)}Ye(void 0,bt)}removeRasterizedImages(je,$e,Ye){this.imageRasterizer.removeImagesFromCacheByIds($e.imageIds,$e.scope,je),Ye()}enforceCacheSizeLimit(je,$e){i.fJ($e)}getWorkerPerformanceMetrics(je,$e,Ye){Ye(void 0,void 0)}}return i.fF(self)&&(self.worker=new Fo(self)),Fo}),o(["./shared"],function(i){var c="3.17.0";const u={create:"create",load:"load",fullLoad:"fullLoad"},p={mark(T){performance.mark(T)},measure(T,h,y){performance.measure(T,h,y)}};function f(T){const h=T.name.split("?")[0];return i.a(h)&&h.includes("mapbox-gl.js")?"javascript":i.a(h)&&h.includes("mapbox-gl.css")?"css":i.b(h)?"fontRange":i.c(h)?"sprite":i.i(h)?"style":i.d(h)?"tilejson":"other"}var g,b={},_=function(){if(g)return b;function T(A){return!h(A)}function h(A){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var F,z,W=new Blob([""],{type:"text/javascript"}),J=URL.createObjectURL(W);try{z=new Worker(J),F=!0}catch{F=!1}return z&&z.terminate(),URL.revokeObjectURL(J),F}()?function(){var F=document.createElement("canvas");F.width=F.height=1;var z=F.getContext("2d");if(!z)return!1;var W=z.getImageData(0,0,1,1);return W&&W.width===F.width}()?(y[D=A&&A.failIfMajorPerformanceCaveat]===void 0&&(y[D]=function(F){var z,W=function(J){var ne=document.createElement("canvas"),le=Object.create(T.webGLContextAttributes);return le.failIfMajorPerformanceCaveat=J,ne.getContext("webgl2",le)}(F);if(!W)return!1;try{z=W.createShader(W.VERTEX_SHADER)}catch{return!1}return!(!z||W.isContextLost())&&(W.shaderSource(z,"void main() {}"),W.compileShader(z),W.getShaderParameter(z,W.COMPILE_STATUS)===!0)}(D)),y[D]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var D}g=1,b.supported=T,b.notSupportedReason=h;var y={};return T.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},b}();function j(T,h,y){const A=document.createElement(T);return h!=null&&(A.className=h),y&&y.appendChild(A),A}function w(T,h,y){const A=document.createElementNS("http://www.w3.org/2000/svg",T);for(const D of Object.keys(h))A.setAttributeNS(null,D,String(h[D]));return y&&y.appendChild(A),A}const k=typeof document<"u"?document.documentElement&&document.documentElement.style:null,S=k&&k.userSelect!==void 0?"userSelect":"WebkitUserSelect";let M;function L(){k&&S&&(M=k[S],k[S]="none")}function I(){k&&S&&(k[S]=M)}function O(T){T.preventDefault(),T.stopPropagation(),window.removeEventListener("click",O,!0)}function q(){window.addEventListener("click",O,!0),window.setTimeout(()=>{window.removeEventListener("click",O,!0)},0)}function U(T,h){const y=T.getBoundingClientRect();return Z(T,y,h)}function B(T,h){const y=T.getBoundingClientRect(),A=[];for(let D=0;Dthis._skuTokenExpiresAt}transformRequest(h,y){return this._transformRequestFn&&this._transformRequestFn(h,y)||{url:h}}normalizeStyleURL(h,y){if(!i.h(h))return h;const A=re(h);return A.params.push(`sdk=js-${c}`),A.path=`/styles/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||y)}normalizeGlyphsURL(h,y){if(!i.h(h))return h;const A=re(h);return A.path=`/fonts/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||y)}normalizeModelURL(h,y){if(!i.h(h))return h;const A=re(h);return A.path=`/models/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||y)}normalizeSourceURL(h,y,A,D){if(!i.h(h))return h;const F=re(h);return F.path=`/v4/${F.authority}.json`,F.params.push("secure"),A&&F.params.push(`language=${A}`),D&&F.params.push(`worldview=${D}`),this._makeAPIURL(F,this._customAccessToken||y)}normalizeIconsetURL(h,y){const A=re(h);return i.h(h)?(A.path=`/styles/v1${A.path}/iconset.pbf`,this._makeAPIURL(A,this._customAccessToken||y)):oe(A)}normalizeSpriteURL(h,y,A,D){const F=re(h);return i.h(h)?(F.path=`/styles/v1${F.path}/sprite${y}${A}`,this._makeAPIURL(F,this._customAccessToken||D)):(F.path+=`${y}${A}`,oe(F))}normalizeTileURL(h,y,A){if(this._isSkuTokenExpired()&&this._createSkuToken(),h&&!i.h(h))return h;const D=re(h);D.path=D.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${y||A&&D.authority!=="raster"&&A===512?"@2x":""}${i.k.supported?".webp":"$1"}`),D.authority==="raster"?D.path=`/${i.e.RASTER_URL_PREFIX}${D.path}`:D.authority==="rasterarrays"?D.path=`/${i.e.RASTERARRAYS_URL_PREFIX}${D.path}`:D.authority==="3dtiles"?D.path=`/${i.e.TILES3D_URL_PREFIX}${D.path}`:(D.path=D.path.replace(/^.+\/v4\//,"/"),D.path=`/${i.e.TILE_URL_VERSION}${D.path}`);const F=this._customAccessToken||function(z){for(const W of z){const J=W.match(/^access_token=(.*)$/);if(J)return J[1]}return null}(D.params)||i.e.ACCESS_TOKEN;return i.e.REQUIRE_ACCESS_TOKEN&&F&&this._skuToken&&D.params.push(`sku=${this._skuToken}`),this._makeAPIURL(D,F)}canonicalizeTileURL(h,y){const A=re(h);if(!A.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!A.path.match(/\.[\w]+$/))return h;let D="mapbox://";A.path.match(/^\/raster\/v1\//)?D+=`raster/${A.path.replace(`/${i.e.RASTER_URL_PREFIX}/`,"")}`:A.path.match(/^\/rasterarrays\/v1\//)?D+=`rasterarrays/${A.path.replace(`/${i.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:D+=`tiles/${A.path.replace(`/${i.e.TILE_URL_VERSION}/`,"")}`;let F=A.params;return y&&(F=F.filter(z=>!z.match(/^access_token=/))),F.length&&(D+=`?${F.join("&")}`),D}canonicalizeTileset(h,y){const A=!!y&&i.h(y),D=[];for(const F of h.tiles||[])i.j(F)?D.push(this.canonicalizeTileURL(F,A)):D.push(F);return D}_makeAPIURL(h,y){const A="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",D=re(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 oe(h);if(y=y||i.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!y)throw new Error(`An API access token is required to use Mapbox GL. ${A}`);if(y[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${A}`)}return h.params=h.params.filter(F=>F.indexOf("access_token")===-1),h.params.push(`access_token=${y||""}`),oe(h)}}const ie=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function re(T){const h=T.match(ie);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 oe(T){const h=T.params.length?`?${T.params.join("&")}`:"";return`${T.protocol}://${T.authority}${T.path}${h}`}const ce="mapbox.eventData";function xe(T){if(!T)return null;const h=T.split(".");if(!h||h.length!==3)return null;try{return JSON.parse(i.l(h[1]))}catch{return null}}class ge{constructor(h){this.type=h,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(h){const y=xe(i.e.ACCESS_TOKEN);let A="";return A=y&&y.u?i.f(y.u):i.e.ACCESS_TOKEN||"",h?`${ce}.${h}:${A}`:`${ce}:${A}`}fetchEventData(){const h=i.s("localStorage"),y=this.getStorageKey(),A=this.getStorageKey("uuid"),D=this.getStorageKey("uuidTimestamp");if(h)try{const F=localStorage.getItem(y);F&&(this.eventData=JSON.parse(F));const z=localStorage.getItem(A);z&&(this.anonId=z);const W=localStorage.getItem(D);W&&(this.anonIdTimestamp=Number(W));const J=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(y,JSON.stringify(this.eventData)),z&&localStorage.setItem(D,z.toString())}catch{i.w("Unable to write to LocalStorage")}}processRequests(h){}postEvent(h,y,A,D){if(!i.e.EVENTS_URL)return;const F=re(i.e.EVENTS_URL);F.params.push(`access_token=${D||i.e.ACCESS_TOKEN||""}`);const z={event:this.type,created:new Date(h).toISOString()},W=y?Object.assign(z,y):z,J={url:oe(F),headers:{"Content-Type":"text/plain"},body:JSON.stringify([W])};this.pendingRequest=i.p(J,ne=>{this.pendingRequest=null,A(ne),this.saveEventData(),this.processRequests(D)})}queueRequest(h,y){this.queue.push(h),this.processRequests(y)}}class ue extends ge{constructor(h){super("metrics"),h&&(this.data=h)}postMetricsEvent(h){if(!i.e.EVENTS_URL||!h&&!i.e.ACCESS_TOKEN)return;this.anonId||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID();const y=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:y},h)}processRequests(h){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:y,payload:A}=this.queue.shift();this.postEvent(y,A,()=>{},h)}}const pe=new class extends ge{constructor(T){super("appUserTurnstile"),this._customAccessToken=T}postTurnstileEvent(T,h){i.e.EVENTS_URL&&i.e.ACCESS_TOKEN&&Array.isArray(T)&&T.some(y=>i.h(y)||i.j(y))&&this.queueRequest(Date.now(),h)}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const h=xe(i.e.ACCESS_TOKEN),y=h?h.u:i.e.ACCESS_TOKEN;let A=y!==this.eventData.tokenU;i.v(this.anonId)||(this.refreshUUID(),A=!0);const D=this.queue.shift();if(this.eventData.lastSuccess){const F=new Date(this.eventData.lastSuccess),z=new Date(D),W=(D-this.eventData.lastSuccess)/864e5;A=A||W>=1||W<-1||F.getDate()!==z.getDate()}else A=!0;A?this.postEvent(D,{sdkIdentifier:"mapbox-gl-js",sdkVersion:c,skuId:X,"enabled.telemetry":!1,userId:this.anonId},F=>{F||(this.eventData.lastSuccess=D,this.eventData.tokenU=y)},T):this.processRequests()}},be=pe.postTurnstileEvent.bind(pe),Me=new class extends ge{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(T,h,y,A){this.skuToken=h,this.errorCb=A,i.e.EVENTS_URL&&(y||i.e.ACCESS_TOKEN?this.queueRequest({id:T,timestamp:Date.now()},y):this.errorCb(new Error(ee)))}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{id:h,timestamp:y}=this.queue.shift();h&&this.success[h]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID(),this.postEvent(y,{sdkIdentifier:"mapbox-gl-js",sdkVersion:c,skuId:X,skuToken:this.skuToken,userId:this.anonId},A=>{A?this.errorCb(A):h&&(this.success[h]=!0)},T))}remove(){this.errorCb=null}},Ne=Me.postMapLoadEvent.bind(Me),Pe=new class extends ge{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(T){let h=this.mapInstanceIdMap.get(T);return h||(h=i.u(),this.mapInstanceIdMap.set(T,h)),h}getEventId(T){const h=this.eventIdPerMapInstanceMap.get(T)||0;return this.eventIdPerMapInstanceMap.set(T,h+1),h}postStyleLoadEvent(T,h){const{map:y,style:A,importedStyles:D}=h;if(!i.e.EVENTS_URL||!T&&!i.e.ACCESS_TOKEN)return;const F=this.getMapInstanceId(y),z={mapInstanceId:F,eventId:this.getEventId(F),style:A};D.length&&(z.importedStyles=D),this.queueRequest({timestamp:Date.now(),payload:z},T)}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,payload:y}=this.queue.shift();this.postEvent(h,y,()=>{},T)}},Oe=Pe.postStyleLoadEvent.bind(Pe),Te=new ue({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),ke=Te.postMetricsEvent.bind(Te),Be=new ue({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),nt=Be.postMetricsEvent.bind(Be),Ae=new class extends ge{constructor(){super("gljs.performance")}postPerformanceEvent(T,h){i.e.EVENTS_URL&&(T||i.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:h},T)}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,performanceData:y}=this.queue.shift(),A=function(D){const F=performance.getEntriesByType("resource"),z=performance.getEntriesByType("mark"),W=function(we){const Le={};if(we){for(const Ie in we)if(Ie!=="other")for(const We of we[Ie]){const Ue=`${Ie}ResolveRangeMin`,st=`${Ie}ResolveRangeMax`,ut=`${Ie}RequestCount`,ot=`${Ie}RequestCachedCount`;Le[Ue]=Math.min(Le[Ue]||1/0,We.startTime),Le[st]=Math.max(Le[st]||-1/0,We.responseEnd);const Et=Nt=>{Le[Nt]===void 0&&(Le[Nt]=0),++Le[Nt]};We.transferSize!==void 0&&We.transferSize===0&&Et(ot),Et(ut)}}return Le}(function(we,Le){const Ie={};if(we)for(const We of we){const Ue=Le(We);Ie[Ue]===void 0&&(Ie[Ue]=[]),Ie[Ue].push(We)}return Ie}(F,f)),J=window.devicePixelRatio,ne=navigator.connection||navigator.mozConnection||navigator.webkitConnection,le=ne?ne.effectiveType:void 0,_e={counters:[],metadata:[],attributes:[]},ye=(we,Le,Ie)=>{Ie!=null&&we.push({name:Le,value:Ie.toString()})};for(const we in W)ye(_e.counters,we,W[we]);if(D.interactionRange[0]!==1/0&&D.interactionRange[1]!==-1/0&&(ye(_e.counters,"interactionRangeMin",D.interactionRange[0]),ye(_e.counters,"interactionRangeMax",D.interactionRange[1])),z)for(const we of Object.values(u)){const Le=z.find(Ie=>Ie.name===we);Le&&ye(_e.counters,we,Le.startTime)}return ye(_e.counters,"visibilityHidden",D.visibilityHidden),ye(_e.attributes,"style",function(we){if(we)for(const Le of we){const Ie=Le.name.split("?")[0];if(i.i(Ie)){const We=Ie.split("/").slice(-2);if(We.length===2)return`mapbox://styles/${We[0]}/${We[1]}`}}}(F)),ye(_e.attributes,"terrainEnabled",D.terrainEnabled?"true":"false"),ye(_e.attributes,"fogEnabled",D.fogEnabled?"true":"false"),ye(_e.attributes,"projection",D.projection),ye(_e.attributes,"zoom",D.zoom),ye(_e.metadata,"devicePixelRatio",J),ye(_e.metadata,"connectionEffectiveType",le),ye(_e.metadata,"navigatorUserAgent",navigator.userAgent),ye(_e.metadata,"screenWidth",window.screen.width),ye(_e.metadata,"screenHeight",window.screen.height),ye(_e.metadata,"windowWidth",window.innerWidth),ye(_e.metadata,"windowHeight",window.innerHeight),ye(_e.metadata,"mapWidth",D.width/J),ye(_e.metadata,"mapHeight",D.height/J),ye(_e.metadata,"webglRenderer",D.renderer),ye(_e.metadata,"webglVendor",D.vendor),ye(_e.metadata,"sdkVersion",c),ye(_e.metadata,"sdkIdentifier","mapbox-gl-js"),_e}(y);for(const D of A.metadata);for(const D of A.counters);for(const D of A.attributes);this.postEvent(h,A,()=>{},T)}},ft=Ae.postPerformanceEvent.bind(Ae),fe=new class extends ge{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(T,h,y,A){if(!i.e.API_URL||!i.e.SESSION_PATH)return;const D=re(i.e.API_URL+i.e.SESSION_PATH);D.params.push(`sku=${h||""}`),D.params.push(`access_token=${A||i.e.ACCESS_TOKEN||""}`);const F={url:oe(D),headers:{"Content-Type":"text/plain"}};this.pendingRequest=i.g(F,z=>{this.pendingRequest=null,y(z),this.saveEventData(),this.processRequests(A)})}getSessionAPI(T,h,y,A){this.skuToken=h,this.errorCb=A,i.e.SESSION_PATH&&i.e.API_URL&&(y||i.e.ACCESS_TOKEN?this.queueRequest({id:T,timestamp:Date.now()},y):this.errorCb(new Error(ee)))}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{id:h,timestamp:y}=this.queue.shift();h&&this.success[h]||this.getSession(y,this.skuToken,A=>{A?this.errorCb(A):h&&(this.success[h]=!0)},T)}remove(){this.errorCb=null}},Ve=fe.getSessionAPI.bind(fe),at=new Set;function et(T,h){h?at.add(T):at.delete(T)}class Ce{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(h,y){this._updatedSourceCaches[h]=y,this.setDirty()}discardSourceCacheUpdate(h){delete this._updatedSourceCaches[h]}updateLayer(h){const y=h.scope;this._updatedLayers[y]=this._updatedLayers[y]||new Set,this._updatedLayers[y].add(h.id),this.setDirty()}removeLayer(h){const y=h.scope;this._removedLayers[y]=this._removedLayers[y]||{},this._updatedLayers[y]=this._updatedLayers[y]||new Set,this._removedLayers[y][h.id]=h,this._updatedLayers[y].delete(h.id),this._updatedPaintProps.delete(h.fqid),this.setDirty()}getRemovedLayer(h){return this._removedLayers[h.scope]?this._removedLayers[h.scope][h.id]:null}discardLayerRemoval(h){this._removedLayers[h.scope]&&delete this._removedLayers[h.scope][h.id]}getLayerUpdatesByScope(){const h={};for(const y in this._updatedLayers)h[y]=h[y]||{},h[y].updatedIds=Array.from(this._updatedLayers[y].values());for(const y in this._removedLayers)h[y]=h[y]||{},h[y].removedIds=Object.keys(this._removedLayers[y]);return h}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(h){this._updatedPaintProps.add(h.fqid),this.setDirty()}getUpdatedImages(h){return this._updatedImages[h]?Array.from(this._updatedImages[h].values()):[]}updateImage(h,y){this._updatedImages[y]=this._updatedImages[y]||new Set,this._updatedImages[y].add(i.I.toString(h)),this.setDirty()}resetUpdatedImages(h){this._updatedImages[h]&&this._updatedImages[h].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function rt(T){const{userImage:h}=T;return!!(h&&h.render&&h.render())&&(T.data.replace(new Uint8Array(h.data.buffer)),!0)}class Ge extends i.E{constructor(h){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.dirty=!0,this.spriteFormat=h,h!=="raster"&&i.r()&&(this.imageRasterizerDispatcher=new i.D(i.t(),this,"Image Rasterizer Worker",1))}addScope(h){this.loaded.set(h,!1),this.imageProviders.set(h,new Map),this.images.set(h,new Map),this.updatedImages.set(h,new Set),this.callbackDispatchedThisFrame.set(h,new Set),this.patterns.set(h,new Map),this.atlasImage.set(h,new i.q({width:1,height:1}))}removeScope(h){this.loaded.delete(h),this.imageProviders.delete(h),this.images.delete(h),this.updatedImages.delete(h),this.callbackDispatchedThisFrame.delete(h),this.patterns.delete(h),this.atlasImage.delete(h);const y=this.atlasTexture.get(h);y&&(y.destroy(),this.atlasTexture.delete(h))}addImageProvider(h,y){this.imageProviders.has(y)||this.imageProviders.set(y,new Map),this.imageProviders.get(y).set(h.id,h)}removeImageProvider(h,y){this.imageProviders.has(y)&&this.imageProviders.get(y).delete(h)}getPendingImageProviders(){const h=[];for(const y of this.imageProviders.values())for(const A of y.values())A.hasPendingRequests()&&h.push(A);return h}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new i.x),this._imageRasterizer}isLoaded(){for(const h of this.loaded.keys())if(!this.loaded.get(h))return!1;return!0}setLoaded(h,y){if(this.loaded.get(y)!==h&&(this.loaded.set(y,h),h)){for(const{ids:A,callback:D}of this.requestors)this._notify(A,y,D);this.requestors=[]}}hasImage(h,y){return!!this.getImage(h,y)}getImage(h,y){return this.images.get(y).get(h.toString())}addImage(h,y,A){this._validate(h,A)&&this.images.get(y).set(h.toString(),A)}_validate(h,y){let A=!0;return this._validateStretch(y.stretchX,y.data&&y.data.width)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchX" value`))),A=!1),this._validateStretch(y.stretchY,y.data&&y.data.height)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchY" value`))),A=!1),this._validateContent(y.content,y)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "content" value`))),A=!1),A}_validateStretch(h,y){if(!h)return!0;let A=0;for(const D of h){if(D[0]i.I.from(y))}getImages(h,y,A){const D=[],F=[],z=this.imageProviders.get(y);for(const le of h){if(!le.iconsetId){D.push(le);continue}const _e=z.get(le.iconsetId);_e&&(this.getImage(le,y)?F.push(le):_e.addPendingRequest(le))}if(D.length===0)return void this._notify(F,y,A);let W=!0;const J=!!this.loaded.get(y),ne=this.images.get(y);if(!J)for(const le of D)ne.has(le.toString())||(W=!1);J||W?this._notify(D,y,A):this.requestors.push({ids:D,scope:y,callback:A})}rasterizeImages(h,y){const A=new Map,{tasks:D,scope:F}=h;for(const[z,W]of D.entries()){const J=this.getImage(W.id,F);J&&A.set(z,{image:J,imageVariant:W})}this._rasterizeImages(F,A,y)}_rasterizeImages(h,y,A){if(i.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:y,scope:h},A);else{const D=new Map;for(const[F,{image:z,imageVariant:W}]of y.entries())D.set(F,this.imageRasterizer.rasterize(W,z,h,0));A(void 0,D)}}getUpdatedImages(h){return this.updatedImages.get(h)||new Set}_notify(h,y,A){const D=this.images.get(y),F=new Map;for(const z of h){if(!D.get(z.toString())){if(z.iconsetId)continue;this.fire(new i.z("styleimagemissing",{id:z.name}))}const W=D.get(z.toString());if(!W){i.w(`Image "${z.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}const J={data:W.usvg?null:W.data.clone(),pixelRatio:W.pixelRatio,sdf:W.sdf,usvg:W.usvg,version:W.version,stretchX:W.stretchX,stretchY:W.stretchY,content:W.content,hasRenderCallback:!!(W.userImage&&W.userImage.render)};W.usvg&&Object.assign(J,{width:W.icon.usvg_tree.width,height:W.icon.usvg_tree.height}),F.set(i.I.toString(z),J)}A(null,F)}getPixelSize(h){const{width:y,height:A}=this.atlasImage.get(h);return{width:y,height:A}}getPattern(h,y,A){const D=h.toString(),F=this.patterns.get(y),z=F.get(D),W=this.getImage(h,y);if(!W)return null;if(z){if(z.position.version===W.version)return z.position;z.position.version=W.version}else{if(W.usvg&&!W.data){const J=this.getPatternInFlightId(D,y);if(this.patternsInFlight.has(J))return null;this.patternsInFlight.add(J);const ne=new i.A(h).scaleSelf(i.o.devicePixelRatio),le=new Map([[ne.toString(),{image:W,imageVariant:ne}]]);return this._rasterizeImages(y,le,(_e,ye)=>this.storePatternImage(ne,y,W,A,ye)),null}this.storePattern(h,y,W)}return this._updatePatternAtlas(y,A),F.get(D).position}getPatternInFlightId(h,y){return i.B(h,y)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(h,y,A,D,F){const z=h.toString(),W=F?F.get(z):void 0;W&&(A.data=W,this.storePattern(h.id,y,A),this._updatePatternAtlas(y,D),this.patternsInFlight.delete(this.getPatternInFlightId(h.id.toString(),y)))}storePattern(h,y,A){const D={w:A.data.width+2*i.C,h:A.data.height+2*i.C,x:0,y:0},F=new i.F(D,A,i.C);this.patterns.get(y).set(h.toString(),{bin:D,position:F})}destroyAtlasTextures(){for(const h of this.atlasTexture.values())h&&h.destroy();this.atlasTexture.clear()}bind(h,y){const A=h.gl;let D=this.atlasTexture.get(y);D?this.dirty&&(D.update(this.atlasImage.get(y)),this.dirty=!1):(D=new i.T(h,this.atlasImage.get(y),A.RGBA8),this.atlasTexture.set(y,D)),D.bind(A.LINEAR,A.CLAMP_TO_EDGE)}_updatePatternAtlas(h,y){const A=this.patterns.get(h),D=Array.from(A.values()).map(({bin:ne})=>ne),{w:F,h:z}=i.G(D),W=this.atlasImage.get(h);W.resize({width:F||1,height:z||1});const J=this.images.get(h);for(const[ne,{bin:le,position:_e}]of A.entries()){let ye=_e.padding;const we=le.x+ye,Le=le.y+ye,Ie=J.get(ne).data,We=Ie.width,Ue=Ie.height;ye=ye>1?ye-1:ye,i.q.copy(Ie,W,{x:0,y:0},{x:we,y:Le},{width:We,height:Ue},y),i.q.copy(Ie,W,{x:0,y:Ue-ye},{x:we,y:Le-ye},{width:We,height:ye},y),i.q.copy(Ie,W,{x:0,y:0},{x:we,y:Le+Ue},{width:We,height:ye},y),i.q.copy(Ie,W,{x:We-ye,y:0},{x:we-ye,y:Le},{width:ye,height:Ue},y),i.q.copy(Ie,W,{x:0,y:0},{x:we+We,y:Le},{width:ye,height:Ue},y),i.q.copy(Ie,W,{x:We-ye,y:Ue-ye},{x:we-ye,y:Le-ye},{width:ye,height:ye},y),i.q.copy(Ie,W,{x:0,y:Ue-ye},{x:we+We,y:Le-ye},{width:ye,height:ye},y),i.q.copy(Ie,W,{x:0,y:0},{x:we+We,y:Le+Ue},{width:ye,height:ye},y),i.q.copy(Ie,W,{x:We-ye,y:0},{x:we-ye,y:Le+Ue},{width:ye,height:ye},y)}this.dirty=!0}beginFrame(){for(const h of this.images.keys())this.callbackDispatchedThisFrame.set(h,new Set)}dispatchRenderCallbacks(h,y){const A=this.images.get(y);for(const D of h){if(this.callbackDispatchedThisFrame.get(y).has(D.toString()))continue;this.callbackDispatchedThisFrame.get(y).add(D.toString());const F=A.get(D.toString());rt(F)&&this.updateImage(D,y,F)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function ct(T){const h=T.value,y=T.valueSpec,A=T.style,D=T.styleSpec,F=T.key,z=T.arrayElementValidator||dr;if(!Array.isArray(h))return[new i.V(F,h,`array expected, ${i.K(h)} found`)];if(y.length&&h.length!==y.length)return[new i.V(F,h,`array length ${y.length} expected, length ${h.length} found`)];if(y["min-length"]&&h.lengthD)return[new i.V(h,y,`${y} is greater than the maximum value ${D}`)]}return[]}function Ze(T){const h=T.key,y=T.value;if(!i.H(y))return[new i.V(h,y,`object expected, ${i.K(y)} found`)];const A=T.valueSpec,D=i.J(y.type);let F,z,W,J={};const ne=D!=="categorical"&&y.property===void 0,le=!ne,_e=function(Ie){const We=Ie.stops;return Array.isArray(We)&&Array.isArray(We[0])&&i.H(We[0][0])}(y),ye=Jr({key:T.key,value:T.value,valueSpec:T.styleSpec.function,style:T.style,styleSpec:T.styleSpec,objectElementValidators:{stops:function(Ie){if(D==="identity")return[new i.V(Ie.key,Ie.value,'identity function may not have a "stops" property')];let We=[];const Ue=Ie.value;return We=We.concat(ct({key:Ie.key,value:Ue,valueSpec:Ie.valueSpec,style:Ie.style,styleSpec:Ie.styleSpec,arrayElementValidator:we})),Array.isArray(Ue)&&Ue.length===0&&We.push(new i.V(Ie.key,Ue,"array must have at least one stop")),We},default:function(Ie){return dr({key:Ie.key,value:Ie.value,valueSpec:A,style:Ie.style,styleSpec:Ie.styleSpec})}}});return D==="identity"&&ne&&ye.push(new i.V(T.key,T.value,'missing required property "property"')),D==="identity"||y.stops||ye.push(new i.V(T.key,T.value,'missing required property "stops"')),D==="exponential"&&A.expression&&!i.M(A)&&ye.push(new i.V(T.key,T.value,"exponential functions not supported")),T.styleSpec.$version>=8&&(le&&!i.N(A)?ye.push(new i.V(T.key,T.value,"property functions not supported")):ne&&!i.O(A)&&ye.push(new i.V(T.key,T.value,"zoom functions not supported"))),D!=="categorical"&&!_e||y.property!==void 0||ye.push(new i.V(T.key,T.value,'"property" property is required')),ye;function we(Ie){let We=[];const Ue=Ie.value,st=Ie.key;if(!Array.isArray(Ue))return[new i.V(st,Ue,`array expected, ${i.K(Ue)} found`)];if(Ue.length!==2)return[new i.V(st,Ue,`array length 2 expected, length ${Ue.length} found`)];if(_e){if(!i.H(Ue[0]))return[new i.V(st,Ue,`object expected, ${i.K(Ue[0])} found`)];const ut=Ue[0];if(ut.zoom===void 0)return[new i.V(st,Ue,"object stop key must have zoom")];if(ut.value===void 0)return[new i.V(st,Ue,"object stop key must have value")];const ot=i.J(ut.zoom);if(typeof ot!="number")return[new i.V(st,ut.zoom,"stop zoom values must be numbers")];if(W&&W>ot)return[new i.V(st,ut.zoom,"stop zoom values must appear in ascending order")];ot!==W&&(W=ot,z=void 0,J={}),We=We.concat(Jr({key:`${st}[0]`,value:Ue[0],valueSpec:{zoom:{}},style:Ie.style,styleSpec:Ie.styleSpec,objectElementValidators:{zoom:qe,value:Le}}))}else We=We.concat(Le({key:`${st}[0]`,value:Ue[0],style:Ie.style,styleSpec:Ie.styleSpec},Ue));return i.Q(i.S(Ue[1]))?We.concat([new i.V(`${st}[1]`,Ue[1],"expressions are not allowed in function stops.")]):We.concat(dr({key:`${st}[1]`,value:Ue[1],valueSpec:A,style:Ie.style,styleSpec:Ie.styleSpec}))}function Le(Ie,We){const Ue=i.K(Ie.value),st=i.J(Ie.value),ut=Ie.value!==null?Ie.value:We;if(F){if(Ue!==F)return[new i.V(Ie.key,ut,`${Ue} stop domain type must match previous stop domain type ${F}`)]}else F=Ue;if(Ue!=="number"&&Ue!=="string"&&Ue!=="boolean"&&typeof st!="number"&&typeof st!="string"&&typeof st!="boolean")return[new i.V(Ie.key,ut,"stop domain value must be a number, string, or boolean")];if(Ue!=="number"&&D!=="categorical"){let ot=`number expected, ${Ue} found`;return i.N(A)&&D===void 0&&(ot+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new i.V(Ie.key,ut,ot)]}return D!=="categorical"||Ue!=="number"||typeof st=="number"&&isFinite(st)&&Math.floor(st)===st?D!=="categorical"&&Ue==="number"&&typeof st=="number"&&typeof z=="number"&&z!==void 0&&stnew i.V(`${T.key}${A.key}`,T.value,A.message));const y=h.value.expression||h.value._styleExpression.expression;if(T.expressionContext==="property"&&T.propertyKey==="text-font"&&!y.outputDefined())return[new i.V(T.key,T.value,`Invalid data expression for "${T.propertyKey}". Output values must be contained as literals within the expression.`)];if(T.expressionContext==="property"&&T.propertyType==="layout"&&!i.Z(y))return[new i.V(T.key,T.value,'"feature-state" data expressions are not supported with layout properties.')];if(T.expressionContext==="filter")return He(y,T);if(T.expressionContext==="appearance")return Je(y,T);if(T.expressionContext&&T.expressionContext.indexOf("cluster")===0){if(!i.X(y,["zoom","feature-state"]))return[new i.V(T.key,T.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(T.expressionContext==="cluster-initial"&&!i.Y(y))return[new i.V(T.key,T.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function He(T,h){const y=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(h.valueSpec&&h.valueSpec.expression)for(const D of h.valueSpec.expression.parameters)y.delete(D);if(y.size===0)return[];const A=[];return T instanceof i._&&y.has(T.name)?[new i.V(h.key,h.value,`["${T.name}"] expression is not supported in a filter for a ${h.object.type} layer with id: ${h.object.id}`)]:(T.eachChild(D=>{A.push(...He(D,h))}),A)}function Je(T,h){const y=new Set;if(h.valueSpec&&h.valueSpec.expression)for(const D of h.valueSpec.expression.parameters)y.add(D);if(y.size===0)return[];const A=[];return T instanceof i._&&!y.has(T.name)?[new i.V(h.key,h.value,`["${T.name}"] is not an allowed parameter`)]:(T.eachChild(D=>{A.push(...Je(D,h))}),A)}function it(T){const h=T.key,y=T.value,A=T.valueSpec,D=[];return Array.isArray(A.values)?A.values.indexOf(i.J(y))===-1&&D.push(new i.V(h,y,`expected one of [${A.values.join(", ")}], ${JSON.stringify(y)} found`)):Object.keys(A.values).indexOf(i.J(y))===-1&&D.push(new i.V(h,y,`expected one of [${Object.keys(A.values).join(", ")}], ${JSON.stringify(y)} found`)),D}function Lt(T){return i.a2(i.S(T.value))?Qe(Object.assign({},T,{expressionContext:"filter",valueSpec:T.styleSpec[`filter_${T.layerType||"fill"}`]})):Vt(T)}function Vt(T){const h=T.value,y=T.key;if(!Array.isArray(h))return[new i.V(y,h,`array expected, ${i.K(h)} found`)];if(h.length<1)return[new i.V(y,h,"filter array must have at least 1 element")];const A=T.styleSpec;let D=it({key:`${y}[0]`,value:h[0],valueSpec:A.filter_operator});const F=()=>{h.length>=2&&(i.a0(h[1])||D.push(new i.V(`${y}[1]`,h[1],`string expected, ${i.K(h[1])} found`)));for(let z=2;z":case">=":h.length>=2&&i.J(h[1])==="$type"&&D.push(new i.V(y,h,`"$type" cannot be use with operator "${h[0]}"`)),h.length!==3&&D.push(new i.V(y,h,`filter array for operator "${h[0]}" must have 3 elements`)),F();break;case"==":case"!=":h.length!==3&&D.push(new i.V(y,h,`filter array for operator "${h[0]}" must have 3 elements`)),F();break;case"in":case"!in":F();break;case"any":case"all":case"none":for(let z=1;z{ne in y&&h.push(new i.V(A,y[ne],`"${ne}" is prohibited for ref layers`))}),D.layers.forEach(ne=>{i.J(ne.id)===W&&(J=ne)}),J?J.ref?h.push(new i.V(A,y.ref,"ref cannot reference another ref layer")):z=i.J(J.type):typeof W=="string"&&h.push(new i.V(A,y.ref,`ref layer "${W}" not found`))}else if(z!=="background"&&z!=="sky"&&z!=="slot")if(y.source)if(i.a0(y.source)){const J=D.sources&&D.sources[y.source],ne=J&&i.J(J.type);J?ne==="vector"&&z==="raster"?h.push(new i.V(A,y.source,`layer "${y.id}" requires a raster source`)):ne==="raster"&&z!=="raster"?h.push(new i.V(A,y.source,`layer "${y.id}" requires a vector source`)):ne!=="vector"||y["source-layer"]?ne==="raster-dem"&&z!=="hillshade"?h.push(new i.V(A,y.source,"raster-dem source can only be used with layer type 'hillshade'.")):ne!=="raster-array"||["raster","raster-particle"].includes(z)?z==="line"&&y.paint&&(y.paint["line-gradient"]||y.paint["line-trim-offset"])&&ne==="geojson"&&!J.lineMetrics?h.push(new i.V(A,y,`layer "${y.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):z==="raster-particle"&&ne!=="raster-array"&&h.push(new i.V(A,y.source,`layer "${y.id}" requires a 'raster-array' source.`)):h.push(new i.V(A,y.source,"raster-array source can only be used with layer type 'raster'.")):h.push(new i.V(A,y,`layer "${y.id}" must specify a "source-layer"`)):h.push(new i.V(A,y.source,`source "${y.source}" not found`))}else h.push(new i.V(`${A}.source`,y.source,'"source" must be a string'));else h.push(new i.V(A,y,'missing required property "source"'));return h=h.concat(Jr({key:A,value:y,valueSpec:F.layer,style:T.style,styleSpec:T.styleSpec,objectElementValidators:{"*":()=>[],type:()=>dr({key:`${A}.type`,value:y.type,valueSpec:F.layer.type,style:T.style,styleSpec:T.styleSpec,object:y,objectKey:"type"}),filter:J=>Lt(Object.assign({layerType:z},J)),layout:J=>Jr({layer:y,key:J.key,value:J.value,valueSpec:{},style:J.style,styleSpec:J.styleSpec,objectElementValidators:{"*":ne=>Cs(Object.assign({layerType:z},ne))}}),paint:J=>Jr({layer:y,key:J.key,value:J.value,valueSpec:{},style:J.style,styleSpec:J.styleSpec,objectElementValidators:{"*":ne=>Ts(Object.assign({layerType:z,layer:y},ne))}}),appearances(J){const ne=ct({key:J.key,value:J.value,valueSpec:J.valueSpec,style:J.style,styleSpec:J.styleSpec,arrayElementValidator:ye=>function(we){const{key:Le,layer:Ie,layerType:We}=we,Ue=i.J(we.value),st=i.J(Ue.name),ut=i.J(Ue.condition),ot=Jr({key:Le,value:Ue,valueSpec:we.styleSpec.appearance,style:we.style,styleSpec:we.styleSpec,objectElementValidators:{condition:Et=>function(Nt){const Tt=[];return Tt.push(...Qe({key:Nt.key,value:Nt.object.condition,valueSpec:i.a6.appearance.condition,expressionContext:"appearance"})),Tt}(Object.assign({layer:Ie,layerType:We},Et)),properties:Et=>function(Nt){const Tt=[],{styleSpec:wt,layer:yt,layerType:Ot}=Nt,Wt=wt[`paint_${Ot}`],Ht=wt[`layout_${Ot}`],es=Nt.object[Nt.objectKey];for(const ts in es){const xs=ts in Wt?"paint":ts in Ht?"layout":void 0;if(!xs){Tt.push(new i.V(Nt.key,ts,`unknown property "${ts}" for layer type "${Ot}"`));continue}const qs=Object.assign({},Nt,{key:`${Nt.key}.${ts}`,object:es,objectKey:ts,layer:yt,layerType:Ot,value:es[ts],valueSpec:xs==="paint"?Wt[ts]:Ht[ts]});Tt.push(...hs(qs,xs))}return Tt}(Object.assign({layer:Ie,layerType:We},Et))}});return st!=="hidden"&&ut===void 0&&ot.push(new i.V(we.key,"name",'Appearance with name different than "hidden" must have a condition')),ot}(Object.assign({layerType:z,layer:y},ye))}),le=Array.isArray(J.value)?J.value:[],_e=new Set;return le.forEach((ye,we)=>{const Le=i.J(ye.name);if(Le)if(_e.has(Le)){const Ie=i.J(y.id);ne.push(new i.V(J.key,Le,`Duplicated appearance name "${Le}" for layer "${Ie}"`))}else _e.add(Le)}),ne}}})),h}function er({key:T,value:h}){return i.a0(h)?[]:[new i.V(T,h,`string expected, ${i.K(h)} found`)]}const xt={promoteId:function T({key:h,value:y}){if(i.a0(y))return er({key:h,value:y});if(Array.isArray(y)){const D=[],F=i.S(y),z=i.U(F);return z.result==="error"&&z.value.forEach(W=>{D.push(new i.V(`${h}${W.key}`,null,`${W.message}`))}),i.X(z.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||D.push(new i.V(`${h}`,null,"promoteId expression should be only feature dependent")),D}if(!i.H(y))return[new i.V(h,y,`string, expression or object expected, "${i.K(y)}" found`)];const A=[];for(const D in y)A.push(...T({key:`${h}.${D}`,value:y[D]}));return A}};function Es(T){const h=T.value,y=T.key,A=T.styleSpec,D=T.style;if(!i.H(h))return[new i.V(y,h,`object expected, ${i.K(h)} found`)];if(!("type"in h))return[new i.V(y,h,'"type" is required')];const F=i.J(h.type);let z=[];switch(["vector","raster","raster-dem","raster-array"].includes(F)&&("url"in h||"tiles"in h||z.push(new i.a3(y,h,'Either "url" or "tiles" is required.'))),F){case"vector":case"raster":case"raster-dem":case"raster-array":return z=z.concat(Jr({key:y,value:h,valueSpec:A[`source_${F.replace("-","_")}`],style:T.style,styleSpec:A,objectElementValidators:xt})),z;case"geojson":if(z=Jr({key:y,value:h,valueSpec:A.source_geojson,style:D,styleSpec:A,objectElementValidators:xt}),"cluster"in h&&"clusterProperties"in h){if(!i.H(h.clusterProperties))return[new i.V(`${y}.clusterProperties`,h,`object expected, ${i.K(h)} found`)];for(const W in h.clusterProperties){const J=h.clusterProperties[W];if(!Array.isArray(J))return[new i.V(`${y}.clusterProperties.${W}`,J,"array expected")];const[ne,le]=J,_e=typeof ne=="string"?[ne,["accumulated"],["get",W]]:ne;z.push(...Qe({key:`${y}.${W}.map`,value:le,expressionContext:"cluster-map"})),z.push(...Qe({key:`${y}.${W}.reduce`,value:_e,expressionContext:"cluster-reduce"}))}}return z;case"video":return Jr({key:y,value:h,valueSpec:A.source_video,style:D,styleSpec:A});case"image":return Jr({key:y,value:h,valueSpec:A.source_image,style:D,styleSpec:A});case"canvas":return[new i.V(y,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return it({key:`${y}.type`,value:h.type,valueSpec:{values:ur(A)}})}}function ur(T){return T.source.reduce((h,y)=>{const A=T[y];return A.type.type==="enum"&&(h=h.concat(Object.keys(A.type.values||{}))),h},[])}function Mr(T){const h=T.value,y=T.styleSpec,A=y.light,D=T.style;if(h===void 0)return[];if(!i.H(h))return[new i.V("light",h,`object expected, ${i.K(h)} found`)];let F=[];for(const z in h){const W=z.match(/^(.*)-transition$/),J=z.match(/^(.*)-use-theme$/);F=F.concat(J&&A[J[1]]?dr({key:z,value:h[z],valueSpec:{type:"string"},style:D,styleSpec:y}):W&&A[W[1]]&&A[W[1]].transition?dr({key:z,value:h[z],valueSpec:y.transition,style:D,styleSpec:y}):A[z]?dr({key:z,value:h[z],valueSpec:A[z],style:D,styleSpec:y}):[new i.V(z,h[z],`unknown property "${z}"`)])}return F}function Lr(T){const h=T.value;if(!h)return[];const y=T.key;if(!i.H(h))return[new i.V(y,h,`object expected, ${i.K(h)} found`)];let A=[];const D=T.styleSpec,F=D["light-3d"],z=T.style,W=T.style.lights;for(const le of["type","id"])if(!(le in h))return A=A.concat([new i.V(y,h,`missing property "${le}"`)]),A;if(!i.a0(h.type))return A=A.concat([new i.V(`${y}.type`,h.type,"string expected")]),A;if(W)for(let le=0;le[],array:ct,boolean:function(T){const h=T.value,y=T.key;return i.$(h)?[]:[new i.V(y,h,`boolean expected, ${i.K(h)} found`)]},number:qe,color:function({key:T,value:h}){return i.a0(h)?i.a1.parseCSSColor(h)===null?[new i.V(T,h,`color expected, "${h}" found`)]:[]:[new i.V(T,h,`color expected, ${i.K(h)} found`)]},enum:it,filter:Lt,function:Ze,layer:cs,object:Jr,source:Es,model:i.a7,light:Mr,"light-3d":Lr,terrain:fn,fog:ki,string:er,formatted:function(T){return er(T).length===0?[]:Qe(T)},resolvedImage:function(T){return er(T).length===0?[]:Qe(T)},projection:function(T){const h=T.value,y=T.styleSpec,A=y.projection,D=T.style;if(i.H(h)){let F=[];for(const z in h)F=F.concat(dr({key:z,value:h[z],valueSpec:A[z],style:D,styleSpec:y}));return F}return i.a0(h)?[]:[new i.V("projection",h,`object or string expected, ${i.K(h)} found`)]},import:function(T){const h=T.key,{value:y,styleSpec:A}=T;if(!i.H(y))return[new i.V(h,y,"import must be an object")];const{data:D,...F}=y;Object.defineProperty(F,"__line__",{value:y.__line__,enumerable:!1});let z=Jr(Object.assign({},T,{value:F,valueSpec:A.import}));return i.J(F.id)===""&&z.push(new i.V(`${T.key}.id`,F,"import id can't be an empty string")),D&&(z=z.concat(dn(D,A,{key:`${T.key}.data`}))),z},iconset:function(T){const h=T.value,y=T.key,A=T.styleSpec,D=T.style;if(!i.H(h))return[new i.V(y,h,"object expected")];if(!h.type)return[new i.V(y,h,'"type" is required')];const F=i.J(h.type);let z=[];if(z=z.concat(Jr({key:y,value:h,valueSpec:A[`iconset_${F}`],style:D,styleSpec:A})),function(W,J){return!(W!=="source"||!J.source)}(F,h)){const W=D.sources&&D.sources[h.source],J=W&&i.J(W.type);W?J!=="raster-array"&&z.push(new i.V(y,h.source,`iconset cannot be used with a source of type ${String(J)}, it only be used with a "raster-array" source type`)):z.push(new i.V(y,h.source,`source "${h.source}" not found`))}return z}};function dr(T,h=!1){const y=T.value,A=T.valueSpec,D=T.styleSpec;if(A.expression){if(i.a4(i.J(y)))return Ze(T);if(i.Q(i.S(y)))return Qe(T)}if(A.type&&Ea[A.type]){const F=Ea[A.type](T);return h===!0&&F.length>0&&Array.isArray(T.value)?Qe(T):F}return Jr(Object.assign({},T,{valueSpec:A.type?D[A.type]:A}))}function Jr(T){const h=T.key,y=T.value,A=T.valueSpec||{},D=T.objectElementValidators||{},F=T.style,z=T.styleSpec;if(!i.H(y))return[new i.V(h,y,`object expected, ${i.K(y)} found`)];let W=[];for(const J in y){const ne=J.split(".")[0];let le;D[ne]?le=D[ne]:A[ne]?le=dr:D["*"]?le=D["*"]:A["*"]&&(le=dr),le?W=W.concat(le({key:(h&&`${h}.`)+J,value:y[J],valueSpec:A[ne]||A["*"],style:F,styleSpec:z,object:y,objectKey:J},y)):W.push(new i.a3(h,y[J],`unknown property "${J}"`))}for(const J in A){if(D[J])continue;const ne=A[J];ne.required&&ne.default===void 0&&y[J]===void 0&&W.push(new i.V(h,y,`missing required property "${J}"`))}return W}function Wr({key:T,value:h}){const y=er({key:T,value:h});if(y.length)return y;const A=h;return A.indexOf("{fontstack}")===-1&&y.push(new i.V(T,h,'"glyphs" url must include a "{fontstack}" token')),A.indexOf("{range}")===-1&&y.push(new i.V(T,h,'"glyphs" url must include a "{range}" token')),y}function dn(T,h=i.a6,y={}){return Jr({key:y.key||"",value:T,valueSpec:Object.assign(h.$root,{"*":{type:"*"}}),styleSpec:h,style:T,objectElementValidators:{glyphs:Wr}})}function Yr(T,h=i.a6){return $e(dn(T,h))}const vi=T=>$e(Es(T)),pt=T=>$e(Mr(T)),ir=T=>$e(Lr(T)),Vn=T=>$e(fn(T)),Sr=T=>$e(ki(T)),jr=T=>$e(function(h){const y=h.value,A=h.style,D=h.styleSpec,F=D.snow;if(y===void 0)return[];if(!i.H(y))return[new i.V("snow",y,`object expected, ${i.K(y)} found`)];let z=[];for(const W in y){const J=W.match(/^(.*)-transition$/);z=z.concat(J&&F[J[1]]&&F[J[1]].transition?dr({key:W,value:y[W],valueSpec:D.transition,style:A,styleSpec:D}):F[W]?dr({key:W,value:y[W],valueSpec:F[W],style:A,styleSpec:D}):[new i.a3(W,y[W],`unknown property "${W}"`)])}return z}(T)),ea=T=>$e(function(h){const y=h.value,A=h.style,D=h.styleSpec,F=D.rain;if(y===void 0)return[];if(!i.H(y))return[new i.V("rain",y,`object expected, ${i.K(y)} found`)];let z=[];for(const W in y){const J=W.match(/^(.*)-transition$/);z=z.concat(J&&F[J[1]]&&F[J[1]].transition?dr({key:W,value:y[W],valueSpec:D.transition,style:A,styleSpec:D}):F[W]?dr({key:W,value:y[W],valueSpec:F[W],style:A,styleSpec:D}):[new i.a3(W,y[W],`unknown property "${W}"`)])}return z}(T)),Pa=T=>$e(cs(T)),Ii=T=>$e(Lt(T)),Fo=T=>$e(Ts(T)),$t=T=>$e(Cs(T)),je=T=>$e(i.a7(T));function $e(T){return T.slice().sort((h,y)=>h.line&&y.line?h.line-y.line:0)}function Ye(T,h){let y=!1;if(h&&h.length)for(const A of h)A instanceof i.a3?i.w(A.message):(T.fire(new i.y(new Error(A.message))),y=!0);return y}const bt=i.a6.light;let gt;class Ft extends i.E{constructor(h,y="flat"){super(),this._transitionable=new i.a8(gt||(gt=new i.a9({anchor:new i.aa(bt.anchor),position:new i.ab(bt.position),color:new i.aa(bt.color),intensity:new i.aa(bt.intensity)}))),this.setLight(h,y),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(h,y,A={}){this._validate(pt,h,A)||(this._transitionable.setTransitionOrValue(h),this.id=y)}updateTransitions(h){this._transitioning=this._transitionable.transitioned(h,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(h){this.properties=this._transitioning.possiblyEvaluate(h)}_validate(h,y,A){return(!A||A.validate!==!1)&&Ye(this,h.call(Yr,Object.assign({value:y,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}const Zt=i.a6.terrain;let Ut=class extends i.E{constructor(T,h,y,A,D){super(),this.scope=y,this._transitionable=new i.a8(new i.a9({source:new i.aa(Zt.source),exaggeration:new i.aa(Zt.exaggeration)}),y,A),this._transitionable.setTransitionOrValue(T,A),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=h,this.worldview=D}get(){return this._transitionable.serialize()}set(T,h){this._transitionable.setTransitionOrValue(T,h)}updateTransitions(T){this._transitioning=this._transitionable.transitioned(T,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(T){this.properties=this._transitioning.possiblyEvaluate(T)}getExaggeration(T){return this._transitioning.possiblyEvaluate(new i.ac(T,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const T=this._transitionable._values.exaggeration;if(!T)return null;const h=T.value.expression;if(!h)return null;let y=-1,A=-1,D=1;for(const F of h.zoomStops)D=h.evaluate(new i.ac(F,{worldview:this.worldview})),D>.01?(y=F,A=-1):A=F;return D<.01&&y>0&&A>y?[y,A]:null}isZoomDependent(){const T=this._transitionable._values.exaggeration;return T!=null&&T.value!=null&&T.value.expression!=null&&T.value.expression instanceof i.ad}};const Xt=45,Ps=65,gs=.05;function vr(T,h,y,A){const D=i.ah(Xt,Ps,y),[F,z]=Hr(T,A);let W=1-Math.min(1,Math.exp((h-F)/(z-F)*-6));return W*=W*W,W=Math.min(1,1.00747*W),W*D*T.alpha}function Hr(T,h){const y=.5/Math.tan(.5*h);return[T.range[0]+y,T.range[1]+y]}function xr(T,h,y,A,D){const F=i.af([],[h,y,A],D.mercatorFogMatrix);return vr(T,i.ag(F),D.pitch,D._fov)}function Ln(T,h,y,A,D,F,z){const W=[[y,A,0],[D,A,0],[D,F,0],[y,F,0]];let J=Number.MAX_VALUE,ne=-Number.MAX_VALUE;for(const le of W){const _e=i.af([],le,h),ye=i.ag(_e);J=Math.min(J,ye),ne=Math.max(ne,ye)}return[vr(T,J,z.pitch,z._fov),vr(T,ne,z.pitch,z._fov)]}const Dn=i.a6.fog;class En extends i.E{constructor(h,y,A,D){super();const F=new i.a9({range:new i.aa(Dn.range),color:new i.aa(Dn.color),"color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new i.aa(Dn["high-color"]),"high-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new i.aa(Dn["space-color"]),"space-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new i.aa(Dn["horizon-blend"]),"star-intensity":new i.aa(Dn["star-intensity"]),"vertical-range":new i.aa(Dn["vertical-range"])});this._transitionable=new i.a8(F,A,new Map(D)),this.set(h,D),this._transitioning=this._transitionable.untransitioned(),this._transform=y,this.properties=new i.ai(F),this.scope=A}get state(){const h=this._transform,y=h.projection.name==="globe",A=i.aj(h.zoom),D=this.properties.get("range"),F=[.5,3];return{range:y?[i.ak(F[0],D[0],A),i.ak(F[1],D[1],A)]:D,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(h,y,A={}){if(this._validate(Sr,h,A))return;const D=Object.assign({},h);for(const F of Object.keys(Dn))D[F]===void 0&&(D[F]=Dn[F].default);this._options=D,this._transitionable.setTransitionOrValue(this._options,y)}getOpacity(h){if(!this._transform.projection.supportsFog)return 0;const y=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:i.ah(Xt,Ps,h))*y.a}getOpacityAtLatLng(h,y){return this._transform.projection.supportsFog?function(A,D,F){const z=i.ae.fromLngLat(D),W=F.elevation?F.elevation.getAtPointOrZero(z):0;return xr(A,z.x,z.y,W,F)}(this.state,h,y):0}getOpacityForTile(h){if(!this._transform.projection.supportsFog)return[1,1];const y=this._transform.calculateFogTileMatrix(h.toUnwrapped());return Ln(this.state,y,0,0,i.al,i.al,this._transform)}getOpacityForBounds(h,y,A,D,F){return this._transform.projection.supportsFog?Ln(this.state,h,y,A,D,F,this._transform):[1,1]}getFovAdjustedRange(h){return this._transform.projection.supportsFog?Hr(this.state,h):[0,1]}isVisibleOnFrustum(h){if(!this._transform.projection.supportsFog)return!1;const y=[4,5,6,7];for(const A of y){const D=h.points[A];let F;if(D[2]>=0)F=D;else{const z=h.points[A-4];F=i.am(z,D,z[2]/(z[2]-D[2]))}if(xr(this.state,F[0],F[1],0,this._transform)>=gs)return!0}return!1}updateConfig(h){this._transitionable.setTransitionOrValue(this._options,new Map(h))}updateTransitions(h){this._transitioning=this._transitionable.transitioned(h,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(h){this.properties=this._transitioning.possiblyEvaluate(h)}_validate(h,y,A){return(!A||A.validate!==!1)&&Ye(this,h.call(Yr,Object.assign({value:y,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}let _a,vo,il,ti,hl=class extends i.E{constructor(T,h,y,A){super();const D=_a||(_a=new i.a9({density:new i.aa(i.a6.snow.density),intensity:new i.aa(i.a6.snow.intensity),color:new i.aa(i.a6.snow.color),opacity:new i.aa(i.a6.snow.opacity),vignette:new i.aa(i.a6.snow.vignette),"vignette-color":new i.aa(i.a6.snow["vignette-color"]),"center-thinning":new i.aa(i.a6.snow["center-thinning"]),direction:new i.aa(i.a6.snow.direction),"flake-size":new i.aa(i.a6.snow["flake-size"])}));this._transitionable=new i.a8(D,y,new Map(A)),this.set(T,A),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=y}get state(){const T=this.properties.get("opacity"),h=this.properties.get("color"),y=this.properties.get("direction"),A=i.an(y[0]),D=-Math.max(i.an(y[1]),.01),F=[Math.cos(A)*Math.cos(D),Math.sin(A)*Math.cos(D),Math.sin(D)],z=this.properties.get("vignette"),W=this.properties.get("vignette-color");return W.a=z,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.ao(h.r,h.g,h.b,h.a*T),direction:F,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:W}}get(){return this._transitionable.serialize()}set(T,h,y={}){if(this._validate(jr,T,y))return;const A=Object.assign({},T),D=i.a6.snow;for(const F of Object.keys(D))A[F]===void 0&&(A[F]=D[F].default);this._options=A,this._transitionable.setTransitionOrValue(this._options,h)}updateConfig(T){this._transitionable.setTransitionOrValue(this._options,new Map(T))}updateTransitions(T){this._transitioning=this._transitionable.transitioned(T,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(T){this.properties=this._transitioning.possiblyEvaluate(T)}_validate(T,h,y){return(!y||y.validate!==!1)&&Ye(this,T.call(Yr,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}},oo=class extends i.E{constructor(T,h,y,A){super();const D=vo||(vo=new i.a9({density:new i.aa(i.a6.rain.density),intensity:new i.aa(i.a6.rain.intensity),color:new i.aa(i.a6.rain.color),opacity:new i.aa(i.a6.rain.opacity),vignette:new i.aa(i.a6.rain.vignette),"vignette-color":new i.aa(i.a6.rain["vignette-color"]),"center-thinning":new i.aa(i.a6.rain["center-thinning"]),direction:new i.aa(i.a6.rain.direction),"droplet-size":new i.aa(i.a6.rain["droplet-size"]),"distortion-strength":new i.aa(i.a6.rain["distortion-strength"])}));this._transitionable=new i.a8(D,y,new Map(A)),this.set(T,A),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=y}get state(){const T=this.properties.get("opacity"),h=this.properties.get("color"),y=this.properties.get("direction"),A=i.an(y[0]),D=-Math.max(i.an(y[1]),.01),F=[Math.cos(A)*Math.cos(D),Math.sin(A)*Math.cos(D),Math.sin(D)],z=this.properties.get("vignette-color");return z.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.ao(h.r,h.g,h.b,h.a*T),direction:F,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:z}}get(){return this._transitionable.serialize()}set(T,h,y={}){if(this._validate(ea,T,y))return;const A=Object.assign({},T),D=i.a6.rain;for(const F of Object.keys(D))A[F]===void 0&&(A[F]=D[F].default);this._options=A,this._transitionable.setTransitionOrValue(this._options,h)}updateConfig(T){this._transitionable.setTransitionOrValue(this._options,new Map(T))}updateTransitions(T){this._transitioning=this._transitionable.transitioned(T,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(T){this.properties=this._transitioning.possiblyEvaluate(T)}_validate(T,h,y){return(!y||y.validate!==!1)&&Ye(this,T.call(Yr,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}};class Ia extends i.E{constructor(h,y,A,D){super(),this.scope=A,this._options=h,this.properties=new i.ai(y),this._transitionable=new i.a8(y,A,new Map(D)),this._transitionable.setTransitionOrValue(h.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(h){this._transitionable.setTransitionOrValue(this._options.properties,new Map(h))}updateTransitions(h){this._transitioning=this._transitionable.transitioned(h,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(h){this.properties=this._transitioning.possiblyEvaluate(h)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(h,y){this._options=h,this._transitionable.setTransitionOrValue(h.properties,y)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}class lo{constructor(h,y,A){this.screenBounds=h,this.cameraPoint=A.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=y,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,A)}static createFromScreenPoints(h,y){let A,D;if(h instanceof i.P||typeof h[0]=="number"){const F=i.P.convert(h);A=[F],D=y.isPointAboveHorizon(F)}else{const F=i.P.convert(h[0]),z=i.P.convert(h[1]),W=F.add(z)._div(2);A=[F,z],D=i.aq(F,z).every(J=>y.isPointAboveHorizon(J))&&y.isPointAboveHorizon(W)}return new lo(A,D,y)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(h){return i.aq(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],h)}bufferedCameraGeometry(h){const y=this.screenBounds[0],A=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(y,A,0,!1);return this.cameraPoint.y>A.y&&(this.cameraPoint.x>y.x&&this.cameraPoint.x=A.x?D[2]=this.cameraPoint:this.cameraPoint.x<=y.x&&(D[3]=this.cameraPoint)),i.ar(D,h)}bufferedCameraGeometryGlobe(h){const y=this.screenBounds[0],A=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(y,A,h),F=this.cameraPoint.clone();switch(3*((F.y>y.y)+(F.y>A.y))+((F.x>y.x)+(F.x>A.x))){case 0:D[0]=F,D[4]=F.clone();break;case 1:D.splice(1,0,F);break;case 2:D[1]=F;break;case 3:D.splice(4,0,F);break;case 5:D.splice(2,0,F);break;case 6:D[3]=F;break;case 7:D.splice(3,0,F);break;case 8:D[2]=F}return D}containsTile(h,y,A,D=0){const F=Math.max(h.queryPadding,h.evaluateQueryRenderedFeaturePadding())/y._pixelsPerMercatorPixel+1,z=A?this._bufferedCameraMercator(F,y):this._bufferedScreenMercator(F,y);let W=h.tileID.wrap+(z.unwrapped?D:0);const J=z.polygon.map(We=>i.as(h.tileTransform,We,W));if(!i.at(J,0,0,i.al,i.al))return;W=h.tileID.wrap+(this.screenGeometryMercator.unwrapped?D:0);const ne=this.screenGeometryMercator.polygon.map(We=>i.au(h.tileTransform,We,W)),le=ne.map(We=>new i.P(We[0],We[1])),_e=y.getFreeCameraOptions().position||new i.ae(0,0,0),ye=i.au(h.tileTransform,_e,W),we=ne.map(We=>{const Ue=i.av(We,We,ye);return i.aw(Ue,Ue),new i.ax(ye,Ue)}),Le=i.ay(h,1,y.zoom)*y._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:le,tilespaceRays:we,bufferedTilespaceGeometry:J,bufferedTilespaceBounds:(Ie=i.az(J),Ie.min.x=i.aA(Ie.min.x,0,i.al),Ie.min.y=i.aA(Ie.min.y,0,i.al),Ie.max.x=i.aA(Ie.max.x,0,i.al),Ie.max.y=i.aA(Ie.max.y,0,i.al),Ie),tile:h,tileID:h.tileID,pixelToTileUnitsFactor:Le};var Ie}_bufferedScreenMercator(h,y){const A=co(h);if(this._screenRaycastCache[A])return this._screenRaycastCache[A];{let D;return D=y.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(h),y):{polygon:this.bufferedScreenGeometry(h).map(F=>y.pointCoordinate3D(F)),unwrapped:!0},this._screenRaycastCache[A]=D,D}}_bufferedCameraMercator(h,y){const A=co(h);if(this._cameraRaycastCache[A])return this._cameraRaycastCache[A];{let D;return D=y.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(h),y):{polygon:this.bufferedCameraGeometry(h).map(F=>y.pointCoordinate3D(F)),unwrapped:!0},this._cameraRaycastCache[A]=D,D}}_projectAndResample(h,y){const A=function(F,z){const W=i.aB([],z.pixelMatrix,z.globeMatrix),J=[0,-i.aD,0,1],ne=[0,i.aD,0,1],le=[0,0,0,1];i.aC(J,J,W),i.aC(ne,ne,W),i.aC(le,le,W);const _e=new i.P(J[0]/J[3],J[1]/J[3]),ye=new i.P(ne[0]/ne[3],ne[1]/ne[3]),we=i.aE(F,_e)&&J[3]1?Ti(F.slice(0,We),z):[],ut=Wenew i.P(ua(Tt.x),Tt.y)),ut=ut.map(Tt=>new i.P(ua(Tt.x),Tt.y));const ot=[...st];ot.length===0&&ot.push(ut[ut.length-1]);const Et=i.ak(ot[ot.length-1].y,(ut.length===0?st[0]:ut[0]).y,Ue);let Nt;return Nt=we?[new i.P(0,Et),new i.P(0,0),new i.P(1,0),new i.P(1,Et)]:[new i.P(1,Et),new i.P(1,1),new i.P(0,1),new i.P(0,Et)],ot.push(...Nt),ut.length===0?ot.push(st[0]):ot.push(...ut),{polygon:ot.map(Tt=>new i.ae(Tt.x,Tt.y)),unwrapped:!1}}(h,y);if(A)return A;const D=function(F,z){let W=!1,J=-1/0,ne=0;for(let _e=0;_eJ&&(J=F[_e].x,ne=_e);for(let _e=0;_e.5&&(we.x{_e.x-=1}),{polygon:F,unwrapped:W}}(Ti(h,y).map(F=>new i.P(ua(F.x),F.y)),y);return{polygon:D.polygon.map(F=>new i.ae(F.x,F.y)),unwrapped:D.unwrapped}}}function Ti(T,h){return i.aG(T,y=>{const A=h.pointCoordinate3D(y);y.x=A.x,y.y=A.y},1/256)}function ua(T){return T<0?1+T%1:T%1}function co(T){return 100*T|0}function Mc(T,h,y,A,D){const F=function(W,J){if(W)return D(W);if(J){if(T.url&&J.tiles&&T.tiles&&delete T.tiles,J.variants){if(!Array.isArray(J.variants))return D(new Error("variants must be an array"));for(const le of J.variants){if(le==null||typeof le!="object"||le.constructor!==Object)return D(new Error("variant must be an object"));if(!Array.isArray(le.capabilities))return D(new Error("capabilities must be an array"));if(le.capabilities.length===1&&le.capabilities[0]==="meshopt"){J=Object.assign(J,le);break}}}const ne=i.aH(Object.assign({},J,T),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);ne.tiles=h.canonicalizeTileset(ne,T.url),D(null,ne)}},z=function(W,J,ne){if(!W)return null;if(!J&&!ne)return W;ne=ne||W.worldview_default;const le=Object.values(W.language||{});if(le.length===0)return null;const _e=Object.values(W.worldview||{});if(_e.length===0)return null;const ye=le.every(Le=>Le===J),we=_e.every(Le=>Le===ne);return ye&&we?W:J in(W.language_options||{})||ne in(W.worldview_options||{})?null:W.language_options&&W.worldview_options?W:null}(T.data,y,A);return z?i.o.frame(()=>F(null,z)):T.url?i.m(h.transformRequest(h.normalizeSourceURL(T.url,null,y,A),i.R.Source),F):i.o.frame(()=>{const{data:W,...J}=T;F(null,J)})}function Wc(T,h){const y=Math.pow(2,h.z),A=Math.floor(i.aF(T.getWest())*y),D=Math.floor(i.aJ(T.getNorth())*y),F=Math.ceil(i.aF(T.getEast())*y),z=Math.ceil(i.aJ(T.getSouth())*y);return h.x>=A&&h.x=D&&h.ythis.maxzoom||h.z{if(this._tileJSONRequest=null,this._loaded=!0,D)y&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${y}`),A&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${A}`),this.fire(new i.y(D));else if(F){if(Object.assign(this,F),this.hasWorldviews=!!F.worldview_options,F.worldview_default&&(this.worldviewDefault=F.worldview_default),F.vector_layers){this.vectorLayers=F.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const z of F.vector_layers)this.vectorLayerIds.push(z.id),F.worldview&&F.worldview[z.source]&&this.localizableLayerIds.add(z.id)}this.tileBounds=lu.fromTileJSON(F),be(F.tiles,this.map._requestManager._customAccessToken),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}h&&h(D)})}loaded(){return this._loaded}hasTile(h){return!this.tileBounds||this.tileBounds.contains(h.canonical)}onAdd(h){this.map=h,this.load()}reload(){this.cancelTileJSONRequest();const h=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(h))}setTiles(h){return this._options.tiles=h,this.reload(),this}setUrl(h){return this.url=h,this._options.url=h,this.reload(),this}onRemove(h){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(h,y){const A=h.tileID.canonical.url(this.tiles,this.scheme),D=this.map._requestManager.normalizeTileURL(A),F=this.map._requestManager.transformRequest(D,i.R.Tile),z=this.map.style?this.map.style.getLut(this.scope):null,W=z?{image:z.image.clone()}:null,J={request:F,data:void 0,uid:h.uid,tileID:h.tileID,tileZoom:h.tileZoom,zoom:h.tileID.overscaledZ,maxZoom:this.maxzoom,lut:W,tileSize:this.tileSize*h.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:h.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:h.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};if(this.hasWorldviews&&i.h(A)&&(J.localizableLayerIds=this.localizableLayerIds),J.request.collectResourceTiming=this._collectResourceTiming,h.actor&&h.state!=="expired")h.state==="loading"?h.reloadCallback=y:h.request=h.actor.send("reloadTile",J,ne.bind(this));else if(h.actor=this._tileWorkers[D]=this._tileWorkers[D]||this.dispatcher.getActor(),this.dispatcher.ready)h.request=h.actor.send("loadTile",J,ne.bind(this),void 0,!0);else{const le=i.aL.call({deduped:this._deduped},J,(_e,ye)=>{if(_e||!ye)ne.call(this,_e);else{const we=i.aM(ye.responseHeaders);J.data={rawData:ye.rawData.slice(0),expires:we.expires,cacheControl:we.cacheControl},h.actor&&h.actor.send("loadTile",J,ne.bind(this),void 0,!0)}},!0);h.request={cancel:le}}function ne(le,_e){return delete h.request,h.aborted?y(null):le&&le instanceof i.aN&&le.status!==404?y(le):(_e&&_e.resourceTiming&&(h.resourceTiming=_e.resourceTiming),this.map._refreshExpiredTiles&&_e&&h.setExpiryData(_e),h.loadVectorData(_e,this.map.painter),i.aO(this.dispatcher),y(null,_e),void(h.reloadCallback&&(this.loadTile(h,h.reloadCallback),h.reloadCallback=null)))}}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.actor&&h.actor.send("abortTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(h,y){h.actor&&h.actor.send("removeTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope}),h.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Fl extends i.E{constructor(h,y,A,D){super(),this.id=h,this.dispatcher=A,this.setEventedParent(D),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Object.assign({type:"raster"},y),Object.assign(this,i.aH(y,["url","scheme","tileSize"]))}load(h){this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"}));const y=this.map.getWorldview();this._tileJSONRequest=Mc(this._options,this.map._requestManager,null,y,(A,D)=>{this._tileJSONRequest=null,this._loaded=!0,A?this.fire(new i.y(A)):D&&(Object.assign(this,D),D.raster_layers&&(this.rasterLayers=D.raster_layers,this.rasterLayerIds=this.rasterLayers.map(F=>F.id)),this.tileBounds=lu.fromTileJSON(D),be(D.tiles),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))),h&&h(A)})}loaded(){return this._loaded}onAdd(h){this.map=h,this.load()}reload(){this.cancelTileJSONRequest();const h=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(h))}setTiles(h){return this._options.tiles=h,this.reload(),this}setUrl(h){return this.url=h,this._options.url=h,this.reload(),this}onRemove(h){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}hasTile(h){return!this.tileBounds||this.tileBounds.contains(h.canonical)}loadTile(h,y){const A=i.o.devicePixelRatio>=2,D=this.map._requestManager.normalizeTileURL(h.tileID.canonical.url(this.tiles,this.scheme),A,this.tileSize);h.request=i.n(this.map._requestManager.transformRequest(D,i.R.Tile),(F,z,W)=>{if(delete h.request,h.aborted)return h.state="unloaded",y(null);if(F)return h.state="errored",y(F);if(!z)return y(null);const J=i.aM(W);this.map._refreshExpiredTiles&&h.setExpiryData(J),h.setTexture(z,this.map.painter),h.state="loaded",i.aO(this.dispatcher),y(null)})}abortTile(h,y){h.request&&(h.request.cancel(),delete h.request),y&&y()}unloadTile(h,y){h.texture&&h.texture instanceof i.T?(h.destroy(!1),h.texture&&h.texture instanceof i.T&&this.map.painter.saveTileTexture(h.texture)):h.destroy(),y&&y()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function ch([T,h],y,A,{scaled:D=!0}={}){const{tileSize:F,buffer:z}=A,{x:W,y:J,z:ne}=y;if(!isFinite(W)||!isFinite(J)||!isFinite(ne))throw new Error("Invalid MRT header");const le=2**ne,_e=le*i.aF(T),ye=le*i.aJ(h);return function([we,Le],Ie,{scaled:We=!0}={}){if(!Ie)throw new Error("bandView is undefined");const{data:Ue,tileSize:st,buffer:ut,offset:ot,scale:Et,dimension:Nt}=Ie;if(we<-ut||we>st+ut||Le<-ut||Le>st+ut)throw new Error(`Point (${we}, ${Le}) out of bounds for tileSize=${st}, buffer=${ut}`);const Tt=(Le+ut)*(st+2*ut)+(we+ut);if(new Uint32Array(Ue.buffer)[Tt]===4294967295)return null;let wt=[];wt=We?[]:new Ie.data.constructor(Nt);for(let yt=0;yt{if(delete h.request,h.aborted)return h.state="unloaded",y(null);if(W)return W.name==="AbortError"?void 0:(h.state="errored",y(W));if(this.map._refreshExpiredTiles&&J){const le=i.aM(ne);h.setExpiryData(le)}if(this.partial&&h.state!=="expired")h.state="empty";else if(!this.partial){if(!J)return y(null);h.state="loaded",h._isHeaderLoaded=!0,h._mrt=J}y(null)};h.request=this.partial?h.fetchHeader(void 0,z.bind(this)):h.actor.send("loadTile",F,z.bind(this),void 0,!0)}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.actor&&h.actor.send("abortTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(h,y){const A=h.texturePerLayer;if(h.flushAllQueues(),A.size){h.destroy(!1);for(const D of A.values())this.map.painter.saveTileTexture(D)}else h.destroy()}prepareTile(h,y,A,D){h._isHeaderLoaded&&(h.state!=="empty"&&(h.state="reloading"),h.fetchBandForRender(y,A,D,(F,z)=>{if(F)return h.state="errored",this.fire(new i.y(F)),void this.triggerRepaint(h);z&&(h._isHeaderLoaded=!0,h.setTexturePerLayer(A,z,this.map.painter),h.state="loaded",this.triggerRepaint(h))}))}getInitialBand(h){if(!this.rasterLayers)return 0;const y=this.rasterLayers.find(({id:F})=>F===h),A=y&&y.fields,D=A&&A.bands&&A.bands;return D?D[0]:0}getTextureDescriptor(h,y,A){if(!h)return;const D=y.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!D)return;let F=null;y instanceof i.aR?F=y.paint.get("raster-array-band"):y instanceof i.aS&&(F=y.paint.get("raster-particle-array-band"));const z=F||this.getInitialBand(D);if(z==null)return;if(!h.textureDescriptorPerLayer.get(y.id))return void this.prepareTile(h,D,y.id,z);if(h.updateNeeded(y.id,z)&&!A)return;const W=h.textureDescriptorPerLayer.get(y.id);return Object.assign({},W,{texture:h.texturePerLayer.get(y.id)})}getImages(h,y){const A=new Map;for(const D of h)for(const F of y){const[z,W]=F.split("/"),J=D.getLayer(z);if(!J||!J.hasBand(W)||!J.hasDataForBand(W))continue;const{bytes:ne,tileSize:le,buffer:_e}=J.getBandView(W),ye=le+2*_e,we={data:new i.q({width:ye,height:ye},ne),pixelRatio:2,sdf:!1,usvg:!1,version:0};A.set(F,we)}return A}queryRasterArrayValueByBandId(h,y,A){const D=y._mrt;return new Promise(F=>{const z={},W=new Set;for(const[J,ne]of Object.entries(D.layers)){if(A.layerName&&J!==A.layerName)continue;const le={};z[J]=le;for(const{bands:_e}of ne.dataIndex)for(const ye of _e)A.bands&&!A.bands.includes(ye)||(W.add(i.B(J,ye)),y.fetchBand(J,null,ye,we=>{i.o.frame(()=>{le[ye]=we?null:ch([h.lng,h.lat],D,ne.getBandView(ye)),W.delete(i.B(J,ye)),W.size===0&&F(z)})},!1))}W.size===0&&F(z)})}_loadTileForQuery(h,y){if(this._loadTileLoaded[h.uid])return void y(null,h._mrt);if(this._loadTilePending[h.uid])return void this._loadTilePending[h.uid].push(y);this._loadTilePending[h.uid]=[y];const A=this.map._requestManager.normalizeTileURL(h.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),D=this.map._requestManager.transformRequest(A,i.R.Tile);h.actor.send("loadTile",{request:D,uid:h.uid,tileID:h.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(F,z,W)=>{if(F)return this._loadTilePending[h.uid].forEach(J=>J(F,null)),void delete this._loadTilePending[h.uid];if(!z)return this._loadTilePending[h.uid].forEach(J=>J(null,null)),void delete this._loadTilePending[h.uid];if(this.map._refreshExpiredTiles&&z){const J=i.aM(W);h.setExpiryData(J)}h._mrt=z,h._isHeaderLoaded=!0,h.state="loaded",this._loadTilePending[h.uid].forEach(J=>J(null,z)),this._loadTileLoaded[h.uid]=!0,delete this._loadTilePending[h.uid]},void 0,!0)}queryRasterArrayValueByAllBands(h,y,A){return new Promise((D,F)=>{this._loadTileForQuery(y,(z,W)=>{z?F(z):D(W?this.queryRasterArrayValueByBandId(h,y,A):null)})})}queryRasterArrayValue(h,y){const A=i.aT.convert(h),D=this.findLoadedParent(A);return D&&D._mrt?y.bands||!this.partial?this.queryRasterArrayValueByBandId(A,D,y):this.queryRasterArrayValueByAllBands(A,D,y):Promise.resolve(null)}findLoadedParent(h){const y=i.ae.fromLngLat(h,this.map.transform.tileSize),A=this.maxzoom+1,D=1<0&&(W[new i.aQ(T.overscaledZ,D,h.z,A,h.y-1).key]={backfilled:!1},W[new i.aQ(T.overscaledZ,T.wrap,h.z,h.x,h.y-1).key]={backfilled:!1},W[new i.aQ(T.overscaledZ,z,h.z,F,h.y-1).key]={backfilled:!1}),h.y+1{if(this._loaded=!0,this._pendingLoad=null,A)this.fire(new i.y(A));else{const F={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&D&&D.resourceTiming&&D.resourceTiming[this.id]&&(F.resourceTiming=D.resourceTiming[this.id]),T&&(this._partialReload=!0),this.fire(new i.z("data",F)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(T),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const T=i.B(this.id,this.scope);this.map.style.clearSource(T),this._updateWorkerData()}loadTile(T,h){const y=T.actor?"reloadTile":"loadTile";T.actor=this.actor;const A=this.map.style?this.map.style.getLut(this.scope):null,D=A?{image:A.image.clone()}:null,F=this._partialReload,z={type:this.type,uid:T.uid,tileID:T.tileID,tileZoom:T.tileZoom,zoom:T.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:D,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:T.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:F,worldview:this.map.getWorldview(),indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};T.request=this.actor.send(y,z,(W,J)=>F&&!J?(T.state="loaded",h(null)):(delete T.request,T.destroy(!1),T.aborted?h(null):W?h(W):(T.loadVectorData(J,this.map.painter,y==="reloadTile"),h(null))),void 0,y==="loadTile")}abortTile(T){T.request&&(T.request.cancel(),delete T.request),T.aborted=!0}unloadTile(T,h){this.actor.send("removeTile",{uid:T.uid,type:this.type,source:this.id,scope:this.scope}),T.destroy()}onRemove(T){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends i.aU{constructor(T,h,y,A){super(T,h,y,A),this.roundZoom=!0,this.type="video",this.options=h}load(){this._loaded=!1;const T=this.options;this.urls=[];for(const h of T.urls)this.urls.push(this.map._requestManager.transformRequest(h,i.R.Source).url);i.aV(this.urls,(h,y)=>{this._loaded=!0,h?this.fire(new i.y(h)):y&&(this.video=y,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(T){if(this.video){const h=this.video.seekable;Th.end(0)?this.fire(new i.y(new i.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${h.start(0)} and ${h.end(0)}-second mark.`))):this.video.currentTime=T}}getVideo(){return this.video}onAdd(T){this.map||(this.map=T,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const T=this.map.painter.context,h=T.gl;this.texture?this.video.paused||(this.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),h.texSubImage2D(h.TEXTURE_2D,0,0,0,h.RGBA,h.UNSIGNED_BYTE,this.video)):(this.texture=new i.T(T,this.video,h.RGBA8),this.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(T)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:i.aU,model:i.aX,"batched-model":class extends i.E{constructor(T,h,y,A){super(),this.type="batched-model",this.id=T,this.tileSize=512,this._options=h,this.tiles=this._options.tiles,this.maxzoom=h.maxzoom||19,this.minzoom=h.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=y,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(A)}onAdd(T){this.map=T,this.load()}reload(){this.cancelTileJSONRequest();const T=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(T))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(T){this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"}));const h=Array.isArray(this.map._language)?this.map._language.join():this.map._language,y=this.map.getWorldview();this._tileJSONRequest=Mc(this._options,this.map._requestManager,h,y,(A,D)=>{this._tileJSONRequest=null,this._loaded=!0,A?(h&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${h}`),y&&y.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${y}`),this.fire(new i.y(A))):D&&(Object.assign(this,D),D.bounds&&(this.tileBounds=new lu(D.bounds,this.minzoom,this.maxzoom)),be(D.tiles,this.map._requestManager._customAccessToken),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))),T&&T(A)})}hasTransition(){return!1}hasTile(T){return!this.tileBounds||this.tileBounds.contains(T.canonical)}loaded(){return this._loaded}loadTile(T,h){const y=this.map._requestManager.normalizeTileURL(T.tileID.canonical.url(this.tiles,this.scheme)),A={request:this.map._requestManager.transformRequest(y,i.R.Tile),data:void 0,uid:T.uid,tileID:T.tileID,tileZoom:T.tileZoom,zoom:T.tileID.overscaledZ,tileSize:this.tileSize*T.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:T.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:i.o.devicePixelRatio,promoteId:this.promoteId};if(T.actor&&T.state!=="expired")if(T.state==="loading")T.reloadCallback=h;else{if(T.buckets){const F=Object.values(T.buckets);for(const z of F)z.dirty=!0;return void(T.state="loaded")}T.request=T.actor.send("reloadTile",A,D.bind(this))}else T.actor=this.dispatcher.getActor(),T.request=T.actor.send("loadTile",A,D.bind(this),void 0,!0);function D(F,z){return T.aborted?h(null):F&&F.status!==404?h(F):(this.map._refreshExpiredTiles&&z&&T.setExpiryData(z),T.loadModelData(z,this.map.painter),T.state="loaded",void h(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends i.aU{constructor(T,h,y,A){super(T,h,y,A),h.coordinates?Array.isArray(h.coordinates)&&h.coordinates.length===4&&!h.coordinates.some(D=>!Array.isArray(D)||D.length!==2||D.some(F=>typeof F!="number"))||this.fire(new i.y(new i.V(`sources.${T}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.y(new i.V(`sources.${T}`,null,'missing required property "coordinates"'))),h.animate&&typeof h.animate!="boolean"&&this.fire(new i.y(new i.V(`sources.${T}`,null,'optional "animate" property must be a boolean value'))),h.canvas?typeof h.canvas=="string"||h.canvas instanceof HTMLCanvasElement||this.fire(new i.y(new i.V(`sources.${T}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new i.y(new i.V(`sources.${T}`,null,'missing required property "canvas"'))),this.options=h,this.animate=h.animate===void 0||h.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.y(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(T){this.map=T,this.load(),this.canvas&&this.animate&&this.play()}onRemove(T){this.pause()}prepare(){let T=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,T=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,T=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const h=this.map.painter.context;this.texture?!T&&!this._playing||this.texture instanceof i.aW||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.T(h,this.canvas,h.gl.RGBA8,{premultiply:!0}),this._prepareData(h)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const T of[this.canvas.width,this.canvas.height])if(isNaN(T)||T<=0)return!0;return!1}},custom:class extends i.E{constructor(T,h,y,A){super(),this.id=T,this.type="custom",this._dataType="raster",this._dispatcher=y,this._implementation=h,this.setEventedParent(A),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new i.y(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new i.y(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new lu(this._implementation.bounds,this.minzoom,this.maxzoom)),h.update=this._update.bind(this),h.clearTiles=this._clearTiles.bind(this),h.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,i.aH(h,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return i.aH(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(T){this.map=T,this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(T),this.load()}onRemove(T){this._implementation.onRemove&&this._implementation.onRemove(T)}hasTile(T){if(this._implementation.hasTile){const{x:h,y,z:A}=T.canonical;return this._implementation.hasTile({x:h,y,z:A})}return!this.tileBounds||this.tileBounds.contains(T.canonical)}loadTile(T,h){const{x:y,y:A,z:D}=T.tileID.canonical,F=new AbortController;T.request=Promise.resolve(this._implementation.loadTile({x:y,y:A,z:D},{signal:F.signal})).then((function(z){return delete T.request,T.aborted?(T.state="unloaded",h(null)):z===void 0?(T.state="errored",h(null)):z===null?(this.loadTileData(T,{width:this.tileSize,height:this.tileSize,data:null}),T.state="loaded",h(null)):function(W){return W instanceof ImageData||W instanceof HTMLCanvasElement||W instanceof ImageBitmap||W instanceof HTMLImageElement}(z)?(this.loadTileData(T,z),T.state="loaded",void h(null)):(T.state="errored",h(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}).bind(this)).catch(z=>{z.name!=="AbortError"&&(T.state="errored",h(z))}),T.request.cancel=()=>F.abort()}loadTileData(T,h){T.setTexture(h,this.map.painter)}unloadTile(T,h){if(T.texture&&T.texture instanceof i.T?(T.destroy(!1),T.texture&&T.texture instanceof i.T&&this.map.painter.saveTileTexture(T.texture)):T.destroy(),this._implementation.unloadTile){const{x:y,y:A,z:D}=T.tileID.canonical;this._implementation.unloadTile({x:y,y:A,z:D})}h&&h()}abortTile(T,h){T.request&&T.request.cancel&&(T.request.cancel(),delete T.request),h&&h()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(T=>({x:T.canonical.x,y:T.canonical.y,z:T.canonical.z}))}_clearTiles(){const T=i.B(this.id,this.scope);this.map.style.clearSource(T)}_update(){this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}}},zl=function(T,h,y,A){const D=new Km[h.type](T,h,y,A);if(D.id!==T)throw new Error(`Expected Source id to be ${T} instead of ${D.id}`);return i.aY(["load","abort","unload","serialize","prepare"],D),D};function Zx(T,h,y=""){return`${y}:${h.id||""}:${h.layer.id}:${function(A){if("layerId"in A)return`layer:${A.layerId}`;{const{featuresetId:D,importId:F}=A;return`featureset:${D}${F?`:import:${F}`:""}`}}(T.target)}`}function yy(T,h,y,A=""){if(T.uniqueFeatureID){const D=Zx(T,h,A);if(y.has(D))return!0;y.add(D)}return!1}function V1(T,h,y,A,D=!1){const F=h.sourceCache.transform,z=h.sourceCache.tilesIn(T,h.has3DLayers,D);z.sort(Dp);const W=[];for(const J of z){const ne=J.tile.queryRenderedFeatures(h,J,y,A,F,D);Object.keys(ne).length&&W.push({wrappedTileID:J.tile.tileID.wrapped().key,queryResults:ne})}for(const J in h.layers){const ne=h.layers[J];if(ne.styleLayer){const le=ne.styleLayer.queryRenderedFeatures(T,h.sourceCache,A);Object.keys(le).length&&W.push({wrappedTileID:0,queryResults:le})}}return W.length===0?{}:function(J){const ne={},le={};for(const _e of J){const ye=_e.queryResults,we=_e.wrappedTileID,Le=le[we]=le[we]||{};for(const Ie in ye){const We=ye[Ie],Ue=Le[Ie]=Le[Ie]||{},st=ne[Ie]=ne[Ie]||[];for(const ut of We)Ue[ut.featureIndex]||(Ue[ut.featureIndex]=!0,st.push(ut))}}return ne}(W)}function H1(T,h,y,A,D,F){const z={},W=A.queryRenderedSymbols(T),J=[];for(const ne of Object.keys(W).map(Number))J.push(D[ne]);J.sort(Dp);for(const ne of J){const le=ne.featureIndex.lookupSymbolFeatures(W[ne.bucketInstanceId],ne.bucketIndex,ne.sourceLayerIndex,h,y,F);for(const _e in le){const ye=z[_e]=z[_e]||[],we=le[_e];we.sort((Le,Ie)=>{const We=ne.featureSortOrder;if(We){const Ue=We.indexOf(Le.featureIndex);return We.indexOf(Ie.featureIndex)-Ue}return Ie.featureIndex-Le.featureIndex});for(const Le of we)ye.push(Le)}}return z}function W1(T,h){const y=T.getRenderableIds().map(F=>T.getTileByID(F)),A=[],D={};for(let F=0;Fh.getLayer(F)).filter(Boolean);if(D.length!==0){A.layers=D,A.stateDependentLayerIds&&(A.stateDependentLayers=A.stateDependentLayerIds.map(F=>D.filter(z=>z.id===F)[0]));for(const F of D)y[F.fqid]=A}}return y}const cu=32,im=33,$d=new Uint16Array(8184);for(let T=0;T<2046;T++){let h=T+2,y=0,A=0,D=0,F=0,z=0,W=0;for(1&h?D=F=z=cu:y=A=W=cu;(h>>=1)>1;){const ne=y+D>>1,le=A+F>>1;1&h?(D=y,F=A,y=z,A=W):(y=D,A=F,D=z,F=W),z=ne,W=le}const J=4*T;$d[J+0]=y,$d[J+1]=A,$d[J+2]=D,$d[J+3]=F}const Sd=new Uint16Array(2178),du=new Uint8Array(1089),Of=new Uint16Array(1089);function Rf(T){return T===0?-.03125:T===32?.03125:0}const Zm={type:2,extent:i.al,loadGeometry:()=>[[new i.P(0,0),new i.P(i.al+1,0),new i.P(i.al+1,i.al+1),new i.P(0,i.al+1),new i.P(0,0)]]};class Ym{constructor(h,y,A,D,F,z){this.tileID=h,this.uid=i.b2(),this.uses=0,this.tileSize=y,this.tileZoom=A,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=F,D&&D.style&&(this._lastUpdatedBrightness=D.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",D&&D.transform&&(this.projection=D.transform.projection),this.worldview=z,this._hasAppearances=null}registerFadeDuration(h){const y=h+this.timeAdded;yA)D=!1;else if(y)if(this.expirationTimeA.appearances&&A.appearances.length>0))return!0;return!1}updateBuckets(h,y){if(!this.latestFeatureIndex||!h.style)return;const A=h.style.listImages(),D=h.style.getBrightness();for(const F in this.buckets){if(!h.style.hasLayer(F))continue;const z=this.buckets[F],W=z.layers[0],J=W.sourceLayer||"_geojsonTileLayer",ne=h.style.getLayerSourceCache(W);let le={};ne&&(le=ne._state.getState(J,void 0));const _e=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},ye=Object.keys(le).length>0&&!y;z.hasAppearances=z.layers.some(Ie=>Ie.appearances&&Ie.appearances.length>0);const we=ye?z.stateDependentLayers:z.layers;if(ye&&z.stateDependentLayers.length!==0||y){const Ie=this.latestFeatureIndex.loadVTLayers();z.update(le,Ie[J],A,_e,we,y,D)}if(ye&&z.stateDependentLayers.length!==0||y||z.hasAppearances){const Ie={zoom:h.transform.zoom,pitch:h.transform.pitch,brightness:h.style.getBrightness()||0,worldview:h.worldview};z.updateAppearances(this.tileID.canonical,le,A,Ie)}(z instanceof i.ba||z instanceof i.bb)&&h._terrain&&h._terrain.enabled&&ne&&z.uploadPending()&&h._terrain._clearRenderCacheForTile(ne.id,this.tileID);const Le=h&&h.style&&h.style.getOwnLayer(F);Le&&(this.queryPadding=Math.max(this.queryPadding,Le.queryRadius(z)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;We--){const Ue=4*We,st=$d[Ue+0],ut=$d[Ue+1],ot=$d[Ue+2],Et=$d[Ue+3],Nt=st+ot>>1,Tt=ut+Et>>1,wt=Nt+Tt-ut,yt=Tt+st-Nt,Ot=ut*im+st,Wt=Et*im+ot,Ht=Tt*im+Nt,es=Math.hypot((Sd[2*Ot+0]+Sd[2*Wt+0])/2-Sd[2*Ht+0],(Sd[2*Ot+1]+Sd[2*Wt+1])/2-Sd[2*Ht+1])>=16;du[Ht]=du[Ht]||(es?1:0),We<1022&&(du[Ht]=du[Ht]||du[(ut+yt>>1)*im+(st+wt>>1)]||du[(Et+yt>>1)*im+(ot+wt>>1)])}const _e=new i.b1,ye=new i.b0;let we=0;function Le(We,Ue){const st=Ue*im+We;return Of[st]===0&&(_e.emplaceBack(Sd[2*st+0],Sd[2*st+1],We*i.al/cu,Ue*i.al/cu),Of[st]=++we),Of[st]-1}function Ie(We,Ue,st,ut,ot,Et){const Nt=We+st>>1,Tt=Ue+ut>>1;if(Math.abs(We-ot)+Math.abs(Ue-Et)>1&&du[Tt*im+Nt])Ie(ot,Et,We,Ue,Nt,Tt),Ie(st,ut,ot,Et,Nt,Tt);else{const wt=Le(We,Ue),yt=Le(st,ut),Ot=Le(ot,Et);ye.emplaceBack(wt,yt,Ot)}}return Ie(0,0,cu,cu,cu,0),Ie(cu,cu,0,0,0,cu),{vertices:_e,indices:ye}}(this.tileID.canonical,y);D=z.vertices,F=z.indices}else{D=new i.b1,F=new i.b0;for(const{x:W,y:J}of A)D.emplaceBack(W,J,0,0);const z=i.bh(D.int16.subarray(0,4*D.length),void 0,4);for(let W=0;W0&&(J=i.bl(new Float64Array(16),y.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(h,D,y,z,J,W),this._makeGlobeTileDebugTextBuffer(h,D,y,z,J,W)}_globePoint(h,y,A,D,F,z,W){let J=i.bm(h,y,A);if(z){const ne=1<.5?we=-1:ye<-.5&&(we=1);let Le=(h/i.al+A.x)/ne+we,Ie=(y/i.al+A.y)/ne;Le=(Le-le)*D._pixelsPerMercatorPixel+le,Ie=(Ie-_e)*D._pixelsPerMercatorPixel+_e;const We=[Le*D.worldSize,Ie*D.worldSize,0];i.af(We,We,z),J=i.bn(J,We,W)}return i.af(J,J,F)}_makeGlobeTileDebugBorderBuffer(h,y,A,D,F,z){const W=new i.bd,J=new i.be,ne=new i.bo,le=(ye,we,Le,Ie,We)=>{const Ue=(Le-ye)/(We-1),st=(Ie-we)/(We-1),ut=W.length;for(let ot=0;ot_e*we+Le;for(let we=0;we<_e;we++){const Le=we*W;for(let Ie=0;Ie<_e;Ie++){const We=Ie*W;J.emplaceBack(We,Le);const Ue=this._globePoint(We,Le,y,A,D,F,z);le.emplaceBack(Ue[0],Ue[1],Ue[2])}}for(let we=0;we<4;we++)for(let Le=0;Le<4;Le++){const Ie=ye(we,Le),We=ye(we,Le+1),Ue=ye(we+1,Le),st=ye(we+1,Le+1);ne.emplaceBack(Ie,We,Ue),ne.emplaceBack(Ue,We,st)}this._tileDebugTextIndexBuffer=h.createIndexBuffer(ne),this._tileDebugTextBuffer=h.createVertexBuffer(J,i.bf.members),this._globeTileDebugTextBuffer=h.createVertexBuffer(le,i.bp.members),this._tileDebugTextSegments=i.bg.simpleSegment(0,0,_e,32)}destroy(h=!0){for(const y in this.buckets)this.buckets[y].destroy(h);this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture.destroy(),delete this.imageAtlasTexture),this.glyphAtlasTexture&&(this.glyphAtlasTexture.destroy(),delete this.glyphAtlasTexture),this.lineAtlasTexture&&(this.lineAtlasTexture.destroy(),delete this.lineAtlasTexture),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),h&&this.texture&&this.texture instanceof i.T&&(this.texture.destroy(),delete this.texture),this.emissiveTexture&&this.emissiveTexture instanceof i.T&&(this.emissiveTexture.destroy(),delete this.emissiveTexture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.rasterParticleState&&(this.rasterParticleState.destroy(),delete this.rasterParticleState),this.latestFeatureIndex=null,this.state="unloaded"}}i.bs.setPbf(i.bt);class Cd extends Ym{constructor(h,y,A,D,F){super(h,y,A,D,F),this._workQueuePerLayer=new Map,this._fetchQueuePerLayer=new Map,this._taskQueue=new Map,this._isHeaderLoaded=!1,this.textureDescriptorPerLayer=new Map,this.texturePerLayer=new Map}getLayers(){return this._mrt?Object.values(this._mrt.layers):[]}getLayer(h){return this._mrt&&this._mrt.getLayer(h)}setTexturePerLayer(h,y,A){const D=A.context,F=D.gl;let z=this.texturePerLayer.get(h)||A.getTileTexture(y.width);z&&z instanceof i.T?z.update(y,{premultiply:!1}):z=new i.T(D,y,F.RGBA8,{premultiply:!1}),this.texturePerLayer.has(h)||this.texturePerLayer.set(h,z)}flushQueues(h){const y=this._workQueuePerLayer.get(h)||[],A=this._fetchQueuePerLayer.get(h)||[];for(;y.length;)y.pop()();for(;A.length;)A.pop()()}flushAllQueues(){for(const h of this._workQueuePerLayer.keys()){const y=this._workQueuePerLayer.get(h)||[];for(;y.length;)y.pop()()}for(const h of this._fetchQueuePerLayer.keys()){const y=this._fetchQueuePerLayer.get(h)||[];for(;y.length;)y.pop()()}}fetchHeader(h=16384,y){const A=this._mrt=new i.bs(30),D=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(h-1)}});return this.entireBuffer=null,this.request=i.bu(D,(F,z,W)=>{if(F)y(F);else try{const J=A.getHeaderLength(z);if(J>h)return void(this.request=this.fetchHeader(J,y));A.parseHeader(z),this._isHeaderLoaded=!0;let ne=0;for(const le of Object.values(A.layers))ne=Math.max(ne,le.dataIndex[le.dataIndex.length-1].lastByte);z.byteLength>=ne&&(this.entireBuffer=z),y(null,this.entireBuffer||z,W)}catch(J){y(J)}}),this.request}fetchBandForRender(h,y,A,D){this.fetchBand(h,y,A,F=>{if(F)return void D(F);this.updateTextureDescriptor(h,y,A);const z=this.textureDescriptorPerLayer.get(y);D(null,z?z.img:null)})}fetchBand(h,y,A,D,F=!0){const z=this._mrt;if(!this._isHeaderLoaded||!z)return void D(new Error("Tile header is not ready"));const W=this.actor;if(!W)return void D(new Error("Can't fetch tile band without an actor"));let J;const ne=i.B(String(A),i.B(this.tileID.key,h));let le=this._taskQueue.get(ne);le?le.add(D):(le=new Set,le.add(D),this._taskQueue.set(ne,le));const _e=(Ie,We)=>{J.complete(Ie,We),Ie?D(Ie):(le.forEach(Ue=>Ue(null,We)),this._taskQueue.delete(ne))},ye=(Ie,We)=>{if(Ie)return D(Ie);const Ue=W.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:We,task:J},_e,void 0,!0);if(y!==null){const st=this._workQueuePerLayer.get(y)||[];st.push(()=>{Ue&&Ue.cancel(),J.cancel()}),this._workQueuePerLayer.has(y)||this._workQueuePerLayer.set(y,st)}};let we;try{we=z.getLayer(h)}catch(Ie){if(this.state==="reloading")return;throw Ie}if(!we)return void D(new Error(`Unknown sourceLayer "${h}"`));if(we.hasDataForBand(A))return le.forEach(Ie=>Ie(null,null)),void this._taskQueue.delete(ne);const Le=we.getDataRange([A]);if(J=z.createDecodingTask(Le),!J||J.tasks.length)if(y!==null&&this.flushQueues(y),this.entireBuffer)ye(null,this.entireBuffer.slice(Le.firstByte,Le.lastByte+1));else{const Ie=Object.assign({},this.requestParams,{headers:{Range:`bytes=${Le.firstByte}-${Le.lastByte}`}}),We=i.bu(Ie,ye);if(y!==null){const Ue=this._fetchQueuePerLayer.get(y)||[];Ue.push(()=>{We.cancel(),J.cancel()}),this._fetchQueuePerLayer.has(y)||this._fetchQueuePerLayer.set(y,Ue)}}}updateNeeded(h,y){return(!this.textureDescriptorPerLayer.get(h)||this.textureDescriptorPerLayer.get(h).band!==y||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(h,y,A){if(!this._mrt)return;const D=this._mrt.getLayer(h);if(!D||!D.hasBand(A)||!D.hasDataForBand(A))return;const{bytes:F,tileSize:z,buffer:W,offset:J,scale:ne}=D.getBandView(A),le=z+2*W,_e=new i.q({width:le,height:le},F),ye=this.texturePerLayer.get(y);ye&&ye instanceof i.T&&ye.update(_e,{premultiply:!1}),this.textureDescriptorPerLayer.set(y,{layer:h,band:A,img:_e,buffer:W,offset:J,tileSize:z,format:D.pixelFormat,mix:[ne,256*ne,65536*ne,16777216*ne]})}destroy(h=!1){if(super.destroy(h),delete this._mrt,!h)for(const y of this.texturePerLayer.values())y&&y instanceof i.T&&y.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1}}class K0{constructor(h,y){this.max=h,this.onRemove=y,this.reset()}reset(){for(const h in this.data)for(const y of this.data[h])y.timeout&&clearTimeout(y.timeout),this.onRemove(y.value);return this.data={},this.order=[],this}add(h,y,A){const D=h.wrapped().key;this.data[D]===void 0&&(this.data[D]=[]);const F={value:y,timeout:void 0};if(A!==void 0&&(F.timeout=setTimeout(()=>{this.remove(h,F)},A)),this.data[D].push(F),this.order.push(D),this.order.length>this.max){const z=this._getAndRemoveByKey(this.order[0]);z&&this.onRemove(z)}return this}has(h){return h.wrapped().key in this.data}getAndRemove(h){return this.has(h)?this._getAndRemoveByKey(h.wrapped().key):null}_getAndRemoveByKey(h){const y=this.data[h].shift();return y.timeout&&clearTimeout(y.timeout),this.data[h].length===0&&delete this.data[h],this.order.splice(this.order.indexOf(h),1),y.value}getByKey(h){const y=this.data[h];return y?y[0].value:null}get(h){return this.has(h)?this.data[h.wrapped().key][0].value:null}remove(h,y){if(!this.has(h))return this;const A=h.wrapped().key,D=y===void 0?0:this.data[A].indexOf(y),F=this.data[A][D];return this.data[A].splice(D,1),F.timeout&&clearTimeout(F.timeout),this.data[A].length===0&&delete this.data[A],this.onRemove(F.value),this.order.splice(this.order.indexOf(A),1),this}setMaxSize(h){for(this.max=h;this.order.length>this.max;){const y=this._getAndRemoveByKey(this.order[0]);y&&this.onRemove(y)}return this}filter(h){const y=[];for(const A in this.data)for(const D of this.data[A])h(D.value)||y.push(D);for(const A of y)this.remove(A.value.tileID,A)}}class Yx{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(h,y,A){const D=String(y);if(this.stateChanges[h]=this.stateChanges[h]||{},this.stateChanges[h][D]=this.stateChanges[h][D]||{},Object.assign(this.stateChanges[h][D],A),this.deletedStates[h]===null){this.deletedStates[h]={};for(const F in this.state[h])F!==D&&(this.deletedStates[h][F]=null)}else if(this.deletedStates[h]&&this.deletedStates[h][D]===null){this.deletedStates[h][D]={};for(const F in this.state[h][D])A[F]||(this.deletedStates[h][D][F]=null)}else for(const F in A)this.deletedStates[h]&&this.deletedStates[h][D]&&this.deletedStates[h][D][F]===null&&delete this.deletedStates[h][D][F]}removeFeatureState(h,y,A){if(this.deletedStates[h]===null)return;const D=String(y);if(this.deletedStates[h]=this.deletedStates[h]||{},A&&y!==void 0)this.deletedStates[h][D]!==null&&(this.deletedStates[h][D]=this.deletedStates[h][D]||{},this.deletedStates[h][D][A]=null);else if(y!==void 0)if(this.stateChanges[h]&&this.stateChanges[h][D])for(A in this.deletedStates[h][D]={},this.stateChanges[h][D])this.deletedStates[h][D][A]=null;else this.deletedStates[h][D]=null;else this.deletedStates[h]=null}getState(h,y){const A=this.state[h]||{},D=this.stateChanges[h]||{},F=this.deletedStates[h];if(F===null)return{};if(y!==void 0){const W=String(y),J=Object.assign({},A[W],D[W]);if(F){const ne=F[y];if(ne===null)return{};for(const le in ne)delete J[le]}return J}const z=Object.assign({},A,D);if(F)for(const W in F)delete z[W];return z}initializeTileState(h,y){h.refreshFeatureState(y)}coalesceChanges(h,y){const A={};for(const D in this.stateChanges){this.state[D]=this.state[D]||{};const F={};for(const z in this.stateChanges[D])this.state[D][z]||(this.state[D][z]={}),Object.assign(this.state[D][z],this.stateChanges[D][z]),F[z]=this.state[D][z];A[D]=F}for(const D in this.deletedStates){this.state[D]=this.state[D]||{};const F={};if(this.deletedStates[D]===null)for(const z in this.state[D])F[z]={},this.state[D][z]={};else for(const z in this.deletedStates[D]){if(this.deletedStates[D][z]===null)this.state[D][z]={};else if(this.state[D][z])for(const W of Object.keys(this.deletedStates[D][z]))delete this.state[D][z][W];F[z]=this.state[D][z]}A[D]=A[D]||{},Object.assign(A[D],F)}if(this.stateChanges={},this.deletedStates={},Object.keys(A).length!==0)for(const D in h)h[D].refreshFeatureState(y)}}class Al extends i.E{constructor(h,y,A){super(),this.id=h,this._onlySymbols=A,y.on("data",D=>{D.dataType==="source"&&D.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&D.dataType==="source"&&D.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),y.on("error",()=>{this._sourceErrored=!0}),this._source=y,this._tiles={},this._cache=new K0(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=y.minTileCacheSize,this._maxTileCacheSize=y.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Yx,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="raster-array"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(h){this.map=h,this._minTileCacheSize=this._minTileCacheSize===void 0&&h?h._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&h?h._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const h in this._tiles)if(!this._tiles[h].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const h=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,h&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(h,y){return h.isSymbolTile=this._onlySymbols,h.isExtraShadowCaster=this._shadowCasterTiles[h.tileID.key],this._source.loadTile(h,y)}_unloadTile(h){if(this._source.unloadTile)return this._source.unloadTile(h)}_abortTile(h){if(this._source.abortTile)return this._source.abortTile(h)}serialize(){return this._source.serialize()}prepare(h){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const y in this._tiles){const A=this._tiles[y];A.upload(h,this.map?this.map.painter:void 0),A.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(h=>h.tileID).sort(G1).map(h=>h.key)}getRenderableIds(h,y){const A=[];for(const D in this._tiles)this._isIdRenderable(+D,h,y)&&A.push(this._tiles[D]);return h?A.sort((D,F)=>{const z=D.tileID,W=F.tileID,J=new i.P(z.canonical.x,z.canonical.y)._rotate(this.transform.angle),ne=new i.P(W.canonical.x,W.canonical.y)._rotate(this.transform.angle);return z.overscaledZ-W.overscaledZ||ne.y-J.y||ne.x-J.x}).map(D=>D.tileID.key):A.map(D=>D.tileID).sort(G1).map(D=>D.key)}hasRenderableParent(h){const y=this.findLoadedParent(h,0);return!!y&&this._isIdRenderable(y.tileID.key)}_isIdRenderable(h,y,A){return this._tiles[h]&&this._tiles[h].hasData()&&!this._coveredTiles[h]&&(y||!this._tiles[h].holdingForFade())&&(A||!this._shadowCasterTiles[h])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const h in this._tiles)this._tiles[h].state!=="errored"&&this._reloadTile(+h,"reloading")}}_reloadTile(h,y){const A=this._tiles[h];A&&(A.state!=="loading"&&(A.state=y),this._loadTile(A,this._tileLoaded.bind(this,A,h,y)))}_tileLoaded(h,y,A,D,F){if(D){if(h.state="errored",D.status!==404)this._source.fire(new i.y(D,{tile:h}));else{if(this._source.fire(new i.z("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:h})),!(h.tileID.key in this._loadedParentTiles))return;if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const W=this.map.painter.terrain;this.update(this.transform,W.getScaledDemTileSize(),!0),W.resetTileLookupCache(this.id)}else this.update(this.transform)}return}h.timeAdded=i.o.now(),A==="expired"&&(h.refreshedUponExpiration=!0),this._setTileReloadTimer(y,h),this._source.type==="raster-dem"&&h.dem&&this._backfillDEM(h),this._state.initializeTileState(h,this.map?this.map.painter:null);let z=new Map;F&&F.responseHeaders&&(z=F.responseHeaders),this._source.fire(new i.z("data",{dataType:"source",tile:h,coord:h.tileID,sourceCacheId:this.id,responseHeaders:z}))}_backfillDEM(h){const y=this.getRenderableIds();for(let D=0;D1||(Math.abs(z)>1&&(Math.abs(z+J)===1?z+=J:Math.abs(z-J)===1&&(z-=J)),F.dem&&D.dem&&(D.dem.backfillBorder(F.dem,z,W),D.neighboringTiles&&D.neighboringTiles[ne]&&(D.neighboringTiles[ne].backfilled=!0)))}}getTile(h){return this.getTileByID(h.key)}getTileByID(h){return this._tiles[h]}_retainLoadedChildren(h,y,A,D){for(const F in this._tiles){let z=this._tiles[F];if(D[F]||!z.hasData()||z.tileID.overscaledZ<=y||z.tileID.overscaledZ>A)continue;let W=z.tileID;for(;z&&z.tileID.overscaledZ>y+1;){const ne=z.tileID.scaledTo(z.tileID.overscaledZ-1);z=this._tiles[ne.key],z&&z.hasData()&&(W=ne)}let J=W;for(;J.overscaledZ>y;)if(J=J.scaledTo(J.overscaledZ-1),h[J.key]){D[W.key]=W;break}}}findLoadedParent(h,y){if(h.key in this._loadedParentTiles){const A=this._loadedParentTiles[h.key];return A&&A.tileID.overscaledZ>=y?A:null}for(let A=h.overscaledZ-1;A>=y;A--){const D=h.scaledTo(A),F=this._getLoadedTile(D);if(F)return F}}_getLoadedTile(h){const y=this._tiles[h.key];return y&&y.hasData()?y:this._cache.getByKey(this._source.reparseOverscaled?h.wrapped().key:h.canonical.key)}updateCacheSize(h,y){y=y||this._source.tileSize;const A=Math.ceil(h.width/y)+1,D=Math.ceil(h.height/y)+1,F=Math.floor(A*D*5),z=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,F):F,W=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,z):z;this._cache.setMaxSize(W)}handleWrapJump(h){const y=Math.round((h-(this._prevLng===void 0?h:this._prevLng))/360);if(this._prevLng=h,y){const A={};for(const D in this._tiles){const F=this._tiles[D];F.tileID=F.tileID.unwrapTo(F.tileID.wrap+y),A[F.tileID.key]=F}this._tiles=A;for(const D in this._timers)clearTimeout(this._timers[D]),delete this._timers[D];for(const D in this._tiles)this._setTileReloadTimer(+D,this._tiles[D])}}update(h,y,A,D,F){if(this.transform=h,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!A)return;this.updateCacheSize(h,y),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const z=this._source.type==="batched-model";let W,J=this._source.maxzoom;const ne=this.map&&this.map.painter?this.map.painter._terrain:null;if(ne&&ne.sourceCache===this&&ne.attenuationRange()){const ye=ne.attenuationRange()[0],we=Math.floor(ye)-Math.log2(ne.getDemUpscale());J>we&&(J=we)}if(this.used||this.usedForTerrain){if(this._source.tileID)W=h.getVisibleUnwrappedCoordinates(this._source.tileID).map(ye=>new i.aQ(ye.canonical.z,ye.wrap,ye.canonical.z,ye.canonical.x,ye.canonical.y));else if(this.tileCoverLift!==0){const ye=h.clone();ye.tileCoverLift=this.tileCoverLift,W=ye.coveringTiles({tileSize:y||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:J,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.minzoom<=1&&h.projection.name==="globe"&&(W.push(new i.aQ(1,0,1,0,0)),W.push(new i.aQ(1,0,1,1,0)),W.push(new i.aQ(1,0,1,0,1)),W.push(new i.aQ(1,0,1,1,1)))}else if(W=h.coveringTiles({tileSize:y||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:J,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.hasTile){const ye=this._source.hasTile.bind(this._source);W=W.filter(we=>ye(we))}}else W=[];if(W.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!Xx(this._source.type)){const ye=h.coveringZoomLevel({tileSize:y||this._source.tileSize,roundZoom:this._source.roundZoom&&!A}),we=Math.min(ye,this._source.maxzoom);if(z){const Le=h.extendTileCover(W,we);for(const Ie of Le)W.push(Ie)}else if(F){const Le=h.extendTileCoverToNearPlane(W,this.transform.getFrustum(we),we);for(const Ie of Le)W.push(Ie)}else if(this.castsShadows&&D){const Le=h.extendTileCover(W,we,D,16);for(const Ie of Le)this._shadowCasterTiles[Ie.key]=!0,W.push(Ie)}}const le=this._updateRetainedTiles(W);if(Xx(this._source.type)&&W.length!==0){const ye={},we={},Le=Object.keys(le);for(const We of Le){const Ue=le[We],st=this._tiles[We];if(!st||st.fadeEndTime&&st.fadeEndTime<=i.o.now())continue;const ut=this.findLoadedParent(Ue,Math.max(Ue.overscaledZ-Al.maxOverzooming,this._source.minzoom));ut&&(this._addTile(ut.tileID),ye[ut.tileID.key]=ut.tileID),we[We]=Ue}const Ie=W[W.length-1].overscaledZ;for(const We in this._tiles){const Ue=this._tiles[We];if(le[We]||!Ue.hasData())continue;let st=Ue.tileID;for(;st.overscaledZ>Ie;){st=st.scaledTo(st.overscaledZ-1);const ut=this._tiles[st.key];if(ut&&ut.hasData()&&we[st.key]){le[We]=Ue.tileID;break}}}for(const We in ye)le[We]||(this._coveredTiles[We]=!0,le[We]=ye[We])}for(const ye in le)this._tiles[ye].clearFadeHold();const _e=i.bv(this._tiles,le);for(const ye of _e){const we=this._tiles[ye];we.hasSymbolBuckets&&!we.holdingForFade()?we.setHoldDuration(this.map._fadeDuration):we.hasSymbolBuckets&&!we.symbolFadeFinished()||this._removeTile(+ye)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const h in this._tiles)this._tiles[h].holdingForFade()&&this._removeTile(+h)}_updateRetainedTiles(h){const y={};if(h.length===0)return y;const A={},D=h.reduce((ne,le)=>Math.min(ne,le.overscaledZ),1/0),F=h[0].overscaledZ,z=Math.max(F-Al.maxOverzooming,this._source.minzoom),W=Math.max(F+Al.maxUnderzooming,this._source.minzoom),J={};for(const ne of h){const le=this._addTile(ne);y[ne.key]=ne,le.hasData()||D=this._source.maxzoom){const ye=ne.children(this._source.maxzoom)[0],we=this.getTile(ye);if(we&&we.hasData()){y[ye.key]=ye;continue}}else{const ye=ne.children(this._source.maxzoom);if(y[ye[0].key]&&y[ye[1].key]&&y[ye[2].key]&&y[ye[3].key])continue}let _e=le.wasRequested();for(let ye=ne.overscaledZ-1;ye>=z;--ye){const we=ne.scaledTo(ye);if(A[we.key]||(A[we.key]=!0,le=this.getTile(we),!le&&_e&&(le=this._addTile(we)),le&&(y[we.key]=we,_e=le.wasRequested(),le.hasData())))break}}return y}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const h in this._tiles){const y=[];let A,D=this._tiles[h].tileID;for(;D.overscaledZ>0;){if(D.key in this._loadedParentTiles){A=this._loadedParentTiles[D.key];break}y.push(D.key);const F=D.scaledTo(D.overscaledZ-1);if(A=this._getLoadedTile(F),A)break;D=F}for(const F of y)this._loadedParentTiles[F]=A}}_addTile(h){let y=this._tiles[h.key];if(y)return y.isExtraShadowCaster!==!0||this._shadowCasterTiles[h.key]||this._reloadTile(h.key,"reloading"),y;y=this._cache.getAndRemove(h),y&&(this._setTileReloadTimer(h.key,y),y.tileID=h,this._state.initializeTileState(y,this.map?this.map.painter:null),this._cacheTimers[h.key]&&(clearTimeout(this._cacheTimers[h.key]),delete this._cacheTimers[h.key],this._setTileReloadTimer(h.key,y)));const A=!!y;if(!A){const D=this.map?this.map.painter:null,F=this._source.tileSize*h.overscaleFactor();y=this._source.type==="raster-array"?new Cd(h,F,this.transform.tileZoom,D,this._isRaster):new Ym(h,F,this.transform.tileZoom,D,this._isRaster,this._source.worldview),this._loadTile(y,this._tileLoaded.bind(this,y,h.key,y.state))}return y.uses++,this._tiles[h.key]=y,A||this._source.fire(new i.z("dataloading",{tile:y,coord:y.tileID,dataType:"source"})),y}_setTileReloadTimer(h,y){h in this._timers&&(clearTimeout(this._timers[h]),delete this._timers[h]);const A=y.getExpiryTimeout();A&&(this._timers[h]=setTimeout(()=>{this._reloadTile(h,"expired"),delete this._timers[h]},A))}_removeTile(h){const y=this._tiles[h];y&&(y.uses--,delete this._tiles[h],this._timers[h]&&(clearTimeout(this._timers[h]),delete this._timers[h]),y.uses>0||(y.hasData()&&y.state!=="reloading"||y.state==="empty"?this._cache.add(y.tileID,y,y.getExpiryTimeout()):(y.aborted=!0,this._abortTile(y),this._unloadTile(y))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const h in this._tiles)this._removeTile(+h);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(h,y,A){const D=[],F=this.transform;if(!F)return D;const z=F.projection.name==="globe",W=i.aF(F.center.lng);for(const J in this._tiles){const ne=this._tiles[J];if(A&&ne.clearQueryDebugViz(),ne.holdingForFade())continue;let le;if(z){const _e=ne.tileID.canonical;if(_e.z===0){const ye=[Math.abs(i.aA(W,...Lh(_e,-1))-W),Math.abs(i.aA(W,...Lh(_e,1))-W)];le=[0,2*ye.indexOf(Math.min(...ye))-1]}else{const ye=[Math.abs(i.aA(W,...Lh(_e,-1))-W),Math.abs(i.aA(W,...Lh(_e,0))-W),Math.abs(i.aA(W,...Lh(_e,1))-W)];le=[ye.indexOf(Math.min(...ye))-1]}}else le=[0];for(const _e of le){const ye=h.containsTile(ne,F,y,_e);ye&&D.push(ye)}}return D}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(h){return this._getRenderableCoordinates(h)}_getRenderableCoordinates(h,y){const A=this.getRenderableIds(h,y).map(F=>this._tiles[F].tileID),D=this.transform.projection.name==="globe";for(const F of A)F.projMatrix=this.transform.calculateProjMatrix(F.toUnwrapped()),F.expandedProjMatrix=D?this.transform.calculateProjMatrix(F.toUnwrapped(),!1,!0):F.projMatrix;return A}sortCoordinatesByDistance(h){const y=h.slice(),A=this.transform._camera.position,D=this.transform._camera.forward(),F={};for(const z of y){const W=1/(1<F[z.key]-F[W.key]),y}hasTransition(){if(this._source.hasTransition())return!0;if(Xx(this._source.type))for(const h in this._tiles){const y=this._tiles[h];if(y.fadeEndTime!==void 0&&y.fadeEndTime>=i.o.now())return!0}return!1}setFeatureState(h,y,A){this._state.updateState(h=h||"_geojsonTileLayer",y,A)}removeFeatureState(h,y,A){this._state.removeFeatureState(h=h||"_geojsonTileLayer",y,A)}getFeatureState(h,y){return this._state.getState(h=h||"_geojsonTileLayer",y)}setDependencies(h,y,A){const D=this._tiles[h];D&&D.setDependencies(y,A)}reloadTilesForDependencies(h,y){for(const A in this._tiles)this._tiles[A].hasDependency(h,y)&&this._reloadTile(+A,"reloading");this._cache.filter(A=>!A.hasDependency(h,y))}_preloadTiles(h,y){if(!this._sourceLoaded){const J=()=>{this._sourceLoaded&&(this._source.off("data",J),this._preloadTiles(h,y))};return void this._source.on("data",J)}const A=new Map,D=Array.isArray(h)?h:[h],F=this.map.painter.terrain,z=this.usedForTerrain&&F?F.getScaledDemTileSize():this._source.tileSize;for(const J of D){const ne=J.coveringTiles({tileSize:z,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const le of ne)A.set(le.key,le);this.usedForTerrain&&J.updateElevation(!1)}const W=Array.from(A.values());i.bw(W,(J,ne)=>{const le=new Ym(J,this._source.tileSize*J.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(le,_e=>{this._source.type==="raster-dem"&&le.dem&&this._backfillDEM(le),ne(_e,le)})},y)}}function G1(T,h){const y=Math.abs(2*T.wrap)-+(T.wrap<0),A=Math.abs(2*h.wrap)-+(h.wrap<0);return T.overscaledZ-h.overscaledZ||A-y||h.canonical.y-T.canonical.y||h.canonical.x-T.canonical.x}function Xx(T){return T==="raster"||T==="image"||T==="video"||T==="custom"}function Lh(T,h){const y=1<0:A.type==="building"?D=!A.isHidden(h)&&A.paint.get("building-opacity")>0:A.type==="model"&&(D=!A.isHidden(h)&&A.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!D&&y.visible,y.visible=D}}updateZOffset(h,y){this.currentBuildingBuckets=[];for(const D of this.layers){const F=D.layer,z=this.style.getLayerSourceCache(F);let W=1;F.type==="fill-extrusion"?W=D.visible?F.paint.get("fill-extrusion-vertical-scale"):0:F.type==="building"&&(W=D.visible?F.paint.get("building-vertical-scale"):0);let J=z?z.getTile(y):null;if(!J&&z)for(const ne in z._tiles){const le=z._tiles[ne];if(y.canonical.isChildOf(le.tileID.canonical)){J=le;break}}this.currentBuildingBuckets.push({bucket:J?J.getBucket(F):null,tileID:J?J.tileID:y,verticalScale:W})}h.hasAnyZOffset=!1;let A=!1;for(let D=0;D{A in h&&(y[A]=h[A])}),y}function Z0(T){T=T.slice();const h=Object.create(null);for(let y=0;y0?(D-z)/W:0;return this.points[F].mult(1-J).add(this.points[y].mult(J))}}class Kw{constructor(h,y,A){const D=this.boxCells=[],F=this.circleCells=[];this.xCellCount=Math.ceil(h/A),this.yCellCount=Math.ceil(y/A);for(let z=0;zthis.width||D<0||y>this.height)return!F&&[];const W=[];if(h<=0&&y<=0&&this.width<=A&&this.height<=D){if(F)return!0;for(let J=0;J0:W}_queryCircle(h,y,A,D,F){const z=h-A,W=h+A,J=y-A,ne=y+A;if(W<0||z>this.width||ne<0||J>this.height)return!D&&[];const le=[];return this._forEachCell(z,J,W,ne,this._queryCellCircle,le,{hitTest:D,circle:{x:h,y,radius:A},seenUids:{box:{},circle:{}}},F),D?le.length>0:le}query(h,y,A,D,F){return this._query(h,y,A,D,!1,F)}hitTest(h,y,A,D,F){return this._query(h,y,A,D,!0,F)}hitTestCircle(h,y,A,D){return this._queryCircle(h,y,A,!0,D)}_queryCell(h,y,A,D,F,z,W,J){const ne=W.seenUids,le=this.boxCells[F];if(le!==null){const ye=this.bboxes;for(const we of le)if(!ne.box[we]){ne.box[we]=!0;const Le=4*we;if(h<=ye[Le+2]&&y<=ye[Le+3]&&A>=ye[Le+0]&&D>=ye[Le+1]&&(!J||J(this.boxKeys[we]))){if(W.hitTest)return z.push(!0),!0;z.push({key:this.boxKeys[we],x1:ye[Le],y1:ye[Le+1],x2:ye[Le+2],y2:ye[Le+3]})}}}const _e=this.circleCells[F];if(_e!==null){const ye=this.circles;for(const we of _e)if(!ne.circle[we]){ne.circle[we]=!0;const Le=3*we;if(this._circleAndRectCollide(ye[Le],ye[Le+1],ye[Le+2],h,y,A,D)&&(!J||J(this.circleKeys[we]))){if(W.hitTest)return z.push(!0),!0;{const Ie=ye[Le],We=ye[Le+1],Ue=ye[Le+2];z.push({key:this.circleKeys[we],x1:Ie-Ue,y1:We-Ue,x2:Ie+Ue,y2:We+Ue})}}}}}_queryCellCircle(h,y,A,D,F,z,W,J){const ne=W.circle,le=W.seenUids,_e=this.boxCells[F];if(_e!==null){const we=this.bboxes;for(const Le of _e)if(!le.box[Le]){le.box[Le]=!0;const Ie=4*Le;if(this._circleAndRectCollide(ne.x,ne.y,ne.radius,we[Ie+0],we[Ie+1],we[Ie+2],we[Ie+3])&&(!J||J(this.boxKeys[Le])))return z.push(!0),!0}}const ye=this.circleCells[F];if(ye!==null){const we=this.circles;for(const Le of ye)if(!le.circle[Le]){le.circle[Le]=!0;const Ie=3*Le;if(this._circlesCollide(we[Ie],we[Ie+1],we[Ie+2],ne.x,ne.y,ne.radius)&&(!J||J(this.circleKeys[Le])))return z.push(!0),!0}}}_forEachCell(h,y,A,D,F,z,W,J){const ne=this._convertToXCellCoord(h),le=this._convertToYCellCoord(y),_e=this._convertToXCellCoord(A),ye=this._convertToYCellCoord(D);for(let we=ne;we<=_e;we++)for(let Le=le;Le<=ye;Le++)if(F.call(this,h,y,A,D,this.xCellCount*Le+we,z,W,J))return}_convertToXCellCoord(h){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(h*this.xScale)))}_convertToYCellCoord(h){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(h*this.yScale)))}_circlesCollide(h,y,A,D,F,z){const W=D-h,J=F-y,ne=A+z;return ne*ne>W*W+J*J}_circleAndRectCollide(h,y,A,D,F,z,W){const J=(z-D)/2,ne=Math.abs(h-(D+J));if(ne>J+A)return!1;const le=(W-F)/2,_e=Math.abs(y-(F+le));if(_e>le+A)return!1;if(ne<=J||_e<=le)return!0;const ye=ne-J,we=_e-le;return ye*ye+we*we<=A*A}}const jt={unknown:0,flipRequired:1,flipNotRequired:2},As=Math.tan(85*Math.PI/180);function Qs(T,h,y,A,D,F,z){const W=i.bC();if(y)if(F.name==="globe"){const J=i.bD(D,h);i.aB(W,W,J)}else{const J=i.bE([],z);W[0]=J[0],W[1]=J[1],W[4]=J[2],W[5]=J[3],A||i.bB(W,W,D.angle)}else i.aB(W,D.labelPlaneMatrix,T);return W}function xn(T,h,y,A,D,F,z){const W=Qs(T,h,y,A,D,F,z);return F.name==="globe"&&y||(W[2]=W[6]=W[10]=W[14]=0),W}function gn(T,h,y,A,D,F,z){if(y){if(F.name==="globe"){const W=Qs(T,h,y,A,D,F,z);return i.bl(W,W),i.aB(W,T,W),W}{const W=i.bz(T),J=i.bA([]);return J[0]=z[0],J[1]=z[1],J[4]=z[2],J[5]=z[3],i.aB(W,W,J),A||i.bB(W,W,-D.angle),W}}return D.glCoordMatrix}function ca(T,h,y,A){const D=[T,h,y,1];y?i.aC(D,D,A):$r(D,D,A);const F=D[3];return D[0]/=F,D[1]/=F,D[2]/=F,D}function Ur(T,h){return Math.min(.5+T/h*.5,1.5)}function uo(T,h){const y=T[0]/T[3],A=T[1]/T[3];return y>=-h[0]&&y<=h[0]&&A>=-h[1]&&A<=h[1]}function Qx(T,h,y,A,D,F,z,W,J,ne,le=1){const _e=y.transform,ye=A?T.textSizeData:T.iconSizeData,we=i.bK(ye,y.transform.zoom,le),Le=_e.projection.name==="globe",Ie=[256/y.width*2+1,256/y.height*2+1],We=A?T.text.dynamicLayoutVertexArray:T.icon.dynamicLayoutVertexArray;We.clear();let Ue=null;Le&&(Ue=A?T.text.globeExtVertexArray:T.icon.globeExtVertexArray);const st=T.lineVertexArray,ut=A?T.text.placedSymbolArray:T.icon.placedSymbolArray,ot=y.transform.width/y.transform.height;let Et,Nt=!1;for(let Tt=0;TtMath.abs(y)?{useVertical:!0}:T===i.bL.vertical?A>0?{needsFlipping:!0}:null:h!==jt.unknown&&function(D,F){return D===0||Math.abs(F/D)>As}(y,A)?h===jt.flipRequired?{needsFlipping:!0}:null:y<0?{needsFlipping:!0}:null}function Q0(T,h,y,A,D,F,z,W,J,ne,le,_e,ye,we,Le,Ie,We,Ue,st,ut){const ot=h/24,Et=T.lineOffsetX*ot,Nt=T.lineOffsetY*ot,{lineStartIndex:Tt,glyphStartIndex:wt,numGlyphs:yt,segment:Ot,writingMode:Wt,flipState:Ht}=T,es=Tt+T.lineLength,ts=xs=>{if(le){const[as,Jt,Is]=xs.up,rr=ne.length;i.bN(le,rr+0,as,Jt,Is),i.bN(le,rr+1,as,Jt,Is),i.bN(le,rr+2,as,Jt,Is),i.bN(le,rr+3,as,Jt,Is)}const[qs,Yt,Bt]=xs.point;i.bO(ne,qs,Yt,Bt,xs.angle)};if(yt>1){const xs=Op(ot,W,Et,Nt,y,_e,ye,T,J,F,we,Ie,!1,We,Ue,st,ut);if(!xs)return{notEnoughRoom:!0};if(A&&!y){let[qs,Yt,Bt]=xs.first.point,[as,Jt,Is]=xs.last.point;[qs,Yt]=ca(qs,Yt,Bt,z),[as,Jt]=ca(as,Jt,Is,z);const rr=Zr(Wt,Ht,(as-qs)*Le,Jt-Yt);if(T.flipState=rr&&rr.needsFlipping?jt.flipRequired:jt.flipNotRequired,rr)return rr}ts(xs.first);for(let qs=wt+1;qs0?as:Qm(ye,Bt,qs,1,D,void 0,We,Ue.canonical),Is=Zr(Wt,Ht,(Jt[0]-qs[0])*Le,Jt[1]-qs[1]);if(T.flipState=Is&&Is.needsFlipping?jt.flipRequired:jt.flipNotRequired,Is)return Is}const xs=Z1(ot*W.getoffsetX(wt),Et,Nt,y,_e,ye,Ot,Tt,es,J,F,we,Ie,!1,!1,We,Ue,st,ut);if(!xs)return{notEnoughRoom:!0};ts(xs)}return{}}function J0(T,h,y,A,D){const{x:F,y:z,z:W}=A.projectTilePoint(T.x,T.y,h);if(!D)return ca(F,z,W,y);const[J,ne,le]=D.getElevation(T,D.elevation,D.elevationFeature);return ca(F+J,z+ne,W+le,y)}function Qm(T,h,y,A,D,F,z,W){const J=J0(T.sub(h)._unit()._add(T),W,D,z,F);return i.av(J,y,J),i.aw(J,J),i.bH(J,y,J,A)}function Z1(T,h,y,A,D,F,z,W,J,ne,le,_e,ye,we,Le,Ie,We,Ue,st){const ut=A?T-h:T+h;let ot=ut>0?1:-1,Et=0;A&&(ot*=-1,Et=Math.PI),ot<0&&(Et+=Math.PI);let Nt=W+z+(ot>0?0:1)|0,Tt=D,wt=D,yt=0,Ot=0;const Wt=Math.abs(ut),Ht=[],es=[];let ts=F,xs=ts,qs=i.bF([]);const Yt=()=>Qm(xs,ts,wt,Wt-yt+1,le,ye,Ie,We.canonical);for(;yt+Ot<=Wt;){if(Nt+=ot,Nt=J)return null;if(wt=Tt,xs=ts,Ht.push(wt),we&&es.push(xs),ts=new i.P(ne.getx(Nt),ne.gety(Nt)),Tt=_e[Nt],!Tt){const Cr=J0(ts,We.canonical,le,Ie,ye);Tt=Cr[3]>0?_e[Nt]=Cr:Yt()}yt+=Ot;const Us=i.av([],Tt,wt),Pr=i.bG(wt,Tt);if(y&&Pr>0&&Ot>0&&i.bJ(qs,Us)/(Ot*Pr)0,ut),Tt=ne*Nt.perspectiveRatio,wt=(A.x1*y+W.x-A.padding)*Tt+Nt.point.x,yt=(A.y1*y+W.y-A.padding)*Tt+Nt.point.y,Ot=(A.x2*y+W.x+A.padding)*Tt+Nt.point.x,Wt=(A.y2*y+W.y+A.padding)*Tt+Nt.point.y,Ht=Nt.perspectiveRatio<=.55||Nt.occluded;return!this.isInsideGrid(wt,yt,Ot,Wt)||!J&&this.grid.hitTest(wt,yt,Ot,Wt,_e)||Ht?{box:[],offscreen:!1,occluded:Nt.occluded}:{box:[wt,yt,Ot,Wt],offscreen:this.isOffscreen(wt,yt,Ot,Wt),occluded:!1}}placeCollisionCircles(h,y,A,D,F,z,W,J,ne,le,_e,ye,we,Le,Ie,We){const Ue=[],st=this.transform.elevation,ut=h.getProjection(),ot=h.elevationType==="road",Et=!!st||ot,Nt=i.bV.getAtTileOffsetFunc(We,this.transform.center.lat,this.transform.worldSize,ut),Tt=new i.P(A.tileAnchorX,A.tileAnchorY),wt=new i.P(A.tileAnchorX,A.tileAnchorY);let{x:yt,y:Ot,z:Wt}=ut.projectTilePoint(wt.x,wt.y,We.canonical),Ht=null;if(Et){const Pr=ot?h.getElevationFeatureForText(D):null;Ht={getElevation:Nt,elevation:st,elevationFeature:Pr};const[Cr,hr,br]=Nt(Tt,st,Pr);yt+=Cr,Ot+=hr,Wt+=br}const es=ut.name==="globe",ts=this.projectAndGetPerspectiveRatio(J,yt,Ot,Wt,We,es||!!st||this.transform.pitch>0,ut),{perspectiveRatio:xs}=ts,qs=(ye?W/xs:W*xs)/i.bY,Yt=ca(yt,Ot,Wt,ne),Bt=A.lineOffsetX*qs,as=A.lineOffsetY*qs,Jt=i.an(h.layers[0].layout.get("text-max-angle")),Is=Math.cos(Jt),rr=ts.signedDistanceFromCamera>0?Op(qs,z,Bt,as,ot&&A.flipState===1,Yt,wt,A,F,ne,{},Et&&!ye?Ht:null,ye&&Et,ut,We,ye,Is):null;let yr=!1,Js=!1,Us=!0;if(rr&&!ts.occluded){const Pr=.5*Le*xs+Ie,Cr=new i.P(-100,-100),hr=new i.P(this.screenRightBoundary,this.screenBottomBoundary),br=new by,{first:Kr,last:Pn}=rr,wa=Kr.path.length;let si=[];for(let Cn=wa-1;Cn>=1;Cn--)si.push(Kr.path[Cn]);for(let Cn=1;Cn(Et&&!es&&(Ci=Nt(biCn[3]<=0)&&(si=[]));let Ka=[];if(si.length>0){let Cn=1/0,di=-1/0,Ci=1/0,bi=-1/0;for(const Ga of si)Cn=Math.min(Cn,Ga[0]),Ci=Math.min(Ci,Ga[1]),di=Math.max(di,Ga[0]),bi=Math.max(bi,Ga[1]);di>=Cr.x&&Cn<=hr.x&&bi>=Cr.y&&Ci<=hr.y&&(Ka=[si.map(Ga=>new i.P(Ga[0],Ga[1]))],(Cnhr.x||Cihr.y)&&(Ka=i.bW(Ka,Cr.x,Cr.y,hr.x,hr.y)))}for(const Cn of Ka){br.reset(Cn,.25*Pr);let di=0;di=br.length<=.5*Pr?1:Math.ceil(br.paddedLength/Or)+1;for(let Ci=0;Ci0?(i.aC(J,J,h),this.fogState&&F&&W.name!=="globe"&&(ne=function(ye,we,Le,Ie,We,Ue){const st=Ue.calculateFogTileMatrix(We),ut=[we,Le,Ie];return i.af(ut,ut,st),vr(ye,i.ag(ut),Ue.pitch,Ue._fov)}(this.fogState,y,A,D,F.toUnwrapped(),this.transform)>.9)):$r(J,J,h);const le=J[3];return{point:new i.P((J[0]/le+1)/2*this.transform.width+Da,(-J[1]/le+1)/2*this.transform.height+Da),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(W)/le*.5,1.5),signedDistanceFromCamera:le,occluded:z&&J[2]>le||ne}}isOffscreen(h,y,A,D){return A=this.screenRightBoundary||Dthis.screenBottomBoundary}isInsideGrid(h,y,A,D){return A>=0&&h=0&&yA.collisionGroupID===y}}return this.collisionGroups[h]}}function qd(T,h,y,A,D){const{horizontalAlign:F,verticalAlign:z}=i.c1(T),W=-(F-.5)*h,J=-(z-.5)*y,ne=i.c2(T,A);return new i.P(W+ne[0]*D,J+ne[1]*D)}function _l(T,h,y,A,D){const F=new i.P(T,h);return y&&F._rotate(A?D:-D),F}class jme{constructor(h,y,A,D,F,z){this.transform=h.clone(),this.projection=h.projection.name,this.collisionIndex=new Si(this.transform,F),this.buildingIndex=z,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=y,this.retainedQueryData={},this.collisionGroups=new Yw(A),this.collisionCircleArrays={},this.prevPlacement=D,D&&(D.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(h,y,A,D,F=1){const z=A.getBucket(y),W=A.latestFeatureIndex;if(!z||!W||y.fqid!==z.layerIds[0])return;const J=z.layers[0].layout,ne=z.layers[0].paint,le=A.collisionBoxArray,_e=Math.pow(2,this.transform.zoom-A.tileID.overscaledZ),ye=A.tileSize/i.al,we=A.tileID.toUnwrapped();this.transform.setProjection(z.projection);const Le=(Ie=A.tileID,We=z.getProjection(),Ue=this.transform,We.name===this.projection?Ue.calculateProjMatrix(Ie.toUnwrapped()):Gw(Ue,We,Ie));var Ie,We,Ue;const st=J.get("text-pitch-alignment")==="map",ut=J.get("text-rotation-alignment")==="map";y.compileFilter(y.options);const ot=y.dynamicFilter(),Et=y.dynamicFilterNeedsFeature(),Nt=this.transform.calculatePixelsToTileUnitsMatrix(A),Tt=xn(Le,A.tileID.canonical,st,ut,this.transform,z.getProjection(),Nt);let wt=null;const yt=z.getProjection().createInversionMatrix(this.transform,A.tileID.canonical);if(st){const Bt=gn(Le,A.tileID.canonical,st,ut,this.transform,z.getProjection(),Nt);wt=i.aB([],this.transform.labelPlaneMatrix,Bt)}let Ot=null;ot&&A.latestFeatureIndex&&(Ot={unwrappedTileID:we,dynamicFilter:ot,dynamicFilterNeedsFeature:Et}),this.retainedQueryData[z.bucketInstanceId]=new Zw(z.bucketInstanceId,W,z.sourceLayerIndex,z.index,A.tileID);const[Wt,Ht]=z.layers[0].layout.get("text-size-scale-range"),es=i.aA(F,Wt,Ht),[ts,xs]=J.get("icon-size-scale-range"),qs=i.aA(F,ts,xs),Yt={bucket:z,layout:J,paint:ne,posMatrix:Le,invMatrix:yt,mercatorCenter:[i.aF(this.transform.center.lng),i.aJ(this.transform.center.lat)],textLabelPlaneMatrix:Tt,labelToScreenMatrix:wt,clippingData:Ot,scale:_e,textPixelRatio:ye,holdingForFade:A.holdingForFade(),collisionBoxArray:le,partiallyEvaluatedTextSize:i.bK(z.textSizeData,this.transform.zoom,es),partiallyEvaluatedIconSize:i.bK(z.iconSizeData,this.transform.zoom,qs),collisionGroup:this.collisionGroups.get(z.sourceID),latestFeatureIndex:A.latestFeatureIndex};if(D)for(const Bt of z.sortKeyRanges){const{sortKey:as,symbolInstanceStart:Jt,symbolInstanceEnd:Is}=Bt;h.push({sortKey:as,symbolInstanceStart:Jt,symbolInstanceEnd:Is,parameters:Yt})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:z.symbolInstances.length,parameters:Yt})}attemptAnchorPlacement(h,y,A,D,F,z,W,J,ne,le,_e,ye,we,Le,Ie,We,Ue,st,ut,ot,Et){const{textOffset0:Nt,textOffset1:Tt,crossTileID:wt}=Ie,yt=[Nt,Tt],Ot=qd(h,z,W,yt,J),Wt=this.collisionIndex.placeCollisionBox(Ue,J,y,A,D,F,_l(Ot.x,Ot.y,ne,le,this.transform.angle),Le,_e,ye,we.predicate);if(ut){const Ht=Ue.getSymbolInstanceIconSize(Et,this.transform.zoom,Ie.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(Ue,Ht,ut,A,D,F,_l(Ot.x,Ot.y,ne,le,this.transform.angle),Le,_e,ye,we.predicate).box.length===0)return}if(Wt.box.length>0){let Ht;return this.prevPlacement&&this.prevPlacement.variableOffsets[wt]&&this.prevPlacement.placements[wt]&&this.prevPlacement.placements[wt].text&&(Ht=this.prevPlacement.variableOffsets[wt].anchor),this.variableOffsets[wt]={textOffset:yt,width:z,height:W,anchor:h,textScale:J,prevAnchor:Ht},this.markUsedJustification(Ue,h,Ie,st),Ue.allowVerticalPlacement&&(this.markUsedOrientation(Ue,st,Ie),this.placedOrientations[wt]=st),{shift:Ot,placedGlyphBoxes:Wt}}}placeLayerBucketPart(h,y,A,D,F=1){const{bucket:z,layout:W,paint:J,posMatrix:ne,textLabelPlaneMatrix:le,labelToScreenMatrix:_e,clippingData:ye,textPixelRatio:we,mercatorCenter:Le,invMatrix:Ie,holdingForFade:We,collisionBoxArray:Ue,partiallyEvaluatedTextSize:st,partiallyEvaluatedIconSize:ut,collisionGroup:ot,latestFeatureIndex:Et}=h.parameters,Nt=W.get("text-optional"),Tt=W.get("icon-optional"),wt=W.get("text-allow-overlap"),yt=W.get("icon-allow-overlap"),Ot=W.get("text-rotation-alignment")==="map",Wt=W.get("icon-rotation-alignment")==="map",Ht=W.get("text-pitch-alignment")==="map",es=J.get("symbol-z-offset"),ts=W.get("symbol-elevation-reference")==="sea",xs=W.get("symbol-placement"),[qs,Yt]=W.get("text-size-scale-range"),[Bt,as]=W.get("icon-size-scale-range"),Jt=i.aA(F,qs,Yt),Is=i.aA(F,Bt,as),rr=W.get("text-variable-anchor"),yr=Ot&&xs!=="point",Js=Wt&&xs!=="point",Us=rr&&z.hasTextData(),Pr=z.hasIconTextFit()&&Us&&z.hasIconData();this.transform.setProjection(z.projection);const Cr=Us||yr,hr=Js||Pr;let br=wt&&(yt||!z.hasIconData()||Tt),Kr=yt&&(wt||!z.hasTextData()||Nt);const Pn=!es.isConstant();!z.collisionArrays&&Ue&&z.deserializeCollisionBoxes(Ue),A&&D&&z.updateCollisionDebugBuffers(this.transform.zoom,Ue,Jt,Is);const wa=(Or,Ka,Cn)=>{const{crossTileID:di,numVerticalGlyphVertices:Ci}=Or;let bi=null;if(ye&&ye.dynamicFilterNeedsFeature||Pn){const Lo=this.retainedQueryData[z.bucketInstanceId];bi=Et.loadFeature({featureIndex:Or.featureIndex,bucketIndex:Lo.bucketIndex,sourceLayerIndex:Lo.sourceLayerIndex,layoutVertexArrayOffset:0});const Jo=bi.properties?bi.properties.worldview:null;if(z.localizable&&z.worldview&&typeof Jo=="string")if(Jo==="all")bi.properties.$localized=!0;else{if(!Jo.split(",").includes(z.worldview))return;bi.properties.$localized=!0,bi.properties.worldview=z.worldview}}if(ye&&!(0,ye.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:z.worldview},bi,this.retainedQueryData[z.bucketInstanceId].tileID.canonical,new i.P(Or.tileAnchorX,Or.tileAnchorY),this.transform.calculateDistanceTileData(ye.unwrappedTileID)))return this.placements[di]=new pi(!1,!1,!1,!0),void y.add(di);const Ga=es.evaluate(bi,{});if(y.has(di))return;if(We)return void(this.placements[di]=new pi(!1,!1,!1));let Wn=!1,ii=!1,So=!0,no=!1,ui=!1,za=null,Gn={box:null,offscreen:null,occluded:null},Xi={box:null},Ho=null,_o=null,Di=null,Bu=0,Md=0,ql=0;Cn.textFeatureIndex?Bu=Cn.textFeatureIndex:Or.useRuntimeCollisionCircles&&(Bu=Or.featureIndex),Cn.verticalTextFeatureIndex&&(Md=Cn.verticalTextFeatureIndex);const Vd=z.elevationFeatures?z.elevationFeatures[Or.elevationFeatureIndex]:void 0,Hd=Lo=>{Lo.tileID=this.retainedQueryData[z.bucketInstanceId].tileID;const Jo=this.transform.elevation;Lo.elevation=ts?Ga:Ga+i.bV.getAtTileOffset(Lo.tileID,new i.P(Lo.tileAnchorX,Lo.tileAnchorY),Jo,Vd),Lo.elevation+=Or.zOffset},id=Cn.textBox;if(id){Hd(id);const Lo=Oi=>{let ml=i.bL.horizontal;if(z.allowVerticalPlacement&&!Oi&&this.prevPlacement){const Co=this.prevPlacement.placedOrientations[di];Co&&(this.placedOrientations[di]=Co,ml=Co,this.markUsedOrientation(z,ml,Or))}return ml},Jo=(Oi,ml)=>{if(z.allowVerticalPlacement&&Ci>0&&Cn.verticalTextBox){for(const Co of z.writingModes)if(Co===i.bL.vertical?(Gn=ml(),Xi=Gn):Gn=Oi(),Gn&&Gn.box&&Gn.box.length)break}else Gn=Oi()};if(rr){let Oi=rr;if(this.prevPlacement&&this.prevPlacement.variableOffsets[di]){const wo=this.prevPlacement.variableOffsets[di];Oi.indexOf(wo.anchor)>0&&(Oi=Oi.filter(ip=>ip!==wo.anchor),Oi.unshift(wo.anchor))}const ml=(wo,ip,N2)=>{const Up=z.getSymbolInstanceTextSize(st,Or,this.transform.zoom,Ka),k2=(wo.x2-wo.x1)*Up+2*wo.padding,vb=(wo.y2-wo.y1)*Up+2*wo.padding,Gf=Or.hasIconTextFit&&!yt?ip:null;Gf&&Hd(Gf);let hg={box:[],offscreen:!1,occluded:!1};const bb=wt?2*Oi.length:Oi.length;for(let Oy=0;Oy=Oi.length,Or,Ka,z,N2,Gf,st,ut);if(mg&&(hg=mg.placedGlyphBoxes,hg&&hg.box&&hg.box.length)){Wn=!0,za=mg.shift;break}}return hg};Jo(()=>ml(id,Cn.iconBox,i.bL.horizontal),()=>{const wo=Cn.verticalTextBox;return wo&&Hd(wo),z.allowVerticalPlacement&&!(Gn&&Gn.box&&Gn.box.length)&&Ci>0&&wo?ml(wo,Cn.verticalIconBox,i.bL.vertical):{box:null,offscreen:null,occluded:null}}),Gn&&(Wn=Gn.box,So=Gn.offscreen,no=Gn.occluded);const Co=Lo(!(!Gn||!Gn.box));if(!Wn&&this.prevPlacement){const wo=this.prevPlacement.variableOffsets[di];wo&&(this.variableOffsets[di]=wo,this.markUsedJustification(z,wo.anchor,Or,Co))}}else{const Oi=(ml,Co)=>{const wo=z.getSymbolInstanceTextSize(st,Or,this.transform.zoom,Ka),ip=this.collisionIndex.placeCollisionBox(z,wo,ml,Le,Ie,Cr,new i.P(0,0),wt,we,ne,ot.predicate);return ip&&ip.box&&ip.box.length&&(this.markUsedOrientation(z,Co,Or),this.placedOrientations[di]=Co),ip};Jo(()=>Oi(id,i.bL.horizontal),()=>{const ml=Cn.verticalTextBox;return z.allowVerticalPlacement&&Ci>0&&ml?(Hd(ml),Oi(ml,i.bL.vertical)):{box:null,offscreen:null,occluded:null}}),Lo(!!(Gn&&Gn.box&&Gn.box.length))}}if(Ho=Gn,Wn=Ho&&Ho.box&&Ho.box.length>0,So=Ho&&Ho.offscreen,no=Ho&&Ho.occluded,Or.useRuntimeCollisionCircles){const Lo=Or.centerJustifiedTextSymbolIndex>=0?Or.centerJustifiedTextSymbolIndex:Or.verticalPlacedTextSymbolIndex,Jo=z.text.placedSymbolArray.get(Lo),Oi=i.bM(z.textSizeData,st,Jo),ml=W.get("text-padding");_o=this.collisionIndex.placeCollisionCircles(z,wt,Jo,Lo,z.lineVertexArray,z.glyphOffsetArray,Oi,ne,le,_e,A,Ht,ot.predicate,Or.collisionCircleDiameter*Oi/i.bY,ml,this.retainedQueryData[z.bucketInstanceId].tileID),Wn=wt||_o.circles.length>0&&!_o.collisionDetected,So=So&&_o.offscreen,no=_o.occluded}if(Cn.iconFeatureIndex&&(ql=Cn.iconFeatureIndex),Cn.iconBox){const Lo=Jo=>{Hd(Jo);const Oi=Or.hasIconTextFit&&za?_l(za.x,za.y,Ot,Ht,this.transform.angle):new i.P(0,0),ml=z.getSymbolInstanceIconSize(ut,this.transform.zoom,Or.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(z,ml,Jo,Le,Ie,hr,Oi,yt,we,ne,ot.predicate)};Xi&&Xi.box&&Xi.box.length&&Cn.verticalIconBox?(Di=Lo(Cn.verticalIconBox),ii=Di.box.length>0):(Di=Lo(Cn.iconBox),ii=Di.box.length>0),So=So&&Di.offscreen,ui=Di.occluded}const hm=Nt||Or.numHorizontalGlyphVertices===0&&Ci===0,ap=Tt||Or.numIconVertices===0;if(hm||ap?ap?hm||(ii=ii&&Wn):Wn=ii&&Wn:ii=Wn=ii&&Wn,Wn&&Ho&&Ho.box&&this.collisionIndex.insertCollisionBox(Ho.box,W.get("text-ignore-placement"),z.bucketInstanceId,Xi&&Xi.box&&Md?Md:Bu,ot.ID),ii&&Di&&this.collisionIndex.insertCollisionBox(Di.box,W.get("icon-ignore-placement"),z.bucketInstanceId,ql,ot.ID),_o&&(Wn&&this.collisionIndex.insertCollisionCircles(_o.circles,W.get("text-ignore-placement"),z.bucketInstanceId,Bu,ot.ID),A)){const Lo=z.bucketInstanceId;let Jo=this.collisionCircleArrays[Lo];Jo===void 0&&(Jo=this.collisionCircleArrays[Lo]=new IC);for(let Oi=0;Oi<_o.circles.length;Oi+=4)Jo.circles.push(_o.circles[Oi+0]),Jo.circles.push(_o.circles[Oi+1]),Jo.circles.push(_o.circles[Oi+2]),Jo.circles.push(_o.collisionDetected?1:0)}const mh=z.projection.name!=="globe";br=br&&(mh||!no),Kr=Kr&&(mh||!ui),this.placements[di]=new pi(Wn||br,ii||Kr,So||z.justReloaded),y.add(di)},si=this.retainedQueryData[z.bucketInstanceId].tileID;if(z.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(z,si),z.elevationType==="road"&&z.updateRoadElevation(si.canonical),z.updateZOffset(),z.sortFeaturesByY){const Or=z.getSortedSymbolIndexes(this.transform.angle);for(let Ka=Or.length-1;Ka>=0;--Ka){const Cn=Or[Ka];wa(z.symbolInstances.get(Cn),Cn,z.collisionArrays[Cn])}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 Or=z.getSortedIndexesByZOffset();for(let Ka=0;Ka=0&&(h.text.placedSymbolArray.get(F).crossTileID=_e>=0&&F!==_e?0:ne),z>=0&&(h.text.placedSymbolArray.get(z).crossTileID=_e>=0&&z!==_e?0:ne),W>=0&&(h.text.placedSymbolArray.get(W).crossTileID=_e>=0&&W!==_e?0:ne),J>=0&&(h.text.placedSymbolArray.get(J).crossTileID=_e>=0&&J!==_e?0:ne)}markUsedOrientation(h,y,A){const D=y===i.bL.horizontal||y===i.bL.horizontalOnly?y:0,F=y===i.bL.vertical?y:0,{leftJustifiedTextSymbolIndex:z,centerJustifiedTextSymbolIndex:W,rightJustifiedTextSymbolIndex:J,verticalPlacedTextSymbolIndex:ne}=A,le=h.text.placedSymbolArray;z>=0&&(le.get(z).placedOrientation=D),W>=0&&(le.get(W).placedOrientation=D),J>=0&&(le.get(J).placedOrientation=D),ne>=0&&(le.get(ne).placedOrientation=F)}commit(h){this.commitTime=h,this.zoomAtLastRecencyCheck=this.transform.zoom;const y=this.prevPlacement;let A=!1;this.prevZoomAdjustment=y?y.zoomAdjustment(this.transform.zoom):0;const D=y?y.symbolFadeChange(h):1,F=y?y.opacities:{},z=y?y.variableOffsets:{},W=y?y.placedOrientations:{};for(const J in this.placements){const ne=this.placements[J],le=F[J];le?(this.opacities[J]=new Ff(le,D,ne.text,ne.icon,null,ne.clipped),A=A||ne.text!==le.text.placed||ne.icon!==le.icon.placed):(this.opacities[J]=new Ff(null,D,ne.text,ne.icon,ne.skipFade,ne.clipped),A=A||ne.text||ne.icon)}for(const J in F){const ne=F[J];if(!this.opacities[J]){const le=new Ff(ne,D,!1,!1);le.isHidden()||(this.opacities[J]=le,A=A||ne.text.placed||ne.icon.placed)}}for(const J in z)this.variableOffsets[J]||!this.opacities[J]||this.opacities[J].isHidden()||(this.variableOffsets[J]=z[J]);for(const J in W)this.placedOrientations[J]||!this.opacities[J]||this.opacities[J].isHidden()||(this.placedOrientations[J]=W[J]);A?this.lastPlacementChangeTime=h:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=y?y.lastPlacementChangeTime:h)}updateLayerOpacities(h,y,A,D){D&&(this.lastReplacementSourceUpdateTime=D.updateTime);const F=new Set;for(const z of y){const W=z.getBucket(h);W&&z.latestFeatureIndex&&h.fqid===W.layerIds[0]&&(this.updateBucketOpacities(W,F,z,z.collisionBoxArray,A,D,z.tileID,h.scope),W.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(W,z.tileID),W.elevationType==="road"&&W.updateRoadElevation(z.tileID.canonical),W.updateZOffset())}}updateBucketOpacities(h,y,A,D,F,z,W,J){h.hasTextData()&&h.text.opacityVertexArray.clear(),h.hasIconData()&&h.icon.opacityVertexArray.clear(),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexArray.clear(),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexArray.clear();const ne=h.layers[0].layout,le=h.layers[0].paint,_e=!!h.layers[0].dynamicFilter(),ye=new Ff(null,0,!1,!1,!0),we=ne.get("text-allow-overlap"),Le=ne.get("icon-allow-overlap"),Ie=ne.get("text-variable-anchor"),We=ne.get("text-rotation-alignment")==="map",Ue=ne.get("text-pitch-alignment")==="map",st=le.get("symbol-z-offset"),ut=ne.get("symbol-elevation-reference")==="sea",ot=!st.isConstant(),Et=new Ff(null,0,we&&(Le||!h.hasIconData()||ne.get("icon-optional")),Le&&(we||!h.hasTextData()||ne.get("text-optional")),!0);!h.collisionArrays&&D&&(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData())&&h.deserializeCollisionBoxes(D);const Nt=(wt,yt,Ot)=>{for(let Wt=0;Wt0||Wt>0,rr=es>0,yr=this.placedOrientations[Ht],Js=yr===i.bL.vertical,Us=yr===i.bL.horizontal||yr===i.bL.horizontalOnly;!Is&&!rr||Jt.isHidden()||Tt++;let Pr=!1;if((Is||rr)&&z)for(const Cr of h.activeReplacements){if(i.bZ(Cr,F,i.b_.Symbol,J)||Cr.min.x>ts||ts>Cr.max.x||Cr.min.y>xs||xs>Cr.max.y)continue;const hr=i.b$(ts,xs,W.canonical,Cr.footprintTileId.canonical);if(Pr=i.c0(hr,Cr.footprint),Pr)break}if(Is){const Cr=Pr?ev:Ou(Jt.text);Nt(h.text,Ot,Js?ev:Cr),Nt(h.text,Wt,Us?ev:Cr);const hr=Jt.text.isHidden(),{leftJustifiedTextSymbolIndex:br,centerJustifiedTextSymbolIndex:Kr,rightJustifiedTextSymbolIndex:Pn,verticalPlacedTextSymbolIndex:wa}=yt,si=h.text.placedSymbolArray,Or=hr||Js?1:0;br>=0&&(si.get(br).hidden=Or),Kr>=0&&(si.get(Kr).hidden=Or),Pn>=0&&(si.get(Pn).hidden=Or),wa>=0&&(si.get(wa).hidden=hr||Us?1:0);const Ka=this.variableOffsets[Ht];Ka&&this.markUsedJustification(h,Ka.anchor,yt,yr);const Cn=this.placedOrientations[Ht];Cn&&(this.markUsedJustification(h,"left",yt,Cn),this.markUsedOrientation(h,Cn,yt))}if(rr){const Cr=Pr?ev:Ou(Jt.icon),{placedIconSymbolIndex:hr,verticalPlacedIconSymbolIndex:br}=yt,Kr=h.icon.placedSymbolArray,Pn=Jt.icon.isHidden()?1:0;hr>=0&&(Nt(h.icon,es,Js?ev:Cr),Kr.get(hr).hidden=Pn),br>=0&&(Nt(h.icon,yt.numVerticalIconVertices,Us?ev:Cr),Kr.get(br).hidden=Pn)}if(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData()){const Cr=h.collisionArrays[wt];if(Cr){let hr=new i.P(0,0),br=!0;if(Cr.textBox||Cr.verticalTextBox){if(Ie){const Pn=this.variableOffsets[Ht];Pn?(hr=qd(Pn.anchor,Pn.width,Pn.height,Pn.textOffset,Pn.textScale),We&&hr._rotate(Ue?this.transform.angle:-this.transform.angle)):br=!1}_e&&(br=!Jt.clipped),Cr.textBox&&_y(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!br||Js,Bt,ut,hr.x,hr.y),Cr.verticalTextBox&&_y(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!br||Us,Bt,ut,hr.x,hr.y)}const Kr=br&&!!(!Us&&Cr.verticalIconBox);Cr.iconBox&&_y(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,Kr,Bt,ut,yt.hasIconTextFit?hr.x:0,yt.hasIconTextFit?hr.y:0),Cr.verticalIconBox&&_y(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,!Kr,Bt,ut,yt.hasIconTextFit?hr.x:0,yt.hasIconTextFit?hr.y:0)}}}if(h.fullyClipped=Tt===0,h.sortFeatures(this.transform.angle),this.retainedQueryData[h.bucketInstanceId]&&(this.retainedQueryData[h.bucketInstanceId].featureSortOrder=h.featureSortOrder),h.hasTextData()&&h.text.opacityVertexBuffer&&h.text.opacityVertexBuffer.updateData(h.text.opacityVertexArray),h.hasIconData()&&h.icon.opacityVertexBuffer&&h.icon.opacityVertexBuffer.updateData(h.icon.opacityVertexArray),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexBuffer&&h.iconCollisionBox.collisionVertexBuffer.updateData(h.iconCollisionBox.collisionVertexArray),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexBuffer&&h.textCollisionBox.collisionVertexBuffer.updateData(h.textCollisionBox.collisionVertexArray),h.bucketInstanceId in this.collisionCircleArrays){const wt=this.collisionCircleArrays[h.bucketInstanceId];h.placementInvProjMatrix=wt.invProjMatrix,h.placementViewportMatrix=wt.viewportMatrix,h.collisionCircleArray=wt.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 _y(T,h,y,A,D,F,z){T.emplaceBack(h?1:0,y?1:0,F||0,z||0,A,D?1:0),T.emplaceBack(h?1:0,y?1:0,F||0,z||0,A,D?1:0),T.emplaceBack(h?1:0,y?1:0,F||0,z||0,A,D?1:0),T.emplaceBack(h?1:0,y?1:0,F||0,z||0,A,D?1:0)}const FE=Math.pow(2,25),Xw=Math.pow(2,24),LC=Math.pow(2,17),zE=Math.pow(2,16),DC=Math.pow(2,9),Du=Math.pow(2,8),Jx=Math.pow(2,1);function Ou(T){if(T.opacity===0&&!T.placed)return 0;if(T.opacity===1&&T.placed)return 4294967295;const h=T.placed?1:0,y=Math.floor(127*T.opacity);return y*FE+h*Xw+y*LC+h*zE+y*DC+h*Du+y*Jx+h}const ev=0;class Y1{constructor(h){this._sortAcrossTiles=h.layout.get("symbol-z-order")!=="viewport-y"&&h.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(h,y,A,D,F,z){const W=this._bucketParts;for(;this._currentTileIndexJ.sortKey-ne.sortKey));this._currentPartIndex{const J=i.o.now()-z;return!this._forceFullPlacement&&J>2};for(;this._currentPlacementIndex>=0;){const J=y[h[this._currentPlacementIndex]],ne=this.placement.collisionIndex.transform.zoom;if(J.type==="symbol"&&J.visibility!=="none"&&(!J.minzoom||J.minzoom<=ne)&&(!J.maxzoom||J.maxzoom>ne)){const le=J,_e=le.layout.get("symbol-z-elevate"),ye=le.layout.get("symbol-sort-key").constantOr(1)!==void 0,we=le.layout.get("symbol-z-order"),Le=we==="viewport-y"||we==="auto"&&!(we!=="viewport-y"&&ye),Ie=le.layout.get("text-allow-overlap")||le.layout.get("icon-allow-overlap")||le.layout.get("text-ignore-placement")||le.layout.get("icon-ignore-placement"),We=Le&&Ie,Ue=this._inProgressLayer=this._inProgressLayer||new Y1(le),st=i.B(J.source,J.scope);if(Ue.continuePlacement(_e||We?D[st]:A[st],this.placement,this._showCollisionBoxes,J,W,F))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(h){return this.placement.commit(h),this.placement}}const Jm=512/i.al/2;class eg{constructor(h,y,A){this.tileID=h,this.bucketInstanceId=A,this.index=new i.c4(y.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const D=h.canonical.x*i.al,F=h.canonical.y*i.al;for(let z=0;zWe-Ue);for(const We of Ie){const Ue=this.crossTileIDs[We];if(this.keys[We]===le&&!A.has(Ue)){A.add(Ue),ne.crossTileID=Ue;break}}}}}class cc{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class BE{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(h){const y=Math.round((h-this.lng)/360);if(y!==0)for(const A in this.indexes){const D=this.indexes[A],F={};for(const z in D){const W=D[z];W.tileID=W.tileID.unwrapTo(W.tileID.wrap+y),F[W.tileID.key]=W}this.indexes[A]=F}this.lng=h}addBucket(h,y,A){if(this.indexes[h.overscaledZ]&&this.indexes[h.overscaledZ][h.key]){if(this.indexes[h.overscaledZ][h.key].bucketInstanceId===y.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(h.overscaledZ,this.indexes[h.overscaledZ][h.key])}for(let F=0;Fh.overscaledZ)for(const W in z){const J=z[W];J.tileID.isChildOf(h)&&J.findMatches(y.symbolInstances,h,D)}else{const W=z[h.scaledTo(Number(F)).key];W&&W.findMatches(y.symbolInstances,h,D)}}for(let F=0;F{y[A]=!0});for(const A in this.layerIndexes)y[A]||delete this.layerIndexes[A]}}const zf=771;class Hn{constructor(h,y,A,D){this.blendFunction=h,this.blendColor=y.toNonPremultipliedRenderColor(null),this.mask=A,this.blendEquation=D}}Hn.Replace=[1,0,1,0],Hn.disabled=new Hn(Hn.Replace,i.ao.transparent,[!1,!1,!1,!1]),Hn.unblended=new Hn(Hn.Replace,i.ao.transparent,[!0,!0,!0,!0]),Hn.alphaBlended=new Hn([1,zf,1,zf],i.ao.transparent,[!0,!0,!0,!0]),Hn.alphaBlendedNonPremultiplied=new Hn([770,zf,770,zf],i.ao.transparent,[!0,!0,!0,!0]),Hn.multiply=new Hn([774,0,774,0],i.ao.transparent,[!0,!0,!0,!0]),Hn.additive=new Hn([1,1,1,1],i.ao.transparent,[!0,!0,!0,!0]);class Fr{constructor(h,y,A){this.func=h,this.mask=y,this.range=A}}Fr.ReadOnly=!1,Fr.ReadWrite=!0,Fr.disabled=new Fr(519,Fr.ReadOnly,[0,1]);const OC=7680;class yn{constructor(h,y,A,D,F,z){this.test=h,this.ref=y,this.mask=A,this.fail=D,this.depthFail=F,this.pass=z}}yn.disabled=new yn({func:519,mask:0},0,0,OC,OC,OC);const X1=1029,RC=2305;class mn{constructor(h,y,A){this.enable=h,this.mode=y,this.frontFace=A}}function Bf(T,h){const y=i.ca(T,3);i.cc(T,h),i.cg(T,3,y)}function $E(T,h){const y=i.c7([]);return i.c8(y,y,-h),i.c9(y,y,-T),y}function FC(T,h){const y=[T[0],T[1],0],A=[h[0],h[1],0];if(i.ag(y)>=1e-15){const z=i.aw([],y);i.c5(A,z,i.bJ(A,z)),h[0]=A[0],h[1]=A[1]}const D=i.bI([],h,T);if(i.c6(D)<1e-15)return null;const F=Math.atan2(-D[1],D[0]);return $E(Math.atan2(Math.sqrt(T[0]*T[0]+T[1]*T[1]),-T[2]),F)}mn.disabled=new mn(!1,X1,RC),mn.backCCW=new mn(!0,X1,RC),mn.backCW=new mn(!0,X1,2304),mn.frontCW=new mn(!0,1028,2304),mn.frontCCW=new mn(!0,1028,RC);class Ru{constructor(h,y){this.position=h,this.orientation=y}get position(){return this._position}set position(h){if(h){const y=h instanceof i.ae?h:new i.ae(h[0],h[1],h[2]);this._renderWorldCopies&&(y.x=i.bT(y.x,0,1)),this._position=y}else this._position=null}lookAtPoint(h,y,A){if(this.orientation=null,!this.position)return;const D=this.position,F=A||(this._elevation?this._elevation.getAtPointOrZero(i.ae.fromLngLat(h)):0),z=i.ae.fromLngLat(h,F),W=[z.x-D.x,z.y-D.y,z.z-D.z];y||(y=[0,0,1]),y[2]=Math.abs(y[2]),this.orientation=FC(W,y)}setPitchBearing(h,y){this.orientation=$E(i.an(h),i.an(-y))}}class zC{constructor(h,y){this._transform=i.bA([]),this.orientation=y,this.position=h}get mercatorPosition(){const h=this.position;return new i.ae(h[0],h[1],h[2])}get position(){const h=i.ca(this._transform,3);return[h[0],h[1],h[2]]}set position(h){var y;h&&i.cg(this._transform,3,[(y=h)[0],y[1],y[2],1])}get orientation(){return this._orientation}set orientation(h){this._orientation=h||i.c7([]),h&&Bf(this._transform,this._orientation)}getPitchBearing(){const h=this.forward(),y=this.right();return{bearing:Math.atan2(-y[1],y[0]),pitch:Math.atan2(Math.sqrt(h[0]*h[0]+h[1]*h[1]),-h[2])}}setPitchBearing(h,y){this._orientation=$E(h,y),Bf(this._transform,this._orientation)}forward(){const h=i.ca(this._transform,2);return[-h[0],-h[1],-h[2]]}up(){const h=i.ca(this._transform,1);return[-h[0],-h[1],-h[2]]}right(){const h=i.ca(this._transform,0);return[h[0],h[1],h[2]]}getCameraToWorld(h,y){const A=new Float64Array(16);return i.bl(A,this.getWorldToCamera(h,y)),A}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(h,y,A){const D=this.position;i.c5(D,D,-h);const F=new Float64Array(16);return i.bq(F,[A,A,A]),i.br(F,F,D),F[10]*=y,F}getWorldToCamera(h,y){const A=new Float64Array(16),D=new Float64Array(4),F=this.position;return i.cb(D,this._orientation),i.c5(F,F,-h),i.cc(A,D),i.br(A,A,F),A[1]*=-1,A[5]*=-1,A[9]*=-1,A[13]*=-1,A[8]*=y,A[9]*=y,A[10]*=y,A[11]*=y,A}getCameraToClipPerspective(h,y,A,D){const F=new Float64Array(16);return i.cd(F,h,y,A,D),F}getCameraToClipOrthographic(h,y,A,D,F,z){const W=new Float64Array(16);return i.ce(W,h,y,A,D,F,z),W}getDistanceToElevation(h,y=!1){const A=h===0?0:i.cf(h,y?i.a$(this.position[1]):this.position[1]),D=this.forward();return(A-this.position[2])/D[2]}clone(){return new zC([...this.position],[...this.orientation])}}const Gc={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class BC{constructor(h=0,y=0,A=0,D=0){if(isNaN(h)||h<0||isNaN(y)||y<0||isNaN(A)||A<0||isNaN(D)||D<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=h,this.bottom=y,this.left=A,this.right=D}interpolate(h,y,A){return y.top!=null&&h.top!=null&&(this.top=i.ak(h.top,y.top,A)),y.bottom!=null&&h.bottom!=null&&(this.bottom=i.ak(h.bottom,y.bottom,A)),y.left!=null&&h.left!=null&&(this.left=i.ak(h.left,y.left,A)),y.right!=null&&h.right!=null&&(this.right=i.ak(h.right,y.right,A)),this}getCenter(h,y){const A=i.aA((this.left+h-this.right)/2,0,h),D=i.aA((this.top+y-this.bottom)/2,0,y);return new i.P(A,D)}equals(h){return this.top===h.top&&this.bottom===h.bottom&&this.left===h.left&&this.right===h.right}clone(){return new BC(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const zp=15;class qE{constructor(h,y,A,D,F,z,W){this.tileSize=512,this._renderWorldCopies=F===void 0||F,this._minZoom=h||0,this._maxZoom=y||22,this._minPitch=A??0,this._maxPitch=D??60,this.setProjection(z),this.setMaxBounds(W),this.width=0,this.height=0,this._center=new i.aT(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new BC,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new zC,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1,this._allowWorldUnderZoom=!1}clone(){const h=new qE(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return h._elevation=this._elevation,h._centerAltitude=this._centerAltitude,h._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,h.tileSize=this.tileSize,h.mercatorFromTransition=this.mercatorFromTransition,h.width=this.width,h.height=this.height,h.cameraElevationReference=this.cameraElevationReference,h._center=this._center,h._setZoom(this.zoom),h._seaLevelZoom=this._seaLevelZoom,h.angle=this.angle,h._fov=this._fov,h._pitch=this._pitch,h._nearZ=this._nearZ,h._farZ=this._farZ,h._averageElevation=this._averageElevation,h._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,h._unmodified=this._unmodified,h._edgeInsets=this._edgeInsets.clone(),h._camera=this._camera.clone(),h._calcMatrices(),h.freezeTileCoverage=this.freezeTileCoverage,h.frustumCorners=this.frustumCorners,h._allowWorldUnderZoom=this._allowWorldUnderZoom,h}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||h===Number.NEGATIVE_INFINITY&&(!y||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const A=this._elevation;y||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&A.exaggeration()&&this._centerAltitudeValidForExaggeration!==A.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*A.exaggeration(),this._centerAltitudeValidForExaggeration=A.exaggeration()):(this._centerAltitude=h||0,this._centerAltitudeValidForExaggeration=A.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(this._centerAltitudeValidForExaggeration===void 0)return;const h=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(h)}sampleAverageElevation(){if(!this._elevation)return 0;const h=this._elevation,y=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],A=this.horizonLineFromTop();let D=0,F=0;for(let z=0;z{const We=i.cY(ye,_e,we,Le,Ie);J.has(We)||(F.push(new i.aQ(_e,ye,we,Le,Ie)),J.add(We))};for(let _e=0;_eye.canonical.z)continue;const we=ye.canonical,Le=ye.overscaledZ,Ie=ye.wrap,We=1<0,ut=we.y+10,Et=ye.wrap-(st?0:1),Nt=ye.wrap+(Ue?0:1),Tt=st?we.x-1:We-1,wt=Ue?we.x+1:0;if(z)A[0]<0?(ne(Le,Nt,we.z,wt,we.y),A[1]<0&&ut&&(ne(Le,Ie,we.z,we.x,we.y+1),ne(Le,Nt,we.z,wt,we.y+1)),A[1]>0&&ot&&(ne(Le,Ie,we.z,we.x,we.y-1),ne(Le,Nt,we.z,wt,we.y-1))):A[0]>0?(ne(Le,Et,we.z,Tt,we.y),A[1]<0&&ut&&(ne(Le,Ie,we.z,we.x,we.y+1),ne(Le,Et,we.z,Tt,we.y+1)),A[1]>0&&ot&&(ne(Le,Ie,we.z,we.x,we.y-1),ne(Le,Et,we.z,Tt,we.y-1))):A[1]<0&&ut?ne(Le,Ie,we.z,we.x,we.y+1):ot&&ne(Le,Ie,we.z,we.x,we.y-1);else{const yt=ye.visibleQuadrants;1&yt&&(ne(Le,Et,we.z,Tt,we.y),ot&&(ne(Le,Ie,we.z,we.x,we.y-1),ne(Le,Et,we.z,Tt,we.y-1))),2&yt&&(ne(Le,Nt,we.z,wt,we.y),ot&&(ne(Le,Ie,we.z,we.x,we.y-1),ne(Le,Nt,we.z,wt,we.y-1))),4&yt&&(ne(Le,Et,we.z,Tt,we.y),ut&&(ne(Le,Ie,we.z,we.x,we.y+1),ne(Le,Et,we.z,Tt,we.y+1))),8&yt&&(ne(Le,Nt,we.z,wt,we.y),ut&&(ne(Le,Ie,we.z,we.x,we.y+1),ne(Le,Nt,we.z,wt,we.y+1)))}}const le=[];for(const _e of F)F.some(ye=>_e.isChildOf(ye))||le.push(_e);if(F=le.filter(_e=>!h.some(ye=>!!(_e.overscaledZ{const Ue=We.canonical.x+.5-we[0],st=We.canonical.y+.5-we[1];return Ue*Ue+st*st{const Tt=i.cY(ut,st,ot,Et,Nt);F.has(Tt)||(D.push(new i.aQ(st,ut,ot,Et,Nt)),F.add(Tt))},W=h.reduce((st,ut)=>Math.max(st,ut.overscaledZ),A),J=1<{const ot=Math.floor(st[0]),Et=Math.floor(st[1]),Nt=(st[0]-ot)*i.al,Tt=(st[1]-Et)*i.al,wt=Math.floor(ut[0]),yt=Math.floor(ut[1]),Ot=(ut[0]-wt)*i.al,Wt=(ut[1]-yt)*i.al;for(let Ht=-1;Ht<=1;Ht++){const es=ot+Ht;if(!(es<0||es>=J)){le.x=Nt-Ht*i.al,_e.x=Ot-(es-wt)*i.al;for(let ts=-1;ts<=1;ts++){const xs=Et+ts;le.y=Tt-ts*i.al,_e.y=Wt-(xs-yt)*i.al,i.cZ(le,_e,ne)&&z(W,0,A,es,xs)}}}},we=y.points,Le=we[i.cv],Ie=we[i.cw],We=this._projectToGround(Le,we[i.cx]),Ue=this._projectToGround(Ie,we[i.cy]);return ye(Le,We),ye(Ie,Ue),D}_projectToGround(h,y){return i.cz(i.cA(),h,y,h[2]/(h[2]-y[2]))}coveringTiles(h){let y=this.coveringZoomLevel(h);const A=y,D=this.elevation&&this.elevation.exaggeration(),F=D&&!h.isTerrainDEM,z=this.projection.name==="mercator";if(h.minzoom!==void 0&&yh.maxzoom&&(y=h.maxzoom);const W=this.locationCoordinate(this.center),J=this.center.lat,ne=1<{const Jt=new i.ae(Bt.x+25e-6,Bt.y,Bt.z),Is=new i.ae(Bt.x,Bt.y+25e-6,Bt.z),rr=Bt.toLngLat(),yr=Jt.toLngLat(),Js=Is.toLngLat(),Us=this.locationCoordinate(rr),Pr=this.locationCoordinate(yr),Cr=this.locationCoordinate(Js),hr=Math.hypot(Pr.x-Us.x,Pr.y-Us.y),br=Math.hypot(Cr.x-Us.x,Cr.y-Us.y);return Math.sqrt(hr*br)*Tt/25e-6},yt=Bt=>{const as=Et,Jt=Nt;return{aabb:i.cF(this,ne,0,0,0,Bt,Jt,as,this.projection),zoom:0,x:0,y:0,minZ:Jt,maxZ:as,wrap:Bt,fullyVisible:!1}},Ot=[];let Wt=[];const Ht=y,es=h.reparseOverscaled?A:y,ts=(We-this._centerAltitude)*Ie,xs=Bt=>{if(!this._elevation||!Bt.tileID||!z)return;const as=this._elevation.getMinMaxForTile(Bt.tileID),Jt=Bt.aabb;as?(Jt.min[2]=as.min,Jt.max[2]=as.max,Jt.center[2]=(Jt.min[2]+Jt.max[2])/2):(Bt.shouldSplit=Yt(Bt),Bt.shouldSplit||(Jt.min[2]=Jt.max[2]=Jt.center[2]=this._centerAltitude))},qs=(Bt,as)=>{if(.707*as{if(Bt.zoom=.9)return!0}else if(F&&(Is=Bt.aabb.distanceZ(Ue)*Ie),this.projection.isReprojectedInTileSpace&&A<=5){const br=Math.pow(2,Bt.zoom),Kr=wt(new i.ae((Bt.x+.5)/br,(Bt.y+.5)/br));rr=Kr>.85?1:Kr}if(!z&&!_e){const br=Math.sqrt(as*as+Jt*Jt+Is*Is);let Kr=(1<0;){const Bt=Ot.pop(),as=Bt.x,Jt=Bt.y;let Is=Bt.fullyVisible;const rr=()=>this.projection.name==="globe"&&(Bt.y===0||Bt.y===(1<>1),Pr={aabb:z?Bt.aabb.quadrant(yr):i.cF(this,ne,Bt.zoom+1,Js,Us,Bt.wrap,Bt.minZ,Bt.maxZ,this.projection),zoom:Bt.zoom+1,x:Js,y:Us,wrap:Bt.wrap,fullyVisible:Is,tileID:void 0,shouldSplit:void 0,minZ:Bt.minZ,maxZ:Bt.maxZ};F&&!_e&&(Pr.tileID=new i.aQ(Bt.zoom+1===Ht?es:Bt.zoom+1,Bt.wrap,Bt.zoom+1,Js,Us),xs(Pr)),Ot.push(Pr)}else{const yr=Bt.zoom===Ht?es:Bt.zoom;if(h.minzoom&&h.minzoom>yr)continue;let Js=0;if(!Is){let hr=st?Bt.aabb.intersectsPrecise(we):Bt.aabb.intersectsPreciseFlat(we);if(hr===0&&rr()){const br=new i.cD(Bt.zoom,as,Jt);hr=i.cE(this,ne,br,!0).intersectsPrecise(we)}if(hr===0)continue;if(h.calculateQuadrantVisibility)if(we.containsPoint(Bt.aabb.center))Js=15;else for(let br=0;br<4;br++)Bt.aabb.quadrant(br).intersects(we)!==0&&(Js|=1<{const Is=[0,0,0,1],rr=[i.al,i.al,0,1],yr=this.calculateFogTileMatrix(Jt.tileID.toUnwrapped());i.aC(Is,Is,yr),i.aC(rr,rr,yr);const Js=i.cG([],Is,rr),Us=i.cH([],Is,rr),Pr=i.c$(Js,Us);if(Pr===0)return!0;let Cr=!1;const hr=this._elevation;if(hr&&Pr>Bt&&as!==0){const br=this.calculateProjMatrix(Jt.tileID.toUnwrapped());let Kr;h.isTerrainDEM||(Kr=hr.getMinMaxForTile(Jt.tileID)),Kr||(Kr={min:Nt,max:Et});const Pn=i.cI(this.rotation),wa=[Pn[0]*i.al,Pn[1]*i.al,Kr.max];i.af(wa,wa,br),Cr=(1-wa[1])*this.height*.5Bt.distanceSq-as.distanceSq).map(Bt=>Bt.tileID)}resize(h,y){this.width=h,this.height=y,this.pixelsToGLUnits=[2/h,-2/y],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(h){return Math.pow(2,h)}scaleZoom(h){return Math.log2(h)}project(h){const y=i.aA(h.lat,-i.cJ,i.cJ),A=this.projection.project(h.lng,y);return new i.P(A.x*this.worldSize,A.y*this.worldSize)}unproject(h){return this.projection.unproject(h.x/this.worldSize,h.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/i.cf(1,this.center.lat)/this.worldSize}setLocationAtPoint(h,y){let A,D;const F=this.centerPoint;if(this.projection.name==="globe"){const W=this.worldSize;A=(y.x-F.x)/W,D=(y.y-F.y)/W}else{const W=this.pointCoordinate(y),J=this.pointCoordinate(F);A=W.x-J.x,D=W.y-J.y}const z=this.locationCoordinate(h);this.setLocation(new i.ae(z.x-A,z.y-D))}setLocation(h){this.center=this.coordinateLocation(h),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(h,y){return this.projection.locationPoint(this,h,y)}locationPoint3D(h,y){return this.projection.locationPoint(this,h,y,!0)}pointLocation(h){return this.coordinateLocation(this.pointCoordinate(h))}pointLocation3D(h,y){return this.coordinateLocation(this.pointCoordinate3D(h,y))}locationCoordinate(h,y){const A=y?i.cf(y,h.lat):void 0,D=this.projection.project(h.lng,h.lat);return new i.ae(D.x,D.y,A)}coordinateLocation(h){return this.projection.unproject(h.x,h.y)}pointRayIntersection(h,y){const A=y??this._centerAltitude,D=[h.x,h.y,0,1],F=[h.x,h.y,1,1];i.aC(D,D,this.pixelMatrixInverse),i.aC(F,F,this.pixelMatrixInverse);const z=F[3];i.cK(D,D,1/D[3]),i.cK(F,F,1/z);const W=D[2],J=F[2];return{p0:D,p1:F,t:W===J?0:(A-W)/(J-W)}}screenPointToMercatorRay(h){const y=[h.x,h.y,0,1],A=[h.x,h.y,1,1];return i.aC(y,y,this.pixelMatrixInverse),i.aC(A,A,this.pixelMatrixInverse),i.cK(y,y,1/y[3]),i.cK(A,A,1/A[3]),y[2]=i.cf(y[2],this._center.lat)*this.worldSize,A[2]=i.cf(A[2],this._center.lat)*this.worldSize,i.cK(y,y,1/this.worldSize),i.cK(A,A,1/this.worldSize),new i.ax([y[0],y[1],y[2]],i.aw([],i.av([],A,y)))}rayIntersectionCoordinate(h){const{p0:y,p1:A,t:D}=h,F=i.cf(y[2],this._center.lat),z=i.cf(A[2],this._center.lat);return new i.ae(i.ak(y[0],A[0],D)/this.worldSize,i.ak(y[1],A[1],D)/this.worldSize,i.ak(F,z,D))}pointCoordinate(h,y=this._centerAltitude){return this.projection.pointCoordinate(this,h.x,h.y,y)}pointCoordinate3D(h,y){if(!this.elevation)return this.pointCoordinate(h,y);let A=this.projection.pointCoordinate3D(this,h.x,h.y);if(A)return new i.ae(A[0],A[1],A[2]);let D=0,F=this.horizonLineFromTop();if(h.y>F)return this.pointCoordinate(h,y);const z=.02*F,W=h.clone();for(let J=0;J<10&&F-D>z;J++){W.y=i.ak(D,F,.66);const ne=this.projection.pointCoordinate3D(this,W.x,W.y);ne?(F=W.y,A=ne):D=W.y}return A?new i.ae(A[0],A[1],A[2]):this.pointCoordinate(h)}isPointAboveHorizon(h){return this.projection.isPointAboveHorizon(this,h)}isPointOnSurface(h){if(h.y<0||h.y>this.height||h.x<0||h.x>this.width)return!1;if(this.elevation||this.zoom>=i.cL)return!this.isPointAboveHorizon(h);const y=this.pointCoordinate(h);return y.y>=0&&y.y<=1}_coordinatePoint(h,y){const A=y&&this.elevation?this.elevation.getAtPointOrZero(h,this._centerAltitude):this._centerAltitude,D=[h.x*this.worldSize,h.y*this.worldSize,A+h.toAltitude(),1];return i.aC(D,D,this.pixelMatrix),D[3]>0?new i.P(D[0]/D[3],D[1]/D[3]):new i.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:h,left:y}=this._edgeInsets,A=this.height-this._edgeInsets.bottom,D=this.width-this._edgeInsets.right,F=this.pointLocation3D(new i.P(y,h)),z=this.pointLocation3D(new i.P(D,h)),W=this.pointLocation3D(new i.P(D,A)),J=this.pointLocation3D(new i.P(y,A));let ne=Math.min(F.lng,z.lng,W.lng,J.lng),le=Math.max(F.lng,z.lng,W.lng,J.lng),_e=Math.min(F.lat,z.lat,W.lat,J.lat),ye=Math.max(F.lat,z.lat,W.lat,J.lat);const we=Math.pow(2,-this.zoom)/16*270,Le=this.projection.name==="globe"?1:4,Ie=(We,Ue,st,ut,ot)=>{const Et=(We+st)/2,Nt=(Ue+ut)/2,Tt=new i.P(Et,Nt),{lng:wt,lat:yt}=this.pointLocation3D(Tt),Ot=Math.max(0,ne-wt,_e-yt,wt-le,yt-ye);ne=Math.min(ne,wt),le=Math.max(le,wt),_e=Math.min(_e,yt),ye=Math.max(ye,yt),(otwe)&&(Ie(We,Ue,Et,Nt,ot+1),Ie(Et,Nt,st,ut,ot+1))};if(Ie(y,h,D,h,1),Ie(D,h,D,A,1),Ie(D,A,y,A,1),Ie(y,A,y,h,1),this.projection.name==="globe"){const[We,Ue]=i.cM(this);We?(ye=90,le=180,ne=-180):Ue&&(_e=-90,le=180,ne=-180)}return new i.aI(new i.aT(ne,_e),new i.aT(le,ye))}_getBoundsRectangular(h,y){const{top:A,left:D}=this._edgeInsets,F=this.height-this._edgeInsets.bottom,z=this.width-this._edgeInsets.right,W=new i.P(D,A),J=new i.P(z,A),ne=new i.P(z,F),le=new i.P(D,F);let _e=this.pointCoordinate(W,h),ye=this.pointCoordinate(J,h);const we=this.pointCoordinate(ne,y),Le=this.pointCoordinate(le,y),Ie=(We,Ue)=>(Ue.y-We.y)/(Ue.x-We.x);return _e.y>1&&ye.y>=0?_e=new i.ae((1-Le.y)/Ie(Le,_e)+Le.x,1):_e.y<0&&ye.y<=1&&(_e=new i.ae(-Le.y/Ie(Le,_e)+Le.x,0)),ye.y>1&&_e.y>=0?ye=new i.ae((1-we.y)/Ie(we,ye)+we.x,1):ye.y<0&&_e.y<=1&&(ye=new i.ae(-we.y/Ie(we,ye)+we.x,0)),new i.aI().extend(this.coordinateLocation(_e)).extend(this.coordinateLocation(ye)).extend(this.coordinateLocation(Le)).extend(this.coordinateLocation(we))}_getBoundsRectangularTerrain(){const h=this.elevation;if(!h.visibleDemTiles.length||h.isUsingMockSource())return this._getBoundsRectangular(0,0);const y=h.visibleDemTiles.reduce((A,D)=>{if(D.dem){const F=D.dem.tree;A.min=Math.min(A.min,F.minimums[0]),A.max=Math.max(A.max,F.maximums[0])}return A},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(y.min*h.exaggeration(),y.max*h.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(h=!0){const y=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,A=this.height/2-y*(1-this._horizonShift);return h?Math.max(0,A):A}getMaxBounds(){return this.maxBounds}setMaxBounds(h){this.maxBounds=h,this.minLat=-i.cJ,this.maxLat=i.cJ,this.minLng=-180,this.maxLng=180,h&&(this.minLat=h.getSouth(),this.maxLat=h.getNorth(),this.minLng=h.getWest(),this.maxLng=h.getEast(),this.maxLng_e&&(W=_e-ne),_e-lewe&&(z=we-J),we-ye{for(let Yt=0;Yt<16;Yt++)es[Yt]=i.ak(ts[Yt],xs[Yt],qs)})(W,W,J,i.d0(this.pitch>=zp?1:this.pitch/zp))}else W=J;const ne=i.cP([],J,z);let le=i.cP([],W,z);if(this.projection.isReprojectedInTileSpace){const yt=this.locationCoordinate(this.center),Ot=i.bA([]);i.br(Ot,Ot,[yt.x*this.worldSize,yt.y*this.worldSize,0]),i.aB(Ot,Ot,i.cQ(this)),i.br(Ot,Ot,[-yt.x*this.worldSize,-yt.y*this.worldSize,0]),i.aB(le,le,Ot),i.aB(ne,ne,Ot),this.inverseAdjustmentMatrix=i.cR(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=i.cS([],le,[this.worldSize,this.worldSize,this.worldSize/F,1]),this.projMatrix=le,this.invProjMatrix=i.bl(new Float64Array(16),this.projMatrix),y){const yt=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);yt[8]=2*-h.x/this.width,yt[9]=2*h.y/this.height,this.expandedFarZProjMatrix=i.cP([],yt,z)}else this.expandedFarZProjMatrix=this.projMatrix;const _e=i.bl([],W);this.frustumCorners=i.cT.fromInvProjectionMatrix(_e,this.horizonLineFromTop(),this.height),this.cameraFrustum=i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!y);const ye=new Float32Array(16);i.bA(ye),i.cS(ye,ye,[1,-1,1]),i.cU(ye,ye,this._pitch),i.bB(ye,ye,this.angle);const we=i.cd(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=i.bz(we);const Le=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;we[8]=2*-h.x/this.width,we[9]=2*(h.y+Le)/this.height,this.skyboxMatrix=i.aB(ye,we,ye);const Ie=this.point,We=Ie.x,Ue=Ie.y,st=this.width%2/2,ut=this.height%2/2,ot=Math.cos(this.angle),Et=Math.sin(this.angle),Nt=We-Math.round(We)+ot*st+Et*ut,Tt=Ue-Math.round(Ue)+ot*ut+Et*st,wt=new Float64Array(le);if(i.br(wt,wt,[Nt>.5?Nt-1:Nt,Tt>.5?Tt-1:Tt,0]),this.alignedProjMatrix=wt,le=i.bC(),i.cS(le,le,[this.width/2,-this.height/2,1]),i.br(le,le,[1,-1,0]),this.labelPlaneMatrix=le,le=i.bC(),i.cS(le,le,[1,-1,1]),i.br(le,le,[-1,-1,0]),i.cS(le,le,[2/this.width,2/this.height,1]),this.glCoordMatrix=le,this.pixelMatrix=i.aB(new Float64Array(16),this.labelPlaneMatrix,ne),this._calcFogMatrices(),this._distanceTileDataCache={},le=i.bl(new Float64Array(16),this.pixelMatrix),!le)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=le,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=i.cV(this);const yt=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.af(yt,yt,z),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=le;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const h=this.cameraWorldSizeForFog,y=this.cameraPixelsPerMeter,A=this._camera.position,D=1/this.height/this._pixelsPerMercatorPixel,F=[h,h,y];i.c5(F,F,D),i.c5(A,A,-1),i.cW(A,A,F);const z=i.bC();i.br(z,z,A),i.cS(z,z,F),this.mercatorFogMatrix=z,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(h,y,D)}_computeCameraPosition(h){const y=(h=h||this.pixelsPerMeter)/this.pixelsPerMeter,A=this._camera.forward(),D=this.point,F=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*y-h/this.worldSize*this._centerAltitude;return[D.x/this.worldSize-A[0]*F,D.y/this.worldSize-A[1]*F,h/this.worldSize*this._centerAltitude-A[2]*F]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(h){const y=this._maxCameraBoundsDistance()*Math.cos(this._pitch),A=this._camera.position[2],D=h[2];let F=1;this.projection.wrap&&(this.center=this.center.wrap()),D>0&&(F=Math.min((y-A)/D,1)),this._camera.position=i.bH([],this._camera.position,h,F),this._updateStateFromCamera()}_updateStateFromCamera(){const h=this._camera.position,y=this._camera.forward(),{pitch:A,bearing:D}=this._camera.getPitchBearing(),F=i.cf(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,z=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.an(this._maxPitch)),W=Math.max((h[2]-F)/Math.cos(A),z),J=this._zoomFromMercatorZ(W);i.bH(h,h,y,W),this._pitch=i.aA(A,i.an(this.minPitch),i.an(this.maxPitch)),this.angle=i.bT(D,-Math.PI,Math.PI),this._setZoom(i.aA(J,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new i.ae(h[0],h[1],h[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(h){return Math.pow(2,h)*this.tileSize}_mercatorZfromZoom(h){return this.cameraToCenterDistance/this._worldSizeFromZoom(h)}_minimumHeightOverTerrain(){const h=Math.min(this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(h)}_zoomFromMercatorZ(h){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,h)*this.tileSize))}zoomFromMercatorZAdjusted(h){let y=0,A=i.cL,D=0,F=1/0;for(;A-y>1e-6&&A>y;){const z=y+.5*(A-y),W=this.tileSize*Math.pow(2,z),J=this.getCameraToCenterDistance(this.projection,z,W),ne=this.scaleZoom(J/(Math.max(0,h)*this.tileSize)),le=Math.abs(z-ne);lene||ye.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+i.cX(this.fovAboveCenter)>88||this.anyCornerOffEdge(new i.P(0,0),new i.P(this.width,this.height))}zoomDeltaToMovement(h,y){const A=i.ag(i.av([],this._camera.position,h)),D=this._zoomFromMercatorZ(A)+y;return A-this._mercatorZfromZoom(D)}getCameraPoint(){if(this.projection.name==="globe"){const h=function([y,A,D],F){const z=[y,A,D,1];i.aC(z,z,F);const W=z[3]=Math.max(z[3],1e-6);return z[0]/=W,z[1]/=W,z[2]/=W,z}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new i.P(h[0],h[1])}{const h=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.P(0,h))}}getCameraToCenterDistance(h,y=this.zoom,A=this.worldSize){const D=i.cO(h,y,this.width,this.height,1024),F=h.pixelSpaceConversion(this.center.lat,A,D);let z=.5/Math.tan(.5*this._fov)*this.height*F;return this.isOrthographic&&(z=i.ak(1,z,i.d0(this.pitch>=zp?1:this.pitch/zp))),z}getWorldToCameraMatrix(){const h=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&i.aB(h,h,this.globeMatrix),h}getFrustum(h){return i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,h,this.projection.zAxisUnit==="meters")}}const wy=(T,h)=>{if(h>0&&T.terrain&&i.w("Cutoff is currently disabled on terrain"),h<=0||T.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const y=T.transform,A=Math.max(Math.abs(y._zoom-(T.minCutoffZoom-1)),1),D=y.isLODDisabled(!1)?i.ah(60,45,y.pitch):i.ah(30,15,y.pitch),F=y._farZ-y._nearZ,z=h*y.height,W=((1-(J=D))*y.cameraToCenterDistance+J*(y._farZ+z))*A;var J;return{shouldRenderCutoff:D<1,uniformValues:{u_cutoff_params:[y._nearZ,y._farZ,(W-y._nearZ)/F,(W-z-y._nearZ)/F]}}},ep=2048;class Qw{constructor(h,y){this.aabb=h,this.lastCascade=y}}class Nme{add(h,y){const A=this.receivers[h.key];A!==void 0?(A.aabb.min[0]=Math.min(A.aabb.min[0],y.min[0]),A.aabb.min[1]=Math.min(A.aabb.min[1],y.min[1]),A.aabb.min[2]=Math.min(A.aabb.min[2],y.min[2]),A.aabb.max[0]=Math.max(A.aabb.max[0],y.max[0]),A.aabb.max[1]=Math.max(A.aabb.max[1],y.max[1]),A.aabb.max[2]=Math.max(A.aabb.max[2],y.max[2])):this.receivers[h.key]=new Qw(y,null)}clear(){this.receivers={}}get(h){return this.receivers[h.key]}computeRequiredCascades(h,y,A){const D=i.d9.fromPoints(h.points);let F=0;for(const z in this.receivers){const W=this.receivers[z];if(!W||!D.intersectsAabb(W.aabb))continue;W.aabb.min=D.closestPoint(W.aabb.min),W.aabb.max=D.closestPoint(W.aabb.max);const J=W.aabb.getCorners();for(let ne=0;ne1||ye[1]<-1||ye[1]>1){le=!1;break}}if(W.lastCascade=ne,F=Math.max(F,ne),le)break}}return F+1}}class Q1{constructor(h){this.painter=h,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new Nme,this._depthMode=new Fr(h.context.gl.LEQUAL,Fr.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this.useNormalOffset=!1}destroy(){for(const h of this._cascades)h.texture.destroy(),h.framebuffer.destroy();this._cascades=[]}updateShadowParameters(h,y){const A=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!y||!y.properties)return;const D=y.properties.get("shadow-intensity");if(!y.shadowsEnabled()||D<=0||(this._shadowLayerCount=A.style.order.reduce((Le,Ie)=>{const We=A.style._mergedLayers[Ie];return Le+(We.hasShadowPass()&&!We.isHidden(h.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled))return;const F=A.context,z=ep,W=ep;if(this._cascades.length===0||ep!==this._cascades[0].texture.size[0]){this._cascades=[];for(let Le=0;Le<2;++Le){const Ie=A._shadowMapDebug,We=F.gl,Ue=F.createFramebuffer(z,W,Ie?1:0,"texture"),st=new i.T(F,{width:z,height:W,data:null},We.DEPTH_COMPONENT16);if(Ue.depthAttachment.set(st.texture),Ie){const ut=new i.T(F,{width:z,height:W,data:null},We.RGBA8);Ue.colorAttachment0.set(ut.texture)}this._cascades.push({framebuffer:Ue,texture:st,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cB,scale:0})}}this.shadowDirection=e2(y);let J=0;if(h.elevation){const Le=h.elevation,Ie=[1e4,-1e4];Le.visibleDemTiles.filter(We=>We.dem).forEach(We=>{const Ue=We.dem.tree;Ie[0]=Math.min(Ie[0],Ue.minimums[0]),Ie[1]=Math.max(Ie[1],Ue.maximums[0])}),Ie[0]!==1e4&&(J=(Ie[1]-Ie[0])*Le.exaggeration())}const ne=1.5*h.cameraToCenterDistance,le=3*ne,_e=new Float64Array(16);for(let Le=0;Le=0)return{};const F=function(J,ne,le){const _e=le/(1<0&&(i.d8(F[1],F[1],[D[0]*z,0,0]),i.d8(F[2],F[2],[D[0]*z,0,0])),D[1]<0?(i.d8(F[0],F[0],[0,D[1]*z,0]),i.d8(F[1],F[1],[0,D[1]*z,0])):D[1]>0&&(i.d8(F[2],F[2],[0,D[1]*z,0]),i.d8(F[3],F[3],[0,D[1]*z,0]));const W={};return W.vertices=F,W.planes=[Jw(F[1],F[0],F[4]),Jw(F[2],F[1],F[5]),Jw(F[3],F[2],F[6]),Jw(F[0],F[3],F[7])],W}addShadowReceiver(h,y,A){this._receivers.add(h,i.d9.fromTileIdAndHeight(h,y,A))}getMaxCascadeForTile(h){const y=this._receivers.get(h);return y&&y.lastCascade?y.lastCascade:0}}function Jw(T,h,y){const A=i.av([],y,h),D=i.av([],T,h),F=i.bI([],A,D),z=i.ag(F);return z===0?[0,0,1,0]:(i.c5(F,F,1/z),[F[0],F[1],F[2],-i.bJ(F,h)])}function e2(T){const h=T.properties.get("direction"),y=i.d4(h.x,h.y,h.z);y[2]=i.aA(y[2],0,75);const A=i.d6([y[0],y[1],y[2]]);return i.d5(A.x,A.y,A.z)}function tg(T,h,y){const A=h.properties.get("color-use-theme")==="none",D=h.properties.get("color"),F=h.properties.get("intensity"),z=h.properties.get("direction"),W=[z.x,z.y,z.z],J=y.properties.get("color-use-theme")==="none",ne=y.properties.get("color"),le=y.properties.get("intensity"),_e=Math.max(i.bJ([0,0,1],W),0),ye=[0,0,0];i.c5(ye,ne.toPremultipliedRenderColor(J?null:T.getLut(h.scope)).toArray01Linear().slice(0,3),le);const we=[0,0,0];return i.c5(we,D.toPremultipliedRenderColor(A?null:T.getLut(y.scope)).toArray01Linear().slice(0,3),_e*F),i.db([ye[0]>0?ye[0]/(ye[0]+we[0]):0,ye[1]>0?ye[1]/(ye[1]+we[1]):0,ye[2]>0?ye[2]/(ye[2]+we[2]):0])}function jy(T,h,y,A,D,F){const z=T.zoom,W=T.scale,J=T.worldSize,ne=1/J,le=T.aspect,_e=Math.sqrt(1+le*le)*Math.tan(.5*T.fovX),ye=_e*_e,we=A-y,Le=A+y;let Ie,We;ye>we/Le?(Ie=A,We=A*_e):(Ie=.5*Le*(1+ye),We=.5*Math.sqrt(we*we+2*(A*A+y*y)*ye+Le*Le*ye*ye));const Ue=T.projection.pixelsPerMeter(T.center.lat,J),st=T._camera.getCameraToWorldMercator(),ut=[0,0,-Ie*ne];i.af(ut,ut,st);let ot=We*ne;const Et=T._edgeInsets;if(!(Et.left===0&&Et.top===0&&Et.right===0&&Et.bottom===0||Et.left===Et.right&&Et.top===Et.bottom)){const Is=T._camera.getWorldToCamera(T.worldSize,T.projection.zAxisUnit==="meters"?Ue:1),rr=T._camera.getCameraToClipPerspective(T._fov,T.width/T.height,y,A);rr[8]=2*-T.centerOffset.x/T.width,rr[9]=2*T.centerOffset.y/T.height;const yr=new Float64Array(16);i.cP(yr,rr,Is);const Js=new Float64Array(16);i.bl(Js,yr);const Us=i.cB.fromInvProjectionMatrix(Js,J,z,!0);for(const Pr of Us.points){const Cr=((Nt=Pr)[0]/=W,Nt[1]/=W,Nt[2]=i.cf(Nt[2],T._center.lat),Nt);ot=Math.max(ot,i.c6(i.da([],ut,Cr)))}}var Nt;ot*=D/(D-1);const Tt=Math.acos(h[2]),wt=Math.atan2(-h[0],-h[1]),yt=new zC;yt.position=ut,yt.setPitchBearing(Tt,wt);const Ot=yt.getWorldToCamera(J,Ue),Wt=ot*J,Ht=Math.min(T._mercatorZfromZoom(17)*J*-2,-2*Wt),es=yt.getCameraToClipOrthographic(-Wt,Wt,-Wt,Wt,Ht,(Wt+F*Ue)/h[2]),ts=new Float64Array(16);i.aB(ts,es,Ot);const xs=i.d5(Math.floor(1e6*ut[0])/1e6*J,Math.floor(1e6*ut[1])/1e6*J,0),qs=.5*D,Yt=[0,0,0];i.af(Yt,xs,ts),i.c5(Yt,Yt,qs);const Bt=[Math.floor(Yt[0]),Math.floor(Yt[1]),Math.floor(Yt[2])],as=[0,0,0];i.av(as,Yt,Bt),i.c5(as,as,-1/qs);const Jt=new Float64Array(16);return i.bA(Jt),i.br(Jt,Jt,as),i.aB(ts,Jt,ts),[ts,Wt]}class kme extends i.E{constructor(h){super(),this.requestManager=h,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(h,y){return i.dc(this.requestManager.transformRequest(y,i.R.Model).url).then(A=>{if(!A)return;const D=i.dd(A),F=new i.de(h,y,void 0,void 0,D);return F.computeBoundsAndApplyParent(),F}).catch(A=>{if(A&&A.status===404)return null;this.fire(new i.y(new Error(`Could not load model ${h} from ${y}: ${A.message}`)))})}load(h,y,A={forceReload:!1}){this.models[y]||(this.models[y]={});const D=Object.keys(h),F=[],z=[];for(const W of D){const J=h[W];this.hasURLBeenRequested(J)&&!A.forceReload||(this.modelByURL[J]={modelId:W,scope:y},F.push(this.loadModel(W,J)),z.push(W)),this.models[y][W]||(this.models[y][W]={model:null,numReferences:1})}this.numModelsLoading[y]=(this.numModelsLoading[y]||0)+z.length,Promise.allSettled(F).then(W=>{for(let J=0;J{this.fire(new i.y(new Error(`Could not load models: ${W.message}`)))})}isLoaded(){for(const h in this.numModelsLoading)if(this.numModelsLoading[h]>0)return!1;return!0}hasModel(h,y,A={exactIdMatch:!1}){return!!(A.exactIdMatch?this.getModel(h,y):this.getModelByURL(this.modelUris[y][h]))}getModel(h,y){return this.models[y]||(this.models[y]={}),this.models[y][h]?this.models[y][h].model:void 0}getModelByURL(h){if(!h)return null;const y=this.modelByURL[h];return y?this.models[y.scope][y.modelId].model:null}hasModelBeenAdded(h,y){return this.models[y]&&this.models[y][h]!==void 0}getModelURIs(h){return this.modelUris[h]||{}}addModel(h,y,A){this.models[A]||(this.models[A]={}),this.modelUris[A]||(this.modelUris[A]={});const D=this.requestManager.normalizeModelURL(y);if((this.hasModel(h,A,{exactIdMatch:!0})||this.hasModelBeenAdded(h,A))&&this.modelUris[A][h]===D)this.models[A][h].numReferences++;else if(this.hasURLBeenRequested(D)){const{scope:F,modelId:z}=this.modelByURL[D];this.models[F][z].numReferences++}else this.modelUris[A][h]=D,this.load({[h]:this.modelUris[A][h]},A)}addModelURLs(h,y){this.models[y]||(this.models[y]={}),this.modelUris[y]||(this.modelUris[y]={});const A=this.modelUris[y];for(const D in h)A[D]=this.requestManager.normalizeModelURL(h[D])}reloadModels(h){this.load(this.modelUris[h],h,{forceReload:!0})}addModelsFromBucket(h,y){this.models[y]||(this.models[y]={}),this.modelUris[y]||(this.modelUris[y]={});const A={};for(const D of h)this.hasModel(D,y,{exactIdMatch:!0})||this.hasURLBeenRequested(D)?this.models[y][D].numReferences++:this.modelUris[y][D]&&!this.hasURLBeenRequested(D)?A[D]=this.modelUris[y][D]:!this.hasURLBeenRequested(D)&&i.df(D,!1)&&(this.modelUris[y][D]=this.requestManager.normalizeModelURL(D),A[D]=this.modelUris[y][D]);this.load(A,y)}hasURLBeenRequested(h){return this.modelByURL[h]!==void 0}removeModel(h,y,A=!1,D=!1){if(this.models[y]&&this.models[y][h]&&(this.models[y][h].numReferences--,this.models[y][h].numReferences===0||D)){const F=this.modelUris[y][h];A||delete this.modelUris[y][h],delete this.modelByURL[F];const z=this.models[y][h].model;if(!z)return;delete this.models[y][h],z.destroy()}}destroy(){for(const h of Object.keys(this.models))for(const y of Object.keys(this.models[h])){const A=this.models[h][y].model;delete this.models[h][y],A&&A.destroy()}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}listModels(h){return this.models[h]||(this.models[h]={}),Object.keys(this.models[h])}upload(h,y){this.models[y]||(this.models[y]={});for(const A in this.models[y])this.models[y][A].model&&this.models[y][A].model.upload(h.context)}}const UE=i.a6.colorTheme,Sme=new i.a9({data:new i.aa(UE.data)});function SR(T){if(!T.metadata||!T.metadata.content_area)return;const h=i.o.devicePixelRatio,{left:y,top:A,width:D,height:F}=T.metadata.content_area,z=y*h,W=A*h;return[z,W,z+D*h,W+F*h]}function CR(T){if(T)return T.map(([h,y])=>[h*i.o.devicePixelRatio,y*i.o.devicePixelRatio])}class VE{constructor(h,y,A){this.id=h,this.scope=y,this.sourceCache=A,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(h){this.missingRequests.has(h.name)||this.pendingRequests.has(h.name)||this.pendingRequests.add(h.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const h=new Map;if(!this.sourceCache.loaded())return h;const y=this.sourceCache.getVisibleCoordinates();if(y.length===0)return h;const A=this.sourceCache.getSource();if(!(A instanceof kd))return h;const D=y.map(z=>this.sourceCache.getTile(z)),F=A.getImages(D,Array.from(this.pendingRequests));for(const[z,W]of F)h.set(i.I.from({name:z,iconsetId:this.id}),W),this.pendingRequests.delete(z);for(const z of this.pendingRequests)this.missingRequests.add(z);return this.pendingRequests.clear(),h}}const Ny=(T,h)=>Ye(T,h&&h.filter(y=>y.identifier!=="source.canvas")),MR=i.aH(La,["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"]),TR=i.aH(La,["setCenter","setZoom","setBearing","setPitch"]),$C=new Set(["background","sky","slot","custom"]),ky={version:8,layers:[],sources:{}},t2={duration:300,delay:0};class tp extends i.E{constructor(h,y={}){super(),this.map=h,this.scope=y.scope||"",this.globalId=null,this.fragments=[],this.importDepth=y.importDepth||0,this.importsCache=y.importsCache||new Map,this.resolvedImports=y.resolvedImports||new Set,this.transition=Object.assign({},t2),this._buildingIndex=new Hw(this),this.crossTileSymbolIndex=new Fp,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=y.styleChanges||new Ce,this._hasDataDrivenEmissive=!1,this.dispatcher=y.dispatcher?y.dispatcher:new i.D(i.dh(),this),y.imageManager?this.imageManager=y.imageManager:(this.imageManager=new Ge(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=y.glyphManager?y.glyphManager:new i.di(h._requestManager,y.localFontFamily?i.dj.all:y.localIdeographFontFamily?i.dj.ideographs:i.dj.none,y.localFontFamily||y.localIdeographFontFamily),y.modelManager?this.modelManager=y.modelManager:(this.modelManager=new kme(h._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=y.configOptions?y.configOptions:new Map,this._configDependentLayers=y.configDependentLayers?y.configDependentLayers:new Set,this._indoorDependentLayers=y.indoorDependentLayers?y.indoorDependentLayers:new Set,this._config=y.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:y.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=y.initialConfig,this.dispatcher.broadcast("setReferrer",i.dk());const A=this;this._rtlTextPluginCallback=tp.registerForPluginStateChange(D=>{A.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:D.pluginStatus,pluginURL:D.pluginURL},(F,z)=>{if(i.dl(F),z&&z.every(W=>W))for(const W in A._sourceCaches){const J=A._sourceCaches[W],ne=J.getSource().type;ne!=="vector"&&ne!=="geojson"||J.reload()}})}),this.on("data",D=>{if(D.dataType!=="source"||D.sourceDataType!=="metadata")return;const F=this.getOwnSource(D.sourceId);if(F&&F.vectorLayerIds)for(const z in this._layers){const W=this._layers[z];W.source===F.id&&this._validateLayer(W)}})}load(h){return h?(typeof h=="string"?this.loadURL(h):this.loadJSON(h),this):this}_getGlobalId(h){if(!h)return null;if(typeof h=="string"){if(i.h(h))return h;const y=i.dm(h);if(!y.startsWith("http"))try{return new URL(y,location.href).toString()}catch{return y}return y}return`json://${i.dn(JSON.stringify(h))}`}_diffStyle(h,y,A){this.globalId=this._getGlobalId(h);const D=(F,z)=>{try{z(null,this.setState(F,A))}catch(W){z(W,!1)}};if(typeof h=="string"){const F=this.map._requestManager.normalizeStyleURL(h),z=this.map._requestManager.transformRequest(F,i.R.Style);i.m(z,(W,J)=>{W?this.fire(new i.y(W)):J&&D(J,y)})}else typeof h=="object"&&D(h,y)}loadURL(h,y={}){this.fire(new i.z("dataloading",{dataType:"style"}));const A=typeof y.validate=="boolean"?y.validate:!i.h(h);this.globalId=this._getGlobalId(h),h=this.map._requestManager.normalizeStyleURL(h,y.accessToken),this.resolvedImports.add(h);const D=this.importsCache.get(h);if(D)return this._load(D,A);const F=this.map._requestManager.transformRequest(h,i.R.Style);this._request=i.m(F,(z,W)=>{if(this._request=null,z)this.fire(new i.y(z));else if(W)return this.importsCache.set(h,W),this._load(W,A)})}loadJSON(h,y={}){this.fire(new i.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(h),this._request=i.o.frame(()=>{this._request=null,this._load(h,y.validate!==!1)})}loadEmpty(){this.fire(new i.z("dataloading",{dataType:"style"})),this._load(ky,!1)}_loadImports(h,y,A){if(this.importDepth>=4)return i.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const D=[];for(const F of h){const z=this._createFragmentStyle(F),W=new Promise(le=>{z.once("style.import.load",le),z.once("error",le)}).then(()=>this.mergeAll());if(D.push(W),this.resolvedImports.has(F.url)){z.loadEmpty();continue}const J=F.data||this.importsCache.get(F.url);J?(z.loadJSON(J,{validate:y}),this._isInternalStyle(J)&&(z.globalId=null)):F.url?z.loadURL(F.url,{validate:y}):z.loadEmpty();const ne={style:z,id:F.id,config:F.config};if(A){const le=this.fragments.findIndex(({id:_e})=>_e===A);this.fragments=this.fragments.slice(0,le).concat(ne).concat(this.fragments.slice(le))}else this.fragments.push(ne)}return Promise.allSettled(D)}getImportGlobalIds(h=this,y=new Set){for(const A of h.fragments)A.style.globalId&&y.add(A.style.globalId),this.getImportGlobalIds(A.style,y);return[...y.values()]}_createFragmentStyle(h){const y=this.scope?i.B(h.id,this.scope):h.id;let A;const D=this._initialConfig&&this._initialConfig[y];(h.config||D)&&(A=Object.assign({},h.config,D));const F=new tp(this.map,{scope:y,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:A,configOptions:this.options,colorThemeOverride:h["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return F.setEventedParent(this.map,{style:F}),F}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle()}_isInternalStyle(h){return this.isRootStyle()&&(h.fragment||!!h.schema&&h.fragment!==!1)}_load(h,y){if(this._isInternalStyle(h)){const F=Object.assign({},ky,{imports:[{id:"basemap",data:h,url:""}]},h.center?{center:h.center}:{},h.bearing?{bearing:h.bearing}:{},h.pitch?{pitch:h.pitch}:{},h.zoom?{zoom:h.zoom}:{},h.light?{light:h.light}:{});return this._importedAsBasemap=!0,void this._load(F,y)}if(this.updateConfig(this._config,h.schema),y&&Ny(this,Yr(h)))return;this._loaded=!0,this.stylesheet=i.dp(h);const A=()=>{for(const J in h.sources)this.addSource(J,h.sources[J],{validate:!1,isInitialLoad:!0});if(h.iconsets)for(const J in h.iconsets)this.addIconset(J,h.iconsets[J]);h.sprite?this._loadIconset(h.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&h.glyphs&&this.glyphManager.setURL(h.glyphs);const F=Z0(this.stylesheet.layers);if(this._order=F.map(J=>J.id),this.stylesheet.light&&i.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(this.stylesheet.lights.length===1&&this.stylesheet.lights[0].type==="flat"){const J=this.stylesheet.lights[0];this.light=new Ft(J.properties,J.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Ft(this.stylesheet.light)),this._layers={};for(const J of F){const ne=i.du(J,this.scope,this._styleColorTheme.lut,this.options);ne.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(ne.fqid),ne.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(ne.fqid),this._hasAppearances=this._hasAppearances||ne.getAppearances().length!==0,ne.setEventedParent(this,{layer:{id:ne.id}}),this._layers[ne.id]=ne;const le=this.getOwnLayerSourceCache(ne),_e=!!this.directionalLight&&this.directionalLight.shadowsEnabled();le&&ne.canCastShadows()&&_e&&(le.castsShadows=!0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const z=this.stylesheet.terrain;z&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(z,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new i.z("data",{dataType:"style"}));const W=this.isRootStyle();h.imports?this._loadImports(h.imports,y).then(()=>{this._reloadImports(),this.fire(new i.z(W?"style.load":"style.import.load"))}).catch(J=>{this.fire(new i.y(new Error("Failed to load imports",J))),this.fire(new i.z(W?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new i.z(W?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const D=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(D){const F=this._evaluateColorThemeData(D);this._loadColorTheme(F).then(()=>{A()}).catch(z=>{i.w(`Couldn't load color theme from the stylesheet: ${z}`),A()})}else this._styleColorTheme.lut=null,A()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(h=>h.style.hasAppearances())}mergeAll(){let h,y,A,D,F,z,W,J,ne,le;const _e={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(ye=>{if(ye.stylesheet){if(ye.light!=null&&(h=ye.light),ye.stylesheet.lights)for(const we of ye.stylesheet.lights)we.type==="ambient"&&ye.ambientLight!=null&&(y=ye.ambientLight),we.type==="directional"&&ye.directionalLight!=null&&(A=ye.directionalLight);D=this._prioritizeTerrain(D,ye.terrain,ye.stylesheet.terrain),ye.stylesheet.fog&&ye.fog!=null&&(F=ye.fog),ye.stylesheet.snow&&ye.snow!=null&&(z=ye.snow),ye.stylesheet.rain&&ye.rain!=null&&(W=ye.rain),ye.stylesheet.camera!=null&&(le=ye.stylesheet.camera),ye.stylesheet.projection!=null&&(J=ye.stylesheet.projection),ye.stylesheet.transition!=null&&(ne=ye.stylesheet.transition),_e[ye.scope]=ye._styleColorTheme}}),this.light=h,this.ambientLight=y,this.directionalLight=A,this.fog=F,this.snow=z,this.rain=W,this._styleColorThemeForScope=_e,D===null?delete this.terrain:this.terrain=D,this.camera=le||{"camera-projection":"perspective"},this.projection=J||{name:"mercator"},this.transition=Object.assign({},t2,ne),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(h){const y=A=>{for(const D of A.fragments)y(D.style);h(A)};y(this)}_prioritizeTerrain(h,y,A){const D=h&&h.drapeRenderMode===0;return A===null?y&&y.drapeRenderMode===0?y:D?h:null:y!=null&&(!h||D||y&&y.drapeRenderMode===1)?y:h}mergeTerrain(){let h;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(y=>{h=this._prioritizeTerrain(h,y.terrain,y.stylesheet.terrain)}),h===null?delete this.terrain:this.terrain=h}mergeProjection(){let h;this.forEachFragmentStyle(y=>{y.stylesheet.projection!=null&&(h=y.stylesheet.projection)}),this.projection=h||{name:"mercator"}}mergeSources(){const h={},y={},A={};this.forEachFragmentStyle(D=>{for(const F in D._sourceCaches){const z=i.B(F,D.scope);h[z]=D._sourceCaches[F]}for(const F in D._otherSourceCaches){const z=i.B(F,D.scope);y[z]=D._otherSourceCaches[F]}for(const F in D._symbolSourceCaches){const z=i.B(F,D.scope);A[z]=D._symbolSourceCaches[F]}}),this._mergedSourceCaches=h,this._mergedOtherSourceCaches=y,this._mergedSymbolSourceCaches=A}mergeIndoor(){this.forEachFragmentStyle(h=>{if(h.stylesheet&&h.stylesheet.indoor)for(const y of Object.values(h.stylesheet.indoor)){const A=y,D=i.B(A.sourceId,h.scope);this._mergedIndoor[D]=new Set(A.sourceLayers||[])}})}mergeLayers(){const h={},y=[],A={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(z=>{for(const W of z._order){const J=z._layers[W];if(J.type==="slot"){const ne=i.dq(W);if(h[ne])continue;h[ne]=[]}J.slot&&h[J.slot]?h[J.slot].push(J):y.push(J)}}),this._mergedOrder=[];let D=-1;const F=(z=[])=>{for(const W of z)if(W.type==="slot"){const J=i.dq(W.id);h[J]&&F(h[J]),this._mergedSlots.push(J)}else{const J=i.B(W.id,W.scope);this._mergedOrder.push(J),A[J]=W,W.is3D(!!this.terrain)&&(this._has3DLayers=!0,D=this._mergedOrder.length-1),W.type==="circle"&&(this._hasCircleLayers=!0),W.type==="symbol"&&(this._hasSymbolLayers=!0),W.type==="clip"&&(this._clipLayerPresent=!0)}};if(F(y),this._has3DLayers){const z={};for(let W=0;Wz[W]-z[J])}this._mergedLayers=A,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}getCamera(){return this.stylesheet.camera}setCamera(h){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,h),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(h){return h.data?function(y,A,D,F){const z=Object.assign({},A);for(const J of Object.keys(UE))z[J]===void 0&&(z[J]=UE[J].default);const W=new i.a8(Sme,y,new Map(D));return W.setTransitionOrValue(z,D),W.untransitioned().possiblyEvaluate(new i.ac(0,{worldview:void 0}))}(this.scope,h,this.options).get("data"):null}_loadColorTheme(h){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const y=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((A,D)=>{const F="data:image/png;base64,";if(!h||h.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void A();let z=h;z.startsWith(F)||(z=F+z);const W=i.I.from("mapbox-reserved-lut"),J=new Image;J.src=z,J.onerror=()=>{this._styleColorTheme.lutLoading=!1,D(new Error("Failed to load image data"))},J.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==y)return void A();this._styleColorTheme.lutLoading=!1;const{width:ne,height:le,data:_e}=i.o.getImageData(J);if(le>32)return void D(new Error("The height of the image must be less than or equal to 32 pixels."));if(ne!==le*le)return void D(new Error("The width of the image must be equal to the height squared."));this.getImage(W)&&this.removeImage(W),this.addImage(W,{data:new i.q({width:ne,height:le},_e),pixelRatio:1,sdf:!1,usvg:!1,version:0});const ye=this.imageManager.getImage(W,this.scope);ye?(this._styleColorTheme.lut={image:ye.data,data:h},A()):D(new Error("Missing LUT image."))}})}getLut(h){const y=this._styleColorThemeForScope[h];return y?y.lut:null}setProjection(h){h?this.stylesheet.projection=h:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(h){this._spriteRequest=function(y,A,D){let F,z,W;const J=i.o.devicePixelRatio>1?"@2x":"";let ne=i.m(A.transformRequest(A.normalizeSpriteURL(y,J,".json"),i.R.SpriteJSON),(ye,we)=>{ne=null,W||(W=ye,F=we,_e())}),le=i.n(A.transformRequest(A.normalizeSpriteURL(y,J,".png"),i.R.SpriteImage),(ye,we)=>{le=null,W||(W=ye,z=we,_e())});function _e(){if(W)D(W);else if(F&&z){const ye=i.o.getImageData(z),we={};for(const Le in F){const{width:Ie,height:We,x:Ue,y:st,sdf:ut,pixelRatio:ot,stretchX:Et,stretchY:Nt,content:Tt}=F[Le],wt=new i.q({width:Ie,height:We});i.q.copy(ye,wt,{x:Ue,y:st},{x:0,y:0},{width:Ie,height:We},null),we[Le]={data:wt,pixelRatio:ot!==void 0?ot:1,sdf:ut!==void 0&&ut,stretchX:Et,stretchY:Nt,content:Tt,usvg:!1,version:0}}D(null,we)}}return{cancel(){ne&&(ne.cancel(),ne=null),le&&(le.cancel(),le=null)}}}(h,this.map._requestManager,(y,A)=>{if(this._spriteRequest=null,y)this.fire(new i.y(y));else if(A){const D=new Map;for(const F in A)D.set(i.I.from(F),A[F]);this.addImages(D)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.z("data",{dataType:"style"}))})}addIconset(h,y){if(y.type==="sprite")return void this._loadSprite(y.url);const A=this.getOwnSourceCache(y.source);if(!A)return void this.fire(new i.y(new Error(`Source "${y.source}" as specified by iconset "${h}" does not exist and cannot be used as an iconset source`)));const D=A.getSource();if(D.type!=="raster-array")return void this.fire(new i.y(new Error(`Source "${y.source}" as specified by iconset "${h}" is not a "raster-array" source and cannot be used as an iconset source`)));D.partial=!1;const F=new VE(h,this.scope,A);this.imageManager.addImageProvider(F,this.scope)}removeIconset(h){this.imageManager.removeImageProvider(h,this.scope)}_loadIconset(h){if(!i.h(h)&&this.map._spriteFormat!=="icon_set"||this.map._spriteFormat==="raster")return void this._loadSprite(h);const y=this.map._spriteFormat==="auto";var A,D;this._spriteRequest=(D=(F,z)=>{if(this._spriteRequest=null,F)y?this._loadSprite(h):this.fire(new i.y(F));else if(z){const W=new Map;for(const J in z)W.set(i.I.from(J),z[J]);this.addImages(W)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.z("data",{dataType:"style"}))},i.bu((A=this.map._requestManager).transformRequest(A.normalizeIconsetURL(h),i.R.Iconset),(F,z)=>{if(F)return void D(F);const W={},J=i.dg(new i.bt(z));for(const ne of J.icons){const le={version:1,pixelRatio:i.o.devicePixelRatio,content:SR(ne),stretchX:ne.metadata?CR(ne.metadata.stretch_x_areas):void 0,stretchY:ne.metadata?CR(ne.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:ne};W[ne.name]=le}D(null,W)}))}_validateLayer(h){const y=this.getOwnSource(h.source);if(!y)return;const A=h.sourceLayer;A&&(y.type==="geojson"||y.vectorLayerIds&&y.vectorLayerIds.indexOf(A)===-1)&&this.fire(new i.y(new Error(`Source layer "${A}" does not exist on source "${y.id}" as specified by style layer "${h.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const h in this._sourceCaches)if(!this._sourceCaches[h].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(const{style:h}of this.fragments)if(!h.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((h,y)=>{const A=this.fragments[y];return A&&A.style&&(h.data=A.style.serialize()),h})}_serializeSources(){const h={};for(const y in this._sourceCaches){const A=this._sourceCaches[y].getSource();h[A.id]||(h[A.id]=A.serialize())}return h}_serializeLayers(h){const y=[];for(const A of h){const D=this._layers[A];D&&D.type!=="custom"&&y.push(D.serialize())}return y}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return!!this.snow&&this.snow.hasTransition()}hasRainTransition(){return!!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions()||this.hasFogTransition()||this.hasSnowTransition()||this.hasRainTransition())return!0;for(const h in this._sourceCaches)if(this._sourceCaches[h].hasTransition())return!0;for(const h in this._layers)if(this._layers[h].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(const h in this._mergedLayers){const y=this._mergedLayers[h];if(y._transitionablePaint&&y._transitionablePaint._values){const A=y._transitionablePaint._values["line-emissive-strength"];if(A&&A.value&&A.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(h){return h?this.order:this._mergedOrder}isLayerDraped(h){return!!this.terrain&&h.isDraped(this.getLayerSourceCache(h))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(h){const y=this.getOwnLayer(h);if(y)return y;this.fire(new i.y(new Error(`The layer '${h}' does not exist in the map's style.`)))}_checkSource(h){const y=this.getOwnSource(h);if(y)return y;this.fire(new i.y(new Error(`The source '${h}' does not exist in the map's style.`)))}precompilePrograms(h,y){const A=this.map.painter;if(A)for(let D=h.minzoom||0;D<(h.maxzoom||25.5);D++){const F=h.getProgramIds();if(F)for(const z of F){const W=h.getDefaultProgramParams(z,y.zoom,this._styleColorTheme.lut);W&&(A.style=this,this.fog&&(A._fogVisible=!0,W.overrideFog=!0,A.getOrCreateProgram(z,W)),A._fogVisible=!1,W.overrideFog=!1,A.getOrCreateProgram(z,W),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(W.overrideRtt=!0,A.getOrCreateProgram(z,W)))}}}update(h){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(h),this.directionalLight&&this.directionalLight.recalculate(h);const y=this.calculateLightsBrightness();h.brightness=y||0,y!==this._brightness&&(this._brightness=y,this.dispatcher.broadcast("setBrightness",y)),h.worldview!==this._worldview&&(this._worldview=h.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const A=this._changes.isDirty();let D=!1;if(this._changes.isDirty()){const W=this._changes.getLayerUpdatesByScope();for(const J in W){const{updatedIds:ne,removedIds:le}=W[J];(ne||le)&&(this._updateWorkerLayers(J,ne,le),D=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(h),this.light&&this.light.updateTransitions(h),this.ambientLight&&this.ambientLight.updateTransitions(h),this.directionalLight&&this.directionalLight.updateTransitions(h),this.fog&&this.fog.updateTransitions(h),this.snow&&this.snow.updateTransitions(h),this.rain&&this.rain.updateTransitions(h),this._changes.reset()}const F={};for(const W in this._mergedSourceCaches){const J=this._mergedSourceCaches[W];F[W]=J.used,J.used=!1,J.tileCoverLift=0}for(const W of this._mergedOrder){const J=this._mergedLayers[W];if(J.visibility!=="none"&&J.recalculate(h,this._availableImages),!J.isHidden(h.zoom)){const ne=this.getLayerSourceCache(J);ne&&(ne.used=!0,ne.tileCoverLift=Math.max(ne.tileCoverLift,J.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(J,h)}):this.precompilePrograms(J,h))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&D&&this.mergeLayers();const z=this.imageManager.getPendingImageProviders();for(const W of z)W.sourceCache.used=!0;for(const W in F){const J=this._mergedSourceCaches[W];F[W]!==J.used&&J.getSource().fire(new i.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:J.getSource().id}))}this.light&&this.light.recalculate(h),this.terrain&&this.terrain.recalculate(h),this.fog&&this.fog.recalculate(h),this.snow&&this.snow.recalculate(h),this.rain&&this.rain.recalculate(h),this.z=h.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),A&&this.fire(new i.z("data",{dataType:"style"}))}updateImageProviders(){const h=this.imageManager.getPendingImageProviders();for(const y of h){const A=y.resolvePendingRequests(),D=this.getFragmentStyle(y.scope);D&&D.addImages(A)}}_updateTilesForChangedImages(){const h={};for(const y in this._mergedSourceCaches){const A=this._mergedSourceCaches[y].getSource().scope;h[A]=h[A]||this._changes.getUpdatedImages(A),h[A].length!==0&&this._mergedSourceCaches[y].reloadTilesForDependencies(["icons","patterns"],h[A])}for(const y in h)this._changes.resetUpdatedImages(y)}_updateWorkerLayers(h,y,A){const D=this.getFragmentStyle(h);D&&this.dispatcher.broadcast("updateLayers",{layers:y?D._serializeLayers(y):[],scope:h,removedIds:A||[],options:D.options})}setState(h,y){if(this._checkLoaded(),Ny(this,Yr(h)))return!1;(h=i.dp(h)).layers=Z0(h.layers);const A=function(z,W){if(!z)return[{command:La.setStyle,args:[W]}];let J=[];try{if(!i.by(z.version,W.version))return[{command:La.setStyle,args:[W]}];if(i.by(z.center,W.center)||J.push({command:La.setCenter,args:[W.center]}),i.by(z.zoom,W.zoom)||J.push({command:La.setZoom,args:[W.zoom]}),i.by(z.bearing,W.bearing)||J.push({command:La.setBearing,args:[W.bearing]}),i.by(z.pitch,W.pitch)||J.push({command:La.setPitch,args:[W.pitch]}),i.by(z.sprite,W.sprite)||J.push({command:La.setSprite,args:[W.sprite]}),i.by(z.glyphs,W.glyphs)||J.push({command:La.setGlyphs,args:[W.glyphs]}),i.by(z.imports,W.imports)||function(we=[],Le=[],Ie){Le=Le||[];const We=(we=we||[]).map(Y0),Ue=Le.map(Y0),st=we.reduce(X0,{}),ut=Le.reduce(X0,{}),ot=We.slice();let Et,Nt,Tt,wt;for(Et=0,Nt=0;Et{we.source&&ne[we.source]?J.push({command:La.removeLayer,args:[we.id]}):_e.push(we)});let ye=z.terrain;ye&&ne[ye.source]&&(J.push({command:La.setTerrain,args:[void 0]}),ye=void 0),J=J.concat(le),i.by(ye,W.terrain)||J.push({command:La.setTerrain,args:[W.terrain]}),function(we,Le,Ie){Le=Le||[];const We=(we=we||[]).map(Y0),Ue=Le.map(Y0),st=we.reduce(X0,{}),ut=Le.reduce(X0,{}),ot=We.slice(),Et=Object.create(null);let Nt,Tt,wt,yt,Ot,Wt,Ht;for(Nt=0,Tt=0;Nt!(z.command in TR));if(A.length===0)return!1;const D=A.filter(z=>!(z.command in MR));if(D.length>0)throw new Error(`Unimplemented: ${D.map(z=>z.command).join(", ")}.`);const F=[];return A.forEach(z=>{F.push(this[z.command](...z.args))}),y&&Promise.all(F).then(y).catch(y),this.stylesheet=h,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages})}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(h){if(h.size===0)return this;for(const[y,A]of h.entries()){if(this.getImage(y))return this.fire(new i.y(new Error(`An image with the name "${y.name}" already exists.`)));this.imageManager.addImage(y,this.scope,A),this._changes.updateImage(y,this.scope)}return this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this}addImage(h,y){return this.getImage(h)?this.fire(new i.y(new Error(`An image with the name "${h.name}" already exists.`))):(this.imageManager.addImage(h,this.scope,y),this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this)}updateImage(h,y,A=!1){this.imageManager.updateImage(h,this.scope,y),A&&(this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})))}getImage(h){return this.imageManager.getImage(h,this.scope)}removeImage(h){return this.getImage(h)?(this.imageManager.removeImage(h,this.scope),this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this):this.fire(new i.y(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(h){return this.modelManager.addModelURLs(h,this.getActualScope()),this._updateWorkerModels(),this.fire(new i.z("data",{dataType:"style"})),this}addModel(h,y,A={}){return this._checkLoaded(),this._validate(je,`models.${h}`,y,null,A)||(this.modelManager.addModel(h,y,this.getActualScope()),this.fire(new i.z("data",{dataType:"style"}))),this}hasModel(h){return this.modelManager.hasModel(h,this.getActualScope())}removeModel(h){return this.hasModel(h)?(this.modelManager.removeModel(h,this.getActualScope(),!1,!0),this.fire(new i.z("data",{dataType:"style"})),this):this.fire(new i.y(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(h,y,A={}){if(this._checkLoaded(),this.getOwnSource(h)!==void 0)throw new Error(`There is already a source with ID "${h}".`);if(!y.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(y).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(y.type)>=0&&this._validate(vi,`sources.${h}`,y,null,A))return;this.map&&this.map._collectResourceTiming&&(y.collectResourceTiming=!0);const D=zl(h,y,this.dispatcher,this);D.scope=this.scope,D.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(D.id),source:D.serialize(),sourceId:D.id}));const F=z=>{const W=(z?"symbol:":"other:")+D.id,J=i.B(W,this.scope),ne=this._sourceCaches[W]=new Al(J,D,z);(z?this._symbolSourceCaches:this._otherSourceCaches)[D.id]=ne,ne.onAdd(this.map)};F(!1),y.type!=="vector"&&y.type!=="geojson"||F(!0),D.onAdd&&D.onAdd(this.map),A.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(h){this._checkLoaded();const y=this.getOwnSource(h);if(!y)throw new Error("There is no source with this ID");for(const D in this._layers)if(this._layers[D].source===h)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while layer "${D}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===h)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const D=Object.entries(this.stylesheet.iconsets).find(([F,z])=>z.type==="source"&&z.source===h);if(D)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while iconset "${D[0]}" is using it.`)))}const A=this.getOwnSourceCaches(h);for(const D of A){const F=i.dq(D.id);delete this._sourceCaches[F],this._changes.discardSourceCacheUpdate(D.id),D.fire(new i.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:D.getSource().id})),D.setEventedParent(null),D.clearTiles()}return delete this._otherSourceCaches[h],delete this._symbolSourceCaches[h],this.mergeSources(),y.setEventedParent(null),y.onRemove&&y.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(h,y){this._checkLoaded(),this.getOwnSource(h).setData(y),this._changes.setDirty()}getOwnSource(h){const y=this.getOwnSourceCache(h);return y&&y.getSource()}getOwnSources(){const h=[];for(const y in this._otherSourceCaches){const A=this.getOwnSourceCache(y);A&&h.push(A.getSource())}return h}areTilesLoaded(){const h=this._mergedSourceCaches;for(const y in h){const A=h[y]._tiles;for(const D in A){const F=A[D];if(F.state!=="loaded"&&F.state!=="errored")return!1}}return!0}setLights(h){if(this._checkLoaded(),!h)return delete this.ambientLight,void delete this.directionalLight;const y=this._getTransitionParameters();for(const F of h){if(this._validate(ir,"lights",F))return;switch(F.type){case"ambient":if(this.ambientLight){const z=this.ambientLight;z.set(F),z.updateTransitions(y)}else this.ambientLight=new Ia(F,il||(il=new i.a9({color:new i.aa(i.a6.properties_light_ambient.color),"color-use-theme":new i.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new i.aa(i.a6.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const z=this.directionalLight;z.set(F),z.updateTransitions(y)}else this.directionalLight=new Ia(F,ti||(ti=new i.a9({direction:new i.ap(i.a6.properties_light_directional.direction),color:new i.aa(i.a6.properties_light_directional.color),"color-use-theme":new i.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new i.aa(i.a6.properties_light_directional.intensity),"cast-shadows":new i.aa(i.a6.properties_light_directional["cast-shadows"]),"shadow-quality":new i.aa(i.a6.properties_light_directional["shadow-quality"]),"shadow-intensity":new i.aa(i.a6.properties_light_directional["shadow-intensity"])})),this.scope,this.options)}}const A=Object.assign(y,{worldview:this.map.getWorldview()}),D=new i.ac(this.z||0,A);this.ambientLight&&this.ambientLight.recalculate(D),this.directionalLight&&this.directionalLight.recalculate(D),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const h=this.directionalLight,y=this.ambientLight;if(!h||!y)return;const A=ye=>.2126*(ye[0]<=.03928?ye[0]/12.92:Math.pow((ye[0]+.055)/1.055,2.4))+.7152*(ye[1]<=.03928?ye[1]/12.92:Math.pow((ye[1]+.055)/1.055,2.4))+.0722*(ye[2]<=.03928?ye[2]/12.92:Math.pow((ye[2]+.055)/1.055,2.4)),D=h.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),F=h.properties.get("intensity"),z=h.properties.get("direction"),W=1-i.d4(z.x,z.y,z.z)[2]/90,J=A(D)*F*W,ne=y.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),le=y.properties.get("intensity"),_e=A(ne)*le;return Number(((J+_e)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const h=[];return this.directionalLight&&h.push(this.directionalLight.get()),this.ambientLight&&h.push(this.ambientLight.get()),h}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(h){if(h==null||h===""&&this.isRootStyle())return this;if(i.dr(h)){const y=i.ds(h),A=this.fragments.find(({id:F})=>F===y);if(!A)return;const D=i.dq(h);return A.style.getFragmentStyle(D)}{const y=this.fragments.find(({id:A})=>A===h);return y?y.style:void 0}}setFeaturesetSelectors(h){if(!h)return;const y={},A=(D,F="")=>`${D}::${F}`;this._featuresetSelectors={};for(const D in h){const F=this._featuresetSelectors[D]=[];for(const z of h[D].selectors){if(z.featureNamespace){const J=this.getOwnLayer(z.layer);if(!J){i.w(`Layer is undefined for selector: ${z.layer}`);continue}const ne=A(J.source,J.sourceLayer);if(ne in y&&y[ne]!==z.featureNamespace){i.w(`"featureNamespace ${z.featureNamespace} of featureset ${D}'s selector is not associated to the same source, skip this selector`);continue}y[ne]=z.featureNamespace}let W;if(z.properties)for(const J in z.properties){const ne=i.U(z.properties[J]);ne.result==="success"&&(W=W||{},W[J]=ne.value)}F.push({layerId:z.layer,namespace:z.featureNamespace,properties:W,uniqueFeatureID:z._uniqueFeatureID})}}}getFeaturesetDescriptors(h){const y=this.getFragmentStyle(h);if(!y||!y.stylesheet.featuresets)return[];const A=[];for(const D in y.stylesheet.featuresets)A.push({featuresetId:D,importId:y.scope?y.scope:void 0});return A}getFeaturesetLayers(h,y){const A=this.getFragmentStyle(y),D=A.stylesheet.featuresets;if(!D||!D[h])return this.fire(new i.y(new Error(`The featureset '${h}' does not exist in the map's style and cannot be queried.`))),[];const F=[];for(const z of D[h].selectors){const W=A.getOwnLayer(z.layer);W&&F.push(W)}return F}getConfigProperty(h,y){const A=this.getFragmentStyle(h);if(!A)return null;const D=i.B(y,A.scope),F=A.options.get(D),z=F?F.value||F.default:null;return z?z.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(h,y){const A=i.B(h,y);return this._mergedIndoor[A]}setIndoorData(h,y){this.map.indoor.setIndoorData(y)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(h,y,A){const D=this.getFragmentStyle(h);if(!D)return;const F=D.stylesheet.schema;if(!F||!F[y])return;const z=i.U(A);if(z.result!=="success")return void Ny(this,z.value);const W=z.value.expression,J=i.B(y,D.scope),ne=D.options.get(J);if(!ne)return;let le;const{minValue:_e,maxValue:ye,stepValue:we,type:Le,values:Ie}=F[y],We=i.U(F[y].default);We.result==="success"&&(le=We.value.expression),le?(this.options.set(J,Object.assign({},ne,{value:W,default:le,minValue:_e,maxValue:ye,stepValue:we,type:Le,values:Ie})),this.updateConfigDependencies(y)):this.fire(new i.y(new Error(`No schema defined for the config option "${y}" in the "${h}" fragment.`)))}getConfig(h){const y=this.getFragmentStyle(h);if(!y)return null;const A=y.stylesheet.schema;if(!A)return null;const D={};for(const F in A){const z=i.B(F,y.scope),W=y.options.get(z),J=W?W.value||W.default:null;D[F]=J?J.serialize():null}return D}setConfig(h,y){const A=this.getFragmentStyle(h);A&&(A.updateConfig(y,A.stylesheet.schema),this.updateConfigDependencies())}getSchema(h){const y=this.getFragmentStyle(h);return y?y.stylesheet.schema:null}setSchema(h,y){const A=this.getFragmentStyle(h);A&&(A.stylesheet.schema=y,A.updateConfig(A._config,y),this.updateConfigDependencies())}updateConfig(h,y){if(this._config=h,h||y)if(y)for(const A in y){let D,F;const z=i.U(y[A].default);if(z.result==="success"&&(D=z.value.expression),h&&h[A]!==void 0){const ye=i.U(h[A]);ye.result==="success"&&(F=ye.value.expression)}const{minValue:W,maxValue:J,stepValue:ne,type:le,values:_e}=y[A];if(D){const ye=i.B(A,this.scope);this.options.set(ye,{default:D,value:F,minValue:W,maxValue:J,stepValue:ne,type:le,values:_e})}else this.fire(new i.y(new Error(`No schema defined for config option "${A}".`)))}else this.fire(new i.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(h,y=()=>!0){for(const A of h){const D=this.getLayer(A);D&&y(D)&&(D.possiblyEvaluateVisibility(),this._updateLayer(D),this._changes.setDirty())}}updateConfigDependencies(h){this._updateLayers(this._configDependentLayers,y=>!h||y.expressionDependencies.configDependencies.has(h)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(y=>{const A=y._styleColorTheme.colorThemeOverride?y._styleColorTheme.colorThemeOverride:y._styleColorTheme.colorTheme;if(A){const D=y._evaluateColorThemeData(A);(!y._styleColorTheme.lut&&D!==""||y._styleColorTheme.lut&&D!==y._styleColorTheme.lut.data)&&y.setColorTheme(A)}}),this._changes.setDirty()}addLayer(h,y,A={}){this._checkLoaded();const D=h.id;if(this._layers[D])return void this.fire(new i.y(new Error(`Layer with id "${D}" already exists on this map`)));let F;if(h.type==="custom"){if(Ny(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(Pa,`layers.${D}`,h,{arrayIndex:-1},A))return;F=i.du(h,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(F),F.setEventedParent(this,{layer:{id:D}})}const z=i.B(F.source,F.scope);F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(z),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(z);let W=this._order.length;if(y){const _e=this._order.indexOf(y);if(_e===-1)return void this.fire(new i.y(new Error(`Layer with id "${y}" does not exist on this map.`)));F.slot===this._layers[y].slot?W=_e:i.w(`Layer with id "${y}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(W,0,D),this._layerOrderChanged=!0,this._layers[D]=F;const J=this.getOwnLayerSourceCache(F),ne=!!this.directionalLight&&this.directionalLight.shadowsEnabled();J&&F.canCastShadows()&&ne&&(J.castsShadows=!0);const le=this._changes.getRemovedLayer(F);if(le&&F.source&&J&&F.type!=="custom"){this._changes.discardLayerRemoval(F);const _e=i.B(F.source,F.scope);le.type!==F.type?this._changes.updateSourceCache(_e,"clear"):(this._changes.updateSourceCache(_e,"reload"),J.pause())}this._updateLayer(F),F.onAdd&&F.onAdd(this.map),F.scope=this.scope,this.mergeLayers()}moveLayer(h,y){this._checkLoaded();const A=this._checkLayer(h);if(!A||h===y)return;const D=this._order.indexOf(h);this._order.splice(D,1);let F=this._order.length;if(y){const z=this._order.indexOf(y);if(z===-1)return void this.fire(new i.y(new Error(`Layer with id "${y}" does not exist on this map.`)));A.slot===this._layers[y].slot?F=z:i.w(`Layer with id "${y}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(F,0,h),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(h){this._checkLoaded();const y=this._checkLayer(h);if(!y)return;y.setEventedParent(null);const A=this._order.indexOf(h);this._order.splice(A,1),delete this._layers[h],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(y.fqid),this._indoorDependentLayers.delete(y.fqid),this._changes.removeLayer(y);const D=this.getOwnLayerSourceCache(y);if(D&&D.castsShadows){let F=!1;for(const z in this._layers)if(this._layers[z].source===y.source&&this._layers[z].canCastShadows()){F=!0;break}D.castsShadows=F}y.onRemove&&y.onRemove(this.map),this.mergeLayers()}getOwnLayer(h){return this._layers[h]}hasLayer(h){return h in this._mergedLayers}hasLayerType(h){for(const y in this._layers)if(this._layers[y].type===h)return!0;return!1}setLayerZoomRange(h,y,A){this._checkLoaded();const D=this._checkLayer(h);D&&(D.minzoom===y&&D.maxzoom===A||(y!=null&&(D.minzoom=y),A!=null&&(D.maxzoom=A),this._updateLayer(D)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(h,y){this._checkLoaded();const A=this._checkLayer(h);A&&A.slot!==y&&(A.slot=y,this._updateLayer(A))}setFilter(h,y,A={}){this._checkLoaded();const D=this._checkLayer(h);if(D&&!i.by(D.filter,y))return y==null?(D.filter=void 0,void this._updateLayer(D)):void(this._validate(Ii,`layers.${D.id}.filter`,y,{layerType:D.type},A)||(D.filter=i.dp(y),this._updateLayer(D)))}getFilter(h){const y=this._checkLayer(h);if(y)return i.dp(y.filter)}setLayoutProperty(h,y,A,D={}){this._checkLoaded();const F=this._checkLayer(h);if(F&&!i.by(F.getLayoutProperty(y),A)){if(A!=null&&(!D||D.validate!==!1)&&Ny(F,$t.call(Yr,{key:`layers.${h}.layout.${y}`,layerType:F.type,objectKey:y,value:A,styleSpec:i.a6,style:{glyphs:!0,sprite:!0}})))return;F.setLayoutProperty(y,A),F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F.fqid),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F.fqid),this._updateLayer(F)}}setLayerProperty(h,y,A,D={}){this._checkLoaded();const F=this._checkLayer(h);F&&(y==="appearances"?(F.setAppearances(A),this._changes.setDirty()):F.isPaintProperty(y)?this.setPaintProperty(h,y,A,D):this.setLayoutProperty(h,y,A,D))}getLayoutProperty(h,y){const A=this._checkLayer(h);if(A)return A.getLayoutProperty(y)}setPaintProperty(h,y,A,D={}){this._checkLoaded();const F=this._checkLayer(h);if(!F||i.by(F.getPaintProperty(y),A)||A!=null&&(!D||D.validate!==!1)&&Ny(F,Fo.call(Yr,{key:`layers.${h}.paint.${y}`,layerType:F.type,objectKey:y,value:A,styleSpec:i.a6})))return;const z=F.setPaintProperty(y,A);F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F.fqid),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F.fqid),z&&this._updateLayer(F),this._changes.updatePaintProperties(F)}getPaintProperty(h,y){const A=this._checkLayer(h);if(A)return A.getPaintProperty(y)}setFeatureState(h,y){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:J,importId:ne}=h.target,le=this.getFragmentStyle(ne),_e=le.getFeaturesetLayers(J);for(const{source:ye,sourceLayer:we}of _e)le.setFeatureState({id:h.id,source:ye,sourceLayer:we},y)}else if("layerId"in h.target){const{layerId:J}=h.target,ne=this.getLayer(J);this.setFeatureState({id:h.id,source:ne.source,sourceLayer:ne.sourceLayer},y)}return}const A=h.source,D=h.sourceLayer,F=this._checkSource(A);if(!F)return;const z=F.type;if(z==="geojson"&&D)return void this.fire(new i.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(z==="vector"&&!D)return void this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")));h.id===void 0&&this.fire(new i.y(new Error("The feature id parameter must be provided.")));const W=this.getOwnSourceCaches(A);for(const J of W)J.setFeatureState(D,h.id,y)}removeFeatureState(h,y){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:J,importId:ne}=h.target,le=this.getFragmentStyle(ne),_e=le.getFeaturesetLayers(J);for(const{source:ye,sourceLayer:we}of _e)le.removeFeatureState({id:h.id,source:ye,sourceLayer:we},y)}else if("layerId"in h.target){const{layerId:J}=h.target,ne=this.getLayer(J);this.removeFeatureState({id:h.id,source:ne.source,sourceLayer:ne.sourceLayer},y)}return}const A=h.source,D=this._checkSource(A);if(!D)return;const F=D.type,z=F==="vector"?h.sourceLayer:void 0;if(F==="vector"&&!z)return void this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")));if(y&&typeof h.id!="string"&&typeof h.id!="number")return void this.fire(new i.y(new Error("A feature id is required to remove its specific state property.")));const W=this.getOwnSourceCaches(A);for(const J of W)J.removeFeatureState(z,h.id,y)}getFeatureState(h){if(this._checkLoaded(),"target"in h){let F;if("featuresetId"in h.target){const{featuresetId:z,importId:W}=h.target,J=this.getFragmentStyle(W),ne=J.getFeaturesetLayers(z);for(const{source:le,sourceLayer:_e}of ne){const ye=J.getFeatureState({id:h.id,source:le,sourceLayer:_e});if(ye&&!F)F=ye;else if(!i.by(F,ye))return void this.fire(new i.y(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in h.target){const{layerId:z}=h.target,W=this.getLayer(z);F=this.getFeatureState({id:h.id,source:W.source,sourceLayer:W.sourceLayer})}return F}const y=h.source,A=h.sourceLayer,D=this._checkSource(y);if(D){if(D.type!=="vector"||A)return h.id===void 0&&this.fire(new i.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(y)[0].getFeatureState(A,h.id);this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(h){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,h),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}serialize(){this._checkLoaded();const h=this.getTerrain(),y=h&&this.terrain&&this.terrain.scope===this.scope?h:this.stylesheet.terrain;return i.dv({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:y,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},A=>A!==void 0)}_updateFilteredLayers(h){for(const y of Object.values(this._mergedLayers))h(y)&&this._updateLayer(y)}_updateLayer(h){this._changes.updateLayer(h);const y=this.getLayerSourceCache(h),A=i.B(h.source,h.scope),D=this._changes.getUpdatedSourceCaches();h.source&&!D[A]&&y&&y.getSource().type!=="raster"&&(this._changes.updateSourceCache(A,"reload"),y.pause()),h.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(h){const y=W=>this._mergedLayers[W].is3D(!!this.terrain),A=this.order,D={},F=[];for(let W=A.length-1;W>=0;W--){const J=A[W];if(y(J)){D[J]=W;for(const ne of h){const le=ne[J];if(le)for(const _e of le)F.push(_e)}}}F.sort((W,J)=>J.intersectionZ-W.intersectionZ);const z=[];for(let W=A.length-1;W>=0;W--){const J=A[W];if(y(J))for(let ne=F.length-1;ne>=0;ne--){const le=F[ne].feature;if(le.layer&&D[le.layer.id]{if($C.has(le.type))return;const _e=this.getOwnLayerSourceCache(le),ye=F[_e.id]=F[_e.id]||{sourceCache:_e,layers:{},has3DLayers:!1};le.is3D(!!this.terrain)&&(ye.has3DLayers=!0),ye.layers[le.fqid]=ye.layers[le.fqid]||{styleLayer:le,targets:[]},ye.layers[le.fqid].targets.push({filter:D})};if(y&&y.layers){if(!Array.isArray(y.layers))return this.fire(new i.y(new Error("parameters.layers must be an Array."))),[];for(const le of y.layers){const _e=this._layers[le];if(!_e)return this.fire(new i.y(new Error(`The layer '${le}' does not exist in the map's style and cannot be queried for features.`))),[];z(_e)}}else for(const le in this._layers)z(this._layers[le]);const W=this._queryRenderedFeatures(h,F,A),J=this._flattenAndSortRenderedFeatures(W),ne=[];for(const le of J)i.dw(le.layer.id)===this.scope&&ne.push(le);return ne}queryRenderedFeatureset(h,y,A){let D;y&&!Array.isArray(y)&&y.filter&&(this._validate(Ii,"queryRenderedFeatures.filter",y.filter,null,y),D=i.b6(y.filter));const F="mock",z=[];if(y&&y.target)z.push(Object.assign({},y,{targetId:F,filter:D}));else{const le=this.getFeaturesetDescriptors();for(const _e of le)z.push({targetId:F,filter:D,target:_e});for(const{style:_e}of this.fragments){const ye=_e.getFeaturesetDescriptors();for(const we of ye)z.push({targetId:F,filter:D,target:we})}}const W=this.queryRenderedTargets(h,z,A),J=[],ne=new Set;for(const le of W)for(const _e of le.variants[F])yy(_e,le,ne)||J.push(new i.dx(le,_e));return J}queryRenderedTargets(h,y,A){const D={},F=(W,J,ne,le)=>{const _e=D[J.id]=D[J.id]||{sourceCache:J,layers:{},has3DLayers:!1};if(_e.layers[W.fqid]=_e.layers[W.fqid]||{styleLayer:W,targets:[]},W.is3D(!!this.terrain)&&(_e.has3DLayers=!0),!le)return ne.uniqueFeatureID=!1,void _e.layers[W.fqid].targets.push(ne);_e.layers[W.fqid].targets.push(Object.assign({},ne,{namespace:le.namespace,properties:le.properties,uniqueFeatureID:le.uniqueFeatureID}))};for(const W of y)if("featuresetId"in W.target){const{featuresetId:J,importId:ne}=W.target,le=this.getFragmentStyle(ne);if(!le||!le._featuresetSelectors)continue;const _e=le._featuresetSelectors[J];if(!_e){this.fire(new i.y(new Error(`The featureset '${J}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const ye of _e){const we=le.getOwnLayer(ye.layerId);we&&!$C.has(we.type)&&F(we,le.getOwnLayerSourceCache(we),W,ye)}}else if("layerId"in W.target){const{layerId:J}=W.target,ne=this.getLayer(J);if(!ne||$C.has(ne.type))continue;F(ne,this.getLayerSourceCache(ne),W)}const z=this._queryRenderedFeatures(h,D,A);return this._flattenAndSortRenderedFeatures(z)}_queryRenderedFeatures(h,y,A){const D=[],F=!!this.map._showQueryGeometry,z=lo.createFromScreenPoints(h,A);for(const W in y){const J=V1(z,y[W],this._availableImages,A,F);Object.keys(J).length&&D.push(J)}if(this.placement)for(const W in y){if(!y[W].sourceCache._onlySymbols)continue;const J=H1(z.screenGeometry,y[W],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(J).length&&D.push(J)}return D}querySourceFeatures(h,y){const A=y&&y.filter;A&&this._validate(Ii,"querySourceFeatures.filter",A,null,y);let D=[];const F=this.getOwnSourceCaches(h);for(const z of F)D=D.concat(W1(z,y));return D}addSourceType(h,y,A){return tp.getSourceType(h)?A(new Error(`A source type called "${h}" already exists.`)):(tp.setSourceType(h,y),y.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:h,url:y.workerSourceURL},A):A(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(h,y,A={}){this._checkLoaded();const D=this.light.getLight();let F=!1;for(const W in h)if(!i.by(h[W],D[W])){F=!0;break}if(!F)return;const z=this._getTransitionParameters();this.light.setLight(h,y,A),this.light.updateTransitions(z)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){this.disableElevatedTerrain===void 0&&(this.disableElevatedTerrain=i.o.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&i.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(h,y=1){if(this._checkLoaded(),!h)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),y===0&&delete this.terrain,h===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let A=h;const D=!("source"in h)||h.source==null;if(y===1){if(this.disableElevatedTerrain)return;if("source"in A&&typeof A.source=="object"){const W="terrain-dem-src";this.addSource(W,A.source),A=i.dp(A),A=Object.assign(A,{source:W})}const F=Object.assign({},A),z={};if(this.terrain&&D){F.source=this.terrain.get().source;const W=this.terrain?this.getFragmentStyle(this.terrain.scope):null;W&&(z.style=W.serialize())}if(this._validate(Vn,"terrain",F,z))return}if(!this.terrain||this.terrain.scope!==this.scope&&!D||this.terrain&&y!==this.terrain.drapeRenderMode){if(!A)return;this._createTerrain(A,y),this.fire(new i.z("data",{dataType:"style"}))}else{const F=this.terrain,z=F.get();for(const W of Object.keys(i.a6.terrain))!A.hasOwnProperty(W)&&i.a6.terrain[W].default&&(A[W]=i.a6.terrain[W].default);for(const W in h)if(!i.by(h[W],z[W])){F.set(h,this.options),this.stylesheet.terrain=h;const J=this._getTransitionParameters({duration:0});F.updateTransitions(J),this.fire(new i.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(h){const y=this.fog=new En(h,this.map.transform,this.scope,this.options);this.stylesheet.fog=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}_createSnow(h){const y=this.snow=new hl(h,this.map.transform,this.scope,this.options);this.stylesheet.snow=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}_createRain(h){const y=this.rain=new oo(h,this.map.transform,this.scope,this.options);this.stylesheet.rain=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const h of this.map._markers)h._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(h){if(this._checkLoaded(),!h)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const y=this.fog;if(!i.by(y.get(),h)){y.set(h,this.options),this.stylesheet.fog=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}}else this._createFog(h);this._markersNeedUpdate=!0}getSnow(){return this.snow?this.snow.get():null}setSnow(h){if(this._checkLoaded(),!h)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const y=this.snow;if(!i.by(y.get(),h)){y.set(h,this.options),this.stylesheet.snow=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}}else this._createSnow(h);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(h){if(this._checkLoaded(),!h)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const y=this.rain;if(!i.by(y.get(),h)){y.set(h,this.options),this.stylesheet.rain=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}}else this._createRain(h);this._markersNeedUpdate=!0}_reloadColorTheme(){const h=()=>{for(const D in this._layers)this._layers[D].lut=this._styleColorTheme.lut;for(const D in this._sourceCaches)this._sourceCaches[D].clearTiles()},y=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!y)return this._styleColorTheme.lut=null,void h();const A=this._evaluateColorThemeData(y);this._loadColorTheme(A).then(()=>{this.fire(new i.z("colorthemeset")),h()}).catch(D=>{i.w(`Couldn't set color theme: ${D}`)})}setColorTheme(h){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&i.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=h,this._reloadColorTheme()}setImportColorTheme(h,y){const A=this.getFragmentStyle(h);A&&(A._styleColorTheme.colorThemeOverride=y,A._reloadColorTheme())}_getTransitionParameters(h){return{now:i.o.now(),transition:Object.assign(this.transition,h)}}updateDrapeFirstLayers(){if(!this.terrain)return;const h=[],y=[];for(const A of this._mergedOrder)this.isLayerDraped(this._mergedLayers[A])?h.push(A):y.push(A);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...h),this._drapedFirstOrder.push(...y)}_createTerrain(h,y){const A=this.terrain=new Ut(h,y,this.scope,this.options,this.map.getWorldview());y===1&&(this.stylesheet.terrain=h),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const D=this._getTransitionParameters({duration:0});A.updateTransitions(D)}_force3DLayerUpdate(){for(const h in this._layers){const y=this._layers[h];y.type==="fill-extrusion"&&this._updateLayer(y)}}_forceSymbolLayerUpdate(){for(const h in this._layers){const y=this._layers[h];y.type==="symbol"&&this._updateLayer(y)}}_validate(h,y,A,D,F={}){if(F&&F.validate===!1)return!1;const z=Object.assign({},this.serialize());return Ny(this,h.call(Yr,Object.assign({key:y,style:z,value:A,styleSpec:i.a6},D)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.dy.off("pluginStateChange",this._rtlTextPluginCallback);for(const h in this._mergedLayers)this._mergedLayers[h].setEventedParent(null);for(const h in this._mergedSourceCaches)this._mergedSourceCaches[h].clearTiles(),this._mergedSourceCaches[h].setEventedParent(null);this.imageManager.removeScope(this.scope),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove())}clearSource(h){const y=this.getSourceCaches(h);for(const A of y)A.clearTiles()}clearSources(){for(const h in this._mergedSourceCaches)this._mergedSourceCaches[h].clearTiles()}clearLayers(){for(const h in this._mergedLayers){const y=this._mergedLayers[h];y._clear&&y._clear()}}reloadSource(h){const y=this.getSourceCaches(h);for(const A of y)A.resume(),A.reload()}reloadSources(){for(const h of this.getSources())h.reload&&h.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(h=>{h.modelManager.reloadModels(h.scope)})}updateSources(h){let y;this.directionalLight&&(y=e2(this.directionalLight));const A=new Set,D=new Set;for(const F in this._mergedLayers){const z=this._mergedLayers[F];z.type==="building"&&A.add(z.source),z.hasElevation()&&!D.has(z.source)&&D.add(z.source)}for(const F in this._mergedSourceCaches){const z=this._mergedSourceCaches[F],W=D.has(z._source.id);A.has(z._source.id)&&(z._source.reparseOverscaled=!1),z.update(h,void 0,void 0,y,W)}}_generateCollisionBoxes(){for(const h in this._sourceCaches){const y=this._sourceCaches[h];y.resume(),y.reload()}}_updatePlacement(h,y,A,D,F,z,W=!1){let J=!1,ne=!1;const le={},_e={};for(const Ie of this._mergedOrder){const We=this._mergedLayers[Ie];if(We.type!=="symbol")continue;const Ue=i.B(We.source,We.scope);let st=le[Ue];if(!st){const ot=this.getLayerSourceCache(We);if(!ot)continue;const Et=ot.getRenderableIds(!0).map(Nt=>ot.getTileByID(Nt));_e[Ue]=Et.slice(),st=le[Ue]=Et.sort((Nt,Tt)=>Tt.tileID.overscaledZ-Nt.tileID.overscaledZ||(Nt.tileID.isLessThan(Tt.tileID)?-1:1))}const ut=this.crossTileSymbolIndex.addLayer(We,st,y.center.lng,y.projection);J=J||ut}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),W=W||this._layerOrderChanged,this._layerOrderChanged&&this.fire(new i.z("neworder"));const ye=!!(this.placement&&!y.equals(this.placement.transform)),we=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!z||this.placement.lastReplacementSourceUpdateTime!==z.updateTime)),Le=(ye||we||J||this.placement&&this.placement.isStale())&&D===0;if((W||!this.pauseablePlacement||Le||D!==0&&this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),y.zoom))&&(this.pauseablePlacement=new Tc(y,this._mergedOrder,W||D===0,A,D,F,this.placement,this.fog&&y.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,le,_e,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.o.now()),ne=!0),J&&this.pauseablePlacement.placement.setStale()),ne||J){this._buildingIndex.onNewFrame(y.zoom);for(let Ie=0;IeF===h.id)!==-1)return void this.fire(new i.y(new Error(`Import with id '${h.id}' already exists in the map's style.`)));if(!y)return A.push(h),this._loadImports([h],!0);const D=A.findIndex(({id:F})=>F===y);return D===-1&&this.fire(new i.y(new Error(`Import with id "${y}" does not exist on this map.`))),this.stylesheet.imports=A.slice(0,D).concat(h).concat(A.slice(D)),this._loadImports([h],!0,y)}updateImport(h,y){this._checkLoaded();const A=this.stylesheet.imports||[],D=this.getImportIndex(h);return D===-1?this:typeof y=="string"?(this.setImportUrl(h,y),this):(y.url&&y.url!==A[D].url&&this.setImportUrl(h,y.url),i.by(y.config,A[D].config)||this.setImportConfig(h,y.config,y.data.schema),i.by(y.data,A[D].data)||this.setImportData(h,y.data),this)}moveImport(h,y){this._checkLoaded();let A=this.stylesheet.imports||[];const D=this.getImportIndex(h);if(D===-1)return this;const F=this.getImportIndex(y);if(F===-1)return this;const z=A[D],W=this.fragments[D];return A=A.filter(({id:J})=>J!==h),this.fragments=this.fragments.filter(({id:J})=>J!==h),this.stylesheet.imports=A.slice(0,F).concat(z).concat(A.slice(F)),this.fragments=this.fragments.slice(0,F).concat(W).concat(this.fragments.slice(F)),this.mergeLayers(),this}setImportUrl(h,y){this._checkLoaded();const A=this.stylesheet.imports||[],D=this.getImportIndex(h);if(D===-1)return this;A[D].url=y;const F=this.fragments[D];return F.style=this._createFragmentStyle(A[D]),F.style.on("style.import.load",()=>this.mergeAll()),F.style.loadURL(y),this}setImportData(h,y){this._checkLoaded();const A=this.getImportIndex(h),D=this.stylesheet.imports||[];return A===-1?this:y?(this.fragments[A].style.setState(y),this._reloadImports(),this):(delete D[A].data,this.setImportUrl(h,D[A].url))}setImportConfig(h,y,A){this._checkLoaded();const D=this.getImportIndex(h),F=this.stylesheet.imports||[];if(D===-1)return this;y?F[D].config=y:delete F[D].config;const z=this.fragments[D];A&&z.style.stylesheet&&(z.style.stylesheet.schema=A);const W=z.style.stylesheet&&z.style.stylesheet.schema;return z.config=y,z.style.updateConfig(y,W),this.updateConfigDependencies(),this}removeImport(h){this._checkLoaded();const y=this.stylesheet.imports||[],A=this.getImportIndex(h);A!==-1&&(y.splice(A,1),this.fragments[A].style._remove(),this.fragments.splice(A,1),this._reloadImports())}getImportIndex(h){const y=(this.stylesheet.imports||[]).findIndex(A=>A.id===h);return y===-1&&this.fire(new i.y(new Error(`Import '${h}' does not exist in the map's style and cannot be updated.`))),y}getLayer(h){return this._mergedLayers[h]}getSources(){const h=[];for(const y in this._mergedOtherSourceCaches){const A=this._mergedOtherSourceCaches[y];A&&h.push(A.getSource())}return h}getSource(h,y){const A=this.getSourceCache(h,y);return A&&A.getSource()}getLayerSource(h){const y=this.getLayerSourceCache(h);return y&&y.getSource()}getSourceCache(h,y){const A=i.B(h,y);return this._mergedOtherSourceCaches[A]}getLayerSourceCache(h){const y=i.B(h.source,h.scope);return h.type==="symbol"?this._mergedSymbolSourceCaches[y]:this._mergedOtherSourceCaches[y]}getSourceCaches(h){if(h==null)return Object.values(this._mergedSourceCaches);const y=[];return this._mergedOtherSourceCaches[h]&&y.push(this._mergedOtherSourceCaches[h]),this._mergedSymbolSourceCaches[h]&&y.push(this._mergedSymbolSourceCaches[h]),y}updateSourceCaches(){const h=this._changes.getUpdatedSourceCaches();for(const y in h){const A=h[y];A==="reload"?this.reloadSource(y):A==="clear"&&this.clearSource(y)}}updateLayers(h){const y=this._changes.getUpdatedPaintProperties();for(const A of y){const D=this.getLayer(A);D&&D.updateTransitions(h)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(h){this.stylesheet.glyphs=h,this.glyphManager.setURL(h)}getImages(h,y,A){this.imageManager.getImages(y.images,y.scope,A),this._updateTilesForChangedImages();const D=z=>{if(z){const W=y.images.map(J=>i.I.toString(J));z.setDependencies(y.tileID.key,y.type,W)}},F=i.B(y.source,y.scope);D(this._mergedOtherSourceCaches[F]),D(this._mergedSymbolSourceCaches[F]),y.images.some(z=>z.iconsetId)&&this.fire(new i.z("data",{dataType:"style"}))}rasterizeImages(h,y,A){this.imageManager.rasterizeImages(y,A)}getGlyphs(h,y,A){this.glyphManager.getGlyphs(y.stacks,A)}getResource(h,y,A){return i.dz(y,A)}getOwnSourceCache(h){return this._otherSourceCaches[h]}getOwnLayerSourceCache(h){return h.type==="symbol"?this._symbolSourceCaches[h.source]:this._otherSourceCaches[h.source]}getOwnSourceCaches(h){const y=[];return this._otherSourceCaches[h]&&y.push(this._otherSourceCaches[h]),this._symbolSourceCaches[h]&&y.push(this._symbolSourceCaches[h]),y}_isSourceCacheLoaded(h){const y=this.getOwnSourceCaches(h);return y.length===0?(this.fire(new i.y(new Error(`There is no source with ID '${h}'`))),!1):y.every(A=>A.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(h,y){if(!this._clipLayerPresent&&h.type!=="fill-extrusion"&&h.type!=="building")return!1;const A=h.type==="fill-extrusion"&&(h.sourceLayer==="building"||h.sourceLayer==="procedural_buildings"),D=h.type==="building";if(h.is3D(!!this.terrain)){if(A||D||y&&y.type==="batched-model"||h.type==="model")return!0}else if(h.type==="symbol")return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach(h=>{h.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}tp.getSourceType=function(T){return Km[T]},tp.setSourceType=function(T,h){Km[T]=h},tp.registerForPluginStateChange=i.dA;class AR extends i.E{constructor(h){super(),this._style=h,this._buildings={},this._activeFloors=new Set,this._activeFloorsVisible=!0,this._indoorState={selectedFloorId:null,lastActiveFloors:null,activeFloorsVisible:!0},i.aY(["_updateUI"],this)}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(h){h===this._selectedFloorId&&this._activeFloorsVisible||(this._selectedFloorId=h,this._activeFloorsVisible=!0,this._updateActiveFloors())}setActiveFloorsVisibility(h){this._activeFloorsVisible=h,this._updateActiveFloors(),this._updateIndoorSelector()}setIndoorData(h){for(const[y,A]of Object.entries(h.buildings))if(this._buildings[y])for(const D of A.floorIds)this._buildings[y].floors[D]||(this._buildings[y].floors[D]=A.floors[D]);else this._buildings[y]=A;for(const y of h.activeFloors)this._activeFloors.add(y);this._updateIndoorSelector()}getIndoorTileOptions(h,y){const A=this._style.getIndoorSourceLayers(h,y);return A&&this._indoorState?{sourceLayers:A,indoorState:this._indoorState}:null}_updateUI(h,y,A){const D=function(F,z,W,J){let ne=null,le=Number.MAX_SAFE_INTEGER;if(J<16)return null;for(const[_e,ye]of Object.entries(F)){const we=ye.center;if(we){const Le=z.distanceTo(i.aT.convert(we));Le({id:z,name:A.floors[z].name,zIndex:A.floors[z].zIndex})).sort((z,W)=>W.zIndex-z.zIndex);this.fire(new i.z("selector-update",{selectedFloorId:D,activeFloorsVisible:this._activeFloorsVisible,floors:F}))}_updateActiveFloors(){const h=this._activeFloors;this._activeFloors=new Set,this._indoorState={selectedFloorId:this._selectedFloorId,lastActiveFloors:h,activeFloorsVisible:this._activeFloorsVisible},this._style.updateIndoorDependentLayers()}}var J1=` #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`,eb=` #ifdef DUAL_SOURCE_BLENDING layout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1; #else layout(location=0) out vec4 glFragColor; #endif #ifdef USE_MRT1 layout(location=1) out vec4 out_Target1; #endif highp float unpack_depth(highp vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;} #ifdef INDICATOR_CUTOUT uniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params; #endif vec4 applyCutout(vec4 color,float height) { #ifdef INDICATOR_CUTOUT float verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0); #else return color; #endif } #ifdef DEBUG_WIREFRAME #define HANDLE_WIREFRAME_DEBUG \\ glFragColor=vec4(0.7,0.0,0.0,0.7); \\ gl_FragDepth=gl_FragCoord.z-0.0001; #else #define HANDLE_WIREFRAME_DEBUG #endif #ifdef RENDER_CUTOFF uniform highp vec4 u_cutoff_params;in float v_cutoff_opacity; #endif vec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb*col.a,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}`,HE=` #define EXTENT 8192.0 #define RAD_TO_DEG 180.0/PI #define DEG_TO_RAD PI/180.0 #define GLOBE_RADIUS EXTENT/PI/2.0 float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;} #ifdef PROJECTION_GLOBE_VIEW vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) { #ifndef PROJECTED_POS_ON_VIEWPORT float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz; #else return vec3(0.0); #endif }vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);} #endif vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4( unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0 );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const vec2 units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (units_to_pixels*pos+offset)/pattern_size;}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);} #ifdef RENDER_CUTOFF uniform vec4 u_cutoff_params;out float v_cutoff_opacity; #endif const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt) {float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);} #ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer #define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib #define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib #define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib #define DECLARE_MATERIAL_TABLE_INFO #endif`,qC="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;}",lm=` #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`,UC=`#ifdef FOG uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);} #endif`,tr=`#ifdef FOG uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport; #ifdef FLIP_Y uv.y=1.0-uv.y; #endif highp vec3 ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);} #endif`,WE=`#ifdef RASTER_ARRAY uniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0) );}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0) );}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);} #endif`,VC=`#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;}`,HC=`#ifdef RENDER_SHADOWS uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];} #endif`,GE=`#ifdef RENDER_SHADOWS precision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) { #ifdef CLIP_ZERO_TO_ONE highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias); #else highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias); #endif return texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w; #ifdef SHADOWS_SINGLE_CASCADE vec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias); #else light_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0); #endif }highp float calculate_shadow_bias(float NDotL) { #ifdef NORMAL_OFFSET return 0.5*u_shadow_bias.x; #else return 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z)); #endif }float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias)*shadow_opacity;return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy) {highp vec2 biasUV=vec2( pos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);} #endif`;const s2=/#include\s+"([^"]+)"/g,$f=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,KE=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,tv=new Set(["ifdef","ifndef","elif","if","defined"]),sv=new Set;Cy(J1,sv),Cy(HE,sv),Cy(eb,sv);const Sy={"_prelude_fog.vertex.glsl":UC,"_prelude_terrain.vertex.glsl":lm,"_prelude_shadow.vertex.glsl":HC,"_prelude_material_table.vertex.glsl":`#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer #define MATERIAL_TABLE_DEBUG 0 uniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset; #if MATERIAL_TABLE_DEBUG vec4 colorDebug; #endif };uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { if (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; }uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { iRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info; #if MATERIAL_TABLE_DEBUG const vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green; #endif uint offset=0u; #if MATERIAL_TABLE_DEBUG bool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;} #endif offset++; #if MATERIAL_TABLE_DEBUG uint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;} #endif offset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++); #if MATERIAL_TABLE_DEBUG if(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;} #endif uint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset); #if MATERIAL_TABLE_DEBUG if(keepFinding) {uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}} #endif offset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup; #if MATERIAL_TABLE_DEBUG if(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}} #endif info.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes) {uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);} #define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset) #define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset) #define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset) #define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); #define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug; #endif`,"_prelude_fog.fragment.glsl":tr,"_prelude_shadow.fragment.glsl":GE,"_prelude_lighting.glsl":` #ifdef LIGHTING_3D_MODE uniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);} #endif`,"_prelude_raster_array.glsl":WE,"_prelude_raster_particle.glsl":VC},WC={};Fa("",lm),Fa(tr,UC),Fa(GE,HC),Fa(WE,""),Fa(VC,"");const ER=Fa(eb,HE),GC=J1,Cme=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",GC,ER.fragmentSource].join(` `),PR=["precision highp float;",GC,ER.vertexSource].join(` `);var ZE={background:Fa(`#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:Fa(`#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:Fa(`#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:Fa(`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:Fa(`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:Fa(`#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:Fa("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:Fa(`#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:Fa(`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:Fa("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:Fa("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:Fa("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:Fa(`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:Fa(`#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:Fa(`#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:Fa(`#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:Fa(`#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:Fa(`#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:Fa(`#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:Fa(`#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:Fa(`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:Fa(`#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:Fa(`#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:Fa(`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:Fa(`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:Fa(`#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:Fa(`#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:Fa(`#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:Fa(`#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:Fa(`#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:Fa("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:Fa("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:Fa(`#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:Fa(`#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:Fa(`#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:Fa("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:Fa(`#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 }`,qC),skyboxGradient:Fa(`#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 }`,qC),skyboxCapture:Fa(` 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:Fa(`#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:Fa(`#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:Fa(`#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:Fa(`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:Fa(`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:Fa("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:Fa("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:Fa("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:Fa("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 Cy(T,h){const y=T.split(` `);for(let A of y){if(A=A.trimStart(),A[0]!=="#"||!A.includes("if")||A.startsWith("#endif"))continue;const D=A.match(KE);if(D)for(const F of D)tv.has(F)||h.add(F)}}function Fa(T,h){const y=new Set,A=[],D=[];T=T.replace(s2,(z,W)=>(D.push(W),"")),h=h.replace(s2,(z,W)=>(A.push(W),""));let F=new Set(sv);Cy(T,F),Cy(h,F);for(const z of[...A,...D])WC[z]||(WC[z]=new Set,Cy(Sy[z],WC[z])),F=new Set([...F,...WC[z]]);return{fragmentSource:T=T.replace($f,(z,W,J,ne,le)=>(y.add(le),W==="define"?` #ifndef HAS_UNIFORM_u_${le} in ${J} ${ne} ${le}; #else uniform ${J} ${ne} u_${le}; #endif `:W==="initialize"?` #ifdef HAS_UNIFORM_u_${le} ${J} ${ne} ${le} = u_${le}; #endif `:W==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${le} in ${J} ${ne} ${le}; #endif `:W==="initialize-attribute"?"":void 0)),vertexSource:h=h.replace($f,(z,W,J,ne,le)=>{const _e=`MATERIAL_ATTRIBUTE_OFFSET_${le}`,ye=ne==="float"?"vec2":ne,we=`GET_ATTRIBUTE_${ye}(a_${le}, materialInfo, ${_e})`,Le=le.match(/color/)?"color":ye;return W==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${le} in ${J} ${ne} a_${le}; #endif `:y.has(le)?W==="define"?` #ifndef HAS_UNIFORM_u_${le} uniform lowp float u_${le}_t; #if !defined(${_e}) in ${J} ${ye} a_${le}; #endif out ${J} ${ne} ${le}; #else uniform ${J} ${ne} u_${le}; #endif `:W==="initialize"?Le==="vec4"?` #ifndef HAS_UNIFORM_u_${le} ${le} = a_${le}; #else ${J} ${ne} ${le} = u_${le}; #endif `:` #if !defined(HAS_UNIFORM_u_${le}) #ifdef ${_e} ${le} = unpack_mix_${Le}(${we}, u_${le}_t); #else ${le} = unpack_mix_${Le}(a_${le}, u_${le}_t); #endif #else ${J} ${ne} ${le} = u_${le}; #endif `:W==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${le} in ${J} ${ne} a_${le}; out ${J} ${ne} ${le}; #endif `:W==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${le} ${le} = a_${le}; #endif `:void 0:W==="define"?` #ifndef HAS_UNIFORM_u_${le} uniform lowp float u_${le}_t; #if !defined(${_e}) in ${J} ${ye} a_${le}; #endif #else uniform ${J} ${ne} u_${le}; #endif `:W==="define-instanced"?Le==="mat4"?` #ifdef INSTANCED_ARRAYS in vec4 a_${le}0; in vec4 a_${le}1; in vec4 a_${le}2; in vec4 a_${le}3; #else uniform ${J} ${ne} u_${le}; #endif `:` #ifdef INSTANCED_ARRAYS in ${J} ${ye} a_${le}; #else uniform ${J} ${ne} u_${le}; #endif `:W==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${le} ${J} ${ne} ${le} = a_${le}; #endif `:Le==="vec4"?` #ifndef HAS_UNIFORM_u_${le} #ifdef ${_e} ${J} ${ne} ${le} = ${we}; #else ${J} ${ne} ${le} = a_${le}; #endif #else ${J} ${ne} ${le} = u_${le}; #endif `:` #ifndef HAS_UNIFORM_u_${le} #ifdef ${_e} ${J} ${ne} ${le} = unpack_mix_${Le}(${we}, u_${le}_t); #else ${J} ${ne} ${le} = unpack_mix_${Le}(a_${le}, u_${le}_t); #endif #else ${J} ${ne} ${le} = u_${le}; #endif `}),usedDefines:F,vertexIncludes:A,fragmentIncludes:D}}class Mme{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(h,y,A,D,F,z,W,J){this.context=h;let ne=this.boundPaintVertexBuffers.length!==D.length;for(let _e=0;!ne&&_e{const Et=ut.paint.get("hillshade-shadow-color"),Nt=ut.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",Tt=ut.paint.get("hillshade-highlight-color"),wt=ut.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",yt=ut.paint.get("hillshade-accent-color"),Ot=ut.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Wt=ut.paint.get("hillshade-emissive-strength");let Ht=i.an(ut.paint.get("hillshade-illumination-direction"));if(ut.paint.get("hillshade-illumination-anchor")==="viewport")Ht-=Ue.transform.angle;else if(Ue.style&&Ue.style.enable3dLights()&&Ue.style.directionalLight){const ts=Ue.style.directionalLight.properties.get("direction"),xs=i.d4(ts.x,ts.y,ts.z);Ht=i.an(xs[1])}const es=!Ue.options.moving;return{u_matrix:ot||Ue.transform.calculateProjMatrix(st.tileID.toUnwrapped(),es),u_image:0,u_latrange:Tme(0,st.tileID),u_light:[ut.paint.get("hillshade-exaggeration"),Ht],u_shadow:Et.toPremultipliedRenderColor(Nt?null:ut.lut),u_highlight:Tt.toPremultipliedRenderColor(wt?null:ut.lut),u_emissive_strength:Wt,u_accent:yt.toPremultipliedRenderColor(Ot?null:ut.lut)}})(T,y,A,T.terrain?h.projMatrix:null);T.uploadCommonUniforms(W,ye,h.toUnwrapped());const{tileBoundsBuffer:Le,tileBoundsIndexBuffer:Ie,tileBoundsSegments:We}=T.getTileBoundsBuffers(y);ye.draw(T,J.TRIANGLES,D,F,z,mn.disabled,we,A.id,Le,Ie,We)}function YE(T,h,y){if(!h.needsDEMTextureUpload)return;const A=T.context,D=A.gl;A.pixelStoreUnpackPremultiplyAlpha.set(!1),h.demTexture=h.demTexture||T.getTileTexture(y.stride);const F=y.getPixels();h.demTexture?h.demTexture.update(F,{premultiply:!1}):h.demTexture=new i.T(A,F,D.R32F,{premultiply:!1}),h.needsDEMTextureUpload=!1}function Eme(T,h,y){const A=T.context,D=A.gl;if(!h.dem)return;const F=h.dem;if(A.activeTexture.set(D.TEXTURE1),YE(T,h,F),!h.demTexture)return;h.demTexture.bind(D.NEAREST,D.CLAMP_TO_EDGE);const z=F.dim;A.activeTexture.set(D.TEXTURE0);let W=h.hillshadeFBO;if(!W){const ye=new i.T(A,{width:z,height:z,data:null},D.RGBA8);ye.bind(D.LINEAR,D.CLAMP_TO_EDGE),W=h.hillshadeFBO=A.createFramebuffer(z,z,1,"renderbuffer"),W.colorAttachment0.set(ye.texture)}A.bindFramebuffer.set(W.framebuffer),A.viewport.set([0,0,z,z]);const{tileBoundsBuffer:J,tileBoundsIndexBuffer:ne,tileBoundsSegments:le}=T.getMercatorTileBoundsBuffers(),_e=[];T.linearFloatFilteringSupported()&&_e.push("TERRAIN_DEM_FLOAT_FORMAT"),T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback"&&_e.push("USE_MRT1"),T.getOrCreateProgram("hillshadePrepare",{defines:_e}).draw(T,D.TRIANGLES,Fr.disabled,yn.disabled,Hn.unblended,mn.disabled,((ye,we)=>{const Le=we.stride,Ie=i.bC();return i.ce(Ie,0,i.al,-i.al,0,0,1),i.br(Ie,Ie,[0,-i.al,0]),{u_matrix:Ie,u_image:1,u_dimension:[Le,Le],u_zoom:ye.overscaledZ}})(h.tileID,F),y.id,J,ne,le),h.needsHillshadePrepare=!1}class ho{constructor(h){this.gl=h.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(h){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Pme extends ho{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(h){const y=this.current;(h.r!==y.r||h.g!==y.g||h.b!==y.b||h.a!==y.a||this.dirty)&&(this.gl.clearColor(h.r,h.g,h.b,h.a),this.current=h,this.dirty=!1)}}class IR extends ho{getDefault(){return 1}set(h){(h!==this.current||this.dirty)&&(this.gl.clearDepth(h),this.current=h,this.dirty=!1)}}class XE extends ho{getDefault(){return 0}set(h){(h!==this.current||this.dirty)&&(this.gl.clearStencil(h),this.current=h,this.dirty=!1)}}class KC extends ho{getDefault(){return[!0,!0,!0,!0]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||h[2]!==y[2]||h[3]!==y[3]||this.dirty)&&(this.gl.colorMask(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class QE extends ho{getDefault(){return!0}set(h){(h!==this.current||this.dirty)&&(this.gl.depthMask(h),this.current=h,this.dirty=!1)}}class rv extends ho{getDefault(){return 255}set(h){(h!==this.current||this.dirty)&&(this.gl.stencilMask(h),this.current=h,this.dirty=!1)}}class tb extends ho{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(h){const y=this.current;(h.func!==y.func||h.ref!==y.ref||h.mask!==y.mask||this.dirty)&&(this.gl.stencilFunc(h.func,h.ref,h.mask),this.current=h,this.dirty=!1)}}class r2 extends ho{getDefault(){const h=this.gl;return[h.KEEP,h.KEEP,h.KEEP]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||h[2]!==y[2]||this.dirty)&&(this.gl.stencilOp(h[0],h[1],h[2]),this.current=h,this.dirty=!1)}}class sb extends ho{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;h?y.enable(y.STENCIL_TEST):y.disable(y.STENCIL_TEST),this.current=h,this.dirty=!1}}class LR extends ho{getDefault(){return[0,1]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||this.dirty)&&(this.gl.depthRange(h[0],h[1]),this.current=h,this.dirty=!1)}}class JE extends ho{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;h?y.enable(y.DEPTH_TEST):y.disable(y.DEPTH_TEST),this.current=h,this.dirty=!1}}class DR extends ho{getDefault(){return this.gl.LESS}set(h){(h!==this.current||this.dirty)&&(this.gl.depthFunc(h),this.current=h,this.dirty=!1)}}class rb extends ho{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;h?y.enable(y.BLEND):y.disable(y.BLEND),this.current=h,this.dirty=!1}}class ZC extends ho{getDefault(){const h=this.gl;return[h.ONE,h.ZERO,h.ONE,h.ZERO]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||h[2]!==y[2]||h[3]!==y[3]||this.dirty)&&(this.gl.blendFuncSeparate(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class YC extends ho{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(h){const y=this.current;(h.r!==y.r||h.g!==y.g||h.b!==y.b||h.a!==y.a||this.dirty)&&(this.gl.blendColor(h.r,h.g,h.b,h.a),this.current=h,this.dirty=!1)}}class e6 extends ho{getDefault(){return this.gl.FUNC_ADD}set(h){(h!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(h,h),this.current=h,this.dirty=!1)}}class XC extends ho{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;h?y.enable(y.CULL_FACE):y.disable(y.CULL_FACE),this.current=h,this.dirty=!1}}class n2 extends ho{getDefault(){return this.gl.BACK}set(h){(h!==this.current||this.dirty)&&(this.gl.cullFace(h),this.current=h,this.dirty=!1)}}class OR extends ho{getDefault(){return this.gl.CCW}set(h){(h!==this.current||this.dirty)&&(this.gl.frontFace(h),this.current=h,this.dirty=!1)}}let RR=class extends ho{getDefault(){return null}set(T){(T!==this.current||this.dirty)&&(this.gl.useProgram(T),this.current=T,this.dirty=!1)}};class FR extends ho{getDefault(){return this.gl.TEXTURE0}set(h){(h!==this.current||this.dirty)&&(this.gl.activeTexture(h),this.current=h,this.dirty=!1)}}class nb extends ho{getDefault(){const h=this.gl;return[0,0,h.drawingBufferWidth,h.drawingBufferHeight]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||h[2]!==y[2]||h[3]!==y[3]||this.dirty)&&(this.gl.viewport(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class zR extends ho{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.bindFramebuffer(y.FRAMEBUFFER,h),this.current=h,this.dirty=!1}}class Ime extends ho{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.bindRenderbuffer(y.RENDERBUFFER,h),this.current=h,this.dirty=!1}}class Lme extends ho{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.bindTexture(y.TEXTURE_2D,h),this.current=h,this.dirty=!1}}class Dme extends ho{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.bindBuffer(y.ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class t6 extends ho{getDefault(){return null}set(h){const y=this.gl;y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class s6 extends ho{getDefault(){return null}set(h){this.gl&&(h!==this.current||this.dirty)&&(this.gl.bindVertexArray(h),this.current=h,this.dirty=!1)}}class r6 extends ho{getDefault(){return 4}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.pixelStorei(y.UNPACK_ALIGNMENT,h),this.current=h,this.dirty=!1}}class n6 extends ho{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,h),this.current=h,this.dirty=!1}}class BR extends ho{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.pixelStorei(y.UNPACK_FLIP_Y_WEBGL,h),this.current=h,this.dirty=!1}}class QC extends ho{constructor(h,y){super(h),this.context=h,this.parent=y}getDefault(){return null}}class JC extends QC{constructor(h,y,A=0){super(h,y),this.attachmentPoint=h.gl.COLOR_ATTACHMENT0+A}setDirty(){this.dirty=!0}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const y=this.gl;y.framebufferTexture2D(y.FRAMEBUFFER,this.attachmentPoint,y.TEXTURE_2D,h,0),this.current=h,this.dirty=!1}}class ab extends QC{attachment(){return this.gl.DEPTH_ATTACHMENT}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const y=this.gl;y.framebufferRenderbuffer(y.FRAMEBUFFER,this.attachment(),y.RENDERBUFFER,h),this.current=h,this.dirty=!1}}class a2 extends QC{attachment(){return this.gl.DEPTH_ATTACHMENT}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const y=this.gl;y.framebufferTexture2D(y.FRAMEBUFFER,this.attachment(),y.TEXTURE_2D,h,0),this.current=h,this.dirty=!1}}class $R extends ab{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const cm=(T,h,y,A)=>({u_matrix:T,u_image0:0,u_image1:1,u_skirt_height:h,u_ground_shadow_factor:y,u_emissive_texture_available:A}),e3=(T,h,y,A,D,F,z,W,J,ne,le,_e,ye,we,Le,Ie,We)=>({u_proj_matrix:Float32Array.from(T),u_globe_matrix:h,u_normalize_matrix:Float32Array.from(A),u_merc_matrix:y,u_zoom_transition:D,u_merc_center:F,u_image0:0,u_image1:1,u_frustum_tl:z,u_frustum_tr:W,u_frustum_br:J,u_frustum_bl:ne,u_globe_pos:le,u_globe_radius:_e,u_viewport:ye,u_grid_matrix:We?Float32Array.from(We):new Float32Array(9),u_skirt_height:we,u_far_z_cutoff:Le,u_emissive_texture_available:Ie});function i2(T,h){return T!=null&&h!=null&&!(!T.hasData()||!h.hasData())&&T.demTexture!=null&&h.demTexture!=null&&T.tileID.key!==h.tileID.key}const sg=new class{constructor(){this.operations={}}newMorphing(T,h,y,A,D){if(T in this.operations){const F=this.operations[T];F.to.tileID.key!==y.tileID.key&&(F.queued=y)}else this.operations[T]={startTime:A,phase:0,duration:D,from:h,to:y,queued:null}}getMorphValuesForProxy(T){if(!(T in this.operations))return null;const h=this.operations[T];return{from:h.from,to:h.to,phase:h.phase}}update(T){for(const h in this.operations){const y=this.operations[h];for(y.phase=(T-y.startTime)/y.duration;y.phase>=1||!this._validOp(y);)if(!this._nextOp(y,T)){delete this.operations[h];break}}}_nextOp(T,h){return!!T.queued&&(T.from=T.to,T.to=T.queued,T.queued=null,T.phase=0,T.startTime=h,!0)}_validOp(T){return T.from.hasData()&&T.to.hasData()}},t3={0:null,1:"TERRAIN_VERTEX_MORPHING"};function s3(T,h,y){if(h===0)return 0;const A=h<1&&y===514?.25/h:1;return 6*Math.pow(1.5,22-T)*Math.max(h,1)*A}function a6(T,h){const y=1<({u_matrix:T});function l2(T,h,y,A,D){if(D>0){const F=i.o.now(),z=(F-T.timeAdded)/D,W=h?(F-h.timeAdded)/D:-1,J=y.getSource(),ne=A.coveringZoomLevel({tileSize:J.tileSize,roundZoom:J.roundZoom}),le=!h||Math.abs(h.tileID.overscaledZ-ne)>Math.abs(T.tileID.overscaledZ-ne),_e=le&&T.refreshedUponExpiration?1:i.aA(le?z:1-W,0,1);return h?{opacity:1,mix:1-_e,isFading:z<1}:{opacity:_e,mix:0,isFading:z<1}}return{opacity:1,mix:0,isFading:!1}}class r3 extends Al{constructor(h){const y=zl("mock-dem",{type:"raster-dem",maxzoom:h.transform.maxZoom},h.style.dispatcher,h.style);super("mock-dem",y,!1),y.setEventedParent(this),this._sourceLoaded=!0}_loadTile(h,y){h.state="loaded",y(null)}}class i6 extends Al{constructor(h){const y=zl("proxy",{type:"geojson",maxzoom:h.transform.maxZoom},h.style.dispatcher,h.style);super("proxy",y,!1),y.setEventedParent(this),this.map=this.getSource().map=h,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(h,y,A){if(h.freezeTileCoverage)return;this.transform=h;const D=h.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((F,z)=>{if(F[z.key]="",!this._tiles[z.key]){const W=new Ym(z,this._source.tileSize*z.overscaleFactor(),h.tileZoom,void 0,void 0,this._source.worldview);W.state="loaded",this._tiles[z.key]=W}return F},{});for(const F in this._tiles)F in D||(this.freeFBO(F),this._tiles[F].unloadVectorData(),delete this._tiles[F])}freeFBO(h){const y=this.proxyCachedFBO[h];if(y!==void 0){const A=Object.values(y);this.renderCachePool.push(...A),delete this.proxyCachedFBO[h]}}deallocRenderCache(){this.renderCache.forEach(h=>h.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class o6 extends i.aQ{constructor(h,y,A){super(h.overscaledZ,h.wrap,h.canonical.z,h.canonical.x,h.canonical.y),this.proxyTileKey=y,this.projMatrix=A}}class l6 extends i.bV{constructor(h,y){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=h,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[A,D,F]=function(J){const ne=new i.bd,le=new i.b0,_e=131;ne.reserve(17161),le.reserve(33800);const ye=i.al/128,we=i.al+ye/2,Le=we+ye;for(let We=-ye;Wewe||We<0||We>we?24575:0,ut=i.aA(Math.round(Ue),0,i.al),ot=i.aA(Math.round(We),0,i.al);ne.emplaceBack(ut+st,ot)}const Ie=(We,Ue)=>{const st=Ue*_e+We;le.emplaceBack(st+1,st,st+_e),le.emplaceBack(st+_e,st+_e+1,st+1)};for(let We=1;We<129;We++)for(let Ue=1;Ue<129;Ue++)Ie(Ue,We);return[0,129].forEach(We=>{for(let Ue=0;Ue<130;Ue++)Ie(Ue,We),Ie(We,Ue)}),[ne,le,32768]}(),z=h.context;this.gridBuffer=z.createVertexBuffer(A,i.bf.members),this.gridIndexBuffer=z.createIndexBuffer(D),this.gridSegments=i.bg.simpleSegment(0,0,A.length,D.length),this.gridNoSkirtSegments=i.bg.simpleSegment(0,0,A.length,F),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new i6(y.map),this.orthoMatrix=i.bC(),i.ce(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,i.al,0,i.al,0,1);const W=z.gl;this._overlapStencilMode=new yn({func:W.GEQUAL,mask:255},0,255,W.KEEP,W.KEEP,W.REPLACE),this._previousZoom=h.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=y,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new r3(y.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1}set style(h){h.on("data",this._onStyleDataEvent.bind(this)),this._style=h,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(h,y,A){if(h&&h.terrain){this._style!==h&&(this.style=h,this._evaluationZoom=void 0);const D=h.terrain.properties,F=h.terrain.drapeRenderMode===0,z=h.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=i.o.now();const W=h.terrain&&h.terrain.scope,J=D.get("source"),ne=F?this._mockSourceCache:h.getSourceCache(J,W);if(!ne)return void i.w(`Couldn't find terrain source "${J}".`);if(this.sourceCache=ne,this._attenuationRange=h.terrain.getAttenuationRange(),this._exaggeration=z?this.calculateExaggeration(y):D.get("exaggeration"),!y.projection.requiresDraping&&z&&this._exaggeration===0)return void this._disable();this.enabled=!0;const le=()=>{this.sourceCache.used&&i.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const _e=this.getScaledDemTileSize();this.sourceCache.update(y,_e,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,le(),this._initializing=!0),le(),y.updateElevation(!0,A),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(y),this._emptyDEMTextureDirty=!0,this._previousZoom=y.zoom}else this._disable()}calculateExaggeration(h){if(this._attenuationRange&&h.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(h.zoom);const y=this._previousCameraAltitude,A=h.getFreeCameraOptions().position.z/h.pixelsPerMeter*h.worldSize;this._previousCameraAltitude=A;const D=y!=null?A-y:Number.MAX_VALUE;if(Math.abs(D)<2)return this._exaggeration;const F=h.zoom,z=this._style.terrain;if(!this._previousUpdateTimestamp)return z.getExaggeration(F);let W=F-this._previousZoom;const J=this._previousUpdateTimestamp;let ne=F;this._evaluationZoom!=null&&(ne=this._evaluationZoom,Math.abs(F-ne)>.5&&(W=.5*(F-ne+W)),W*D<0&&(ne+=W)),this._evaluationZoom=ne;const le=z.getExaggeration(ne),_e=le===z.getExaggeration(Math.max(0,ne-.1));if(_e&&Math.abs(le-this._exaggeration)<.01)return le;let ye=Math.min(.1,.00375*(this._updateTimestamp-J));return(_e||le<.1||Math.abs(W)<1e-4)&&(ye=Math.min(.2,4*ye)),i.ak(this._exaggeration,le,ye)}resetTileLookupCache(h){this._findCoveringTileCache[h]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(h){h.dataType==="source"&&h.coord?this._clearRenderCacheForTile(h.sourceCacheId,h.coord):h.dataType==="style"&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const h in this._style._mergedSourceCaches)this._style._mergedSourceCaches[h].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(h=>h.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const h=2*this.proxySourceCache.getSource().tileSize;return[h,h]}set useVertexMorphing(h){this._useVertexMorphing=h}updateTileBinding(h){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const y=this.proxySourceCache,A=this.painter.transform;this._initializing&&(this._initializing=A._centerAltitude===0&&this.getAtPointOrZero(i.ae.fromLngLat(A.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const D=this.proxyCoords=y.getIds().map(J=>{const ne=y.getTileByID(J).tileID;return ne.projMatrix=A.calculateProjMatrix(ne.toUnwrapped()),ne});(function(J,ne){const le=ne.transform.pointCoordinate(ne.transform.getCameraPoint()),_e=new i.P(le.x,le.y);J.sort((ye,we)=>{if(we.overscaledZ-ye.overscaledZ)return we.overscaledZ-ye.overscaledZ;const Le=new i.P(ye.canonical.x+(1<{this.proxyToSource[J.key]={}}),this.terrainTileForTile={};const z=this._style._mergedSourceCaches;for(const J in z){const ne=z[J];if(!ne.used||(ne!==this.sourceCache&&this.resetTileLookupCache(ne.id),this._setupProxiedCoordsForOrtho(ne,h[J],F),ne.usedForTerrain))continue;const le=h[J];ne.getSource().reparseOverscaled&&this._assignTerrainTiles(le)}this.proxiedCoords[y.id]=D.map(J=>new o6(J,J.key,this.orthoMatrix)),this._assignTerrainTiles(D),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(F),this.renderingToTexture=!1;const W={};this._visibleDemTiles=[];for(const J of this.proxyCoords){const ne=this.terrainTileForTile[J.key];if(!ne)continue;const le=ne.tileID.key;le in W||(this._visibleDemTiles.push(ne),W[le]=le)}}_assignTerrainTiles(h){this._initializing||h.forEach(y=>{if(this.terrainTileForTile[y.key])return;const A=this._findTileCoveringTileID(y,this.sourceCache);A&&(this.terrainTileForTile[y.key]=A)})}_prepareDEMTextures(){const h=this.painter.context,y=h.gl;for(const A in this.terrainTileForTile){const D=this.terrainTileForTile[A],F=D.dem;!F||D.demTexture&&!D.needsDEMTextureUpload||(h.activeTexture.set(y.TEXTURE1),YE(this.painter,D,F))}}_prepareDemTileUniforms(h,y,A,D){if(!y||y.demTexture==null)return!1;const F=h.tileID.canonical,z=Math.pow(2,y.tileID.canonical.z-F.z),W=D||"";return A[`u_dem_tl${W}`]=[F.x*z%1,F.y*z%1],A[`u_dem_scale${W}`]=z,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let h=0;const y=this._visibleDemTiles.reduce((A,D)=>{if(!D.dem)return A;const F=D.dem.tree.minimums[0];return F>0&&h++,A+F},0);return h?y/h:0}_updateEmptyDEMTexture(){const h=this.painter.context,y=h.gl;h.activeTexture.set(y.TEXTURE2);const A=this._getLoadedAreaMinimum(),D=new i.dL({width:1,height:1},new Float32Array([A]));this._emptyDEMTextureDirty=!1;let F=this._emptyDEMTexture;return F?F.update(D,{premultiply:!1}):F=this._emptyDEMTexture=new i.T(h,D,y.R32F,{premultiply:!1}),F}setupElevationDraw(h,y,A){const D=this.painter.context,F=D.gl,z={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};z.u_exaggeration=this.exaggeration();let W=null,J=null,ne=1;if(A&&A.morphing&&this._useVertexMorphing){const we=A.morphing.srcDemTile,Le=A.morphing.dstDemTile;ne=A.morphing.phase,we&&Le&&(this._prepareDemTileUniforms(h,we,z,"_prev")&&(J=we),this._prepareDemTileUniforms(h,Le,z)&&(W=Le))}const le=we=>we&&we.demTexture&&this.painter.linearFloatFilteringSupported()?F.LINEAR:F.NEAREST;let _e=null;var ye;if(this.enabled?J&&W?(_e=W.demTexture,D.activeTexture.set(F.TEXTURE4),J.demTexture.bind(le(J),F.CLAMP_TO_EDGE),z.u_dem_lerp=ne):(W=this.terrainTileForTile[h.tileID.key],_e=this._prepareDemTileUniforms(h,W,z)?W.demTexture:this.emptyDEMTexture):_e=this.emptyDEMTexture,D.activeTexture.set(F.TEXTURE2),_e&&(z.u_dem_size=(ye=_e).size[0]===1?1:ye.size[0]-2,_e.bind(le(W),F.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(A&&A.useDepthForOcclusion,y,z),A&&A.useMeterToDem&&W){const we=(1<{if(Ue===ts)return;const xs=[t3[ts],"PROJECTION_GLOBE_VIEW"];ut&&xs.push("CUSTOM_ANTIALIASING");const qs=ne.isTileAffectedByFog(es);We=ne.getOrCreateProgram("globeRaster",{defines:xs,overrideFog:qs}),Ue=ts},Et=ne.colorModeForRenderPass(),Nt=new Fr(Ie.LEQUAL,Fr.ReadWrite,ne.depthRangeFor3D);sg.update(we);const Tt=i.dF(st),wt=[i.aF(st.center.lng),i.aJ(st.center.lat)],yt=ne.globeSharedBuffers,Ot=[st.width*i.o.devicePixelRatio,st.height*i.o.devicePixelRatio],Wt=Float32Array.from(st.globeMatrix),Ht={useDenormalizedUpVectorScale:!0};{const es=ne.transform,ts=s3(es.zoom,le.exaggeration(),le.sourceCache._source.tileSize);Ue=-1;const xs=Ie.TRIANGLES;for(const qs of ye){const Yt=_e.getTile(qs),Bt=yn.disabled,as=le.prevTerrainTileForTile[qs.key],Jt=le.terrainTileForTile[qs.key];i2(as,Jt)&&sg.newMorphing(qs.key,as,Jt,we,250),ib(ne,Yt.emissiveTexture),Le.activeTexture.set(Ie.TEXTURE0),Yt.texture&&Yt.texture.bind(Ie.LINEAR,Ie.CLAMP_TO_EDGE);const Is=sg.getMorphValuesForProxy(qs.key),rr=Is?1:0;Is&&Object.assign(Ht,{morphing:{srcDemTile:Is.from,dstDemTile:Is.to,phase:i.dD(Is.phase)}});const yr=i.dG(qs.canonical),Js=i.dH(yr.getCenter().lat),Us=i.dI(qs.canonical,yr,Js,es.worldSize/es._pixelsPerMercatorPixel),Pr=i.bk(i.dJ(qs.canonical)),Cr=ne.emissiveMode==="mrt-fallback"?1:0,hr=e3(es.expandedFarZProjMatrix,Wt,Tt,Pr,i.aj(es.zoom),wt,es.frustumCorners.TL,es.frustumCorners.TR,es.frustumCorners.BR,es.frustumCorners.BL,es.globeCenterInViewSpace,es.globeRadius,Ot,ts,es._farZ,Cr,Us);if(ot(qs,rr),We&&(le.setupElevationDraw(Yt,We,Ht),ne.uploadCommonUniforms(Le,We,qs.toUnwrapped()),yt)){const[br,Kr,Pn]=yt.getGridBuffers(Js,ts!==0);We.draw(ne,xs,Nt,Bt,Et,mn.backCCW,hr,"globe_raster",br,Kr,Pn)}}}if(yt&&(ne.renderDefaultNorthPole||ne.renderDefaultSouthPole)){const es=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];ut&&es.push("CUSTOM_ANTIALIASING"),We=ne.getOrCreateProgram("globeRaster",{defines:es});for(const ts of ye){const{x:xs,y:qs,z:Yt}=ts.canonical,Bt=qs===0,as=qs===(1<br.draw(ne,Ie.TRIANGLES,Nt,yn.disabled,Et,mn.disabled,e3(st.expandedFarZProjMatrix,Us,Us,Pr,0,wt,st.frustumCorners.TL,st.frustumCorners.TR,st.frustumCorners.BR,st.frustumCorners.BL,st.globeCenterInViewSpace,st.globeRadius,Ot,0,st._farZ,Cr),"globe_pole_raster",Kr,rr,yr);le.setupElevationDraw(Js,We,Ht),ne.uploadCommonUniforms(Le,We,ts.toUnwrapped()),Bt&&ne.renderDefaultNorthPole&&hr(We,Jt),as&&ne.renderDefaultSouthPole&&(Us=i.cS(i.bC(),Us,[1,-1,1]),hr(We,Is))}}}})(D,F,z,W,J);else{const ne=D.context,le=ne.gl;let _e,ye;const we=D.shadowRenderer,Le=wy(D,D.longestCutoffRange),Ie=Et=>{if(ye===Et)return;const Nt=[];Nt.push(t3[Et]),Le.shouldRenderCutoff&&Nt.push("RENDER_CUTOFF"),we&&(Nt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),we.useNormalOffset&&Nt.push("NORMAL_OFFSET")),_e=D.getOrCreateProgram("terrainRaster",{defines:Nt}),ye=Et},We=D.colorModeForRenderPass(),Ue=new Fr(le.LEQUAL,Fr.ReadWrite,D.depthRangeFor3D);sg.update(J);const st=D.transform,ut=s3(st.zoom,F.exaggeration(),F.sourceCache._source.tileSize);let ot=[0,0,0];if(we){const Et=D.style.directionalLight,Nt=D.style.ambientLight;Et&&Nt&&(ot=tg(D.style,Et,Nt))}{ye=-1;const Et=le.TRIANGLES,[Nt,Tt]=[F.gridIndexBuffer,F.gridSegments];for(const wt of W){const yt=z.getTile(wt),Ot=yn.disabled,Wt=F.prevTerrainTileForTile[wt.key],Ht=F.terrainTileForTile[wt.key];i2(Wt,Ht)&&sg.newMorphing(wt.key,Wt,Ht,J,250),ib(D,yt.emissiveTexture),ne.activeTexture.set(le.TEXTURE0),yt.texture&&yt.texture.bind(le.LINEAR,le.CLAMP_TO_EDGE);const es=sg.getMorphValuesForProxy(wt.key),ts=es?1:0;let xs;es&&(xs={morphing:{srcDemTile:es.from,dstDemTile:es.to,phase:i.dD(es.phase)}});const qs=D.emissiveMode==="mrt-fallback"?1:0,Yt=cm(wt.projMatrix,a6(wt.canonical,st.renderWorldCopies)?ut/10:ut,ot,qs);if(Ie(ts),!_e)continue;F.setupElevationDraw(yt,_e,xs);const Bt=wt.toUnwrapped();we&&we.setupShadows(Bt,_e),D.uploadCommonUniforms(ne,_e,Bt,null,Le),_e.draw(D,Et,Ue,Ot,We,mn.backCCW,Yt,"terrain_raster",F.gridBuffer,Nt,Tt)}}}}(y,this,this.proxySourceCache,h,this._updateTimestamp),this.renderingToTexture=!0,y.gpuTimingDeferredRenderEnd(),h.splice(0,h.length))}renderBatch(h){if(this._drapedRenderBatches.length===0)return h+1;this.renderingToTexture=!0;const y=this.painter,A=this.painter.context,D=this.proxySourceCache,F=this.proxiedCoords[D.id],z=this._drapedRenderBatches.shift(),W=y.style.order,J=[];this._updateFBOs(y.emissiveMode==="mrt-fallback");let ne=0;for(const le of F){const _e=D.getTileByID(le.proxyTileKey),ye=D.proxyCachedFBO[le.key]?D.proxyCachedFBO[le.key][h]:void 0,we=ye!==void 0?D.renderCache[ye]:this.pool[ne++],Le=ye!==void 0;if(_e.texture=we.tex,_e.emissiveTexture=we.emissiveTex,Le&&!we.dirty){J.push(_e.tileID);continue}A.bindFramebuffer.set(we.fb.framebuffer);const Ie=A.gl;let We;Ie.drawBuffers(y.emissiveMode==="mrt-fallback"?[Ie.COLOR_ATTACHMENT0,Ie.COLOR_ATTACHMENT1]:[Ie.COLOR_ATTACHMENT0]),this.renderedToTile=!1,we.dirty&&(A.clear({color:i.ao.transparent,stencil:0}),we.dirty=!1);for(let Ue=z.start;Ue<=z.end;++Ue){const st=y.style._mergedLayers[W[Ue]];if(st.isHidden(y.transform.zoom))continue;const ut=y.style.getLayerSourceCache(st),ot=ut?this.proxyToSource[le.key][ut.id]:[le];if(!ot)continue;const Et=ot;A.viewport.set([0,0,we.fb.width,we.fb.height]),We!==(ut?ut.id:null)&&(this._setupStencil(we,ot,st,ut),We=ut?ut.id:null),y.renderLayer(y,ut,st,Et)}if(Ie.drawBuffers([Ie.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const Ue of this._pendingGroundEffectLayers){const st=y.style._mergedLayers[W[Ue]];if(st.isHidden(y.transform.zoom))continue;const ut=y.style.getLayerSourceCache(st),ot=ut?this.proxyToSource[le.key][ut.id]:[le];if(!ot)continue;const Et=ot;A.viewport.set([0,0,we.fb.width,we.fb.height]),We!==(ut?ut.id:null)&&(this._setupStencil(we,ot,st,ut),We=ut?ut.id:null),y.renderLayer(y,ut,st,Et)}this.renderedToTile?(we.dirty=!0,J.push(_e.tileID)):Le||--ne,ne===5&&(ne=0,this.renderToBackBuffer(J))}return this.renderToBackBuffer(J),this.renderingToTexture=!1,A.bindFramebuffer.set(null),A.viewport.set([0,0,y.width,y.height]),z.end+1}postRender(){}isLayerOrderingCorrect(h){const y=h.order.length;let A=-1,D=y;for(let F=0;FA}getMinElevationBelowMSL(){let h=0;return this._visibleDemTiles.filter(y=>y.dem).forEach(y=>{h=Math.min(h,y.dem.tree.minimums[0])}),h===0?h:(h-30)*this._exaggeration}raycast(h,y,A){if(!this._visibleDemTiles)return null;const D=this._visibleDemTiles.filter(F=>F.dem).map(F=>{const z=F.tileID,W=1<(F.t!==null?F.t:Number.MAX_VALUE)-(z.t!==null?z.t:Number.MAX_VALUE));for(const F of D){if(F.t==null)return null;const z=F.tile.dem.tree.raycast(F.minx,F.miny,F.maxx,F.maxy,h,y,A);if(z!=null)return z}return null}_createFBO(){const h=this.painter.context,y=h.gl,A=this.drapeBufferSize;h.activeTexture.set(y.TEXTURE0);const D=new i.T(h,{width:A[0],height:A[1],data:null},y.RGBA8);D.bind(y.LINEAR,y.CLAMP_TO_EDGE);const F=h.createFramebuffer(A[0],A[1],1,null);let z;return F.colorAttachment0.set(D.texture),this._emissiveTexture&&(z=new i.T(h,{width:A[0],height:A[1],data:null},y.R8),z.bind(y.LINEAR,y.CLAMP_TO_EDGE),F.createColorAttachment(h,1),F.colorAttachment1.set(z.texture)),F.depthAttachment=new $R(h,F.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=h.createRenderbuffer(h.gl.DEPTH_STENCIL,A[0],A[1]),this._stencilRef=0,F.depthAttachment.set(this._sharedDepthStencil),h.clear({stencil:0})):F.depthAttachment.set(this._sharedDepthStencil),h.extTextureFilterAnisotropic&&y.texParameterf(y.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax),{fb:F,tex:D,emissiveTex:z,dirty:!1}}_updateFBOs(h){if(this._emissiveTexture!==h){for(const y of this.pool)this._updateFBO(y,h);for(const y of this.proxySourceCache.renderCache)this._updateFBO(y,h);this._emissiveTexture=h}}_updateFBO(h,y){const A=h.fb,D=this.painter.context,F=D.gl,z=this.drapeBufferSize;if(y){const W=new i.T(D,{width:z[0],height:z[1],data:null},F.R8);W.bind(F.LINEAR,F.CLAMP_TO_EDGE),h.emissiveTex=W,A.createColorAttachment(D,1),A.colorAttachment1.set(W.texture)}else h.emissiveTex=void 0,A.removeColorAttachment(D,1);h.dirty=!0}_initFBOPool(){for(;this.pool.length{const y=this._style._mergedLayers[h],A=y.isHidden(this.painter.transform.zoom);return y.type==="hillshade"||y.type==="custom"?!A&&y.shouldRedrape():!A&&y.hasTransition()})}_clearLineLayersFromRenderCache(){let h=!1;for(const A of this._style.getSources())if(A instanceof Df){h=!0;break}if(!h)return;const y={};for(let A=0;AJ>W.end)||i.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=A}_setupRenderCache(h){const y=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,y.renderCache.length>y.renderCachePool.length){const z=Object.values(y.proxyCachedFBO);y.proxyCachedFBO={};for(let W=0;W=0;z--){const W=A[z];if(y.getTileByID(W.key),y.proxyCachedFBO[W.key]!==void 0){const J=h[W.key],ne=this.proxyToSource[W.key];let le=0;for(const _e in ne){const ye=ne[_e],we=J[_e];if(!we||we.length!==ye.length||ye.some((Le,Ie)=>Le!==we[Ie]||D[_e]&&D[_e].hasOwnProperty(Le.key))){le=-1;break}++le}for(const _e in y.proxyCachedFBO[W.key])y.renderCache[y.proxyCachedFBO[W.key][_e]].dirty=le<0||le!==Object.values(J).length}}const F=[...this._drapedRenderBatches];F.sort((z,W)=>W.end-W.start-(z.end-z.start));for(const z of F)for(const W of A){if(y.proxyCachedFBO[W.key])continue;let J=y.renderCachePool.pop();J===void 0&&y.renderCache.length<50&&(J=y.renderCache.length,y.renderCache.push(this._createFBO())),J!==void 0&&(y.proxyCachedFBO[W.key]={},y.proxyCachedFBO[W.key][z.start]=J,y.renderCache[J].dirty=!0)}this._tilesDirty={}}_setupStencil(h,y,A,D){if(!D||!this._sourceTilesOverlap[D.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const F=this.painter.context,z=F.gl;if(y.length<=1)return void(this._overlapStencilType=!1);let W;if(A.isTileClipped())W=y.length,this._overlapStencilMode.test={func:z.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(y[0].overscaledZ>y[y.length-1].overscaledZ))return void(this._overlapStencilType=!1);W=1,this._overlapStencilMode.test={func:z.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+W>255&&(F.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=W,this._overlapStencilMode.ref=this._stencilRef,A.isTileClipped()&&this._renderTileClippingMasks(y,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(h){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[h.key]),this._overlapStencilMode):yn.disabled}_renderTileClippingMasks(h,y){const A=this.painter,D=this.painter.context,F=D.gl;A._tileClippingMaskIDs={},D.setColorMode(Hn.disabled),D.setDepthMode(Fr.disabled);const z=A.getOrCreateProgram("clippingMask");for(const W of h){const J=A._tileClippingMaskIDs[W.key]=--y;z.draw(A,F.TRIANGLES,Fr.disabled,new yn({func:F.ALWAYS,mask:0},J,255,F.KEEP,F.KEEP,F.REPLACE),Hn.disabled,mn.disabled,o2(W.projMatrix),"$clipping",A.tileExtentBuffer,A.quadTriangleIndexBuffer,A.tileExtentSegments)}}pointCoordinate(h){const y=this.painter.transform;if(h.x<0||h.x>y.width||h.y<0||h.y>y.height)return null;const A=[h.x,h.y,1,1];i.aC(A,A,y.pixelMatrixInverse),i.cK(A,A,1/A[3]),A[0]/=y.worldSize,A[1]/=y.worldSize;const D=y._camera.position,F=i.cf(1,y.center.lat),z=[D[0],D[1],D[2]/F,0],W=i.da([],A.slice(0,3),z);i.aw(W,W);const J=this.raycast(z,W,this._exaggeration);return J!==null&&J?(i.bH(z,z,W,J),z[3]=z[2],z[2]*=F,z):null}_setupProxiedCoordsForOrtho(h,y,A){if(h.getSource()instanceof i.aU)return this._setupProxiedCoordsForImageSource(h,y,A);this._findCoveringTileCache[h.id]=this._findCoveringTileCache[h.id]||{};const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords;for(let J=0;Jle.overscaledZ-ne.overscaledZ)}_setupProxiedCoordsForImageSource(h,y,A){if(!h.getSource().loaded())return;const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords,z=h.getSource(),W=z.tileID;if(!W)return;const J=new i.P(W.x,W.y)._div(1<(_e.min.x=Math.min(_e.min.x,ye.x-J.x),_e.min.y=Math.min(_e.min.y,ye.y-J.y),_e.max.x=Math.max(_e.max.x,ye.x-J.x),_e.max.y=Math.max(_e.max.y,ye.y-J.y),_e),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),le=(_e,ye)=>{const we=_e.wrap+_e.canonical.x/(1<<_e.canonical.z),Le=_e.canonical.y/(1<<_e.canonical.z),Ie=i.al/(1<<_e.canonical.z),We=ye.wrap+ye.canonical.x/(1<We+ne.max.x||Le+IeUe+ne.max.y};for(let _e=0;_ez.key===y.tileID.key);if(F)return F}if(y.tileID.key!==h.key){const F=h.canonical.z-y.tileID.canonical.z;let z,W,J;D=i.bC();const ne=y.tileID.wrap-h.wrap<0?(z=i.al>>F,W=z*((y.tileID.canonical.x<=_e){const ye=h.canonical.z-_e;y.getSource().reparseOverscaled?(W=Math.max(h.canonical.z+2,y.transform.tileZoom),z=new i.aQ(W,h.wrap,_e,h.canonical.x>>ye,h.canonical.y>>ye)):ye!==0&&(W=_e,z=new i.aQ(W,h.wrap,_e,h.canonical.x>>ye,h.canonical.y>>ye))}z.key!==h.key&&(ne.push(z.key),A=y.getTile(z))}const le=_e=>{ne.forEach(ye=>{D[ye]=_e}),ne.length=0};for(W-=1;W>=J&&(!A||!A.hasData());W--){A&&le(A.tileID.key);const _e=z.calculateScaledKey(W);if(A=y.getTileByID(_e),A&&A.hasData())break;const ye=D[_e];if(ye===null)break;ye===void 0?ne.push(_e):A=y.getTileByID(ye)}return le(A?A.tileID.key:null),A&&A.hasData()?A:null}findDEMTileFor(h){return this.enabled?this._findTileCoveringTileID(h,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(h,y){let A=this._tilesDirty[h];A||(A=this._tilesDirty[h]={}),A[y.key]=!0}}function ob(T,h,y){const A=function(W,J,ne){const le=i.bJ(J,W),_e=i.bJ(ne,[.2126,.7152,.0722]),ye=(Le,Ie,We)=>(1-We)*Le+We*Ie,we=ye(1-.3*Math.min(_e,1),1,Math.min(le+1,1));return ye(.92,1,Math.asin(i.aA(J[2],-1,1))/Math.PI+.5)*we}(T,[0,0,1],h),D=[0,0,0];i.c5(D,y.slice(0,3),A);const F=[0,0,0];i.c5(F,h.slice(0,3),T[2]);const z=[0,0,0];return i.d8(z,D,F),i.db(z)}const Ome=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Rme=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class qR{static cacheKey(h,y,A,D){const F=[y];D&&F.push(D.cacheKey);for(const z of A)h.usedDefines.has(z)&&F.push(z);return F.join("/")}constructor(h,y,A,D,F,z){const W=h.gl;this.program=W.createProgram(),this.configuration=D,this.name=y,this.fixedDefines=[...z];const J=`#version 300 es ${(D?D.defines():[]).concat(z.map(Ie=>`#define ${Ie}`)).join(` `)}`,ne=[J,Cme];for(const Ie of A.fragmentIncludes)ne.push(Sy[Ie]);ne.push(A.fragmentSource);const le=ne.join(` `),_e=[J,PR];for(const Ie of A.vertexIncludes)_e.push(Sy[Ie]);this.forceManualRenderingForInstanceIDShaders=h.forceManualRenderingForInstanceIDShaders&&A.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&_e.push("uniform int u_instanceID;"),_e.push(A.vertexSource);let ye=_e.join(` `);this.forceManualRenderingForInstanceIDShaders&&(ye=ye.replaceAll("gl_InstanceID","u_instanceID"));const we=W.createShader(W.FRAGMENT_SHADER);if(W.isContextLost())return void(this.failedToCreate=!0);W.shaderSource(we,le),W.compileShader(we),W.attachShader(this.program,we);const Le=W.createShader(W.VERTEX_SHADER);W.isContextLost()?this.failedToCreate=!0:(W.shaderSource(Le,ye),W.compileShader(Le),W.attachShader(this.program,Le),this.attributes={},W.linkProgram(this.program),W.deleteShader(Le),W.deleteShader(we),this.fixedUniforms=F(h),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=D?D.getUniforms(h):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(Ie=>({u_instanceID:new i.ch(Ie)}))(h)),(z.includes("TERRAIN")||y.includes("symbol")||y.includes("circle"))&&(this.terrainUniforms=(Ie=>({u_dem:new i.ch(Ie),u_dem_prev:new i.ch(Ie),u_dem_tl:new i.ck(Ie),u_dem_scale:new i.cj(Ie),u_dem_tl_prev:new i.ck(Ie),u_dem_scale_prev:new i.cj(Ie),u_dem_size:new i.cj(Ie),u_dem_lerp:new i.cj(Ie),u_exaggeration:new i.cj(Ie),u_depth:new i.ch(Ie),u_depth_size_inv:new i.ck(Ie),u_depth_range_unpack:new i.ck(Ie),u_occluder_half_size:new i.cj(Ie),u_occlusion_depth_offset:new i.cj(Ie),u_meter_to_dem:new i.cj(Ie),u_label_plane_matrix_inv:new i.cl(Ie)}))(h)),z.includes("GLOBE")&&(this.globeUniforms=(Ie=>({u_tile_tl_up:new i.ci(Ie),u_tile_tr_up:new i.ci(Ie),u_tile_br_up:new i.ci(Ie),u_tile_bl_up:new i.ci(Ie),u_tile_up_scale:new i.cj(Ie)}))(h)),z.includes("FOG")&&(this.fogUniforms=(Ie=>({u_fog_matrix:new i.cl(Ie),u_fog_range:new i.ck(Ie),u_fog_color:new i.d3(Ie),u_fog_horizon_blend:new i.cj(Ie),u_fog_vertical_limit:new i.ck(Ie),u_fog_temporal_offset:new i.cj(Ie),u_frustum_tl:new i.ci(Ie),u_frustum_tr:new i.ci(Ie),u_frustum_br:new i.ci(Ie),u_frustum_bl:new i.ci(Ie),u_globe_pos:new i.ci(Ie),u_globe_radius:new i.cj(Ie),u_globe_transition:new i.cj(Ie),u_is_globe:new i.ch(Ie),u_viewport:new i.ck(Ie)}))(h)),z.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(Ie=>({u_cutoff_params:new i.d3(Ie)}))(h)),z.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(Ie=>({u_lighting_ambient_color:new i.ci(Ie),u_lighting_directional_dir:new i.ci(Ie),u_lighting_directional_color:new i.ci(Ie),u_ground_radiance:new i.ci(Ie)}))(h)),z.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(Ie=>({u_light_matrix_0:new i.cl(Ie),u_light_matrix_1:new i.cl(Ie),u_fade_range:new i.ck(Ie),u_shadow_normal_offset:new i.ci(Ie),u_shadow_intensity:new i.cj(Ie),u_shadow_texel_size:new i.cj(Ie),u_shadow_map_resolution:new i.cj(Ie),u_shadow_direction:new i.ci(Ie),u_shadow_bias:new i.ci(Ie),u_shadowmap_0:new i.ch(Ie),u_shadowmap_1:new i.ch(Ie)}))(h)))}getAttributeLocation(h,y){let A=this.attributes[y];return A===void 0&&(A=this.attributes[y]=h.getAttribLocation(this.program,y)),A}setTerrainUniformValues(h,y){if(!this.terrainUniforms)return;const A=this.terrainUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D]&&A[D].set(this.program,D,y[D])}}setGlobeUniformValues(h,y){if(!this.globeUniforms)return;const A=this.globeUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D]&&A[D].set(this.program,D,y[D])}}setFogUniformValues(h,y){if(!this.fogUniforms)return;const A=this.fogUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D].set(this.program,D,y[D])}}setCutoffUniformValues(h,y){if(!this.cutoffUniforms)return;const A=this.cutoffUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D].set(this.program,D,y[D])}}setLightsUniformValues(h,y){if(!this.lightsUniforms)return;const A=this.lightsUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D].set(this.program,D,y[D])}}setShadowUniformValues(h,y){if(this.failedToCreate||!this.shadowUniforms)return;const A=this.shadowUniforms;h.program.set(this.program);for(const D in y)A[D].set(this.program,D,y[D])}_drawDebugWireframe(h,y,A,D,F,z,W,J,ne,le){const _e=h.options.wireframe;if(_e.terrain===!1&&_e.layers2D===!1&&_e.layers3D===!1)return;const ye=h.context;if(!(!(!_e.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!_e.layers2D||h._terrain&&h._terrain.renderingToTexture||!Ome.includes(this.name))||!(!_e.layers3D||!Rme.includes(this.name))))return;const we=ye.gl,Le=h.wireframeDebugCache.getLinesFromTrianglesBuffer(h.frameCounter,F,ye);if(!Le)return;const Ie=[...this.fixedDefines,"DEBUG_WIREFRAME"],We=h.getOrCreateProgram(this.name,{config:this.configuration,defines:Ie});ye.program.set(We.program);const Ue=(ot,Et,Nt)=>{if(Et[ot]&&Nt[ot])for(const Tt in Et[ot])Nt[ot][Tt]&&Nt[ot][Tt].set(Nt.program,Tt,Et[ot][Tt].current)};ne&&ne.setUniforms(We.program,ye,We.binderUniforms,W,{zoom:J}),Ue("fixedUniforms",this,We),Ue("terrainUniforms",this,We),Ue("globeUniforms",this,We),Ue("fogUniforms",this,We),Ue("lightsUniforms",this,We),Ue("shadowUniforms",this,We),Le.bind(),ye.setColorMode(new Hn([we.ONE,we.ONE_MINUS_SRC_ALPHA,we.ZERO,we.ONE],i.ao.transparent,[!0,!0,!0,!1])),ye.setDepthMode(new Fr(y.func===we.LESS?we.LEQUAL:y.func,Fr.ReadOnly,y.range)),ye.setStencilMode(yn.disabled);const st=3*z.primitiveLength*2,ut=3*z.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const ot=le||1;for(let Et=0;Et1?we.drawElementsInstanced(we.LINES,st,we.UNSIGNED_SHORT,ut,le):we.drawElements(we.LINES,st,we.UNSIGNED_SHORT,ut);F.bind(),ye.program.set(this.program),ye.setDepthMode(y),ye.setStencilMode(A),ye.setColorMode(D)}checkUniforms(h,y,A){if(this.fixedDefines.includes(y)){for(const D of Object.keys(A))if(!A[D].initialized)throw new Error(`Program '${this.name}', from draw '${h}': uniform ${D} not set but required by ${y} being defined`)}}draw(h,y,A,D,F,z,W,J,ne,le,_e,ye,we,Le,Ie,We){const Ue=h.context,st=Ue.gl;if(this.failedToCreate)return;Ue.program.set(this.program),Ue.setDepthMode(A),Ue.setStencilMode(D),Ue.setColorMode(F),Ue.setCullFace(z);for(const[wt,yt]of this.fixedUniformsEntries)yt.set(this.program,wt,W[wt]);Le&&Le.setUniforms(this.program,Ue,this.binderUniforms,ye,{zoom:we});const ut={[st.POINTS]:1,[st.LINES]:2,[st.TRIANGLES]:3,[st.LINE_STRIP]:1}[y];this.checkUniforms(J,"RENDER_SHADOWS",this.shadowUniforms);const ot=Ie||[],Et=Le?Le.getPaintVertexBuffers():[],Nt=y===st.TRIANGLES&&le,Tt=We&&We>0?1:void 0;for(const wt of _e.get()){const yt=wt.vaos||(wt.vaos={});if((yt[J]||(yt[J]=new Mme)).bind(Ue,this,ne,Et,le,wt.vertexOffset,ot,Tt),this.forceManualRenderingForInstanceIDShaders){const Ot=We||1;for(let Wt=0;Wt1?st.drawElementsInstanced(y,wt.primitiveLength*ut,st.UNSIGNED_SHORT,wt.primitiveOffset*ut*2,We):le?st.drawElements(y,wt.primitiveLength*ut,st.UNSIGNED_SHORT,wt.primitiveOffset*ut*2):st.drawArrays(y,wt.vertexOffset,wt.vertexLength);Nt&&this._drawDebugWireframe(h,A,D,F,le,wt,ye,we,Le,We)}}}function UR(T,h,y=0){const A=Math.pow(2,h.tileID.overscaledZ),D=h.tileSize*Math.pow(2,T.transform.tileZoom)/A,F=D*(h.tileID.canonical.x+h.tileID.wrap*A),z=D*h.tileID.canonical.y;return{u_image:0,u_texsize:h.imageAtlasTexture?h.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/i.ay(h,1,T.transform.tileZoom),u_pixel_coord_upper:[F>>16,z>>16],u_pixel_coord_lower:[65535&F,65535&z],u_pattern_transition:y}}const n3={terrain:0,flat:1},Fme=i.bC(),a3=(T,h,y,A,D,F,z,W,J,ne,le,_e,ye,we,Le,Ie,We,Ue)=>{const st=h.style.light,ut=st.properties.get("position"),ot=[ut.x,ut.y,ut.z],Et=i.dO();st.properties.get("anchor")==="viewport"&&(i.dP(Et,-h.transform.angle),i.dQ(ot,ot,Et));const Nt=st.properties.get("color").toPremultipliedRenderColor(null),Tt=h.transform,wt={u_matrix:T,u_lightpos:ot,u_lightintensity:st.properties.get("intensity"),u_lightcolor:[Nt.r,Nt.g,Nt.b],u_vertical_gradient:+y,u_opacity:A,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Fme,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:n3[ne],u_base_type:n3[le],u_ao:D,u_edge_radius:F,u_width_scale:z,u_flood_light_color:Le,u_vertical_scale:Ie,u_flood_light_intensity:We,u_ground_shadow_factor:Ue};return Tt.projection.name==="globe"&&(wt.u_tile_id=[W.canonical.x,W.canonical.y,1<({u_matrix:T,u_edge_radius:h,u_width_scale:y,u_vertical_scale:A,u_height_type:n3[D],u_base_type:n3[F]}),VR=(T,h,y,A,D,F,z,W,J,ne,le,_e,ye,we,Le,Ie,We,Ue)=>{const st=a3(T,h,y,A,D,F,z,W,ne,le,_e,ye,we,Le,Ie,We,1,[0,0,0]),ut={u_height_factor:-Math.pow(2,W.overscaledZ)/J.tileSize/8};return Object.assign(st,UR(h,J,Ue),ut)},lb=(T,h,y,A,D,F,z,W,J,ne,le)=>({u_matrix:h,u_opacity:y,u_ao_pass:A?1:0,u_meter_to_tile:D,u_ao:F,u_flood_light_intensity:z,u_flood_light_color:W,u_attenuation:J,u_edge_radius:ne,u_fb:0,u_fb_size:le,u_dynamic_offset:1}),d6=(T,h,y)=>({u_matrix:T,u_emissive_strength:h,u_ground_shadow_factor:y}),u6=(T,h,y,A,D,F=0)=>Object.assign(d6(T,h,D),UR(y,A,F)),HR=(T,h,y,A)=>({u_matrix:T,u_world:y,u_emissive_strength:h,u_ground_shadow_factor:A}),h6=(T,h,y,A,D,F,z=0)=>Object.assign(u6(T,h,y,A,F,z),{u_world:D}),My=(T,h)=>({u_matrix:T,u_ground_shadow_factor:h}),nv=(T,h,y,A,D)=>({u_matrix:T,u_camera_pos:[h[0],h[1],h[2]],u_depth_bias:y,u_height_scale:A,u_reset_depth:D}),i3=(T,h,y,A,D,F,z,W,J)=>({u_matrix:T,u_normal_matrix:h,u_opacity:y,u_faux_facade_ao_intensity:A,u_camera_pos:D,u_tile_to_meter:F,u_facade_emissive_chance:z,u_flood_light_color:W,u_flood_light_intensity:J}),WR=T=>({u_matrix:T}),Ty=T=>({u_matrix:T}),m6=(T,h,y,A,D,F,z,W)=>{const J=i.al/F.tileSize;return{u_matrix:T,u_inv_rot_matrix:h,u_camera_to_center_distance:y.getCameraToCenterDistance(W),u_extrude_scale:[y.pixelsToGLUnits[0]/J,y.pixelsToGLUnits[1]/J],u_zoom_transition:A,u_tile_id:z,u_merc_center:D}},c2=(T,h,y=1)=>({u_matrix:T,u_color:h,u_overlay:0,u_overlay_scale:y}),GR=i.bC(),KR=(T,h,y,A,D,F,z)=>{const W=T.transform,J=W.projection.name==="globe",ne=J?i.dR(W.zoom,h.canonical)*W._pixelsPerMercatorPixel:i.ay(y,1,F),le={u_matrix:h.projMatrix,u_extrude_scale:ne,u_intensity:z,u_inv_rot_matrix:GR,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(J){le.u_inv_rot_matrix=A,le.u_merc_center=D,le.u_tile_id=[h.canonical.x,h.canonical.y,1<({u_matrix:T,u_normalize_matrix:h,u_globe_matrix:y,u_merc_matrix:A,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:ne,u_fade_t:le.mix,u_opacity:le.opacity*_e.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:_e.paint.get("raster-brightness-min"),u_brightness_high:_e.paint.get("raster-brightness-max"),u_saturation_factor:i.dT(_e.paint.get("raster-saturation")),u_contrast_factor:i.dS(_e.paint.get("raster-contrast")),u_spin_weights:YR(_e.paint.get("raster-hue-rotate")),u_perspective_transform:ye,u_raster_elevation:we,u_zoom_transition:z,u_merc_center:W,u_cutoff_params:J,u_colorization_mix:o3(i.dU,Ie,Ue),u_colorization_offset:l3(i.dU,We,Ue),u_color_ramp:Le,u_texture_offset:[ut/(st+2*ut),st/(st+2*ut)],u_texture_res:[st+2*ut,st+2*ut],u_emissive_strength:ot});function YR(T){T*=Math.PI/180;const h=Math.sin(T),y=Math.cos(T);return[(2*y+1)/3,(-Math.sqrt(3)*h-y+1)/3,(Math.sqrt(3)*h-y+1)/3]}const qf=.05,zme=(T,h,y,A,D,F,z,W,J,ne,le,_e)=>({u_matrix:T,u_normalize_matrix:h,u_globe_matrix:y,u_merc_matrix:A,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:ne,u_fade_t:le.mix,u_opacity:le.opacity,u_image0:0,u_image1:1,u_raster_elevation:_e,u_zoom_transition:z,u_merc_center:W,u_cutoff_params:J}),Bme=(T,h,y,A,D,F,z,W,J,ne)=>({u_particle_texture:T,u_particle_texture_side_len:h,u_tile_offset:y,u_velocity:A,u_color_ramp:F,u_velocity_res:D,u_max_speed:z,u_uv_offset:W,u_data_scale:[255*J[0],255*J[1]],u_data_offset:ne,u_particle_pos_scale:1.1,u_particle_pos_offset:[qf,qf]}),XR=(T,h,y,A,D,F,z,W,J,ne)=>({u_particle_texture:T,u_particle_texture_side_len:h,u_velocity:y,u_velocity_res:A,u_max_speed:D,u_speed_factor:F,u_reset_rate:z,u_rand_seed:Math.random(),u_uv_offset:W,u_data_scale:[255*J[0],255*J[1]],u_data_offset:ne,u_particle_pos_scale:1.1,u_particle_pos_offset:[qf,qf]}),QR=i.bC(),c3=(T,h,y,A,D,F,z,W,J,ne,le,_e,ye,we,Le,Ie,We,Ue,st,ut,ot,Et,Nt,Tt)=>{const wt=D.transform,yt={u_is_size_zoom_constant:+(T==="constant"||T==="source"),u_is_size_feature_constant:+(T==="constant"||T==="camera"),u_size_t:h?h.uSizeT:0,u_size:h?h.uSize:0,u_camera_to_center_distance:wt.getCameraToCenterDistance(st),u_rotate_symbol:+y,u_aspect_ratio:wt.width/wt.height,u_fade_change:D.options.fadeDuration?D.symbolFadeChange:1,u_matrix:F,u_label_plane_matrix:z,u_coord_matrix:W,u_is_text:+ne,u_elevation_from_sea:J?1:0,u_pitch_with_map:+A,u_texsize:le,u_texsize_icon:_e,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:QR,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:QR,u_up_vector:[0,-1,0],u_color_adj_mat:Et,u_icon_transition:Nt||0,u_gamma_scale:A?D.transform.getCameraToCenterDistance(st)*Math.cos(D.terrain?0:D.transform._pitch):1,u_device_pixel_ratio:i.o.devicePixelRatio,u_is_halo:1,u_scale_factor:Tt||1,u_ground_shadow_factor:ut,u_inv_matrix:i.bl(i.bC(),z),u_normal_scale:ot,u_lutTexture:Gc.LUT};return st.name==="globe"&&(yt.u_tile_id=[we.canonical.x,we.canonical.y,1<({u_matrix:T,u_emissive_strength:h,u_opacity:y,u_color:A}),Ay=(T,h,y,A,D,F,z,W,J)=>Object.assign(function(ne,le,_e,ye,we,Le){const{width:Ie,height:We}=ye.imageManager.getPixelSize(le),Ue=Math.pow(2,Le.tileID.overscaledZ),st=Le.tileSize*Math.pow(2,ye.transform.tileZoom)/Ue,ut=st*(Le.tileID.canonical.x+Le.tileID.wrap*Ue),ot=st*Le.tileID.canonical.y;return{u_image:0,u_pattern_tl:_e.tl,u_pattern_br:_e.br,u_texsize:[Ie,We],u_pattern_size:_e.displaySize,u_pattern_units_to_pixels:we?[ye.transform.width,-1*ye.transform.height]:[1/i.ay(Le,1,ye.transform.tileZoom),1/i.ay(Le,1,ye.transform.tileZoom)],u_pixel_coord_upper:[ut>>16,ot>>16],u_pixel_coord_lower:[65535&ut,65535&ot]}}(0,F,z,A,W,J),{u_matrix:T,u_emissive_strength:h,u_opacity:y}),cb=new Float32Array(i.bA([])),av=(T,h,y,A,D,F,z,W,J,ne,le,_e,ye,we=[0,0,0],Le,Ie,We)=>{const Ue=D.style.light,st=Ue.properties.get("position"),ut=[-st.x,-st.y,st.z],ot=i.dO();Ue.properties.get("anchor")==="viewport"&&(i.dP(ot,-D.transform.angle),i.dQ(ut,ut,ot));const Et=le.alphaMode==="MASK",Nt=Ue.properties.get("color").toNonPremultipliedRenderColor(null),Tt=ye.paint.get("model-ambient-occlusion-intensity"),wt=ye.paint.get("model-color").constantOr(i.ao.white).toNonPremultipliedRenderColor(null);return wt.a=ye.paint.get("model-color-mix-intensity").constantOr(0),We&&(wt.r=We[0],wt.g=We[1],wt.b=We[2],wt.a=We[3]),Ie&&(wt.r=Ie.color.r,wt.g=Ie.color.g,wt.b=Ie.color.b,wt.a=Ie.colorMix,_e=Ie.emissionStrength,F*=Ie.opacity),{u_matrix:T,u_lighting_matrix:h,u_normal_matrix:y,u_node_matrix:A||cb,u_lightpos:ut,u_lightintensity:Ue.properties.get("intensity"),u_lightcolor:[Nt.r,Nt.g,Nt.b],u_camera_pos:we,u_opacity:F,u_baseTextureIsAlpha:0,u_alphaMask:+Et,u_alphaCutoff:le.alphaCutoff,u_baseColorFactor:z.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:W.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:J,u_roughnessFactor:ne,u_baseColorTexture:Gc.BaseColor,u_metallicRoughnessTexture:Gc.MetallicRoughness,u_normalTexture:Gc.Normal,u_occlusionTexture:Gc.Occlusion,u_emissionTexture:Gc.Emission,u_lutTexture:Gc.LUT,u_color_mix:wt.toArray01(),u_aoIntensity:Tt,u_emissive_strength:_e,u_occlusionTextureTransform:Le||[0,0,0,0]}},p6=(T,h=cb,y=cb)=>({u_matrix:T,u_instance:h,u_node_matrix:y}),d3={fillExtrusion:T=>({u_matrix:new i.cl(T),u_lightpos:new i.ci(T),u_lightintensity:new i.cj(T),u_lightcolor:new i.ci(T),u_vertical_gradient:new i.cj(T),u_opacity:new i.cj(T),u_edge_radius:new i.cj(T),u_width_scale:new i.cj(T),u_ao:new i.ck(T),u_height_type:new i.ch(T),u_base_type:new i.ch(T),u_tile_id:new i.ci(T),u_zoom_transition:new i.cj(T),u_inv_rot_matrix:new i.cl(T),u_merc_center:new i.ck(T),u_up_dir:new i.ci(T),u_height_lift:new i.cj(T),u_flood_light_color:new i.ci(T),u_vertical_scale:new i.cj(T),u_flood_light_intensity:new i.cj(T),u_ground_shadow_factor:new i.ci(T)}),fillExtrusionDepth:T=>({u_matrix:new i.cl(T),u_edge_radius:new i.cj(T),u_width_scale:new i.cj(T),u_vertical_scale:new i.cj(T),u_height_type:new i.ch(T),u_base_type:new i.ch(T)}),fillExtrusionPattern:T=>({u_matrix:new i.cl(T),u_lightpos:new i.ci(T),u_lightintensity:new i.cj(T),u_lightcolor:new i.ci(T),u_vertical_gradient:new i.cj(T),u_height_factor:new i.cj(T),u_edge_radius:new i.cj(T),u_width_scale:new i.cj(T),u_ao:new i.ck(T),u_height_type:new i.ch(T),u_base_type:new i.ch(T),u_tile_id:new i.ci(T),u_zoom_transition:new i.cj(T),u_inv_rot_matrix:new i.cl(T),u_merc_center:new i.ck(T),u_up_dir:new i.ci(T),u_height_lift:new i.cj(T),u_image:new i.ch(T),u_texsize:new i.ck(T),u_pixel_coord_upper:new i.ck(T),u_pixel_coord_lower:new i.ck(T),u_tile_units_to_pixels:new i.cj(T),u_opacity:new i.cj(T),u_pattern_transition:new i.cj(T)}),fillExtrusionGroundEffect:T=>({u_matrix:new i.cl(T),u_opacity:new i.cj(T),u_ao_pass:new i.cj(T),u_meter_to_tile:new i.cj(T),u_ao:new i.ck(T),u_flood_light_intensity:new i.cj(T),u_flood_light_color:new i.ci(T),u_attenuation:new i.cj(T),u_edge_radius:new i.cj(T),u_fb:new i.ch(T),u_fb_size:new i.cj(T),u_dynamic_offset:new i.cj(T)}),fill:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_ground_shadow_factor:new i.ci(T)}),fillPattern:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_image:new i.ch(T),u_texsize:new i.ck(T),u_pixel_coord_upper:new i.ck(T),u_pixel_coord_lower:new i.ck(T),u_tile_units_to_pixels:new i.cj(T),u_ground_shadow_factor:new i.ci(T),u_pattern_transition:new i.cj(T)}),fillOutline:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_world:new i.ck(T),u_ground_shadow_factor:new i.ci(T)}),fillOutlinePattern:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_world:new i.ck(T),u_image:new i.ch(T),u_texsize:new i.ck(T),u_pixel_coord_upper:new i.ck(T),u_pixel_coord_lower:new i.ck(T),u_tile_units_to_pixels:new i.cj(T),u_ground_shadow_factor:new i.ci(T),u_pattern_transition:new i.cj(T)}),building:T=>({u_matrix:new i.cl(T),u_normal_matrix:new i.cl(T),u_opacity:new i.cj(T),u_faux_facade_ao_intensity:new i.cj(T),u_camera_pos:new i.ci(T),u_tile_to_meter:new i.cj(T),u_facade_emissive_chance:new i.cj(T),u_flood_light_color:new i.ci(T),u_flood_light_intensity:new i.cj(T)}),buildingBloom:T=>({u_matrix:new i.cl(T)}),buildingDepth:T=>({u_matrix:new i.cl(T)}),elevatedStructuresDepth:T=>({u_matrix:new i.cl(T),u_depth_bias:new i.cj(T)}),elevatedStructures:T=>({u_matrix:new i.cl(T),u_ground_shadow_factor:new i.ci(T)}),elevatedStructuresDepthReconstruct:T=>({u_matrix:new i.cl(T),u_camera_pos:new i.ci(T),u_depth_bias:new i.cj(T),u_height_scale:new i.cj(T),u_reset_depth:new i.cj(T)}),circle:i.dY,collisionBox:T=>({u_matrix:new i.cl(T),u_inv_rot_matrix:new i.cl(T),u_camera_to_center_distance:new i.cj(T),u_extrude_scale:new i.ck(T),u_zoom_transition:new i.cj(T),u_merc_center:new i.ck(T),u_tile_id:new i.ci(T)}),collisionCircle:T=>({u_matrix:new i.cl(T),u_inv_matrix:new i.cl(T),u_camera_to_center_distance:new i.cj(T),u_viewport_size:new i.ck(T)}),debug:T=>({u_color:new i.dB(T),u_matrix:new i.cl(T),u_overlay:new i.ch(T),u_overlay_scale:new i.cj(T)}),clippingMask:T=>({u_matrix:new i.cl(T)}),heatmap:T=>({u_extrude_scale:new i.cj(T),u_intensity:new i.cj(T),u_matrix:new i.cl(T),u_inv_rot_matrix:new i.cl(T),u_merc_center:new i.ck(T),u_tile_id:new i.ci(T),u_zoom_transition:new i.cj(T),u_up_dir:new i.ci(T)}),heatmapTexture:T=>({u_image:new i.ch(T),u_color_ramp:new i.ch(T),u_opacity:new i.cj(T)}),hillshade:T=>({u_matrix:new i.cl(T),u_image:new i.ch(T),u_latrange:new i.ck(T),u_light:new i.ck(T),u_shadow:new i.dB(T),u_highlight:new i.dB(T),u_emissive_strength:new i.cj(T),u_accent:new i.dB(T)}),hillshadePrepare:T=>({u_matrix:new i.cl(T),u_image:new i.ch(T),u_dimension:new i.ck(T),u_zoom:new i.cj(T)}),line:i.dX,linePattern:i.dW,raster:T=>({u_matrix:new i.cl(T),u_normalize_matrix:new i.cl(T),u_globe_matrix:new i.cl(T),u_merc_matrix:new i.cl(T),u_grid_matrix:new i.dC(T),u_tl_parent:new i.ck(T),u_scale_parent:new i.cj(T),u_fade_t:new i.cj(T),u_opacity:new i.cj(T),u_image0:new i.ch(T),u_image1:new i.ch(T),u_brightness_low:new i.cj(T),u_brightness_high:new i.cj(T),u_saturation_factor:new i.cj(T),u_contrast_factor:new i.cj(T),u_spin_weights:new i.ci(T),u_perspective_transform:new i.ck(T),u_raster_elevation:new i.cj(T),u_zoom_transition:new i.cj(T),u_merc_center:new i.ck(T),u_cutoff_params:new i.d3(T),u_colorization_mix:new i.d3(T),u_colorization_offset:new i.cj(T),u_color_ramp:new i.ch(T),u_texture_offset:new i.ck(T),u_texture_res:new i.ck(T),u_emissive_strength:new i.cj(T)}),rasterParticle:T=>({u_matrix:new i.cl(T),u_normalize_matrix:new i.cl(T),u_globe_matrix:new i.cl(T),u_merc_matrix:new i.cl(T),u_grid_matrix:new i.dC(T),u_tl_parent:new i.ck(T),u_scale_parent:new i.cj(T),u_fade_t:new i.cj(T),u_opacity:new i.cj(T),u_image0:new i.ch(T),u_image1:new i.ch(T),u_raster_elevation:new i.cj(T),u_zoom_transition:new i.cj(T),u_merc_center:new i.ck(T),u_cutoff_params:new i.d3(T)}),rasterParticleTexture:T=>({u_texture:new i.ch(T),u_opacity:new i.cj(T)}),rasterParticleDraw:T=>({u_particle_texture:new i.ch(T),u_particle_texture_side_len:new i.cj(T),u_tile_offset:new i.ck(T),u_velocity:new i.ch(T),u_color_ramp:new i.ch(T),u_velocity_res:new i.ck(T),u_max_speed:new i.cj(T),u_uv_offset:new i.ck(T),u_data_scale:new i.ck(T),u_data_offset:new i.cj(T),u_particle_pos_scale:new i.cj(T),u_particle_pos_offset:new i.ck(T)}),rasterParticleUpdate:T=>({u_particle_texture:new i.ch(T),u_particle_texture_side_len:new i.cj(T),u_velocity:new i.ch(T),u_velocity_res:new i.ck(T),u_max_speed:new i.cj(T),u_speed_factor:new i.cj(T),u_reset_rate:new i.cj(T),u_rand_seed:new i.cj(T),u_uv_offset:new i.ck(T),u_data_scale:new i.ck(T),u_data_offset:new i.cj(T),u_particle_pos_scale:new i.cj(T),u_particle_pos_offset:new i.ck(T)}),symbol:T=>({u_is_size_zoom_constant:new i.ch(T),u_is_size_feature_constant:new i.ch(T),u_size_t:new i.cj(T),u_size:new i.cj(T),u_camera_to_center_distance:new i.cj(T),u_rotate_symbol:new i.ch(T),u_aspect_ratio:new i.cj(T),u_fade_change:new i.cj(T),u_matrix:new i.cl(T),u_label_plane_matrix:new i.cl(T),u_coord_matrix:new i.cl(T),u_is_text:new i.ch(T),u_elevation_from_sea:new i.ch(T),u_pitch_with_map:new i.ch(T),u_texsize:new i.ck(T),u_texsize_icon:new i.ck(T),u_texture:new i.ch(T),u_texture_icon:new i.ch(T),u_gamma_scale:new i.cj(T),u_device_pixel_ratio:new i.cj(T),u_tile_id:new i.ci(T),u_zoom_transition:new i.cj(T),u_inv_rot_matrix:new i.cl(T),u_merc_center:new i.ck(T),u_camera_forward:new i.ci(T),u_tile_matrix:new i.cl(T),u_up_vector:new i.ci(T),u_ecef_origin:new i.ci(T),u_is_halo:new i.ch(T),u_icon_transition:new i.cj(T),u_color_adj_mat:new i.cl(T),u_scale_factor:new i.cj(T),u_ground_shadow_factor:new i.ci(T),u_inv_matrix:new i.cl(T),u_normal_scale:new i.cj(T),u_lutTexture:new i.ch(T)}),background:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_opacity:new i.cj(T),u_color:new i.dB(T)}),backgroundPattern:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_opacity:new i.cj(T),u_image:new i.ch(T),u_pattern_tl:new i.ck(T),u_pattern_br:new i.ck(T),u_texsize:new i.ck(T),u_pattern_size:new i.ck(T),u_pixel_coord_upper:new i.ck(T),u_pixel_coord_lower:new i.ck(T),u_pattern_units_to_pixels:new i.ck(T)}),terrainRaster:T=>({u_matrix:new i.cl(T),u_image0:new i.ch(T),u_image1:new i.ch(T),u_skirt_height:new i.cj(T),u_ground_shadow_factor:new i.ci(T),u_emissive_texture_available:new i.cj(T)}),skybox:T=>({u_matrix:new i.cl(T),u_sun_direction:new i.ci(T),u_cubemap:new i.ch(T),u_opacity:new i.cj(T),u_temporal_offset:new i.cj(T)}),skyboxGradient:T=>({u_matrix:new i.cl(T),u_color_ramp:new i.ch(T),u_center_direction:new i.ci(T),u_radius:new i.cj(T),u_opacity:new i.cj(T),u_temporal_offset:new i.cj(T)}),skyboxCapture:T=>({u_matrix_3f:new i.dC(T),u_sun_direction:new i.ci(T),u_sun_intensity:new i.cj(T),u_color_tint_r:new i.d3(T),u_color_tint_m:new i.d3(T),u_luminance:new i.cj(T)}),globeRaster:T=>({u_proj_matrix:new i.cl(T),u_globe_matrix:new i.cl(T),u_normalize_matrix:new i.cl(T),u_merc_matrix:new i.cl(T),u_zoom_transition:new i.cj(T),u_merc_center:new i.ck(T),u_image0:new i.ch(T),u_image1:new i.ch(T),u_grid_matrix:new i.dC(T),u_skirt_height:new i.cj(T),u_far_z_cutoff:new i.cj(T),u_frustum_tl:new i.ci(T),u_frustum_tr:new i.ci(T),u_frustum_br:new i.ci(T),u_frustum_bl:new i.ci(T),u_globe_pos:new i.ci(T),u_globe_radius:new i.cj(T),u_viewport:new i.ck(T),u_emissive_texture_available:new i.cj(T)}),globeAtmosphere:T=>({u_frustum_tl:new i.ci(T),u_frustum_tr:new i.ci(T),u_frustum_br:new i.ci(T),u_frustum_bl:new i.ci(T),u_horizon:new i.cj(T),u_transition:new i.cj(T),u_fadeout_range:new i.cj(T),u_atmosphere_fog_color:new i.d3(T),u_high_color:new i.d3(T),u_space_color:new i.d3(T),u_temporal_offset:new i.cj(T),u_horizon_angle:new i.cj(T)}),model:T=>({u_matrix:new i.cl(T),u_lighting_matrix:new i.cl(T),u_normal_matrix:new i.cl(T),u_node_matrix:new i.cl(T),u_lightpos:new i.ci(T),u_lightintensity:new i.cj(T),u_lightcolor:new i.ci(T),u_camera_pos:new i.ci(T),u_opacity:new i.cj(T),u_baseColorFactor:new i.d3(T),u_emissiveFactor:new i.d3(T),u_metallicFactor:new i.cj(T),u_roughnessFactor:new i.cj(T),u_baseTextureIsAlpha:new i.ch(T),u_alphaMask:new i.ch(T),u_alphaCutoff:new i.cj(T),u_baseColorTexture:new i.ch(T),u_metallicRoughnessTexture:new i.ch(T),u_normalTexture:new i.ch(T),u_occlusionTexture:new i.ch(T),u_emissionTexture:new i.ch(T),u_lutTexture:new i.ch(T),u_color_mix:new i.d3(T),u_aoIntensity:new i.cj(T),u_emissive_strength:new i.cj(T),u_occlusionTextureTransform:new i.d3(T)}),modelDepth:T=>({u_matrix:new i.cl(T),u_instance:new i.cl(T),u_node_matrix:new i.cl(T)}),groundShadow:T=>({u_matrix:new i.cl(T),u_ground_shadow_factor:new i.ci(T)}),stars:T=>({u_matrix:new i.cl(T),u_up:new i.ci(T),u_right:new i.ci(T),u_intensity_multiplier:new i.cj(T)}),snowParticle:T=>({u_modelview:new i.cl(T),u_projection:new i.cl(T),u_time:new i.cj(T),u_cam_pos:new i.ci(T),u_velocityConeAperture:new i.cj(T),u_velocity:new i.cj(T),u_horizontalOscillationRadius:new i.cj(T),u_horizontalOscillationRate:new i.cj(T),u_boxSize:new i.cj(T),u_billboardSize:new i.cj(T),u_simpleShapeParameters:new i.ck(T),u_screenSize:new i.ck(T),u_thinningCenterPos:new i.ck(T),u_thinningShape:new i.ci(T),u_thinningAffectedRatio:new i.cj(T),u_thinningParticleOffset:new i.cj(T),u_particleColor:new i.d3(T),u_direction:new i.ci(T)}),rainParticle:T=>({u_modelview:new i.cl(T),u_projection:new i.cl(T),u_time:new i.cj(T),u_cam_pos:new i.ci(T),u_texScreen:new i.ch(T),u_velocityConeAperture:new i.cj(T),u_velocity:new i.cj(T),u_boxSize:new i.cj(T),u_rainDropletSize:new i.ck(T),u_distortionStrength:new i.cj(T),u_rainDirection:new i.ci(T),u_color:new i.d3(T),u_screenSize:new i.ck(T),u_thinningCenterPos:new i.ck(T),u_thinningShape:new i.ci(T),u_thinningAffectedRatio:new i.cj(T),u_thinningParticleOffset:new i.cj(T),u_shapeDirectionalPower:new i.cj(T),u_shapeNormalPower:new i.cj(T),u_mode:new i.cj(T)}),vignette:T=>({u_vignetteShape:new i.ci(T),u_vignetteColor:new i.d3(T)}),occlusion:T=>({u_matrix:new i.cl(T),u_anchorPos:new i.ci(T),u_screenSizePx:new i.ck(T),u_occluderSizePx:new i.ck(T),u_color:new i.d3(T)})};class Bp{constructor(h,y,A,D){this.id=Bp.uniqueIdxCounter,Bp.uniqueIdxCounter++,this.context=h;const F=h.gl;this.buffer=F.createBuffer(),this.dynamicDraw=!!A,this.context.unbindVAO(),h.bindElementBuffer.set(this.buffer),F.bufferData(F.ELEMENT_ARRAY_BUFFER,y.arrayBuffer,this.dynamicDraw?F.DYNAMIC_DRAW:F.STATIC_DRAW),this.dynamicDraw||D||y.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(h){this.id=Bp.uniqueIdxCounter,Bp.uniqueIdxCounter++;const y=this.context.gl;this.context.unbindVAO(),this.bind(),y.bufferSubData(y.ELEMENT_ARRAY_BUFFER,0,h.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}Bp.uniqueIdxCounter=0;const f6={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class JR{constructor(h,y,A,D,F,z){this.length=y.length,this.attributes=A,this.itemSize=y.bytesPerElement,this.dynamicDraw=D,this.instanceCount=z,this.context=h;const W=h.gl;this.buffer=W.createBuffer(),h.bindVertexBuffer.set(this.buffer),W.bufferData(W.ARRAY_BUFFER,y.arrayBuffer,this.dynamicDraw?W.DYNAMIC_DRAW:W.STATIC_DRAW),this.dynamicDraw||F||y.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(h){const y=this.context.gl;this.bind(),y.bufferSubData(y.ARRAY_BUFFER,0,h.arrayBuffer)}enableAttributes(h,y){for(let A=0;A0&&h.vertexAttribDivisor(F,A)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class eF{constructor(h,y,A,D,F){this.context=h,this.width=y,this.height=A;const z=this.framebuffer=h.gl.createFramebuffer();D>0&&(this.colorAttachment0=new JC(h,z,0)),D>1&&(this.colorAttachment1=new JC(h,z,1)),F&&(this.depthAttachmentType=F,this.depthAttachment=F==="renderbuffer"?new ab(h,z):new a2(h,z))}createColorAttachment(h,y){y===0?this.colorAttachment0=new JC(h,this.framebuffer,0):y===1&&(this.colorAttachment1=new JC(h,this.framebuffer,1))}removeColorAttachment(h,y){const A=this.context.gl;let D;y===0?(D=this.colorAttachment0.get(),this.colorAttachment0=void 0):y===1&&(D=this.colorAttachment1.get(),this.colorAttachment1=void 0),D&&A.deleteTexture(D)}destroy(){const h=this.context.gl;if(this.colorAttachment0){const y=this.colorAttachment0.get();y&&h.deleteTexture(y)}if(this.colorAttachment1){const y=this.colorAttachment1.get();y&&h.deleteTexture(y)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const y=this.depthAttachment.get();y&&h.deleteRenderbuffer(y)}else{const y=this.depthAttachment.get();y&&h.deleteTexture(y)}h.deleteFramebuffer(this.framebuffer)}}class db{constructor(h,y){this.gl=h,this.clearColor=new Pme(this),this.clearDepth=new IR(this),this.clearStencil=new XE(this),this.colorMask=new KC(this),this.depthMask=new QE(this),this.stencilMask=new rv(this),this.stencilFunc=new tb(this),this.stencilOp=new r2(this),this.stencilTest=new sb(this),this.depthRange=new LR(this),this.depthTest=new JE(this),this.depthFunc=new DR(this),this.blend=new rb(this),this.blendFunc=new ZC(this),this.blendColor=new YC(this),this.blendEquation=new e6(this),this.cullFace=new XC(this),this.cullFaceSide=new n2(this),this.frontFace=new OR(this),this.program=new RR(this),this.activeTexture=new FR(this),this.viewport=new nb(this),this.bindFramebuffer=new zR(this),this.bindRenderbuffer=new Ime(this),this.bindTexture=new Lme(this),this.bindVertexBuffer=new Dme(this),this.bindElementBuffer=new t6(this),this.bindVertexArrayOES=new s6(this),this.pixelStoreUnpack=new r6(this),this.pixelStoreUnpackPremultiplyAlpha=new n6(this),this.pixelStoreUnpackFlipY=new BR(this),this.options=y?Object.assign({},y):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=h.getExtension("EXT_texture_filter_anisotropic")||h.getExtension("MOZ_EXT_texture_filter_anisotropic")||h.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=h.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=h.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=h.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=h.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=y&&!!y.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.indexOf("PowerVR")!==-1,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=h.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=h.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=h.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=h.getParameter(h.MAX_TEXTURE_SIZE),this.extBlendFuncExtended=h.getExtension("WEBGL_blend_func_extended")}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(h,y,A){return new Bp(this,h,y,A)}createVertexBuffer(h,y,A,D,F){return new JR(this,h,y,A,D,F)}createRenderbuffer(h,y,A){const D=this.gl,F=D.createRenderbuffer();return this.bindRenderbuffer.set(F),D.renderbufferStorage(D.RENDERBUFFER,h,y,A),this.bindRenderbuffer.set(null),F}createFramebuffer(h,y,A,D){return new eF(this,h,y,A,D)}clear({color:h,depth:y,stencil:A,colorMask:D}){const F=this.gl;let z=0;h&&(z|=F.COLOR_BUFFER_BIT,this.clearColor.set(h.toNonPremultipliedRenderColor(null)),this.colorMask.set(D||[!0,!0,!0,!0])),y!==void 0&&(z|=F.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(y),this.depthMask.set(!0)),A!==void 0&&(z|=F.STENCIL_BUFFER_BIT,this.clearStencil.set(A),this.stencilMask.set(255)),F.clear(z)}setCullFace(h){h.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(h.mode),this.frontFace.set(h.frontFace))}setDepthMode(h){h.func!==this.gl.ALWAYS||h.mask?(this.depthTest.set(!0),this.depthFunc.set(h.func),this.depthMask.set(h.mask),this.depthRange.set(h.range)):this.depthTest.set(!1)}setStencilMode(h){h.test.func!==this.gl.ALWAYS||h.mask?(this.stencilTest.set(!0),this.stencilMask.set(h.mask),this.stencilOp.set([h.fail,h.depthFail,h.pass]),this.stencilFunc.set({func:h.test.func,ref:h.ref,mask:h.test.mask})):this.stencilTest.set(!1)}setColorMode(h){i.by(h.blendFunction,Hn.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(h.blendFunction),this.blendColor.set(h.blendColor),h.blendEquation?this.blendEquation.set(h.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(h.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let iv;function kr(T,h,y,A,D,F,z){const W=T.context,J=W.gl,ne=T.transform,le=[i.aF(ne.center.lng),i.aJ(ne.center.lat)],_e=y.layout.get("symbol-placement"),ye=y.layout.get("text-variable-anchor"),we=y.layout.get("icon-rotation-alignment")==="map",Le=y.layout.get("text-rotation-alignment")==="map",Ie=_e!=="point",We=[];let Ue=0,st=0;for(let yt=0;yt0){const hr=i.bC(),br=Js;i.cP(hr,Ht.placementInvProjMatrix,ne.glCoordMatrix),i.cP(hr,hr,Ht.placementViewportMatrix),We.push({circleArray:Pr,circleOffset:st,transform:br,invTransform:hr,projection:Ht.getProjection()}),Ue+=Pr.length/4,st=Ue}if(!Us)continue;T.terrain&&T.terrain.setupElevationDraw(Wt,yr);const Cr=Is?[Ot.canonical.x,Ot.canonical.y,1<=0&&(we[ut.associatedIconIndex]={x:Ht,y:es,z:ts,angle:as})}else Rp(Nt,_e)}if(ne){ye.clear();const st=T.icon.placedSymbolArray;for(let ut=0;ut{let za=[0,0,0];if(ui){const Gn=T.style.directionalLight,Xi=T.style.ambientLight;Gn&&Xi&&(za=tg(T.style,Gn,Xi))}return za},Ka=ui=>{yt.depthOcclusionForSymbolsAndCircles&&(y.hasOcclusionOpacityProperties||T.terrain)&&(ui.push("DEPTH_D24"),ui.push("DEPTH_OCCLUSION"))},Cn=ui=>{y.lut&&!Nt&&(y.lut.texture||(y.lut.texture=new i.d$(T.context,y.lut.image,[y.lut.image.height,y.lut.image.height,y.lut.image.height],Tt.gl.RGBA8)),Tt.activeTexture.set(Tt.gl.TEXTURE0+Gc.LUT),y.lut.texture&&y.lut.texture.bind(Tt.gl.LINEAR,Tt.gl.CLAMP_TO_EDGE),ui.push("APPLY_LUT_ON_GPU"))},di=()=>{const ui=Ot&&y.layout.get("symbol-placement")!=="point",za=[];Ka(za),Cn(za);const Gn=ui||Pn,Xi=Us.elevationType==="road",Ho=T.shadowRenderer,_o=Xi&&Ht&&!!Ho&&Ho.enabled,Di=Or(_o),Bu=Xi&&Ht&&!T.terrain?Yt:qs,Md=y.paint.get("icon-image-cross-fade");T.terrainRenderModeElevated()&&Ht&&za.push("PITCH_WITH_MAP_TERRAIN"),Pr&&(za.push("PROJECTION_GLOBE_VIEW"),Gn&&za.push("PROJECTED_POS_ON_VIEWPORT")),Md>0&&Us.hasAnySecondaryIcon&&za.push("ICON_TRANSITION"),!Us.icon.zOffsetVertexBuffer||Xi&&T.terrain||za.push("Z_OFFSET"),Ue===0&&st===0&&ut===0&&ot===1||za.push("COLOR_ADJUSTMENT"),Us.sdfIcons&&za.push("RENDER_SDF"),_o&&za.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Xi&&Ht&&!T.terrain&&Us.icon.orientationVertexBuffer&&za.push("ELEVATED_ROADS");const ql=Us.icon.programConfigurations.get(y.id),Vd=T.getOrCreateProgram("symbol",{config:ql,defines:za}),Hd=Js.imageAtlasTexture?Js.imageAtlasTexture.size:[0,0],id=Us.iconSizeData,hm=i.bK(id,yt.zoom),ap=Ht||!yt.isOrthographic,mh=Qs(hr,Js.tileID.canonical,Ht,Ot,yt,Us.getProjection(),br),Lo=gn(hr,Js.tileID.canonical,Ht,Ot,yt,Us.getProjection(),br),Jo=T.translatePosMatrix(Lo,Js,W,ne,!0),Oi=T.translatePosMatrix(hr,Js,W,ne),ml=Gn?u2:mh,Co=Ot&&!Ht&&!ui;let wo=rr;!Jt&&!yt.mercatorFromTransition||Ot||(wo=rg(yt));const ip=Pr?wo:rr,N2=y.getColorAdjustmentMatrix(Ue,st,ut,ot),Up=c3(id.kind,hm,Co,Ht,T,Oi,ml,Jo,Et,!1,Hd,[0,0],0,yr,Cr,Bt,wa,ip,Us.getProjection(),Di,si,N2,Md,null),k2=Js.imageAtlasTexture?Js.imageAtlasTexture:null,vb=y.layout.get("icon-size").constantOr(0)!==1||Us.iconsNeedLinear,Gf=Us.sdfIcons||T.options.rotating||T.options.zooming||vb||ap?wt.LINEAR:wt.NEAREST,hg=Us.sdfIcons&&y.paint.get("icon-halo-width").constantOr(1)!==0,bb=T.terrain&&Ht&&ui?i.bl(i.bC(),mh):u2;if(ui&&Us.icon){const Oy=i.bV.getAtTileOffsetFunc(yr,yt.center.lat,yt.worldSize,Us.getProjection()),mg=xn(hr,Js.tileID.canonical,Ht,Ot,yt,Us.getProjection(),br),Vp=y.layout.get("icon-size-scale-range"),pg=i.aA(T.scaleFactor,Vp[0],Vp[1]);Qx(Us,hr,T,!1,mg,Lo,Ht,Ie,Oy,yr,pg)}return{program:Vd,buffers:Us.icon,uniformValues:Up,atlasTexture:k2,atlasTextureIcon:null,atlasInterpolation:Gf,atlasInterpolationIcon:null,isSDF:Us.sdfIcons,hasHalo:hg,depthMode:Bu,tile:Js,renderWithShadows:_o,labelPlaneMatrixInv:bb}},Ci=()=>{const ui=Wt&&y.layout.get("symbol-placement")!=="point",za=[],Gn=ui||as||Pn,Xi=Us.elevationType==="road",Ho=T.shadowRenderer,_o=Xi&&es&&!!Ho&&Ho.enabled,Di=Or(_o),Bu=Xi&&es&&!T.terrain?Yt:qs;T.terrainRenderModeElevated()&&es&&za.push("PITCH_WITH_MAP_TERRAIN"),Pr&&(za.push("PROJECTION_GLOBE_VIEW"),Gn&&za.push("PROJECTED_POS_ON_VIEWPORT")),!Us.text.zOffsetVertexBuffer||Xi&&T.terrain||za.push("Z_OFFSET"),Us.iconsInText&&za.push("RENDER_TEXT_AND_SYMBOL"),za.push("RENDER_SDF"),_o&&za.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Xi&&es&&!T.terrain&&Us.text.orientationVertexBuffer&&za.push("ELEVATED_ROADS"),Ka(za);const Md=Us.text.programConfigurations.get(y.id),ql=T.getOrCreateProgram("symbol",{config:Md,defines:za});let Vd,Hd=[0,0],id=null;const hm=Us.textSizeData;Us.iconsInText&&(Hd=Js.imageAtlasTexture?Js.imageAtlasTexture.size:[0,0],id=Js.imageAtlasTexture?Js.imageAtlasTexture:null,Vd=es||!yt.isOrthographic||T.options.rotating||T.options.zooming||hm.kind==="composite"||hm.kind==="camera"?wt.LINEAR:wt.NEAREST);const ap=Js.glyphAtlasTexture?Js.glyphAtlasTexture.size:[0,0],mh=y.layout.get("text-size-scale-range"),Lo=i.aA(T.scaleFactor,mh[0],mh[1]),Jo=i.bK(hm,yt.zoom,Lo),Oi=Qs(hr,Js.tileID.canonical,es,Wt,yt,Us.getProjection(),br),ml=gn(hr,Js.tileID.canonical,es,Wt,yt,Us.getProjection(),br),Co=T.translatePosMatrix(ml,Js,J,le,!0),wo=T.translatePosMatrix(hr,Js,J,le),ip=Gn?u2:Oi,N2=Wt&&!es&&!ui;let Up=rr;!Jt&&!yt.mercatorFromTransition||Wt||(Up=rg(yt));const k2=c3(hm.kind,Jo,N2,es,T,wo,ip,Co,Et,!0,ap,Hd,0,yr,Cr,Bt,wa,Pr?Up:rr,Us.getProjection(),Di,si,null,null,Lo),vb=Js.glyphAtlasTexture?Js.glyphAtlasTexture:null,Gf=wt.LINEAR,hg=y.paint.get("text-halo-width").constantOr(1)!==0,bb=T.terrain&&es&&ui?i.bl(i.bC(),Oi):u2;if(ui&&Us.text){const Oy=i.bV.getAtTileOffsetFunc(yr,yt.center.lat,yt.worldSize,Us.getProjection()),mg=xn(hr,Js.tileID.canonical,es,Wt,yt,Us.getProjection(),br);Qx(Us,hr,T,!0,mg,ml,es,We,Oy,yr,Lo)}return{program:ql,buffers:Us.text,uniformValues:k2,atlasTexture:vb,atlasTextureIcon:id,atlasInterpolation:Gf,atlasInterpolationIcon:Vd,isSDF:!0,hasHalo:hg,depthMode:Bu,tile:Js,renderWithShadows:_o,labelPlaneMatrixInv:bb}},bi=Us.icon.segments.get().length,Ga=Us.text.segments.get().length,Wn=bi&&!z.onlyText?di():null,ii=Ga&&!z.onlyIcons?Ci():null,So=y.paint.get("icon-opacity").constantOr(1),no=y.paint.get("text-opacity").constantOr(1);if(ts&&Us.canOverlap){xs=!0;const ui=So&&!z.onlyText?Us.icon.segments.get():[],za=no&&!z.onlyIcons?Us.text.segments.get():[];for(const Gn of ui)Is.push({segments:new i.bg([Gn]),sortKey:Gn.sortKey,state:Wn});for(const Gn of za)Is.push({segments:new i.bg([Gn]),sortKey:Gn.sortKey,state:ii})}else z.onlyText||Is.push({segments:So?Us.icon.segments:new i.bg([]),sortKey:0,state:Wn}),z.onlyIcons||Is.push({segments:no?Us.text.segments:new i.bg([]),sortKey:0,state:ii})}xs&&Is.sort((yr,Js)=>yr.sortKey-Js.sortKey);for(const yr of Is){const Js=yr.state;if(Js)if(T.terrain?T.terrain.setupElevationDraw(Js.tile,Js.program,{useDepthForOcclusion:yt.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Js.labelPlaneMatrixInv}):T.setupDepthForOcclusion(yt.depthOcclusionForSymbolsAndCircles,Js.program),Tt.activeTexture.set(wt.TEXTURE0),Js.atlasTexture&&Js.atlasTexture.bind(Js.atlasInterpolation,wt.CLAMP_TO_EDGE,!0),Js.atlasTextureIcon&&(Tt.activeTexture.set(wt.TEXTURE1),Js.atlasTextureIcon&&Js.atlasTextureIcon.bind(Js.atlasInterpolationIcon,wt.CLAMP_TO_EDGE,!0)),Js.renderWithShadows&&T.shadowRenderer.setupShadows(Js.tile.tileID.toUnwrapped(),Js.program,"vector-tile"),T.uploadCommonLightUniforms(T.context,Js.program),Js.hasHalo){const Us=Js.uniformValues;Us.u_is_halo=1,x6(Js.buffers,yr.segments,y,T,Js.program,Js.depthMode,D,F,Us,2),Us.u_is_halo=0}else{if(Js.isSDF){const Us=Js.uniformValues;Js.hasHalo&&(Us.u_is_halo=1,x6(Js.buffers,yr.segments,y,T,Js.program,Js.depthMode,D,F,Us,1)),Us.u_is_halo=0}x6(Js.buffers,yr.segments,y,T,Js.program,Js.depthMode,D,F,Js.uniformValues,1)}}}function x6(T,h,y,A,D,F,z,W,J,ne){const le=[T.dynamicLayoutVertexBuffer,T.opacityVertexBuffer,T.iconTransitioningVertexBuffer,T.globeExtVertexBuffer,T.zOffsetVertexBuffer,T.orientationVertexBuffer];D.draw(A,A.context.gl.TRIANGLES,F,z,W,mn.disabled,J,y.id,T.layoutVertexBuffer,T.indexBuffer,h,y.paint,A.transform.zoom,T.programConfigurations.get(y.id),le,ne)}function tF(T,h){const y=1<=zp?1:we.pitch/zp))),2*Le}(T.transform),ne=T.transform.getFreeCameraOptions().position,le="elevatedStructuresDepthReconstruct",_e=T.getOrCreateProgram(le,{defines:["DEPTH_RECONSTRUCTION"]}),ye=T.getOrCreateProgram(le);for(const we of A){const Le=h.getTile(we),Ie=Le.getBucket(y);if(!Ie)continue;const We=Ie.elevatedStructures;if(!We)continue;const Ue=Ie.elevationBufferData.heightRange,st=tF(we.toUnwrapped(),ne),ut=T.translatePosMatrix(we.projMatrix,Le,y.paint.get("fill-translate"),y.paint.get("fill-translate-anchor"));let ot,Et,Nt,Tt;if(D==="initialize"){if(!Ue||Ue.min>=1||We.depthSegments.segments[0].primitiveLength===0)continue;ot=nv(ut,st,J,1,0),Et=z,Nt=We.depthSegments,Tt=_e}else if(D==="reset"){if(!Ue||Ue.min>=0||We.maskSegments.segments[0].primitiveLength===0)continue;ot=nv(ut,st,0,0,1),Et=W,Nt=We.maskSegments,Tt=_e}else if(D==="geometry"){if(We.depthSegments.segments[0].primitiveLength===0)continue;ot=nv(ut,st,J,1,0),Et=z,Nt=We.depthSegments,Tt=ye}Tt.draw(T,F.TRIANGLES,Et,yn.disabled,Hn.disabled,mn.disabled,ot,y.id,We.vertexBuffer,We.indexBuffer,Nt,y.paint,T.transform.zoom)}}function h3(T,h,y,A){const{painter:D,sourceCache:F,layer:z,coords:W,colorMode:J,elevationType:ne,terrainEnabled:le,pass:_e}=T,ye=D.context.gl,we=z.paint.get("fill-pattern"),Le=z.paint.get("fill-pattern-cross-fade"),Ie=we.constantOr(null);let We=ne;ne!=="road"||h&&!le||(We="none");const Ue=We==="road",st=T.painter.shadowRenderer,ut=Ue&&!!st&&st.enabled,ot=new Fr(D.context.gl.LEQUAL,Fr.ReadOnly,D.depthRangeFor3D);let Et=[0,0,0];if(ut){const yt=D.style.directionalLight,Ot=D.style.ambientLight;yt&&Ot&&(Et=tg(D.style,yt,Ot))}const Nt=we&&we.constantOr(1),Tt=D.terrain&&D.terrain.renderingToTexture,wt=(yt,Ot)=>{let Wt,Ht,es,ts,xs;Ot?(Wt=Nt&&!z.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",es=ye.LINES):(Wt=Nt?"fillPattern":"fill",es=ye.TRIANGLES);for(const qs of W){const Yt=F.getTile(qs);if(Nt&&!Yt.patternsLoaded())continue;const Bt=Yt.getBucket(z);if(!Bt)continue;const as=h?Bt.elevationBufferData:Bt.bufferData;if(as.isEmpty())continue;D.prepareDrawTile();const Jt=as.programConfigurations.get(z.id),Is=D.isTileAffectedByFog(qs),rr=[],yr=[];Ue&&(rr.push("ELEVATED_ROADS"),yr.push(as.elevatedLayoutVertexBuffer)),ut&&rr.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Tt&&y&&rr.push("USE_MRT1"),Nt&&(D.context.activeTexture.set(ye.TEXTURE0),Yt.imageAtlasTexture&&Yt.imageAtlasTexture.bind(ye.LINEAR,ye.CLAMP_TO_EDGE),Jt.updatePaintBuffers());let Js=!1;if(Ie&&Yt.imageAtlas){const br=Yt.imageAtlas,Kr=i.e3.from(Ie),Pn=Kr.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),wa=Kr.getSecondary(),si=br.patternPositions.get(Pn),Or=wa?br.patternPositions.get(wa.scaleSelf(i.o.devicePixelRatio).toString()):null;Js=!!si&&!!Or,si&&Jt.setConstantPatternPositions(si,Or)}Le>0&&(Js||Jt.getPatternTransitionVertexBuffer("fill-pattern"))&&rr.push("FILL_PATTERN_TRANSITION");const Us=D.getOrCreateProgram(Wt,{config:Jt,overrideFog:Is,defines:rr}),Pr=D.translatePosMatrix(qs.projMatrix,Yt,z.paint.get("fill-translate"),z.paint.get("fill-translate-anchor"));ut&&st.setupShadows(Yt.tileID.toUnwrapped(),Us,"vector-tile");const Cr=z.paint.get("fill-emissive-strength");if(Ot){ts=as.lineIndexBuffer,xs=as.lineSegments;const br=D.terrain&&D.terrain.renderingToTexture?D.terrain.drapeBufferSize:[ye.drawingBufferWidth,ye.drawingBufferHeight];Ht=Wt==="fillOutlinePattern"&&Nt?h6(Pr,Cr,D,Yt,br,Et,Le):HR(Pr,Cr,br,Et)}else ts=as.indexBuffer,xs=as.triangleSegments,Ht=Nt?u6(Pr,Cr,D,Yt,Et,Le):d6(Pr,Cr,Et);D.uploadCommonUniforms(D.context,Us,qs.toUnwrapped());let hr=yt;(ne==="road"&&!le||ne==="offset")&&(hr=ot),Us.draw(D,es,hr,A||D.stencilModeForClipping(qs),J,mn.disabled,Ht,z.id,as.layoutVertexBuffer,ts,xs,z.paint,D.transform.zoom,Jt,yr)}};D.renderPass===_e&&wt(D.depthModeForSublayer(1,D.renderPass==="opaque"?Fr.ReadWrite:Fr.ReadOnly),!1),We==="none"&&D.renderPass==="translucent"&&z.paint.get("fill-antialias")&&wt(D.depthModeForSublayer(z.getPaintProperty("fill-outline-color")?2:0,Fr.ReadOnly),!0)}function m3(T,h,y,A,D,F,z,W){y.resetLayerRenderingStats(T);const J=T.context,ne=J.gl,le=T.transform,_e=y.paint.get("fill-extrusion-pattern"),ye=y.paint.get("fill-extrusion-pattern-cross-fade"),we=_e.constantOr(null),Le=_e.constantOr(1),Ie=y.paint.get("fill-extrusion-opacity"),We=T.style.enable3dLights(),Ue=y.paint.get(We&&!Le?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),st=[y.paint.get("fill-extrusion-ambient-occlusion-intensity"),Ue],ut=y.layout.get("fill-extrusion-edge-radius"),ot=ut>0&&!y.paint.get("fill-extrusion-rounded-roof"),Et=ot?0:ut,Nt=le.projection.name==="globe"?i.eb():0,Tt=le.projection.name==="globe",wt=Tt?i.aj(le.zoom):0,yt=[i.aF(le.center.lng),i.aJ(le.center.lat)],Ot=y.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Wt=y.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Ot?null:y.lut).toArray01().slice(0,3),Ht=y.paint.get("fill-extrusion-flood-light-intensity"),es=y.paint.get("fill-extrusion-vertical-scale"),ts=y.paint.get("fill-extrusion-line-width").constantOr(1)!==0,xs=y.paint.get("fill-extrusion-height-alignment"),qs=y.paint.get("fill-extrusion-base-alignment"),Yt=wy(T,y.paint.get("fill-extrusion-cutoff-fade-range")),Bt=[];let as;Tt&&Bt.push("PROJECTION_GLOBE_VIEW"),st[0]>0&&Bt.push("FAUX_AO"),ot&&Bt.push("ZERO_ROOF_RADIUS"),W&&Bt.push("HAS_CENTROID"),Ht>0&&Bt.push("FLOOD_LIGHT"),Yt.shouldRenderCutoff&&Bt.push("RENDER_CUTOFF"),ts&&Bt.push("RENDER_WALL_MODE");const Jt=T.renderPass==="shadow",Is=T.shadowRenderer,rr=Jt&&!!Is,yr=Jt?mn.disabled:mn.backCCW;T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!0);let Js=[0,0,0];if(Is){const Cr=T.style.directionalLight,hr=T.style.ambientLight;Cr&&hr&&(Js=tg(T.style,Cr,hr)),Jt||(Bt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),Is.useNormalOffset&&Bt.push("NORMAL_OFFSET")),as=Bt.concat(["SHADOWS_SINGLE_CASCADE"])}const Us=rr?"fillExtrusionDepth":Le?"fillExtrusionPattern":"fillExtrusion",Pr=y.getLayerRenderingStats();for(const Cr of A){const hr=h.getTile(Cr),br=hr.getBucket(y);if(!br||br.projection.name!==le.projection.name)continue;let Kr=!1;Is&&(Kr=Is.getMaxCascadeForTile(Cr.toUnwrapped())===0);const Pn=T.isTileAffectedByFog(Cr),wa=br.programConfigurations.get(y.id);let si=!1;if(we&&hr.imageAtlas){const Ga=hr.imageAtlas,Wn=i.e3.from(we),ii=Wn.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),So=Wn.getSecondary(),no=Ga.patternPositions.get(ii),ui=So?Ga.patternPositions.get(So.scaleSelf(i.o.devicePixelRatio).toString()):null;si=!!no&&!!ui,no&&wa.setConstantPatternPositions(no,ui)}ye>0&&(si||wa.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Bt.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Or=T.getOrCreateProgram(Us,{config:wa,defines:Kr?as:Bt,overrideFog:Pn});if(T.terrain&&T.terrain.setupElevationDraw(hr,Or,{useMeterToDem:!0}),!br.centroidVertexBuffer){const Ga=Or.getAttributeLocation(ne,"a_centroid_pos");Ga!==-1&&ne.vertexAttrib2f(Ga,0,0)}!Jt&&Is&&Is.setupShadows(hr.tileID.toUnwrapped(),Or,"vector-tile"),Le&&(T.context.activeTexture.set(ne.TEXTURE0),hr.imageAtlasTexture&&hr.imageAtlasTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),wa.updatePaintBuffers());const Ka=y.paint.get("fill-extrusion-vertical-gradient"),Cn=1/br.tileToMeter;let di;if(Jt&&Is){if(ag(hr.tileID,br.maxHeight,T))continue;const Ga=Is.calculateShadowPassMatrixFromTile(hr.tileID.toUnwrapped());di=c6(Ga,Et,Cn,es,xs,qs)}else{const Ga=T.translatePosMatrix(Cr.expandedProjMatrix,hr,y.paint.get("fill-extrusion-translate"),y.paint.get("fill-extrusion-translate-anchor")),Wn=le.projection.createInversionMatrix(le,Cr.canonical);di=Le?VR(Ga,T,Ka,Ie,st,Et,Cn,Cr,hr,Nt,xs,qs,wt,yt,Wn,Wt,es,ye):a3(Ga,T,Ka,Ie,st,Et,Cn,Cr,Nt,xs,qs,wt,yt,Wn,Wt,es,Ht,Js)}T.uploadCommonUniforms(J,Or,Cr.toUnwrapped(),null,Yt);let Ci=br.segments;if(le.projection.name==="mercator"&&!Jt&&(Ci=br.getVisibleSegments(hr.tileID,T.terrain,T.transform.getFrustum(0)),!Ci.get().length))continue;if(Pr)if(Jt)for(const Ga of Ci.get())Pr.numRenderedVerticesInShadowPass+=Ga.primitiveLength;else for(const Ga of Ci.get())Pr.numRenderedVerticesInTransparentPass+=Ga.primitiveLength;const bi=[];(T.terrain||W)&&bi.push(br.centroidVertexBuffer),Tt&&bi.push(br.layoutVertexExtBuffer),ts&&bi.push(br.wallVertexBuffer),Or.draw(T,J.gl.TRIANGLES,D,F,z,yr,di,y.id,br.layoutVertexBuffer,br.indexBuffer,Ci,y.paint,T.transform.zoom,wa,bi)}T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!1)}class g6{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function ng(T,h,y,A,D,F,z,W,J,ne,le,_e,ye,we,Le,Ie,We,Ue,st,ut){const ot=h.context,Et=ot.gl,Nt=h.transform,Tt=h.transform.zoom,wt=[],yt=T.translate,Ot=T.translateAnchor,Wt=T.edgeRadius,Ht=wy(h,T.cutoffFadeRange);le==="clear"?(wt.push("CLEAR_SUBPASS"),ut&&(wt.push("CLEAR_FROM_TEXTURE"),ot.activeTexture.set(Et.TEXTURE0),ut.bind(Et.LINEAR,Et.CLAMP_TO_EDGE))):le==="sdf"?wt.push("SDF_SUBPASS"):le==="emissive"&&(wt.push("USE_MRT1"),ot.activeTexture.set(Et.TEXTURE0),ut.bind(Et.LINEAR,Et.CLAMP_TO_EDGE)),Ue&&wt.push("HAS_CENTROID"),Ht.shouldRenderCutoff&&wt.push("RENDER_CUTOFF");const es=(ts,xs,qs,Yt,Bt)=>{let as=wt;xs.groundRadiusBuffer!=null&&(as=wt.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const Jt=xs.programConfigurations.get(A.id),Is=h.isTileAffectedByFog(ts),rr=h.getOrCreateProgram("fillExtrusionGroundEffect",{config:Jt,defines:as,overrideFog:Is}),yr=lb(h,Yt,_e,ne,Bt,[ye,we*Bt],Le,Ie,We,Tt>=17?0:Wt*Bt,ut?ut.size[0]:0),Js=[];Ue&&Js.push(xs.hiddenByLandmarkVertexBuffer),xs.groundRadiusBuffer!=null&&Js.push(xs.groundRadiusBuffer),h.uploadCommonUniforms(ot,rr,ts.toUnwrapped(),null,Ht),rr.draw(h,ot.gl.TRIANGLES,F,z,W,J,yr,A.id,xs.vertexBuffer,xs.indexBuffer,qs,A.paint,Tt,Jt,Js)};for(const ts of D){const xs=y.getTile(ts),qs=xs.getBucket(A);if(!qs||qs.projection.name!==Nt.projection.name||!qs.groundEffect||qs.groundEffect&&!qs.groundEffect.hasData())continue;const Yt=qs.groundEffect,Bt=1/qs.tileToMeter;{const as=h.translatePosMatrix(ts.projMatrix,xs,yt,Ot),Jt=Yt.getDefaultSegment();es(ts,Yt,Jt,as,Bt)}if(st)for(let as=0;as<4;as++){const Jt=i.e9[as](ts),Is=y.getTile(Jt);if(!Is)continue;const rr=Is.getBucket(A);if(!rr||rr.projection.name!==Nt.projection.name||!rr.groundEffect||rr.groundEffect&&!rr.groundEffect.hasData())continue;const yr=rr.groundEffect;let Js,Us;as===0?(Js=[-i.al,0,0],Us=1):as===1?(Js=[i.al,0,0],Us=0):as===2?(Js=[0,-i.al,0],Us=3):(Js=[0,i.al,0],Us=2);const Pr=yr.regionSegments[Us];if(!Pr)continue;const Cr=new Float32Array(16);i.br(Cr,ts.projMatrix,Js),es(ts,yr,Pr,h.translatePosMatrix(Cr,xs,yt,Ot),Bt)}}}function $me(T,h,y,A,D,F,z){A.centroidVertexArray.length===0&&A.createCentroidsBuffer();const W=F?F.findDEMTileFor(y):null;if(!(W&&W.dem||z))return;F&&W&&W.dem&&A.selfDEMTileTimestamp!==W.dem._timestamp&&(A.borderDoneWithNeighborZ=[-1,-1,-1,-1],A.selfDEMTileTimestamp=W.dem._timestamp);const J=Ue=>new i.P(Math.ceil((Ue+i.ed)*i.ee),0),ne=Ue=>{const st=h.getSource().minzoom,ut=Et=>{const Nt=h.getTileByID(Et);if(Nt&&Nt.hasData())return Nt.getBucket(D)},ot=[0,-1,1];for(const Et of ot){if(Ue.overscaledZ+Et(le[0]=Math.min(Ue.min.y,st.min.y),le[1]=Math.max(Ue.max.y,st.max.y),le[2]=i.al-st.min.x>Ue.max.x?st.min.x-i.al:Ue.max.x,le),ye=(Ue,st)=>(le[0]=Math.min(Ue.min.x,st.min.x),le[1]=Math.max(Ue.max.x,st.max.x),le[2]=i.al-st.min.y>Ue.max.y?st.min.y-i.al:Ue.max.y,le),we=[(Ue,st)=>_e(Ue,st),(Ue,st)=>_e(st,Ue),(Ue,st)=>ye(Ue,st),(Ue,st)=>ye(st,Ue)],Le=(Ue,st,ut,ot,Et,Nt,Tt)=>{if(!F)return 0;const wt=[[Nt?ut:Ue,Nt?Ue:ut,0],[Nt?ut:st,Nt?st:ut,0]],yt=Tt<0?i.al+Tt:Tt,Ot=[Nt?yt:(Ue+st)/2,Nt?(Ue+st)/2:yt,0];return ut===0&&Tt<0||ut!==0&&Tt>0?F.getForTilePoints(Et,[Ot],!0,ot):wt.push(Ot),F.getForTilePoints(y,wt,!0,W),Math.max(wt[0][2],wt[1][2],Ot[2])/F.exaggeration()};for(let Ue=0;Ue<4;Ue++){const st=A.borderFeatureIndices[Ue];if(st.length===0)continue;const ut=i.e9[Ue](y),ot=ne(ut);if(!(ot&&ot instanceof i.ea))continue;const Et=F?F.findDEMTileFor(ut):null;if(!(Et&&Et.dem||z)||(F&&Et&&Et.dem&&A.borderDEMTileTimestamp[Ue]!==Et.dem._timestamp&&(A.borderDoneWithNeighborZ[Ue]=-1,A.borderDEMTileTimestamp[Ue]=Et.dem._timestamp),A.borderDoneWithNeighborZ[Ue]===ot.canonical.z))continue;ot.centroidVertexArray.length===0&&ot.createCentroidsBuffer();const Nt=(Ue<2?1:5)-Ue,Tt=ot.borderDoneWithNeighborZ[Nt]!==A.canonical.z,wt=ot.borderFeatureIndices[Nt];let yt=0;if(A.canonical.z!==ot.canonical.z){for(const Ot of st)A.showCentroid(A.featuresOnBorder[Ot]);if(Tt)for(const Ot of wt)ot.showCentroid(ot.featuresOnBorder[Ot]);A.borderDoneWithNeighborZ[Ue]=ot.canonical.z,ot.borderDoneWithNeighborZ[Nt]=A.canonical.z}for(const Ot of st){const Wt=A.featuresOnBorder[Ot],Ht=A.centroidData[Wt.centroidDataIndex],es=Wt.borders[Ue];let ts;for(;ytes[0]+3||xs[0]>es[0]-3)break;ot.showCentroid(ts),yt++}if(ts&&ytes[1]-3)&&(qs++,++yt!==wt.length);)ts=ot.featuresOnBorder[wt[yt]];ts=ot.featuresOnBorder[wt[xs]];let Yt=!1;if(qs>=1){const Jt=ts.borders[Nt];Math.abs(es[0]-Jt[0])<3&&Math.abs(es[1]-Jt[1])<3&&(qs=1,Yt=!0,yt=xs+1)}else if(qs===0){A.showCentroid(Wt);continue}const Bt=ot.centroidData[ts.centroidDataIndex];z&&Yt&&(((Ie=Ht).flags|(We=Bt).flags)&i.ec?(Ie.flags|=i.ec,We.flags|=i.ec):(Ie.flags&=~i.ec,We.flags&=~i.ec));const as=Wt.intersectsCount()>1||ts.intersectsCount()>1;if(qs>1)yt=xs,Ht.centroidXY=Bt.centroidXY=new i.P(0,0);else if(Et&&Et.dem&&!as){const Jt=we[Ue](Ht,Bt),Is=Ue%2?i.al-1:0,rr=Le(Jt[0],Math.min(i.al-1,Jt[1]),Is,Et,ut,Ue<2,Jt[2]);Ht.centroidXY=Bt.centroidXY=J(rr)}else as?Ht.centroidXY=Bt.centroidXY=new i.P(0,0):(Ht.centroidXY=A.encodeBorderCentroid(Wt),Bt.centroidXY=ot.encodeBorderCentroid(ts));A.writeCentroidToBuffer(Ht),ot.writeCentroidToBuffer(Bt)}else A.showCentroid(Wt)}A.borderDoneWithNeighborZ[Ue]=ot.canonical.z,ot.borderDoneWithNeighborZ[Nt]=A.canonical.z}var Ie,We;(A.needsCentroidUpdate||!A.centroidVertexBuffer&&A.centroidVertexArray.length!==0)&&A.uploadCentroid(T)}const Dh=[1,0,0],y6=[0,1,0],Fu=[0,0,1];function ag(T,h,y){const A=y.transform,D=y.shadowRenderer;if(!D)return!0;const F=T.toUnwrapped(),z=A.tileSize*D._cascades[y.currentShadowCascade].scale;let W=h;if(A.elevation){const Ie=A.elevation.getMinMaxForTile(T);Ie&&(W+=Ie.max)}const J=[...D.shadowDirection];J[2]=-J[2];const ne=D.computeSimplifiedTileShadowVolume(F,W,z,J);if(!ne)return!1;const le=[Dh,y6,Fu,J,[J[0],0,J[2]],[0,J[1],J[2]]],_e=A.projection.name==="globe",ye=A.scaleZoom(z),we=i.cB.fromInvProjectionMatrix(A.invProjMatrix,A.worldSize,ye,!_e),Le=D.getCurrentCascadeFrustum();return we.intersectsPrecise(ne.vertices,ne.planes,le)===0||Le.intersectsPrecise(ne.vertices,ne.planes,le)===0}function m2(T){const{painter:h,source:y,layer:A,coords:D}=T;let F=T.defines;const z=h.context,W=h.renderPass==="shadow",J=h.renderPass==="light-beam",ne=h.shadowRenderer,le=i.ef(h.transform.center.lat,h.transform.zoom),_e=wy(h,A.paint.get("building-cutoff-fade-range"));_e.shouldRenderCutoff&&(F=F.concat("RENDER_CUTOFF")),T.floodLightIntensity>0&&(F=F.concat("FLOOD_LIGHT"));for(const ye of D){const we=y.getTile(ye),Le=we.getBucket(A);if(!Le)continue;ne&&ne.getMaxCascadeForTile(ye.toUnwrapped())===0&&(F=F.concat("SHADOWS_SINGLE_CASCADE"));const Ie=Le.programConfigurations.get(A.id);let We,Ue,st,ut=h.translatePosMatrix(ye.expandedProjMatrix,we,[0,0],"map");if(ut=i.cS(i.bC(),ut,[1,1,T.verticalScale]),W&&ne){if(ag(we.tileID,Le.maxHeight*le,h))continue;let Et=ne.calculateShadowPassMatrixFromTile(we.tileID.toUnwrapped());Et=i.cS(i.bC(),Et,[1,1,T.verticalScale]),st=Ty(Et),We=Ue=h.getOrCreateProgram("buildingDepth",{config:Ie,defines:F,overrideFog:!1})}else if(J)We=Ue=h.getOrCreateProgram("buildingBloom",{config:Ie,defines:F,overrideFog:!1}),st=WR(ut);else{const Et=h.transform.calculatePosMatrix(ye.toUnwrapped(),h.transform.worldSize);i.cS(Et,Et,[1,1,T.verticalScale]);const Nt=i.bC();i.cS(Nt,Et,[1,-1,1/le]),i.bl(Nt,Nt),i.eg(Nt,Nt);const Tt=h.transform.getFreeCameraOptions().position,wt=1<{if(J){const Tt=Et.entranceBloom;Nt.draw(h,z.gl.TRIANGLES,T.depthMode,yn.disabled,T.blendMode,mn.disabled,st,A.id,Tt.layoutVertexBuffer,Tt.indexBuffer,Tt.segmentsBucket,A.paint,h.transform.zoom,Ie,[Tt.layoutAttenuationBuffer,Tt.layoutColorBuffer])}else{const Tt=Et.segmentsBucket;let wt=[Et.layoutNormalBuffer,Et.layoutCentroidBuffer,Et.layoutColorBuffer,Et.layoutFloodLightDataBuffer];Et.layoutFacadePaintBuffer&&(wt=wt.concat([Et.layoutFacadeDataBuffer,Et.layoutFacadeVerticalRangeBuffer,Et.layoutFacadePaintBuffer])),Nt.draw(h,z.gl.TRIANGLES,T.depthMode,yn.disabled,T.blendMode,W?mn.disabled:mn.backCW,st,A.id,Et.layoutVertexBuffer,Et.indexBuffer,Tt,A.paint,h.transform.zoom,Ie,wt)}};h.uploadCommonUniforms(z,Ue,ye.toUnwrapped(),null,_e),Le.buildingWithoutFacade&&ot(Le.buildingWithoutFacade,Ue),Le.buildingWithFacade&&(We!==Ue&&h.uploadCommonUniforms(z,We,ye.toUnwrapped(),null,_e),ot(Le.buildingWithFacade,We))}}function p3(T,h,y,A,D,F,z,W,J,ne,le,_e,ye){const we=T.context.gl,Le=T.depthModeForSublayer(1,Fr.ReadOnly,we.LEQUAL,!0),Ie=.1*(1-(We=le))+3*We;var We;const Ue=T._showOverdrawInspector,st=_e,ut=new g6;Ue||ng(ut,T,h,y,A,Le,new yn({func:we.ALWAYS,mask:255},255,255,we.KEEP,we.KEEP,we.REPLACE),new Hn([we.ONE,we.ONE,we.ONE,we.ONE],i.ao.transparent,[!1,!1,!1,!0],we.MIN),mn.disabled,D,"sdf",F,z,W,J,ne,Ie,st,!1);{const ot=Ue?yn.disabled:new yn({func:we.EQUAL,mask:255},255,255,we.KEEP,we.DECR,we.DECR),Et=Ue?T.colorModeForRenderPass():new Hn([we.ONE_MINUS_DST_ALPHA,we.DST_ALPHA,we.ONE,we.ONE],i.ao.transparent,[!0,!0,!0,!0]);ng(ut,T,h,y,A,Le,ot,Et,mn.disabled,D,"color",F,z,W,J,ne,Ie,st,!1)}}function f3(T){return[T[0]*i.eh,T[1]*i.eh,T[2]*i.eh,0]}function p2(T,h,y,A,D,F,z,W,J){const ne=A.getSource(),le=y.globeSharedBuffers;if(!le)return;let _e,ye,we;if(h&&(_e=A.getTile(h)),ne instanceof i.aU?(ye=ne.texture,we=i.dK(0,0,y.transform)):_e&&h&&(ye=_e.texture,we=i.dK(h.canonical.z,h.canonical.x,y.transform)),!ye||!we)return;T||(we=i.cS(i.bC(),we,[1,-1,1]));const Le=y.context,Ie=Le.gl,We=D.paint.get("raster-resampling")==="nearest"?Ie.NEAREST:Ie.LINEAR,Ue=y.colorModeForDrapableLayerRenderPass(F),st=z.defines;st.push("GLOBE_POLES");const ut=new Fr(Ie.LEQUAL,Fr.ReadWrite,y.depthRangeFor3D),ot=Float32Array.from(y.transform.expandedFarZProjMatrix),Et=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0))));y.terrain&&y.terrain.prepareDrawTile(),Le.activeTexture.set(Ie.TEXTURE0),ye.bind(We,Ie.CLAMP_TO_EDGE),Le.activeTexture.set(Ie.TEXTURE1),ye.bind(We,Ie.CLAMP_TO_EDGE),"useMipmap"in ye&&Le.extTextureFilterAnisotropic&&y.transform.pitch>20&&Ie.texParameterf(Ie.TEXTURE_2D,Le.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,Le.extTextureFilterAnisotropicMax);const[Nt,Tt,wt,yt]=h?le.getPoleBuffers(h.canonical.z,!1):le.getPoleBuffers(0,!0),Ot=D.paint.get("raster-elevation");let Wt;T?(Wt=Nt,y.renderDefaultNorthPole=Ot!==0):(Wt=Tt,y.renderDefaultSouthPole=Ot!==0);const Ht=f3(z.mix),es=((xs,qs,Yt,Bt,as,Jt,Is,rr,yr,Js,Us,Pr,Cr)=>ZR(xs,qs,Yt,new Float32Array(16),new Float32Array(9),[0,0],Bt,[0,0],[0,0,0,0],1,{opacity:1,mix:0},Jt,[0,0],rr,2,Js,Us,Pr,1,0,Cr))(ot,Et,we,i.aj(y.transform.zoom),0,D,0,Ot,0,Ht,z.offset,z.range,F),ts=y.getOrCreateProgram("raster",{defines:st});y.uploadCommonUniforms(Le,ts,null),ts.draw(y,Ie.TRIANGLES,ut,J,Ue,W,es,D.id,Wt,wt,yt)}function sF(T){const h=T._nearZ,y=T.projection.farthestPixelDistance(T),A=y-h,D=.2*T.height,F=h+D;return[h,y,(F-D-h)/A,(F-h)/A]}function ig(T,h,y,A){if(T)return h instanceof kd&&T instanceof Cd?h.getTextureDescriptor(T,y,!0):{texture:T.texture,mix:f3(A.mix),offset:A.offset,buffer:0,tileSize:1}}var Ki=i.ei([{name:"a_index",type:"Int16",components:1}]);class x3{constructor(h,y,A,D){const F={width:A[0],height:A[1],data:null},z=h.gl;this.targetColorTexture=new i.T(h,F,z.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new i.T(h,F,z.RGBA8,{useMipmap:!1}),this.context=h,this.updateParticleTexture(y,D),this.lastInvalidatedAt=0}updateParticleTexture(h,y){if(this.particleTextureDimension===y.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const A=this.context.gl,D=y.width*y.height;this.particleTexture0=new i.T(this.context,y,A.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new i.T(this.context,y,A.RGBA8,{premultiply:!1,useMipmap:!1});const F=new i.ej;F.reserve(D);for(let z=0;z0){const Ht=i.bj(y.canonical,J),es=i.el(Ht);ye=i.aB(new Float32Array(16),J.globeMatrix,es),i.aB(ye,J.projMatrix,ye)}const we=i.bC();we[12]+=2*D/(i.o.devicePixelRatio*J.width),we[13]+=2*F/(i.o.devicePixelRatio*J.height),i.aB(ye,we,ye);const Le=T.getOrCreateProgram("debug",{defines:_e}),Ie=h.getTileByID(y.key);T.terrain&&T.terrain.setupElevationDraw(Ie,Le);const We=Fr.disabled,Ue=yn.disabled,st=T.colorModeForRenderPass(),ut="$debug";W.activeTexture.set(ne.TEXTURE0),T.emptyTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),le?Ie._makeGlobeTileDebugBuffers(T.context,J):Ie._makeDebugTileBoundsBuffers(T.context,J.projection);const ot=Ie._tileDebugBuffer||T.debugBuffer,Et=Ie._tileDebugIndexBuffer||T.debugIndexBuffer,Nt=Ie._tileDebugSegments||T.debugSegments;if(Le.draw(T,ne.LINE_STRIP,We,Ue,st,mn.disabled,c2(ye,A.toPremultipliedRenderColor(null)),ut,ot,Et,Nt,null,null,null,[Ie._globeTileDebugBorderBuffer]),z){const Ht=Ie.latestRawTileData,es=Math.floor((Ht&&Ht.byteLength||0)/1024);let ts=y.canonical.toString();y.overscaledZ!==y.canonical.z&&(ts+=` => ${y.overscaledZ}`),ts+=` ${Ie.state}`,ts+=` ${es}kb`,function(xs,qs){xs.initDebugOverlayCanvas();const Yt=xs.debugOverlayCanvas,Bt=xs.context.gl,as=xs.debugOverlayCanvas.getContext("2d");as.clearRect(0,0,Yt.width,Yt.height),as.shadowColor="white",as.shadowBlur=2,as.lineWidth=1.5,as.strokeStyle="white",as.textBaseline="top",as.font="bold 36px Open Sans, sans-serif",as.fillText(qs,5,5),as.strokeText(qs,5,5),xs.debugOverlayTexture.update(Yt),xs.debugOverlayTexture.bind(Bt.LINEAR,Bt.CLAMP_TO_EDGE)}(T,ts)}const Tt=h.getTile(y).tileSize,wt=512/Math.min(Tt,512)*(y.overscaledZ/J.zoom)*.5,yt=Ie._tileDebugTextBuffer||T.debugBuffer,Ot=Ie._tileDebugTextIndexBuffer||T.quadTriangleIndexBuffer,Wt=Ie._tileDebugTextSegments||T.debugSegments;Le.draw(T,ne.TRIANGLES,We,Ue,Hn.alphaBlended,mn.disabled,c2(ye,i.ao.transparent.toPremultipliedRenderColor(null),wt),ut,yt,Ot,Wt,null,null,null,[Ie._globeTileDebugTextBuffer])}function cv(T,h,y,A){Kt(T,0,h+y/2,T.transform.width,y,A)}function Io(T,h,y,A){Kt(T,h-y/2,0,y,T.transform.height,A)}function Kt(T,h,y,A,D,F){const z=T.context,W=z.gl;W.enable(W.SCISSOR_TEST),W.scissor(h*i.o.devicePixelRatio,y*i.o.devicePixelRatio,A*i.o.devicePixelRatio,D*i.o.devicePixelRatio),z.clear({color:F}),W.disable(W.SCISSOR_TEST)}const oF=i.ei([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:g3}=oF;function Uf(T,h,y,A){T.emplaceBack(h,y,A)}class y3{constructor(h){this.vertexArray=new i.em,this.indices=new i.b0,Uf(this.vertexArray,-1,-1,1),Uf(this.vertexArray,1,-1,1),Uf(this.vertexArray,-1,1,1),Uf(this.vertexArray,1,1,1),Uf(this.vertexArray,-1,-1,-1),Uf(this.vertexArray,1,-1,-1),Uf(this.vertexArray,-1,1,-1),Uf(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=h.createVertexBuffer(this.vertexArray,g3),this.indexBuffer=h.createIndexBuffer(this.indices),this.segment=i.bg.simpleSegment(0,0,36,12)}}function dv(T,h,y,A,D,F){const z=T.context.gl,W=h.paint.get("sky-atmosphere-color"),J=h.paint.get("sky-atmosphere-halo-color"),ne=h.paint.get("sky-atmosphere-sun-intensity"),le=((_e,ye,we,Le,Ie)=>({u_matrix_3f:_e,u_sun_direction:ye,u_sun_intensity:we,u_color_tint_r:[Le.r,Le.g,Le.b,Le.a],u_color_tint_m:[Ie.r,Ie.g,Ie.b,Ie.a],u_luminance:5e-5}))(i.eo(i.dO(),A),D,ne,W.toPremultipliedRenderColor(null),J.toPremultipliedRenderColor(null));z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+F,h.skyboxTexture,0),y.draw(T,z.TRIANGLES,Fr.disabled,yn.disabled,Hn.unblended,mn.frontCW,le,"skyboxCapture",h.skyboxGeometry.vertexBuffer,h.skyboxGeometry.indexBuffer,h.skyboxGeometry.segment)}const lF=i.ei([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class ub{constructor(h){const y=new i.ep;y.emplaceBack(-1,1,1,0,0),y.emplaceBack(1,1,1,1,0),y.emplaceBack(1,-1,1,1,1),y.emplaceBack(-1,-1,1,0,1);const A=new i.b0;A.emplaceBack(0,1,2),A.emplaceBack(2,3,0),this.vertexBuffer=h.createVertexBuffer(y,lF.members),this.indexBuffer=h.createIndexBuffer(A),this.segments=i.bg.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const qme=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 Ume{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class cF{constructor(h){this.colorModeAlphaBlendedWriteRGB=new Hn([1,zf,1,zf],i.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Hn([1,0,1,0],i.ao.transparent,[!1,!1,!1,!0]),this.params=new Ume,this.updateNeeded=!0}update(h){const y=h.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new ub(y);const A=this.params.sizeRange,D=this.params.intensityRange,F=function(le){const _e=i.eq(30),ye=[];for(let we=0;we{const wt=F.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];Tt&&wt.push("ALPHA_PASS");const yt=h.getOrCreateProgram("globeAtmosphere",{defines:wt}),Ot=((Ht,es,ts,xs,qs,Yt,Bt,as,Jt,Is,rr,yr)=>({u_frustum_tl:Ht,u_frustum_tr:es,u_frustum_br:ts,u_frustum_bl:xs,u_horizon:qs,u_transition:Yt,u_fadeout_range:Bt,u_atmosphere_fog_color:as.toArray01(),u_high_color:Jt.toArray01(),u_space_color:Is.toArray01(),u_temporal_offset:rr,u_horizon_angle:yr}))(F.frustumCorners.TL,F.frustumCorners.TR,F.frustumCorners.BR,F.frustumCorners.BL,F.frustumCorners.horizon,W,We,le,ye,Le,st,Et);h.uploadCommonUniforms(A,yt);const Wt=this.atmosphereBuffer;Wt&&yt.draw(h,D.TRIANGLES,z,yn.disabled,Tt?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,mn.backCW,Ot,Tt?"atmosphere_glow_alpha":"atmosphere_glow",Wt.vertexBuffer,Wt.indexBuffer,Wt.segments)};Nt(!1),Nt(!0)}drawStars(h,y){const A=i.aA(y.properties.get("star-intensity"),0,1);if(A===0)return;const D=h.context,F=D.gl,z=h.transform,W=h.getOrCreateProgram("stars"),J=i.c7([]);i.c9(J,J,-z._pitch),i.c8(J,J,-z.angle),i.c9(J,J,i.an(z._center.lat)),i.et(J,J,-i.an(z._center.lng));const ne=i.cc(new Float32Array(16),J),le=i.aB([],z.starsProjMatrix,ne),_e=i.eo([],ne),ye=i.eu([],_e),we=[0,1,0];i.dQ(we,we,ye),i.c5(we,we,this.params.sizeMultiplier);const Le=[1,0,0];i.dQ(Le,Le,ye),i.c5(Le,Le,this.params.sizeMultiplier);const Ie=(We=we,Ue=Le,st=A,{u_matrix:Float32Array.from(le),u_up:We,u_right:Ue,u_intensity_multiplier:st});var We,Ue,st;h.uploadCommonUniforms(D,W),this.starsVx&&this.starsIdx&&W.draw(h,F.TRIANGLES,Fr.disabled,yn.disabled,this.colorModeAlphaBlendedWriteRGB,mn.disabled,Ie,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class v3{constructor(){this.visibleTiles=[]}updateBorders(h,y){const A=[],D=[],F=h._getRenderableCoordinates(!1,!0);for(const J of F){const ne=h.getTile(J);if(!ne.hasData())continue;const le=ne.getBucket(y);le&&(le.isEmpty()||(A.push(J.key),D.push({bucket:le,tileID:J.canonical})))}let z=A.length!==this.visibleTiles.length;if(!z){A.sort();for(let J=0;JJ.tileID.z-ne.tileID.z||J.tileID.x-ne.tileID.x||J.tileID.y-ne.tileID.y);for(const J of D){const ne=new Array,le=new Array,_e=J.bucket;for(const ye of _e.featuresOnBorder)W.has(ye.featureId)?le.push(ye.footprintIndex):(W.add(ye.featureId),ne.push(ye.footprintIndex));_e.updateFootprintHiddenFlags(ne,i.ev,!1),_e.updateFootprintHiddenFlags(le,i.ev,!0)}}}function b3(T,h){const y=[...T],A=h.cameraWorldSizeForFog/h.worldSize,D=i.bA([]);return i.cS(D,D,[A,A,1]),i.aB(y,D,y),i.aB(y,h.worldToFogMatrix,y),y}function _3(T,h,y,A,D){const F=y.material,z=A.context,{baseColorTexture:W,metallicRoughnessTexture:J}=F.pbrMetallicRoughness,{normalTexture:ne,occlusionTexture:le,emissionTexture:_e}=F;function ye(Le,Ie,We){if(Le&&(T.push(Ie),z.activeTexture.set(z.gl.TEXTURE0+We),Le.gfxTexture)){const{minFilter:Ue,magFilter:st,wrapS:ut,wrapT:ot}=Le.sampler;Le.gfxTexture.bindExtraParam(Ue,st,ut,ot)}}ye(W,"HAS_TEXTURE_u_baseColorTexture",Gc.BaseColor),ye(J,"HAS_TEXTURE_u_metallicRoughnessTexture",Gc.MetallicRoughness),ye(ne,"HAS_TEXTURE_u_normalTexture",Gc.Normal),ye(le,"HAS_TEXTURE_u_occlusionTexture",Gc.Occlusion),ye(_e,"HAS_TEXTURE_u_emissionTexture",Gc.Emission),D&&(D.texture||(D.texture=new i.d$(A.context,D.image,[D.image.height,D.image.height,D.image.height],z.gl.RGBA8)),z.activeTexture.set(z.gl.TEXTURE0+Gc.LUT),D.texture&&D.texture.bind(z.gl.LINEAR,z.gl.CLAMP_TO_EDGE),T.push("APPLY_LUT_ON_GPU")),y.texcoordBuffer&&(T.push("HAS_ATTRIBUTE_a_uv_2f"),h.push(y.texcoordBuffer)),y.colorBuffer&&(T.push(y.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),h.push(y.colorBuffer)),y.normalBuffer&&(T.push("HAS_ATTRIBUTE_a_normal_3f"),h.push(y.normalBuffer)),y.pbrBuffer&&(T.push("HAS_ATTRIBUTE_a_pbr"),T.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),h.push(y.pbrBuffer)),F.alphaMode!=="OPAQUE"&&F.alphaMode!=="MASK"||T.push("UNPREMULT_TEXTURE_IN_SHADER"),F.defined||T.push("DIFFUSE_SHADED");const we=A.shadowRenderer;we&&(T.push("RENDER_SHADOWS","DEPTH_TEXTURE"),we.useNormalOffset&&T.push("NORMAL_OFFSET"))}function w3(T,h,y,A,D,F){const z=T.modelOpacity,W=h.context,J=new Fr(h.context.gl.LEQUAL,T.isLightMesh?Fr.ReadOnly:Fr.ReadWrite,h.depthRangeFor3D),ne=h.transform,le=T.mesh,_e=le.material,ye=_e.pbrMetallicRoughness,we=h.style.fog;let Le;Le=h.transform.projection.zAxisUnit==="pixels"?[...T.nodeModelMatrix]:i.aB([],A.zScaleMatrix,T.nodeModelMatrix),i.aB(Le,A.negCameraPosMatrix,Le);const Ie=i.bl([],Le);i.eg(Ie,Ie);const We=y.paint.get("model-color-use-theme").constantOr("default")==="none",Ue=y.paint.get("model-emissive-strength").constantOr(0),st=av(new Float32Array(T.worldViewProjection),new Float32Array(Le),new Float32Array(Ie),null,h,z,ye.baseColorFactor,_e.emissiveFactor,ye.metallicFactor,ye.roughnessFactor,_e,Ue,y,void 0,void 0,T.materialOverride,T.modelColor),ut={defines:[]},ot=[],Et=h.shadowRenderer;Et&&(Et.useNormalOffset=!1),_3(ut.defines,ot,le,h,We?null:y.lut);let Nt=null;if(we){const yt=b3(T.nodeModelMatrix,h.transform);if(Nt=new Float32Array(yt),ne.projection.name!=="globe"){const Ot=le.aabb.min,Wt=le.aabb.max,[Ht,es]=we.getOpacityForBounds(yt,Ot[0],Ot[1],Wt[0],Wt[1]);ut.overrideFog=Ht>=gs||es>=gs}}const Tt=wy(h,y.paint.get("model-cutoff-fade-range"));Tt.shouldRenderCutoff&&ut.defines.push("RENDER_CUTOFF");const wt=h.getOrCreateProgram("model",ut);h.uploadCommonUniforms(W,wt,null,Nt,Tt),h.renderPass!=="shadow"&&Et&&Et.setupShadowsFromMatrix(T.nodeModelMatrix,wt),wt.draw(h,W.gl.TRIANGLES,J,D,F,le.material.doubleSided?mn.disabled:mn.backCCW,st,y.id,le.vertexBuffer,le.indexBuffer,le.segments,y.paint,h.transform.zoom,void 0,ot)}function f2(T,h){return T.style._importedAsBasemap?"basemap":h.scope}function uv(T,h,y,A,D,F,z,W,J,ne){const le=T.transform,_e=!!h.isGeometryBloom&&h.isGeometryBloom;if(_e&&T.renderPass==="shadow")return;const ye=le.projection.name==="globe"?i.eD(y,le):[...y];i.aB(ye,ye,h.globalMatrix);const we=i.aB([],A,ye);if(h.meshes)for(const Le of h.meshes){const Ie=W.get(Le.material.name);if(Ie&&Ie.opacity<=0)continue;if(Le.material.alphaMode!=="BLEND"){z.push({mesh:Le,depth:0,modelIndex:D,worldViewProjection:we,nodeModelMatrix:ye,isLightMesh:_e,materialOverride:Ie,modelOpacity:J,modelColor:ne});continue}const We=i.af([],Le.centroid,we);!le.isOrthographic&&We[2]<=0||F.push({mesh:Le,depth:We[2],modelIndex:D,worldViewProjection:we,nodeModelMatrix:ye,isLightMesh:_e,materialOverride:Ie,modelOpacity:J,modelColor:ne})}if(h.children)for(const Le of h.children)uv(T,Le,y,A,D,F,z,W,J,ne)}function $p(T,h,y,A){const D=y.shadowRenderer;if(!D)return;const F=D.getShadowPassDepthMode(),z=D.getShadowPassColorMode(),W=D.calculateShadowPassMatrixFromMatrix(h),J=p6(W);y.getOrCreateProgram("modelDepth",{defines:y._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(y,y.context.gl.TRIANGLES,F,yn.disabled,z,mn.disabled,J,A.id,T.vertexBuffer,T.indexBuffer,T.segments,A.paint,y.transform.zoom,void 0,void 0)}function dF(T,h,y,A,D,F){for(const z of D){const W=Object.assign({},A);W.part=z;const J={type:"Unknown",id:h,properties:W},ne={orientation:T.paint.get("model-rotation").evaluate(J,y)};F.set(z,ne)}}function uF(T,h,y,A,D,F){for(const z of D){const W=Object.assign({},A);W.part=z;const J={type:"Unknown",id:h,properties:W},ne={color:T.paint.get("model-color").evaluate(J,y),colorMix:T.paint.get("model-color-mix-intensity").evaluate(J,y),opacity:T.paint.get("model-opacity").evaluate(J,y),emissionStrength:T.paint.get("model-emissive-strength").evaluate(J,y)};F.set(z,ne)}}function hF(T,h,y,A,D){let F=!1;for(const W of A)W.modelOpacity!==1&&(w3(W,T,h,D[W.modelIndex],yn.disabled,Hn.disabled),F=!0);for(const W of A)w3(W,T,h,D[W.modelIndex],W.modelOpacity!==1?T.stencilModeFor3D():yn.disabled,T.colorModeForRenderPass());F&&T.resetStencilClippingMasks();const z=Hn.additive;for(const W of y)w3(W,T,h,D[W.modelIndex],yn.disabled,W.isLightMesh?z:T.colorModeForRenderPass())}function mF(T,h,y){const A=h.updateZoomBasedPaintProperties(),D=function(F,z,W){let J,ne,le,_e=F.terrain?F.terrain.exaggeration():0;if(F.terrain&&_e>0){const ye=F.terrain,we=ye.findDEMTileFor(W);we&&we.dem?J=i.eF.create(ye,W,we):_e=0}if(_e===0&&(z.terrainElevationMin=0,z.terrainElevationMax=0),_e===z.validForExaggeration&&(_e===0||J&&J._demTile&&J._demTile.tileID===z.validForDEMTile.id&&J._dem._timestamp===z.validForDEMTile.timestamp))return!1;for(const ye in z.instancesPerModel){const we=z.instancesPerModel[ye];for(let Le=0;Lene&&(ne=we.max)}const le=i.aA(A.x,F,z)-A.x,_e=i.aA(A.y,W,J)-A.y,ye=i.cf(ne,h.center.lat)-A.z;return h._zoomFromMercatorZ(Math.sqrt(le*le+_e*_e+ye*ye))}function pF(T,h,y,A,D,F,z){const W=T.context,J=T.renderPass==="shadow",ne=T.shadowRenderer,le=J&&ne?ne.getShadowPassDepthMode():new Fr(W.gl.LEQUAL,Fr.ReadWrite,T.depthRangeFor3D),_e=T.isTileAffectedByFog(F),ye=T.transform.projection.name==="globe";if(y.meshes)for(const we of y.meshes){const Le=ye?[]:["MODEL_POSITION_ON_GPU"],Ie=[];let We,Ue,st;const ut=!ye&&A.instancedDataArray.length>20;ut&&Le.push("INSTANCED_ARRAYS");const ot=wy(T,h.paint.get("model-cutoff-fade-range"));if(ot.shouldRenderCutoff&&Le.push("RENDER_CUTOFF"),J&&ne)We=T.getOrCreateProgram("modelDepth",{defines:Le}),Ue=p6(z.shadowTileMatrix,z.shadowTileMatrix,Float32Array.from(y.globalMatrix)),st=ne.getShadowPassColorMode();else{_3(Le,Ie,we,T,h.paint.get("model-color-use-theme").constantOr("default")==="none"?null:h.lut),We=T.getOrCreateProgram("model",{defines:Le,overrideFog:_e});const Nt=we.material,Tt=Nt.pbrMetallicRoughness,wt=h.paint.get("model-opacity").constantOr(1),yt=h.paint.get("model-emissive-strength").constantOr(0);Ue=av(F.expandedProjMatrix,Float32Array.from(y.globalMatrix),new Float32Array(16),null,T,wt,Tt.baseColorFactor,Nt.emissiveFactor,Tt.metallicFactor,Tt.roughnessFactor,Nt,yt,h,D),ne&&(z.shadowUniformsInitialized?We.setShadowUniformValues(W,ne.getShadowUniformValues()):(ne.setupShadows(F.toUnwrapped(),We,"model-tile"),z.shadowUniformsInitialized=!0)),st=ot.shouldRenderCutoff||wt<1||Nt.alphaMode!=="OPAQUE"?Hn.alphaBlended:Hn.unblended}T.uploadCommonUniforms(W,We,F.toUnwrapped(),null,ot);const Et=we.material.doubleSided?mn.disabled:mn.backCCW;if(ut)Ie.push(A.instancedDataBuffer),We.draw(T,W.gl.TRIANGLES,le,yn.disabled,st,Et,Ue,h.id,we.vertexBuffer,we.indexBuffer,we.segments,h.paint,T.transform.zoom,void 0,Ie,A.instancedDataArray.length);else{const Nt=J?"u_instance":"u_normal_matrix";for(let Tt=0;TtJ[1]?z:J,F[0]=y.max[0],z=i.aC(i.eG(),F,D),W=z[1]J[1]?z:J,F[1]=y.min[1],z=i.aC(i.eG(),F,D),W=z[1]J[1]?z:J;const ne=i.aA(A[0],0,1),le=100*h.pixelsPerMeter*i.aA(A[1],0,1),_e=i.aA(A[2],0,1),ye=i.eH(i.eG(),W,J,ne),we=Math.tan(.5*h.fovX),Le=-ye[2]*we;if(le===0)return ye[1]<-Math.abs(Le)?_e:1;const Ie=(-Math.abs(Le)-ye[1])/le,We=(st,ut,ot)=>(1-ot)*st+ot*ut,Ue=i.aA(We(1,_e,Ie),_e,1);return We(1,Ue,i.aA((h.pitch-20)/20,0,1))}class fF{}class Py{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(h,y,A){{const _e=this._storage.get(y.id);if(_e)return _e.lastUsedFrameIdx=h,_e.buf}const D=A.gl,F=D.getBufferParameter(D.ELEMENT_ARRAY_BUFFER,D.BUFFER_SIZE),z=new ArrayBuffer(F),W=new Int16Array(z);D.getBufferSubData(D.ELEMENT_ARRAY_BUFFER,0,new Int16Array(z));const J=new i.eJ;for(let _e=0;_e30&&(A.buf.destroy(),this._storage.delete(y))}destroy(){for(const[h,y]of this._storage)y.buf.destroy(),this._storage.delete(h)}}class hb{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const mb=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 og{constructor(h){this.revealStart=11,this.revealRange=2}}const b6=i.ei([{type:"Float32",name:"a_pos_2f",components:2}]);class _6{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(h,y){const A=h.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const z=new i.eK,W=new i.b0;z.emplaceBack(-1,-1),z.emplaceBack(1,-1),z.emplaceBack(1,1),z.emplaceBack(-1,1),W.emplaceBack(0,1,2),W.emplaceBack(0,2,3),this.vignetteVx=h.context.createVertexBuffer(z,b6.members),this.vignetteIdx=h.context.createIndexBuffer(W)}const D=i.bg.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){h.uploadCommonUniforms(h.context,A);const z={u_vignetteShape:(F={vignetteShape:[y.start,y.range,Math.pow(10,y.fadePower)],vignetteColor:[y.color.r,y.color.g,y.color.b,y.color.a*y.strength]}).vignetteShape,u_vignetteColor:F.vignetteColor};A.draw(h,h.context.gl.TRIANGLES,Fr.disabled,yn.disabled,Hn.alphaBlended,mn.disabled,z,"vignette",this.vignetteVx,this.vignetteIdx,D)}var F}}class w6{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(h,y){const A=h.getFreeCameraOptions().position,D=A.toAltitude(),F=A.toLngLat(),z=i.an(F.lng),W=i.an(F.lat),J=h.pixelsPerMeter/y,ne=z*i.eM,le=i.eM*Math.log(Math.tan(Math.PI/4+W/2));if(this._offsetXPrev===void 0)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{const _e=-this._offsetYPrev+le,ye=-this._elevationPrev+D;this._accumulatedOffsetX+=(-this._offsetXPrev+ne)*J,this._accumulatedOffsetY+=_e*J,this._accumulatedElevation+=ye*J,this._offsetXPrev=ne,this._offsetYPrev=le,this._elevationPrev=D}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function j3(T,h){return[-(T[0]-Math.floor(T[0]/h)*h),-(T[1]-Math.floor(T[1]/h)*h),-(T[2]-Math.floor(T[2]/h)*h)]}function dm(T){const h=i.eq(1323123451230),y=[];for(let A=0;A Rain"),this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3}update(h){const y=h.context;if(!this.particlesVx){const A=dm(this.particlesCount),D=new i.eN,F=new i.b0;let z=0;const W=i.eq(1323123451230);for(let J=0;JA)return;const D=uh(0,1,y.revealStart,y.revealStart+y.revealRange,A);if(!this.particlesVx||!this.particlesIdx)return;const F=structuredClone(this._params);let z=[-F.direction.x,F.direction.y,-100];i.aw(z,z);const W=structuredClone(this._vignetteParams);W.strength*=D,F.overrideStyleParameters||(F.intensity=h.style.rain.state.density,F.timeFactor=h.style.rain.state.intensity,F.color=structuredClone(h.style.rain.state.color),z=structuredClone(h.style.rain.state.direction),F.screenThinning.intensity=h.style.rain.state.centerThinning,F.dropletSizeX=h.style.rain.state.dropletSize[0],F.dropletSizeYScale=h.style.rain.state.dropletSize[1]/h.style.rain.state.dropletSize[0],F.distortionStrength=100*h.style.rain.state.distortionStrength,W.strength=1,W.color=structuredClone(h.style.rain.state.vignetteColor));const J=this.updateOnRender(h,F.timeFactor),ne=h.context,le=ne.gl,_e=h.transform;this.screenTexture&&this.screenTexture.size[0]===h.width&&this.screenTexture.size[1]===h.height||(this.screenTexture=new i.T(ne,{width:h.width,height:h.height,data:null},le.RGBA8)),F.distortionStrength>0&&(ne.activeTexture.set(le.TEXTURE0),this.screenTexture.bind(le.LINEAR,le.CLAMP_TO_EDGE),le.copyTexSubImage2D(le.TEXTURE_2D,0,0,0,0,0,h.width,h.height));const ye=h.getOrCreateProgram("rainParticle");h.uploadCommonUniforms(ne,ye),ne.activeTexture.set(le.TEXTURE0),this.screenTexture.bind(le.LINEAR,le.CLAMP_TO_EDGE);const we=[F.color.r,F.color.g,F.color.b,F.color.a],Le=(Ie,We)=>{const Ue=j3(this._movement.getPosition(),Ie),st=F.dropletSizeX,ut=F.dropletSizeX*F.dropletSizeYScale,ot=h.width/2,Et=h.height/2,Nt=uh(0,F.screenThinning.start,0,1,F.screenThinning.intensity),Tt=uh(.001,F.screenThinning.range,0,1,F.screenThinning.intensity),wt=uh(0,F.screenThinning.particleOffset,0,1,F.screenThinning.intensity),yt=(Ot={modelview:J.modelviewMatrix,projection:J.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Ue,velocityConeAperture:F.velocityConeAperture,velocity:F.velocity,boxSize:Ie,rainDropletSize:[st,ut],distortionStrength:F.distortionStrength,rainDirection:z,color:we,screenSize:[_e.width,_e.height],thinningCenterPos:[ot,Et],thinningShape:[Nt,Tt,Math.pow(10,F.screenThinning.fadePower)],thinningAffectedRatio:F.screenThinning.affectedRatio,thinningParticleOffset:wt,shapeDirectionalPower:F.shapeDirPower,shapeNormalPower:F.shapeNormalPower,mode:We?0:1},{u_modelview:Float32Array.from(Ot.modelview),u_projection:Float32Array.from(Ot.projection),u_time:Ot.time,u_cam_pos:Ot.camPos,u_texScreen:0,u_velocityConeAperture:Ot.velocityConeAperture,u_velocity:Ot.velocity,u_boxSize:Ot.boxSize,u_rainDropletSize:Ot.rainDropletSize,u_distortionStrength:Ot.distortionStrength,u_rainDirection:Ot.rainDirection,u_color:Ot.color,u_screenSize:Ot.screenSize,u_thinningCenterPos:Ot.thinningCenterPos,u_thinningShape:Ot.thinningShape,u_thinningAffectedRatio:Ot.thinningAffectedRatio,u_thinningParticleOffset:Ot.thinningParticleOffset,u_shapeDirectionalPower:Ot.shapeDirectionalPower,u_shapeNormalPower:Ot.shapeNormalPower,u_mode:Ot.mode});var Ot;const Wt=Math.round(F.intensity*this.particlesCount),Ht=i.bg.simpleSegment(0,0,4*Wt,2*Wt);ye.draw(h,le.TRIANGLES,Fr.disabled,yn.disabled,Hn.alphaBlended,mn.disabled,yt,"rain_particles",this.particlesVx,this.particlesIdx,Ht)};F.distortionStrength>0&&Le(F.boxSize,!0),Le(F.boxSize,!1),this._vignette.draw(h,W)}}const j6=i.ei([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]);class N6 extends hv{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 og("Precipitation > Snow"),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3}update(h){const y=h.context;if(!this.particlesVx){const A=dm(this.particlesCount),D=new i.eO,F=new i.b0;let z=0;const W=i.eq(1323123451230);for(let J=0;Jz)return;const W=uh(0,1,F.revealStart,F.revealStart+F.revealRange,z);D.strength*=W,y.overrideStyleParameters||(y.intensity=h.style.snow.state.density,y.timeFactor=h.style.snow.state.intensity,y.color=structuredClone(h.style.snow.state.color),A=structuredClone(h.style.snow.state.direction),y.screenThinning.intensity=h.style.snow.state.centerThinning,y.billboardSize=2.79*h.style.snow.state.flakeSize,D.strength=1,D.color=structuredClone(h.style.snow.state.vignetteColor));const J=this.updateOnRender(h,y.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const ne=h.context,le=ne.gl,_e=h.transform,ye=h.getOrCreateProgram("snowParticle");h.uploadCommonUniforms(ne,ye),((we,Le,Ie)=>{const We=j3(this._movement.getPosition(),we),Ue=_e.width/2,st=_e.height/2,ut=uh(0,Ie.screenThinning.start,0,1,Ie.screenThinning.intensity),ot=uh(.001,Ie.screenThinning.range,0,1,Ie.screenThinning.intensity),Et=uh(0,Ie.screenThinning.particleOffset,0,1,Ie.screenThinning.intensity),Nt=(Tt={modelview:J.modelviewMatrix,projection:J.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:We,velocityConeAperture:Ie.velocityConeAperture,velocity:Ie.velocity,horizontalOscillationRadius:Ie.horizontalOscillationRadius,horizontalOscillationRate:Ie.horizontalOscillationRate,boxSize:we,billboardSize:1*Ie.billboardSize,simpleShapeParameters:[Ie.shapeFadeStart,Ie.shapeFadePower],screenSize:[_e.width,_e.height],thinningCenterPos:[Ue,st],thinningShape:[ut,ot,Math.pow(10,Ie.screenThinning.fadePower)],thinningAffectedRatio:Ie.screenThinning.affectedRatio,thinningParticleOffset:Et,color:[Ie.color.r,Ie.color.g,Ie.color.b,Ie.color.a],direction:A},{u_modelview:Float32Array.from(Tt.modelview),u_projection:Float32Array.from(Tt.projection),u_time:Tt.time,u_cam_pos:Tt.camPos,u_velocityConeAperture:Tt.velocityConeAperture,u_velocity:Tt.velocity,u_horizontalOscillationRadius:Tt.horizontalOscillationRadius,u_horizontalOscillationRate:Tt.horizontalOscillationRate,u_boxSize:Tt.boxSize,u_billboardSize:Tt.billboardSize,u_simpleShapeParameters:Tt.simpleShapeParameters,u_screenSize:Tt.screenSize,u_thinningCenterPos:Tt.thinningCenterPos,u_thinningShape:Tt.thinningShape,u_thinningAffectedRatio:Tt.thinningAffectedRatio,u_thinningParticleOffset:Tt.thinningParticleOffset,u_particleColor:Tt.color,u_direction:Tt.direction});var Tt;const wt=Math.round(Ie.intensity*this.particlesCount),yt=i.bg.simpleSegment(0,0,4*wt,2*wt);this.particlesVx&&this.particlesIdx&&ye.draw(h,le.TRIANGLES,Fr.disabled,yn.disabled,Hn.alphaBlended,mn.disabled,Nt,"snow_particles",this.particlesVx,this.particlesIdx,yt)})(y.boxSize,0,y),this._vignette.draw(h,D)}}const Iy={symbol:function(T,h,y,A,D){if(T.renderPass!=="translucent")return;const F=yn.disabled,z=T.colorModeForRenderPass(),W=y.layout.get("text-variable-anchor"),J=y.layout.get("text-size-scale-range"),ne=i.aA(T.scaleFactor,J[0],J[1]);W&&function(ye,we,Le,Ie,We,Ue,st,ut){const ot=we.transform,Et=We==="map",Nt=Ue==="map";for(const Tt of ye){const wt=Ie.getTile(Tt),yt=wt.getBucket(Le);if(!yt||!yt.text||!yt.text.segments.get().length)continue;const Ot=i.bK(yt.textSizeData,ot.zoom,ut),Wt=Xm(Tt,yt.getProjection(),ot),Ht=ot.calculatePixelsToTileUnitsMatrix(wt),es=Qs(Wt,wt.tileID.canonical,Nt,Et,ot,yt.getProjection(),Ht),ts=yt.hasIconTextFit()&&yt.hasIconData();Ot&&en(yt,Et,Nt,st,ot,es,Tt,Math.pow(2,ot.zoom-wt.tileID.overscaledZ),Ot,ts)}}(A,T,y,h,y.layout.get("text-rotation-alignment"),y.layout.get("text-pitch-alignment"),D,ne);const le=y.paint.get("icon-opacity").constantOr(1)!==0,_e=y.paint.get("text-opacity").constantOr(1)!==0;y.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(le||_e)?h2(T,h,y,A,F,z):(le&&h2(T,h,y,A,F,z,{onlyIcons:!0}),_e&&h2(T,h,y,A,F,z,{onlyText:!0})),h.map.showCollisionBoxes&&(kr(T,h,y,A,y.paint.get("text-translate"),y.paint.get("text-translate-anchor"),!0),kr(T,h,y,A,y.paint.get("icon-translate"),y.paint.get("icon-translate-anchor"),!1))},circle:function(T,h,y,A){if(T.renderPass!=="translucent")return;const D=y.paint.get("circle-opacity"),F=y.paint.get("circle-stroke-width"),z=y.paint.get("circle-stroke-opacity"),W=y.layout.get("circle-sort-key").constantOr(1)!==void 0,J=y.paint.get("circle-emissive-strength");if(D.constantOr(1)===0&&(F.constantOr(1)===0||z.constantOr(1)===0))return;const ne=T.context,le=ne.gl,_e=T.transform,ye=!(!T.terrain||!T.terrain.enabled),we=y.layout.get("circle-elevation-reference"),Le=T.depthModeForSublayer(0,Fr.ReadOnly),Ie=new Fr(T.context.gl.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D),We=we==="none"||ye?Le:Ie,Ue=yn.disabled,st=T.colorModeForDrapableLayerRenderPass(J),ut=_e.projection.name==="globe",ot=[i.aF(_e.center.lng),i.aJ(_e.center.lat)],Et=[];for(let Tt=0;TtTt.sortKey-wt.sortKey);const Nt={useDepthForOcclusion:_e.depthOcclusionForSymbolsAndCircles};for(const Tt of Et){const{programConfiguration:wt,program:yt,layoutVertexBuffer:Ot,dynamicBuffers:Wt,indexBuffer:Ht,uniformValues:es,tile:ts}=Tt.state,xs=Tt.segments;T.terrain&&T.terrain.setupElevationDraw(ts,yt,Nt),T.uploadCommonUniforms(ne,yt,ts.tileID.toUnwrapped()),yt.draw(T,le.TRIANGLES,We,Ue,st,mn.disabled,es,y.id,Ot,Ht,xs,y.paint,_e.zoom,wt,Wt)}},heatmap:function(T,h,y,A){if(y.paint.get("heatmap-opacity")!==0)if(T.renderPass==="offscreen"){const D=T.context,F=D.gl,z=yn.disabled,W=new Hn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!0,!0,!0,!0]);(function(we,Le,Ie,We){const Ue=we.gl,st=Le.width*We,ut=Le.height*We;we.activeTexture.set(Ue.TEXTURE1),we.viewport.set([0,0,st,ut]);let ot=Ie.heatmapFbo;if(!ot||ot&&(ot.width!==st||ot.height!==ut)){ot&&ot.destroy();const Et=Ue.createTexture();Ue.bindTexture(Ue.TEXTURE_2D,Et),Ue.texParameteri(Ue.TEXTURE_2D,Ue.TEXTURE_WRAP_S,Ue.CLAMP_TO_EDGE),Ue.texParameteri(Ue.TEXTURE_2D,Ue.TEXTURE_WRAP_T,Ue.CLAMP_TO_EDGE),Ue.texParameteri(Ue.TEXTURE_2D,Ue.TEXTURE_MIN_FILTER,Ue.LINEAR),Ue.texParameteri(Ue.TEXTURE_2D,Ue.TEXTURE_MAG_FILTER,Ue.LINEAR),ot=Ie.heatmapFbo=we.createFramebuffer(st,ut,1,null),function(Nt,Tt,wt,yt,Ot,Wt){const Ht=Nt.gl;Ht.texImage2D(Ht.TEXTURE_2D,0,Nt.extRenderToTextureHalfFloat?Ht.RGBA16F:Ht.RGBA,Ot,Wt,0,Ht.RGBA,Nt.extRenderToTextureHalfFloat?Ht.HALF_FLOAT:Ht.UNSIGNED_BYTE,null),yt.colorAttachment0.set(wt)}(we,0,Et,ot,st,ut)}else Ue.bindTexture(Ue.TEXTURE_2D,ot.colorAttachment0.get()),we.bindFramebuffer.set(ot.framebuffer)})(D,T,y,T.transform.projection.name==="globe"?.5:.25),D.clear({color:i.ao.transparent});const J=T.transform,ne=J.projection.name==="globe",le=ne?["PROJECTION_GLOBE_VIEW"]:[],_e=ne?mn.frontCCW:mn.disabled,ye=[i.aF(J.center.lng),i.aJ(J.center.lat)];for(let we=0;we({u_image:0,u_color_ramp:1,u_opacity:_e.paint.get("heatmap-opacity")}))(0,F),F.id,D.viewportBuffer,D.quadTriangleIndexBuffer,D.viewportSegments,F.paint,D.transform.zoom)}(T,y))},line:function(T,h,y,A){if(T.renderPass!=="translucent")return;const D=y.paint.get("line-opacity"),F=y.paint.get("line-width");if(D.constantOr(1)===0||F.constantOr(1)===0)return;const z=y.paint.get("line-emissive-strength").isConstant(),W=y.paint.get("line-emissive-strength").constantOr(0),J=y.paint.get("line-occlusion-opacity"),ne=y.layout.get("line-elevation-reference"),le=y.layout.get("line-width-unit")==="meters",_e=ne==="sea",ye=!(!T.terrain||!T.terrain.enabled),we=T.context,Le=we.gl;if(y.hasElevatedBuckets&&T.transform.projection.name==="globe")return;const Ie=y.layout.get("line-cross-slope"),We=Ie!==void 0,Ue=Ie<1,st=T.colorModeForDrapableLayerRenderPass(z?W:null),ut=T.terrain&&T.terrain.renderingToTexture,ot=ut?1:i.o.devicePixelRatio,Et=y.paint.get("line-dasharray"),Nt=Et.constantOr(1),Tt=y.layout.get("line-cap"),wt=Et.constantOr(null),yt=Tt.constantOr(null),Ot=y.paint.get("line-pattern"),Wt=Ot.constantOr(1),Ht=y.paint.get("line-pattern-cross-fade"),es=Ot.constantOr(null),ts=y.paint.get("line-opacity").constantOr(1);let xs=!Wt&&ts!==1||T.depthOcclusion&&J>0&&J<1;const qs=y.paint.get("line-gradient"),Yt=Wt?"linePattern":"line",Bt=i.e2(y);let as;if(ut&&T.terrain&&T.terrain.clipOrMaskOverlapStencilType()&&(xs=!1),J!==0&&T.depthOcclusion){const yr=y.paint._values["line-opacity"];yr&&yr.value&&yr.value.kind==="constant"?as=yr.value:i.w(`Occlusion opacity for layer ${y.id} is supported only when line-opacity isn't data-driven.`)}F.value.kind!=="constant"&&F.value.isLineProgressConstant===!1&&Bt.push("VARIABLE_LINE_WIDTH"),ut&&(T.emissiveMode!=="dual-source-blending"||z?T.emissiveMode==="mrt-fallback"&&Bt.push("USE_MRT1"):Bt.push("DUAL_SOURCE_BLENDING"));const Jt=(yr,Js,Us,Pr,Cr,hr)=>{for(const br of yr){const Kr=h.getTile(br);if(Wt&&!Kr.patternsLoaded())continue;const Pn=Kr.getBucket(y);if(!Pn||Pn.elevationType!=="none"&&!Cr||Pn.elevationType==="none"&&Cr)continue;T.prepareDrawTile();const wa=[...Js],si=T.shadowRenderer,Or=Pn.elevationType==="road"&&!!si&&si.enabled;let Ka=[0,0,0];if(Or){const Gn=T.style.directionalLight,Xi=T.style.ambientLight;Gn&&Xi&&(Ka=tg(T.style,Gn,Xi)),wa.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const Cn=Pn.programConfigurations.get(y.id);let di=!1;if(es&&Kr.imageAtlas){const Gn=i.e3.from(es),Xi=Gn.getPrimary().scaleSelf(ot).toString(),Ho=Kr.imageAtlas.patternPositions.get(Xi),_o=Gn.getSecondary(),Di=_o?Kr.imageAtlas.patternPositions.get(_o.scaleSelf(ot).toString()):null;di=!!Ho&&!!Di,Ho&&Cn.setConstantPatternPositions(Ho,Di)}Ht>0&&(di||Cn.getPatternTransitionVertexBuffer("line-pattern"))&&wa.push("LINE_PATTERN_TRANSITION");const Ci=T.isTileAffectedByFog(br),bi=T.getOrCreateProgram(Yt,{config:Cn,defines:wa,overrideFog:Ci});if(!Wt&&wt&&yt&&Kr.lineAtlas){const Gn=Kr.lineAtlas.getDash(wt,yt);Gn&&Cn.setConstantPatternPositions(Gn)}Or&&si.setupShadows(Kr.tileID.toUnwrapped(),bi,"vector-tile");let[Ga,Wn]=y.paint.get("line-trim-offset");(yt==="round"||yt==="square")&&Ga!==Wn&&(Ga===0&&(Ga-=1),Wn===1&&(Wn+=1));const ii=ut?br.projMatrix:null,So=le?1/Pn.tileToMeter/i.ay(Kr,1,T.transform.zoom):1,no=le?1/Pn.tileToMeter/i.ay(Kr,1,Math.floor(T.transform.zoom)):1,ui=Wt?i.e4(T,Kr,y,ii,ot,So,no,[Ga,Wn],Ka,Ht):i.e5(T,Kr,y,ii,Pn.lineClipsArray.length,ot,So,no,[Ga,Wn],Ka);if(qs){const Gn=Pn.gradients[y.id];let Xi=Gn.texture;if(y.gradientVersion!==Gn.version){let Ho=256;if(y.stepInterpolant){const _o=h.getSource().maxzoom,Di=br.canonical.z===_o?Math.ceil(1<{as!=null&&(as.value=ts*J),bi.draw(T,Le.TRIANGLES,Us,Gn,st,mn.disabled,ui,y.id,Pn.layoutVertexBuffer,Pn.indexBuffer,Pn.segments,y.paint,T.transform.zoom,Cn,[Pn.layoutVertexBuffer2,Pn.patternVertexBuffer,Pn.zOffsetVertexBuffer]),as!=null&&(as.value=ts)};if(xs&&!Cr){const Gn=T.stencilModeForClipping(br).ref;Gn===0&&ut&&we.clear({stencil:0});const Xi={func:Le.EQUAL,mask:255};ui.u_alpha_discard_threshold=.8,za(new yn(Xi,Gn,255,Le.KEEP,Le.KEEP,Le.INVERT)),ui.u_alpha_discard_threshold=0,za(new yn(Xi,Gn,255,Le.KEEP,Le.KEEP,Le.KEEP))}else ui.u_alpha_discard_threshold=xs&&Cr&&hr?.8:0,za(Cr?Pr:T.stencilModeForClipping(br))}};let Is=T.depthModeForSublayer(0,Fr.ReadOnly);const rr=new Fr(T.depthOcclusion?Le.GREATER:Le.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D);if(y.hasNonElevatedBuckets){const yr=!ut&&T.terrain;J!==0&&yr?i.w(`Occlusion opacity for layer ${y.id} is supported on terrain only if the layer has line-z-offset enabled.`):yr?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${y.id}.`):Jt(A,Bt,Is,yn.disabled,!1,!0)}if(y.hasElevatedBuckets){ne==="hd-road-markup"?ye||(Is=rr,Bt.push("ELEVATED_ROADS")):(Bt.push("ELEVATED"),Is=rr,We&&Bt.push(Ue?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),_e&&Bt.push("ELEVATION_REFERENCE_SEA"));const yr=xs?T.stencilModeFor3D():yn.disabled;T.forceTerrainMode=!0,Jt(A,Bt,Is,yr,!0,!0),xs&&Jt(A,Bt,Is,yr,!0,!1),T.forceTerrainMode=!1}xs&&(T.resetStencilClippingMasks(),ut&&we.clear({stencil:0})),J===0||T.depthOcclusion||ut||T.layersWithOcclusionOpacity.push(T.currentLayer)},fill:function(T,h,y,A){const D=y.paint.get("fill-color"),F=y.paint.get("fill-opacity");if(F.constantOr(1)===0)return;const z=y.paint.get("fill-emissive-strength"),W=T.colorModeForDrapableLayerRenderPass(z),J=y.paint.get("fill-pattern"),ne=T.opaquePassEnabledForLayer()&&!J.constantOr(1)&&D.constantOr(i.ao.transparent).a===1&&F.constantOr(0)===1?"opaque":"translucent";let le="none";y.layout.get("fill-elevation-reference")!=="none"?le="road":y.paint.get("fill-z-offset").constantOr(1)!==0&&(le="offset");const _e=!(!T.terrain||!T.terrain.enabled),ye={painter:T,sourceCache:h,layer:y,coords:A,colorMode:W,elevationType:le,terrainEnabled:_e,pass:ne};if(T.renderPass==="shadow")return void(T.shadowRenderer&&le==="road"&&!_e&&function(Le){const{painter:Ie,sourceCache:We,layer:Ue,coords:st}=Le,ut=Ie.context.gl,ot=Le.painter.shadowRenderer;for(const Et of st){const Nt=We.getTile(Et),Tt=Nt.getBucket(Ue);if(!Tt)continue;const wt=Tt.elevatedStructures;if(!wt||!wt.shadowCasterSegments||wt.shadowCasterSegments.segments[0].primitiveLength===0)continue;Ie.prepareDrawTile();const yt=Tt.bufferData.programConfigurations.get(Ue.id),Ot=Ie.isTileAffectedByFog(Et),Wt=Ie.getOrCreateProgram("elevatedStructuresDepth",{config:yt,overrideFog:Ot}),Ht=ot.calculateShadowPassMatrixFromTile(Nt.tileID.toUnwrapped());Ie.uploadCommonUniforms(Ie.context,Wt,Et.toUnwrapped());const es={u_matrix:Ht,u_depth_bias:0};Wt.draw(Ie,ut.TRIANGLES,ot.getShadowPassDepthMode(),yn.disabled,ot.getShadowPassColorMode(),mn.disabled,es,Ue.id,wt.vertexBuffer,wt.indexBuffer,wt.shadowCasterSegments,Ue.paint,Ie.transform.zoom,yt)}}(ye));const we=T.emissiveMode==="mrt-fallback";if(le!=="offset"){if(h3(ye,!1,we),le==="road"){const Le=!_e&&T.renderPass==="translucent";Le&&u3(T,h,y,A,"geometry"),h3(ye,!0,we,yn.disabled),Le&&function(Ie){const{painter:We,sourceCache:Ue,layer:st,coords:ut,colorMode:ot}=Ie,Et=We.context.gl,Nt=Ie.painter.shadowRenderer,Tt=!!Nt&&Nt.enabled,wt=new Fr(We.context.gl.LEQUAL,Fr.ReadOnly,We.depthRangeFor3D);let yt=[0,0,0];if(Tt){const Wt=We.style.directionalLight,Ht=We.style.ambientLight;Wt&&Ht&&(yt=tg(We.style,Wt,Ht))}const Ot=Wt=>{for(const Ht of ut){const es=Ue.getTile(Ht),ts=es.getBucket(st);if(!ts)continue;const xs=ts.elevatedStructures;if(!xs)continue;let qs,Yt;if(Wt?(qs=xs.renderableBridgeSegments,Yt=xs.bridgeProgramConfigurations.get(st.id)):(qs=xs.renderableTunnelSegments,Yt=xs.tunnelProgramConfigurations.get(st.id)),!qs||qs.segments[0].primitiveLength===0)continue;Yt.updatePaintBuffers(),We.prepareDrawTile();const Bt=We.isTileAffectedByFog(Ht),as=[];Tt&&as.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const Jt=We.getOrCreateProgram("elevatedStructures",{config:Yt,overrideFog:Bt,defines:as}),Is=We.translatePosMatrix(Ht.projMatrix,es,st.paint.get("fill-translate"),st.paint.get("fill-translate-anchor"));Tt&&Nt.setupShadows(es.tileID.toUnwrapped(),Jt,"vector-tile");const rr=My(Is,yt);We.uploadCommonUniforms(We.context,Jt,Ht.toUnwrapped()),Jt.draw(We,Et.TRIANGLES,wt,yn.disabled,ot,mn.backCCW,rr,st.id,xs.vertexBuffer,xs.indexBuffer,qs,st.paint,We.transform.zoom,Yt,[xs.vertexBufferNormal])}};Ot(!0),Ot(!1)}(ye)}}else h3(ye,!1,we,T.stencilModeFor3D())},"fill-extrusion":function(T,h,y,A){const D=y.paint.get("fill-extrusion-opacity"),F=T.context,z=F.gl,W=T.terrain,J=W&&W.renderingToTexture;if(D===0)return;const ne=T.emissiveMode==="mrt-fallback",le=T.conflationActive&&T.style.isLayerClipped(y,h.getSource()),_e=T.style.order.indexOf(y.fqid);if(le&&function(ye,we,Le,Ie,We){for(const Ue of Ie){const st=we.getTile(Ue).getBucket(Le);st&&(st.updateReplacement(Ue,ye.replacementSource,We),st.uploadCentroid(ye.context))}}(T,h,y,A,_e),W||le)for(const ye of A){const we=h.getTile(ye).getBucket(y);we&&$me(T.context,h,ye,we,y,W,le)}if(T.renderPass==="shadow"&&T.shadowRenderer){const ye=T.shadowRenderer;if(W&&D<.65&&y._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof i.ad)return;const we=ye.getShadowPassDepthMode(),Le=ye.getShadowPassColorMode();m3(T,h,y,A,we,yn.disabled,Le,le)}else if(T.renderPass==="translucent"){const ye=!y.paint.get("fill-extrusion-pattern").constantOr(1),we=y.paint.get("fill-extrusion-color").constantOr(i.ao.white);if(!J&&we.a!==0){const Le=new Fr(T.context.gl.LEQUAL,Fr.ReadWrite,T.depthRangeFor3D);D===1&&ye?m3(T,h,y,A,Le,yn.disabled,Hn.unblended,le):(m3(T,h,y,A,Le,yn.disabled,Hn.disabled,le),m3(T,h,y,A,Le,T.stencilModeFor3D(),T.colorModeForRenderPass(),le),T.resetStencilClippingMasks())}if(T.style.enable3dLights()&&ye&&(!W&&T.transform.projection.name!=="globe"||J)){const Le=y.paint.get("fill-extrusion-opacity"),Ie=y.paint.get("fill-extrusion-ambient-occlusion-intensity"),We=y.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),Ue=y.paint.get("fill-extrusion-flood-light-intensity"),st=y.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",ut=y.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(st?null:y.lut).toArray01().slice(0,3),ot=Ie>0&&We>0,Et=Ue>0,Nt=(yt,Ot,Wt)=>(1-Wt)*yt+Wt*Ot,Tt=new g6;Tt.translate=y.paint.get("fill-extrusion-translate"),Tt.translateAnchor=y.paint.get("fill-extrusion-translate-anchor"),Tt.edgeRadius=y.layout.get("fill-extrusion-edge-radius"),Tt.cutoffFadeRange=y.paint.get("fill-extrusion-cutoff-fade-range");const wt=yt=>{const Ot=T.depthModeForSublayer(1,Fr.ReadOnly,z.LEQUAL,!0),Wt=y.paint.get(yt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Ht=Nt(.1,3,Wt),es=T._showOverdrawInspector;if(!es){const ts=new yn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),xs=new Hn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);ng(Tt,T,h,y,A,Ot,ts,xs,mn.disabled,yt,"sdf",Le,Ie,We,Ue,ut,Ht,le,!1)}{const ts=es?yn.disabled:new yn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),xs=es?T.colorModeForRenderPass():new Hn([z.ONE_MINUS_DST_ALPHA,z.DST_ALPHA,z.ONE,z.ONE],i.ao.transparent,[!0,!0,!0,!0]);ng(Tt,T,h,y,A,Ot,ts,xs,mn.disabled,yt,"color",Le,Ie,We,Ue,ut,Ht,le,!1)}};if(J){const yt=()=>{const Wt=W.drapeBufferSize[0],Ht=W.drapeBufferSize[1];let es=W.framebufferCopyTexture;return es&&(!es||es.size[0]===Wt&&es.size[1]===Ht)||(es&&es.destroy(),es=W.framebufferCopyTexture=new i.T(F,new i.q({width:Wt,height:Ht}),z.RGBA8)),es.bind(z.LINEAR,z.CLAMP_TO_EDGE),z.copyTexSubImage2D(z.TEXTURE_2D,0,0,0,0,0,Wt,Ht),es},Ot=(Wt,Ht,es)=>{const ts=T.depthModeForSublayer(1,Fr.ReadOnly,z.LEQUAL,!1),xs=y.paint.get(Wt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),qs=Nt(.1,3,xs);{const Yt=new Hn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0]);ng(Tt,T,h,y,A,ts,yn.disabled,Yt,mn.disabled,Wt,"clear",Le,Ie,We,Ue,ut,qs,le,Ht)}{const Yt=new yn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),Bt=new Hn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);ng(Tt,T,h,y,A,ts,Yt,Bt,mn.disabled,Wt,"sdf",Le,Ie,We,Ue,ut,qs,le,Ht)}ne&&!Wt&&(es=yt());{const Yt=Wt?z.ZERO:z.ONE_MINUS_DST_ALPHA,Bt=new yn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),as=new Hn([Yt,z.DST_ALPHA,z.ONE_MINUS_DST_ALPHA,z.ZERO],i.ao.transparent,[!0,!0,!0,!0]);ng(Tt,T,h,y,A,ts,Bt,as,mn.disabled,Wt,"color",Le,Ie,We,Ue,ut,qs,le,Ht)}if(!ne||Wt){const Yt=new Hn([z.ONE,z.ONE,z.ONE,Wt?z.ZERO:z.ONE],i.ao.transparent,[!1,!1,!1,!0],Wt?z.FUNC_ADD:z.MAX);ng(Tt,T,h,y,A,ts,yn.disabled,Yt,mn.disabled,Wt,"clear",Le,Ie,We,Ue,ut,qs,le,Ht,es)}else{z.drawBuffers([z.NONE,z.COLOR_ATTACHMENT1]);const Yt=new yn({func:z.EQUAL,mask:255},254,255,z.KEEP,z.DECR,z.DECR),Bt=new Hn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!0,!1,!1,!1],z.MAX);ng(Tt,T,h,y,A,ts,Yt,Bt,mn.disabled,Wt,"emissive",Le,Ie,We,Ue,ut,qs,le,Ht,es),z.drawBuffers([z.COLOR_ATTACHMENT0])}};if(ot||Et){let Wt;T.prepareDrawTile(),ne&&!ot||(Wt=yt()),ot&&Ot(!0,!1,Wt),Et&&Ot(!1,!0,Wt)}}else ot&&wt(!0),Et&&wt(!1),(ot||Et)&&T.resetStencilClippingMasks()}}},building:function(T,h,y,A){T.currentLayer0&&F>0,ne=!0;const le=y.paint.get("building-vertical-scale");if(le<=0)return;T.shadowRenderer||(ne=!1);const _e=T.conflationActive&&T.style.isLayerClipped(y,h.getSource()),ye=T.style.order.indexOf(y.fqid);if(function(we,Le,Ie,We,Ue,st){for(const ut of st){const ot=Le.getTile(ut).getBucket(Ie);ot&&(Ue&&ot.updateReplacement(ut,we.replacementSource,We),ot.uploadUpdatedIndexBuffer(we.context))}}(T,h,y,ye,_e,A),function(we,Le,Ie,We){for(const Ue of We){const st=Le.getTile(Ue).getBucket(Ie);st&&st.needsEvaluation()&&st.uploadUpdatedColorBuffer(we.context)}}(T,h,y,A),y.resetLayerRenderingStats(T),T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!0),T.renderPass==="shadow"&&T.shadowRenderer){const we=T.shadowRenderer,Le=[],Ie=we.getShadowPassDepthMode();m2({painter:T,source:h,layer:y,coords:A,defines:Le,blendMode:we.getShadowPassColorMode(),depthMode:Ie,opacity:W,verticalScale:le,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(T.renderPass==="translucent"){let we=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];ne&&(we=we.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),T.shadowRenderer&&T.shadowRenderer.useNormalOffset&&(we=we.concat("NORMAL_OFFSET"));const Le=y.paint.get("building-facade-emissive-chance"),Ie=y.paint.get("building-ambient-occlusion-intensity"),We=y.paint.get("building-flood-light-intensity"),Ue=y.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",st=y.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(Ue?null:y.lut).toArray01().slice(0,3),ut=y.paint.get("building-flood-light-ground-attenuation"),ot=We>0,Et=new Fr(T.context.gl.LEQUAL,Fr.ReadWrite,T.depthRangeFor3D);W<1&&m2({painter:T,source:h,layer:y,coords:A,defines:we,blendMode:Hn.disabled,depthMode:Et,opacity:W,verticalScale:le,facadeEmissiveChance:Le,facadeAOIntensity:Ie,floodLightIntensity:We,floodLightColor:st,depthOnly:!0});const Nt=T.colorModeForRenderPass();m2({painter:T,source:h,layer:y,coords:A,defines:we,blendMode:Nt,depthMode:Et,opacity:W,verticalScale:le,facadeEmissiveChance:Le,facadeAOIntensity:Ie,floodLightIntensity:We,floodLightColor:st}),J&&p3(T,h,y,A,!0,W,D,F,We,st,z,_e),ot&&p3(T,h,y,A,!1,W,D,F,We,st,ut,_e)}else if(T.renderPass==="light-beam"){const we=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],Le=new Fr(T.context.gl.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D);m2({painter:T,source:h,layer:y,coords:A,defines:we,blendMode:Hn.alphaBlended,depthMode:Le,opacity:W,verticalScale:le,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!1),T.resetStencilClippingMasks()},hillshade:function(T,h,y,A){if(T.renderPass!=="offscreen"&&T.renderPass!=="translucent"||T.style.disableElevatedTerrain)return;const D=T.context,F=T.terrain&&T.terrain.renderingToTexture,[z,W]=T.renderPass!=="translucent"||F?[{},A]:T.stencilConfigForOverlap(A);for(const J of W){const ne=h.getTile(J);if(ne.needsHillshadePrepare&&T.renderPass==="offscreen")Eme(T,ne,y);else if(T.renderPass==="translucent"){const le=T.depthModeForSublayer(0,Fr.ReadOnly),_e=y.paint.get("hillshade-emissive-strength"),ye=T.colorModeForDrapableLayerRenderPass(_e),we=F&&T.terrain?T.terrain.stencilModeForRTTOverlap(J):z[J.overscaledZ];Ame(T,J,ne,y,le,we,ye)}}D.viewport.set([0,0,T.width,T.height]),T.resetStencilClippingMasks()},raster:function(T,h,y,A,D,F){if(T.renderPass!=="translucent"||y.paint.get("raster-opacity")===0)return;const z=T.transform.projection.name==="globe",W=y.paint.get("raster-elevation")!==0,J=W&&z;if(T.renderElevatedRasterBackface&&!J)return;const ne=T.context,le=ne.gl,_e=h.getSource(),ye=function(Nt,Tt,wt,yt,Ot){const Wt=Tt.paint.get("raster-color"),Ht=Nt.type==="raster-array",es=[],ts=Tt.paint.get("raster-resampling"),xs=Tt.paint.get("raster-color-mix");let qs=Tt.paint.get("raster-color-range");const Yt=[xs[0],xs[1],xs[2],0],Bt=xs[3];let as=ts==="nearest"?yt.NEAREST:yt.LINEAR;if(Ht&&(es.push("RASTER_ARRAY"),Wt||es.push("RASTER_COLOR"),ts==="linear"&&es.push("RASTER_ARRAY_LINEAR"),as=yt.NEAREST,!qs&&Nt.rasterLayers)){const Jt=Nt.rasterLayers.find(({id:Is})=>Is===Tt.sourceLayer);Jt&&Jt.fields&&Jt.fields.range&&(qs=Jt.fields.range)}if(qs=qs||[0,1],Wt){es.push("RASTER_COLOR"),wt.activeTexture.set(yt.TEXTURE2),Tt.updateColorRamp(qs);let Jt=Tt.colorRampTexture;Jt||(Jt=Tt.colorRampTexture=new i.T(wt,Tt.colorRamp,yt.RGBA8)),Jt.bind(yt.LINEAR,yt.CLAMP_TO_EDGE)}return Ot&&es.push("USE_MRT1"),{mix:Yt,range:qs,offset:Bt,defines:es,resampling:as}}(_e,y,ne,le,T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback");if(_e instanceof i.aU&&!A.length&&!z)return;const we=y.paint.get("raster-emissive-strength"),Le=T.colorModeForDrapableLayerRenderPass(we),Ie=T.terrain&&T.terrain.renderingToTexture,We=!T.options.moving,Ue=y.paint.get("raster-resampling")==="nearest"?le.NEAREST:le.LINEAR;if(_e instanceof i.aU&&!A.length&&(_e.onNorthPole||_e.onSouthPole)){const Nt=W?T.stencilModeFor3D():yn.disabled;return void p2(!!_e.onNorthPole,null,T,h,y,we,ye,mn.disabled,Nt)}if(!A.length)return;const[st,ut]=_e instanceof i.aU||Ie?[{},A]:T.stencilConfigForOverlap(A),ot=ut[ut.length-1].overscaledZ;J&&ye.defines.push("PROJECTION_GLOBE_VIEW"),W&&ye.defines.push("RENDER_CUTOFF");const Et=(Nt,Tt,wt)=>{for(const yt of Nt){const Ot=yt.toUnwrapped(),Wt=h.getTile(yt);if(Ie&&(!Wt||!Wt.hasData()))continue;ne.activeTexture.set(le.TEXTURE0);const Ht=ig(Wt,_e,y,ye);if(!Ht||!Ht.texture)continue;const{texture:es,mix:ts,offset:xs,tileSize:qs,buffer:Yt}=Ht;let Bt,as;Ie?(Bt=Fr.disabled,as=yt.projMatrix):W?(Bt=new Fr(le.LEQUAL,Fr.ReadWrite,T.depthRangeFor3D),as=z?Float32Array.from(T.transform.expandedFarZProjMatrix):T.transform.calculateProjMatrix(Ot,We)):(Bt=T.depthModeForSublayer(yt.overscaledZ-ot,y.paint.get("raster-opacity")===1?Fr.ReadWrite:Fr.ReadOnly,le.LESS),as=T.transform.calculateProjMatrix(Ot,We));const Jt=T.terrain&&Ie?T.terrain.stencilModeForRTTOverlap(yt):st[yt.overscaledZ],Is=F?0:y.paint.get("raster-fade-duration");Wt.registerFadeDuration(Is);const rr=h.findLoadedParent(yt,0),yr=l2(Wt,rr,h,T.transform,Is);let Js,Us;!yr.isFading&&Wt.refreshedUponExpiration&&(Wt.refreshedUponExpiration=!1),T.terrain&&T.terrain.prepareDrawTile(),ne.activeTexture.set(le.TEXTURE0),es.bind(Ue,le.CLAMP_TO_EDGE),ne.activeTexture.set(le.TEXTURE1),rr?(rr.texture&&rr.texture.bind(Ue,le.CLAMP_TO_EDGE),Js=Math.pow(2,rr.tileID.overscaledZ-Wt.tileID.overscaledZ),Us=[Wt.tileID.canonical.x*Js%1,Wt.tileID.canonical.y*Js%1]):es.bind(Ue,le.CLAMP_TO_EDGE),"useMipmap"in es&&ne.extTextureFilterAnisotropic&&T.transform.pitch>20&&le.texParameterf(le.TEXTURE_2D,ne.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,ne.extTextureFilterAnisotropicMax);const Pr=T.transform;let Cr;const hr=W?sF(Pr):[0,0,0,0];let br,Kr,Pn,wa,si,Or=0;if(J&&_e instanceof i.aU&&_e.coordinates.length>3)br=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0)))),Kr=Float32Array.from(Pr.globeMatrix),Pn=Float32Array.from(i.dF(Pr)),wa=[i.aF(Pr.center.lng),i.aJ(Pr.center.lat)],Cr=_e.elevatedGlobePerspectiveTransform,si=_e.elevatedGlobeGridMatrix||new Float32Array(9);else if(J){const Ci=i.dG(yt.canonical);Or=i.dH(Ci.getCenter().lat),br=Float32Array.from(i.bk(i.dJ(yt.canonical))),Kr=Float32Array.from(Pr.globeMatrix),Pn=Float32Array.from(i.dF(Pr)),wa=[i.aF(Pr.center.lng),i.aJ(Pr.center.lat)],Cr=[0,0],si=Float32Array.from(i.dI(yt.canonical,Ci,Or,Pr.worldSize/Pr._pixelsPerMercatorPixel))}else Cr=_e instanceof i.aU?_e.perspectiveTransform:[0,0],br=new Float32Array(16),Kr=new Float32Array(9),Pn=new Float32Array(16),wa=[0,0],si=new Float32Array(9);const Ka=ZR(as,br,Kr,Pn,si,Us||[0,0],i.aj(T.transform.zoom),wa,hr,Js||1,yr,y,Cr,W?y.paint.get("raster-elevation"):0,2,ts,xs,ye.range,qs,Yt,we),Cn=T.isTileAffectedByFog(yt),di=T.getOrCreateProgram("raster",{defines:ye.defines,overrideFog:Cn});if(T.uploadCommonUniforms(ne,di,Ot),_e instanceof i.aU){const Ci=_e.elevatedGlobeVertexBuffer,bi=_e.elevatedGlobeIndexBuffer;if(Ie||!z)_e.boundsBuffer&&_e.boundsSegments&&di.draw(T,le.TRIANGLES,Bt,yn.disabled,Le,mn.disabled,Ka,y.id,_e.boundsBuffer,T.quadTriangleIndexBuffer,_e.boundsSegments);else if(Ci&&bi){const Ga=Pr.zoom<=i.c_?_e.elevatedGlobeSegments:_e.getSegmentsForLongitude(Pr.center.lng);Ga&&di.draw(T,le.TRIANGLES,Bt,yn.disabled,Le,Tt,Ka,y.id,Ci,bi,Ga)}}else if(J){Bt=new Fr(le.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D);const Ci=T.globeSharedBuffers;if(Ci){const[bi,Ga,Wn]=Ci.getGridBuffers(Or,!1);di.draw(T,le.TRIANGLES,Bt,wt||Jt,T.colorModeForRenderPass(),Tt,Ka,y.id,bi,Ga,Wn)}}else{const{tileBoundsBuffer:Ci,tileBoundsIndexBuffer:bi,tileBoundsSegments:Ga}=T.getTileBoundsBuffers(Wt);di.draw(T,le.TRIANGLES,Bt,Jt,Le,mn.disabled,Ka,y.id,Ci,bi,Ga)}}if(!(_e instanceof i.aU)&&J)for(const yt of Nt){const Ot=yt.canonical.y===(1<>>16,2654435769),((yt=Math.imul(yt^yt>>>16,2654435769))>>>0)/4294967296},wt=1/1.1;for(let yt=0;yti.e9[Jt](es));Yt.push(es);const Bt=es.canonical.x,as=es.canonical.y;for(const Jt of Yt){const Is=ot.getTile(Ot?Jt.wrapped():Jt);if(!Is)continue;const rr=Is.rasterParticleState;if(!rr)continue;const yr=Jt.canonical.x+(1<Tt.tileID)),we&&(ne.activeTexture.set(le.TEXTURE0),T.imageManager.bind(T.context,y.scope));const Nt=[];if(T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback"&&Nt.push("USE_MRT1"),J){const Tt=T.getOrCreateProgram(ut,{overrideFog:!1,overrideRtt:!0,defines:Nt}),wt=new Float32Array(i.bA([])),yt=new i.aQ(0,0,0,0,0),Ot=we?Ay(wt,W,z,T,0,y.scope,Le,J,{tileID:yt,tileSize:ye}):d2(wt,W,z,D.toPremultipliedRenderColor(F?null:y.lut));Tt.draw(T,le.TRIANGLES,Ue,We,st,mn.disabled,Ot,y.id,T.viewportBuffer,T.quadTriangleIndexBuffer,T.viewportSegments)}else for(const Tt of Et){const wt=T.isTileAffectedByFog(Tt),yt=T.getOrCreateProgram(ut,{overrideFog:wt,defines:Nt}),Ot=Tt.toUnwrapped(),Wt=A?Tt.projMatrix:T.transform.calculateProjMatrix(Ot);T.prepareDrawTile();const Ht=h?h.getTile(Tt):ot?ot[Tt.key]:new Ym(Tt,ye,_e.zoom,T),es=we?Ay(Wt,W,z,T,0,y.scope,Le,J,{tileID:Tt,tileSize:ye}):d2(Wt,W,z,D.toPremultipliedRenderColor(F?null:y.lut));T.uploadCommonUniforms(ne,yt,Ot);const{tileBoundsBuffer:ts,tileBoundsIndexBuffer:xs,tileBoundsSegments:qs}=T.getTileBoundsBuffers(Ht);yt.draw(T,le.TRIANGLES,Ue,We,st,mn.disabled,es,y.id,ts,xs,qs)}},sky:function(T,h,y){const A=T._atmosphere?i.aj(T.transform.zoom):1,D=y.paint.get("sky-opacity")*A;if(D===0)return;const F=T.context,z=y.paint.get("sky-type"),W=new Fr(F.gl.LEQUAL,Fr.ReadOnly,[0,1]),J=T.frameCounter/1e3%1;z==="atmosphere"?T.renderPass==="offscreen"?y.needsSkyboxCapture(T)&&(function(ne,le,_e,ye){const we=ne.context,Le=we.gl;let Ie=le.skyboxFbo;if(!Ie){Ie=le.skyboxFbo=we.createFramebuffer(32,32,1,null),le.skyboxGeometry=new y3(we),le.skyboxTexture=we.gl.createTexture(),Le.bindTexture(Le.TEXTURE_CUBE_MAP,le.skyboxTexture),Le.texParameteri(Le.TEXTURE_CUBE_MAP,Le.TEXTURE_WRAP_S,Le.CLAMP_TO_EDGE),Le.texParameteri(Le.TEXTURE_CUBE_MAP,Le.TEXTURE_WRAP_T,Le.CLAMP_TO_EDGE),Le.texParameteri(Le.TEXTURE_CUBE_MAP,Le.TEXTURE_MIN_FILTER,Le.LINEAR),Le.texParameteri(Le.TEXTURE_CUBE_MAP,Le.TEXTURE_MAG_FILTER,Le.LINEAR);for(let ut=0;ut<6;++ut)Le.texImage2D(Le.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,Le.RGBA,32,32,0,Le.RGBA,Le.UNSIGNED_BYTE,null)}we.bindFramebuffer.set(Ie.framebuffer),we.viewport.set([0,0,32,32]);const We=le.getCenter(ne,!0),Ue=ne.getOrCreateProgram("skyboxCapture"),st=new Float64Array(16);i.bA(st),i.en(st,st,.5*-Math.PI),dv(ne,le,Ue,st,We,0),i.bA(st),i.en(st,st,.5*Math.PI),dv(ne,le,Ue,st,We,1),i.bA(st),i.cU(st,st,.5*-Math.PI),dv(ne,le,Ue,st,We,2),i.bA(st),i.cU(st,st,.5*Math.PI),dv(ne,le,Ue,st,We,3),i.bA(st),dv(ne,le,Ue,st,We,4),i.bA(st),i.en(st,st,Math.PI),dv(ne,le,Ue,st,We,5),we.viewport.set([0,0,ne.width,ne.height])}(T,y),y.markSkyboxValid(T)):T.renderPass==="sky"&&function(ne,le,_e,ye,we){const Le=ne.context,Ie=Le.gl,We=ne.transform,Ue=ne.getOrCreateProgram("skybox");Le.activeTexture.set(Ie.TEXTURE0),Ie.bindTexture(Ie.TEXTURE_CUBE_MAP,le.skyboxTexture);const st=((ut,ot,Et,Nt,Tt)=>({u_matrix:ut,u_sun_direction:ot,u_cubemap:0,u_opacity:Nt,u_temporal_offset:Tt}))(We.skyboxMatrix,le.getCenter(ne,!1),0,ye,we);ne.uploadCommonUniforms(Le,Ue),Ue.draw(ne,Ie.TRIANGLES,_e,yn.disabled,ne.colorModeForRenderPass(),mn.backCW,st,"skybox",le.skyboxGeometry.vertexBuffer,le.skyboxGeometry.indexBuffer,le.skyboxGeometry.segment)}(T,y,W,D,J):z==="gradient"&&T.renderPass==="sky"&&function(ne,le,_e,ye,we){const Le=ne.context,Ie=Le.gl,We=ne.transform,Ue=ne.getOrCreateProgram("skyboxGradient");le.skyboxGeometry||(le.skyboxGeometry=new y3(Le)),Le.activeTexture.set(Ie.TEXTURE0);let st=le.colorRampTexture;st||(st=le.colorRampTexture=new i.T(Le,le.colorRamp,Ie.RGBA8)),st.bind(Ie.LINEAR,Ie.CLAMP_TO_EDGE);const ut=((ot,Et,Nt,Tt,wt)=>({u_matrix:ot,u_color_ramp:0,u_center_direction:Et,u_radius:i.an(Nt),u_opacity:Tt,u_temporal_offset:wt}))(We.skyboxMatrix,le.getCenter(ne,!1),le.paint.get("sky-gradient-radius"),ye,we);ne.uploadCommonUniforms(Le,Ue),Ue.draw(ne,Ie.TRIANGLES,_e,yn.disabled,ne.colorModeForRenderPass(),mn.backCW,ut,"skyboxGradient",le.skyboxGeometry.vertexBuffer,le.skyboxGeometry.indexBuffer,le.skyboxGeometry.segment)}(T,y,W,D,J)},custom:function(T,h,y,A){const D=T.context,F=y.implementation;if(!T.transform.projection.unsupportedLayers||!T.transform.projection.unsupportedLayers.includes("custom")||T.terrain&&(T.terrain.renderingToTexture||T.renderPass==="offscreen")&&y.isDraped(h)){if(T.renderPass==="offscreen"){const z=F.prerender;if(z){if(T.setCustomLayerDefaults(),D.setColorMode(T.colorModeForRenderPass()),T.transform.projection.name==="globe"){const W=T.transform.pointMerc;z.call(F,D.gl,T.transform.customLayerMatrix(),T.transform.getProjection(),T.transform.globeToMercatorMatrix(),i.aj(T.transform.zoom),[W.x,W.y],T.transform.pixelsPerMeterRatio)}else z.call(F,D.gl,T.transform.customLayerMatrix());D.setDirty(),T.setBaseState()}}else if(T.renderPass==="translucent"){if(T.terrain&&T.terrain.renderingToTexture){const W=F.renderToTile;if(W){const J=A[0].canonical,ne={x:J.x+A[0].wrap*(F.wrapTileId?0:1<{ne&&(ne.useNormalOffset=!0,le||(ne.enabled=!0))},ye=h.getSource();if(T.renderPass==="light-beam"&&ye.type!=="batched-model")return;if(ye.type==="vector"||ye.type==="geojson")return function(ot,Et,Nt,Tt,wt){const yt=ot.transform,Ot=yt.projection.name==="globe",Wt=yt.getFreeCameraOptions().position;if(!ot.modelManager)return;const Ht=ot.modelManager;Nt.modelManager=Ht;const es=ot.shadowRenderer;if(!Nt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const ts=Nt._unevaluatedLayout._values["model-id"],xs=Object.assign({},Nt.layout.get("model-id").parameters),qs=ot.style.order.indexOf(Nt.fqid),Yt=Nt.paint.get("model-opacity").constantOr(1);for(const Bt of Tt){const as=Et.getTile(Bt).getBucket(Nt);if(!as||as.projection.name!==yt.projection.name)continue;const Jt=as.getModelUris();if(Jt&&!as.modelsRequested&&(Ht.addModelsFromBucket(Jt,wt),as.modelsRequested=!0),Ot)xs.zoom=Bt.overscaledZ;else{const hr=zu(Bt,yt);xs.zoom=hr}const Is=ts.possiblyEvaluate(xs);if(mF(ot,as,Bt),Vf.shadowUniformsInitialized=!1,Vf.useSingleShadowCascade=!!es&&es.getMaxCascadeForTile(Bt.toUnwrapped())===0,ot.renderPass==="shadow"&&es){if(ot.currentShadowCascade===1&&as.isInsideFirstShadowMapFrustum)continue;const hr=yt.calculatePosMatrix(Bt.toUnwrapped(),yt.worldSize);if(Vf.tileMatrix.set(hr),Vf.shadowTileMatrix=Float32Array.from(es.calculateShadowPassMatrixFromMatrix(hr)),Vf.aabb.min=[0,0,0],Vf.aabb.max[0]=Vf.aabb.max[1]=i.al,Vf.aabb.max[2]=0,Vme(as,Vf,ot,Nt.scope))continue}const rr=1<0&&ot.style.isLayerClipped(Nt,Et.getSource())&&as.updateReplacement(Bt,ot.replacementSource,qs,Nt.scope)&&(as.uploaded=!1,as.upload(ot.context));let Js=0;const Us=new Array,Pr=new Array,Cr=new Array;for(let hr in as.instancesPerModel){const br=as.instancesPerModel[hr];br.features.length>0&&!Ot&&(hr=Is.evaluate(br.features[0].feature,{}));const Kr=Ht.getModel(hr,wt);if(Kr||Ht.hasURLBeenRequested(hr)||as.modelUris.includes(hr)||(as.modelUris.push(hr),as.modelsRequested=!1),Kr&&Kr.uploaded)if(Ot){const Pn=i.c5([],[Wt.x,Wt.y,Wt.z],ot.transform.worldSize);i.ew(Pn,Pn);for(let wa=0;wa0&&Ka.elevationUpdate(hr.terrain,wa,Or,Kr.source),Ka.needsReEvaluation(hr,si,Kr)&&Ka.evaluate(Kr))}})(ot,Et,Nt,Tt),function(){let hr,br,Kr;Us?(hr=Tt.length-1,br=-1,Kr=-1):(hr=0,br=Tt.length,Kr=1);const Pn=new Float64Array(16),wa=i.cA(),si=new i.P(0,0);for(let Or=hr;Or!==br;Or+=Kr){const Ka=Tt[Or],Cn=Et.getTile(Ka).getBucket(Nt);if(!Cn||!Cn.uploaded)continue;let di=!1;Wt&&(di=Wt.getMaxCascadeForTile(Ka.toUnwrapped())===0);const Ci=yt.calculatePosMatrix(Ka.toUnwrapped(),yt.worldSize),bi=Cn.modelTraits;!rr&&Us&&(i.bl(Pn,Ci),i.af(wa,es,Pn),si.x=wa[0],si.y=wa[1]);const Ga=[];Cn.setFilter(Nt.filter);for(const Wn of Cn.getNodesInfo()){if(Wn.hiddenByReplacement||!Wn.node.meshes)continue;const ii=Wn.node;let So=0;ot.terrain&&ii.elevation&&(So=ii.elevation*ot.terrain.exaggeration());const no=(()=>{const Vd=Wn.aabb;return Is.min=[...Vd.min],Is.max=[...Vd.max],Is.min[2]+=So,Is.max[2]+=So,i.af(Is.min,Is.min,Ci),i.af(Is.max,Is.max,Ci),Is})(),ui=Wn.evaluatedScale;if(ui[0]<=1&&ui[1]<=1&&ui[2]<=1&&no.intersects(yr)===0)continue;if(!rr&&Us){const Vd=.16666666666666666;Wn.cameraCollisionOpacity=es[0]>no.min[0]&&es[0]no.min[1]&&es[1]!Us||Wn.opacity===1&&ii.opacity===1?Wn.depthii.depth?-1:1);for(const Wn of Ga){const ii=Wn.nodeInfo,So=ii.node;let no=i.aB([],Yt,Wn.tileModelMatrix);i.aB(no,xs,no);const ui=i.bl([],no);i.eg(ui,ui),i.cS(ui,ui,x2),no=i.aB(no,no,So.globalMatrix);const za=ot.renderPass==="light-beam",Gn=Nt.paint.get("model-color-use-theme").constantOr("default")==="none",Xi=bi&i.eI.HasMapboxMeshFeatures,Ho=Xi?0:ii.evaluatedRMEA[0][2];for(let _o=0;_o=gs||wo>=gs}}const id=Di.material;let hm;id.occlusionTexture&&id.occlusionTexture.offsetScale&&(hm=id.occlusionTexture.offsetScale,ql.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const ap=ot.getOrCreateProgram("model",ql);!rr&&Wt&&Wt.setupShadowsFromMatrix(Wn.tileModelMatrix,ap,Wt.useNormalOffset),ot.uploadCommonUniforms(wt,ap,null,Hd);const mh=id.pbrMetallicRoughness;mh.metallicFactor=.9,mh.roughnessFactor=.5;const Lo=av(new Float32Array(Md),new Float32Array(no),new Float32Array(ui),new Float32Array(So.globalMatrix),ot,Wn.opacity,mh.baseColorFactor,id.emissiveFactor,mh.metallicFactor,mh.roughnessFactor,id,Ho,Nt,[0,0,0],hm);!Bu&&(ii.hasTranslucentParts||Wn.opacity<1)&&ap.draw(ot,wt.gl.TRIANGLES,as,yn.disabled,Hn.disabled,mn.backCCW,Lo,Nt.id,Di.vertexBuffer,Di.indexBuffer,Di.segments,Nt.paint,ot.transform.zoom,void 0,Vd),ap.draw(ot,wt.gl.TRIANGLES,Bu?Jt:as,yn.disabled,Bu||Wn.opacity<1||ii.hasTranslucentParts?Hn.alphaBlended:Hn.unblended,mn.backCCW,Lo,Nt.id,Di.vertexBuffer,Di.indexBuffer,Di.segments,Nt.paint,ot.transform.zoom,void 0,Vd)}}}}()}(T,h,y,A),void _e();if(ye.type!=="model")return;const we=ye.getModels(),Le=[],Ie=T.transform.getFreeCameraOptions().position,We=i.c5([],[Ie.x,Ie.y,Ie.z],T.transform.worldSize);i.ew(We,We);const Ue=[],st=[];let ut=0;for(const ot of we){const Et=h.getFeatureState("",ot.id),Nt={type:"Unknown",id:ot.id,properties:ot.featureProperties},Tt=y.paint.get("model-rotation").evaluate(Nt,Et),wt=y.paint.get("model-scale").evaluate(Nt,Et),yt=y.paint.get("model-translation").evaluate(Nt,Et),Ot=y.paint.get("model-opacity").evaluate(Nt,Et);dF(y,ot.id,Et,ot.featureProperties,ot.nodeOverrideNames,ot.nodeOverrides),uF(y,ot.id,Et,ot.featureProperties,ot.materialOverrideNames,ot.materialOverrides),ot.nodeOverrides.size>0&&ot.computeBoundsAndApplyParent(),ot.computeModelMatrix(T,Tt,wt,yt,W,z,!1);const Wt=i.bA([]),Ht=i.ef(ot.position.lat,T.transform.zoom),es=i.bq([],[1,1,1/Ht]);i.br(Wt,Wt,We),Le.push({zScaleMatrix:es,negCameraPosMatrix:Wt});for(const ts of ot.nodes)uv(T,ts,ot.matrix,T.transform.expandedFarZProjMatrix,ut,Ue,st,ot.materialOverrides,Ot);ut++}if(Ue.sort((ot,Et)=>Et.depth-ot.depth),T.renderPass!=="shadow")hF(T,y,Ue,st,Le),_e();else{for(const ot of st)$p(ot.mesh,ot.nodeModelMatrix,T,y);for(const ot of Ue)$p(ot.mesh,ot.nodeModelMatrix,T,y);_e()}}},k3={line:function(T,h,y){if(T.hasElevatedBuckets=!1,T.hasNonElevatedBuckets=!1,T._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||T._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(h){const A=h.getVisibleCoordinates();for(const D of A){const F=h.getTile(D).getBucket(T);if(F&&(F.elevationType!=="none"?T.hasElevatedBuckets=!0:T.hasNonElevatedBuckets=!0,T.hasElevatedBuckets&&T.hasNonElevatedBuckets))break}}}else T.hasNonElevatedBuckets=!0},model:function(T,h,y){const A=h.getSource();if(!A.loaded())return;if(A.type==="vector"||A.type==="geojson")return void(y.modelManager&&y.modelManager.upload(y,f2(y,T)));if(A.type==="batched-model"||A.type!=="model")return;const D=A.getModels();for(const F of D)F.upload(y.context)},raster:function(T,h,y){const A=h.getSource();if(!(A instanceof kd&&A.loaded()))return;const D=T.sourceLayer||A.rasterLayerIds&&A.rasterLayerIds[0];if(!D)return;const F=T.paint.get("raster-array-band")||A.getInitialBand(D);if(F==null)return;const z=h.getIds().map(W=>h.getTileByID(W));for(const W of z)W.updateNeeded(T.id,F)&&A.prepareTile(W,D,T.id,F)},"raster-particle":function(T,h,y){const A=h.getSource();if(!(A instanceof kd&&A.loaded()))return;const D=T.sourceLayer||A.rasterLayerIds&&A.rasterLayerIds[0];if(!D)return;const F=T.paint.get("raster-particle-array-band")||A.getInitialBand(D);if(F==null)return;const z=h.getIds().map(W=>h.getTileByID(W));for(const W of z)W.updateNeeded(T.id,F)&&A.prepareTile(W,D,T.id,F)}},um={fill:u3},S3={fill:function(T,h,y,A){if(!y.layout||y.layout.get("fill-elevation-reference")==="none"||y.paint.get("fill-opacity").constantOr(1)===0)return;const D=T.context.gl,F=new Fr(D.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D),z=new yn({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),W=T.transform.getFreeCameraOptions().position,J=T.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const ne of A){const le=h.getTile(ne),_e=le.getBucket(y);if(!_e)continue;const ye=_e.elevatedStructures;if(!ye||ye.depthSegments.segments[0].primitiveLength===0)continue;const we=tF(ne.toUnwrapped(),W),Le=T.translatePosMatrix(ne.projMatrix,le,y.paint.get("fill-translate"),y.paint.get("fill-translate-anchor")),Ie=nv(Le,we,0,1,0);J.draw(T,D.TRIANGLES,F,z,Hn.disabled,mn.disabled,Ie,y.id,ye.vertexBuffer,ye.indexBuffer,ye.depthSegments,y.paint,T.transform.zoom)}}};class C3{constructor(h,y,A,D,F){this.context=new db(h,y),this.transform=A,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this._timeStamp=i.o.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const z=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const J of z)this._debugParams.enabledLayers[J]=!0;for(const J of z);this.occlusionParams=new hb,this.setup(),this.numSublayers=Al.maxUnderzooming+Al.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 Q1(this),this._wireframeDebugCache=new Py,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const W=new i.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new i.T(this.context,W,h.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=D,this.worldview=F,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(h,y){const A=!!h&&!!h.terrain&&this.transform.projection.supportsTerrain;if(!(A||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new l6(this,h));const D=this._terrain;this.transform.elevation=A?D:null,D.update(h,this.transform,y),this.transform.elevation&&!D.enabled&&(this.transform.elevation=null)}_updateFog(h){const y=h.fog;if(!y||this.transform.projection.name==="globe"||y.getOpacity(this.transform.pitch)<1||y.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[A,D]=y.getFovAdjustedRange(this.transform._fov);if(A>D)return void(this.transform.fogCullDistSq=null);const F=A+.78*(D-A);this.transform.fogCullDistSq=F*F}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(h){h&&!this._terrain&&(this._terrain=new l6(this,this.style)),this._forceTerrainMode=h}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(h,y){if(this.width=h*i.o.devicePixelRatio,this.height=y*i.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const A of this.style.order)this.style._mergedLayers[A].resize()}setup(){const h=this.context,y=new i.bd;y.emplaceBack(0,0),y.emplaceBack(i.al,0),y.emplaceBack(0,i.al),y.emplaceBack(i.al,i.al),this.tileExtentBuffer=h.createVertexBuffer(y,i.bf.members),this.tileExtentSegments=i.bg.simpleSegment(0,0,4,2);const A=new i.bd;A.emplaceBack(0,0),A.emplaceBack(i.al,0),A.emplaceBack(0,i.al),A.emplaceBack(i.al,i.al),this.debugBuffer=h.createVertexBuffer(A,i.bf.members),this.debugSegments=i.bg.simpleSegment(0,0,4,5);const D=new i.bd;D.emplaceBack(-1,-1),D.emplaceBack(1,-1),D.emplaceBack(-1,1),D.emplaceBack(1,1),this.viewportBuffer=h.createVertexBuffer(D,i.bf.members),this.viewportSegments=i.bg.simpleSegment(0,0,4,2);const F=new i.b1;F.emplaceBack(0,0,0,0),F.emplaceBack(i.al,0,i.al,0),F.emplaceBack(0,i.al,0,i.al),F.emplaceBack(i.al,i.al,i.al,i.al),this.mercatorBoundsBuffer=h.createVertexBuffer(F,i.bi.members),this.mercatorBoundsSegments=i.bg.simpleSegment(0,0,4,2);const z=new i.b0;z.emplaceBack(0,1,2),z.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=h.createIndexBuffer(z);const W=new i.be;for(const ne of[0,1,3,2,0])W.emplaceBack(ne);this.debugIndexBuffer=h.createIndexBuffer(W),this.emptyTexture=new i.T(h,new i.q({width:1,height:1},Uint8Array.of(0,0,0,0)),h.gl.RGBA8),this.identityMat=i.bC();const J=this.context.gl;this.stencilClearMode=new yn({func:J.ALWAYS,mask:0},0,255,J.ZERO,J.ZERO,J.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(h){return h._makeTileBoundsBuffers(this.context,this.transform.projection),h._tileBoundsBuffer?{tileBoundsBuffer:h._tileBoundsBuffer,tileBoundsIndexBuffer:h._tileBoundsIndexBuffer,tileBoundsSegments:h._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const h=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,h.TRIANGLES,Fr.disabled,this.stencilClearMode,Hn.disabled,mn.disabled,o2(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(h,y,A){if(!y||this.currentStencilSource===y.id||!h.isTileClipped()||!A||A.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let W=!1;for(const J of A)if(this._tileClippingMaskIDs[J.key]===void 0){W=!0;break}if(!W)return}this.currentStencilSource=y.id;const D=this.context,F=D.gl;this.nextStencilID+A.length>256&&this.clearStencil(),D.setColorMode(Hn.disabled),D.setDepthMode(Fr.disabled);const z=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const W of A){const J=y.getTile(W),ne=this._tileClippingMaskIDs[W.key]=this.nextStencilID++,{tileBoundsBuffer:le,tileBoundsIndexBuffer:_e,tileBoundsSegments:ye}=this.getTileBoundsBuffers(J);z.draw(this,F.TRIANGLES,Fr.disabled,new yn({func:F.ALWAYS,mask:0},ne,255,F.KEEP,F.KEEP,F.REPLACE),Hn.disabled,mn.disabled,o2(W.projMatrix),"$clipping",le,_e,ye)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const h=this.nextStencilID++,y=this.context.gl;return new yn({func:y.NOTEQUAL,mask:255},h,255,y.KEEP,y.KEEP,y.REPLACE)}stencilModeForClipping(h){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(h);const y=this.context.gl;return new yn({func:y.EQUAL,mask:255},this._tileClippingMaskIDs[h.key],0,y.KEEP,y.KEEP,y.REPLACE)}stencilConfigForOverlap(h){const y=this.context.gl,A=h.sort((z,W)=>W.overscaledZ-z.overscaledZ),D=A[A.length-1].overscaledZ,F=A[0].overscaledZ-D+1;if(F>1){this.currentStencilSource=void 0,this.nextStencilID+F>256&&this.clearStencil();const z={};for(let W=0;Wthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((h,y)=>h+y/this._fpsHistory.length,0))}render(h,y){const A=i.o.now();this._dt=A-this._timeStamp,this._timeStamp=A,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=h.map.repaint,this.style=h,this.options=y;const D=this.style._mergedLayers,F=!(!this.terrain||!this.terrain.enabled),z=()=>this.style._getOrder(F).filter(Yt=>{const Bt=D[Yt];return!(Bt.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[Bt.type]});let W=z(),J=!1,ne=!1,le=null,_e=0,ye=!1;for(const Yt of W){const Bt=D[Yt];Bt.visibility!=="none"&&(Bt.type==="circle"?J=!0:Bt.type==="building"?(le=Bt,++_e):Bt.type==="symbol"&&(Bt.hasOcclusionOpacityProperties?ne=!0:J=!0))}this.updateEmissiveMode();let we=W.map(Yt=>D[Yt]);const Le=this.style._mergedSourceCaches;this.imageManager=h.imageManager,this.modelManager=h.modelManager,this.symbolFadeChange=h.placement.symbolFadeChange(i.o.now()),this.imageManager.beginFrame();for(const Yt in Le){const Bt=Le[Yt];Bt.used&&(Bt.prepare(this.context),Bt.getSource().usedInConflation&&++_e)}let Ie=!1;for(const Yt of we)Yt.isHidden(this.transform.zoom)||(Yt.type==="clip"&&(Ie=!0),this.prepareLayer(Yt));const We={},Ue={},st={},ut={},ot={};for(const Yt in Le){const Bt=Le[Yt];We[Yt]=Bt.getVisibleCoordinates(),Ue[Yt]=We[Yt].slice().reverse(),st[Yt]=Bt.getVisibleCoordinates(!0).reverse(),ut[Yt]=Bt.getShadowCasterCoordinates(),ot[Yt]=Bt.sortCoordinatesByDistance(We[Yt])}const Et=Yt=>{const Bt=this.style.getLayerSourceCache(Yt);return Bt&&Bt.used?Bt.getSource():null};if(_e||Ie||this._clippingActiveLastFrame){const Yt=[],Bt=[];let as=0;for(const Jt of we)this.isSourceForClippingOrConflation(Jt,Et(Jt))&&(Yt.push(Jt),Bt.push(as)),as++;if(Yt&&(Ie||Yt.length>1)||this._clippingActiveLastFrame){Ie=!1;const Jt=[];for(let Is=0;Is0){const Jt=Et(Bt);Jt&&(this.minCutoffZoom=Math.max(Jt.minzoom,this.minCutoffZoom)),Bt.minzoom&&(this.minCutoffZoom=Math.max(Bt.minzoom,this.minCutoffZoom))}Bt.is3D(F)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Yt),this._lastOcclusionLayer=Yt)}const Nt=this.style&&this.style.fog;Nt?(this._fogVisible=Nt.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=Nt.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(st),this.opaquePassCutoff=0,W=z(),we=W.map(Yt=>D[Yt]));const Tt=this._shadowRenderer;if(Tt){Tt.updateShadowParameters(this.transform,this.style.directionalLight);for(const Yt in Le)for(const Bt of We[Yt]){let as={min:0,max:0};this.terrain&&(as=this.terrain.getMinMaxForTile(Bt)||as),Tt.addShadowReceiver(Bt.toUnwrapped(),as.min,as.max)}}this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new i.eR(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new cF(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const wt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),yt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(wt&&!this._snow&&(this._snow=new N6(this)),!wt&&this._snow&&(this._snow.destroy(),delete this._snow),yt&&!this._rain&&(this._rain=new N3(this)),!yt&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),le){this.buildingTileBorderManager||(this.buildingTileBorderManager=new v3);const Yt=this.style.getLayerSourceCache(le);this.buildingTileBorderManager.updateBorders(Yt,le)}if(!at.has(this.context.gl))return;this.renderPass="offscreen";for(const Yt of we){const Bt=h.getLayerSourceCache(Yt);if(!Yt.hasOffscreenPass()||Yt.isHidden(this.transform.zoom))continue;const as=Bt?Ue[Bt.id]:void 0;(Yt.type==="custom"||Yt.type==="raster"||Yt.type==="raster-particle"||Yt.isSky()||as&&as.length)&&this.renderLayer(this,Bt,Yt,as)}this.depthRangeFor3D=[0,1-(we.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,ut)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const Ot=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Wt=(()=>{if(y.showOverdrawInspector)return i.ao.black;const Yt=this.style.fog;if(Yt&&this.transform.projection.supportsFog){const Bt=this.style.getLut(Yt.scope);if(!Ot){const as=Yt.properties.get("color-use-theme")==="none",Jt=Yt.properties.get("color").toNonPremultipliedRenderColor(as?null:Bt).toArray01();return new i.ao(...Jt)}if(Ot){const as=Yt.properties.get("space-color-use-theme")==="none",Jt=Yt.properties.get("space-color").toNonPremultipliedRenderColor(as?null:Bt).toArray01();return new i.ao(...Jt)}}return i.ao.transparent})();if(this.context.clear({color:Wt,depth:1}),this.clearStencil(),this._showOverdrawInspector=y.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Ot&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=W.length-1;this.currentLayer>=0;this.currentLayer--){const Yt=we[this.currentLayer],Bt=h.getLayerSourceCache(Yt);if(Yt.isSky())continue;const as=Bt?(Yt.is3D(F)?ot:Ue)[Bt.id]:void 0;this._renderTileClippingMasks(Yt,Bt,as),this.renderLayer(this,Bt,Yt,as)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Ot&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||i.aj(this.transform.zoom)>0)&&(this.transform.projection.name==="globe"||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer0&&Yt.hasShadowPass()&&--es==0){{this.clearStencil(),this.resetStencilClippingMasks();const as=this.currentLayer;for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const as=this.currentLayer;this.depthOcclusion=!0;for(const Jt of this.layersWithOcclusionOpacity){this.currentLayer=Jt;const Is=we[this.currentLayer],rr=h.getLayerSourceCache(Is),yr=rr?Ue[rr.id]:void 0;this.terrain||this._renderTileClippingMasks(Is,rr,rr?We[rr.id]:void 0),this.renderLayer(this,rr,Is,yr)}this.depthOcclusion=!1,this.currentLayer=as,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let Yt=null;we.forEach(Bt=>{const as=h.getLayerSourceCache(Bt);as&&!Bt.isHidden(this.transform.zoom)&&as.getVisibleCoordinates().length&&(!Yt||Yt.getSource().maxzoom0?y.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(h,y,A){const D=A===void 0?this.terrain&&this.terrain.renderingToTexture:A,F=[];return this.style&&this.style.enable3dLights()&&(h==="globeRaster"||h==="terrainRaster"?(F.push("LIGHTING_3D_MODE"),F.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):D||F.push("LIGHTING_3D_MODE")),this.renderPass==="shadow"&&(this._shadowMapDebug||F.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(F.push("TERRAIN"),this.linearFloatFilteringSupported()&&F.push("TERRAIN_DEM_FLOAT_FORMAT")),this.transform.projection.name==="globe"&&F.push("GLOBE"),!this._fogVisible||D||y!==void 0&&!y||F.push("FOG","FOG_DITHERING"),D&&F.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&F.push("OVERDRAW_INSPECTOR"),F}getOrCreateProgram(h,y){this.cache=this.cache||{};const A=y&&y.defines||[],D=y&&y.config,F=this.currentGlobalDefines(h,y&&y.overrideFog,y&&y.overrideRtt).concat(A),z=qR.cacheKey(ZE[h],h,F,D);return this.cache[z]||(this.cache[z]=new qR(this.context,h,ZE[h],D,d3[h],F)),this.cache[z]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const h=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(h.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new i.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(h,y){if(this.style.enable3dLights()){const A=this.style.directionalLight,D=this.style.ambientLight;if(A&&D){const F=((z,W,J)=>{const ne=z.properties.get("direction"),le=z.properties.get("color-use-theme")==="none",_e=z.properties.get("color").toNonPremultipliedRenderColor(le?null:J.getLut(z.scope)).toArray01(),ye=z.properties.get("intensity"),we=W.properties.get("color-use-theme")==="none",Le=W.properties.get("color").toNonPremultipliedRenderColor(we?null:J.getLut(W.scope)).toArray01(),Ie=W.properties.get("intensity"),We=[ne.x,ne.y,ne.z],Ue=i.dN(Le,Ie),st=i.dN(_e,ye);return{u_lighting_ambient_color:Ue,u_lighting_directional_dir:We,u_lighting_directional_color:st,u_ground_radiance:ob(We,st,Ue)}})(A,D,this.style);y.setLightsUniformValues(h,F)}}}uploadCommonUniforms(h,y,A,D,F){if(this.uploadCommonLightUniforms(h,y),this.terrain&&this.terrain.renderingToTexture)return;const z=this.style.fog;if(z){const W=z.getOpacity(this.transform.pitch),J=((ne,le,_e,ye,we,Le,Ie,We,Ue,st,ut,ot)=>{const Et=ne.transform,Nt=le.properties.get("color-use-theme")==="none",Tt=le.properties.get("color").toNonPremultipliedRenderColor(Nt?null:ne.style.getLut(le.scope)).toArray01();Tt[3]=ye;const wt=ne.frameCounter/1e3%1,[yt,Ot]=le.properties.get("vertical-range");return{u_fog_matrix:_e?Et.calculateFogTileMatrix(_e):ot||ne.identityMat,u_fog_range:le.getFovAdjustedRange(Et._fov),u_fog_color:Tt,u_fog_horizon_blend:le.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(yt,Ot),Ot],u_fog_temporal_offset:wt,u_frustum_tl:we,u_frustum_tr:Le,u_frustum_br:Ie,u_frustum_bl:We,u_globe_pos:Ue,u_globe_radius:st,u_viewport:ut,u_globe_transition:i.aj(Et.zoom),u_is_globe:+(Et.projection.name==="globe")}})(this,z,A,W,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*i.o.devicePixelRatio,this.transform.height*i.o.devicePixelRatio],D);y.setFogUniformValues(h,J)}F&&y.setCutoffUniformValues(h,F.uniformValues)}setTileLoadedFlag(h){this.tileLoaded=h}saveCanvasCopy(){const h=this.canvasCopy();h&&(this.frameCopies.push(h),this.tileLoaded=!1)}canvasCopy(){const h=this.context.gl,y=h.createTexture();return h.bindTexture(h.TEXTURE_2D,y),h.copyTexImage2D(h.TEXTURE_2D,0,h.RGBA,0,0,h.drawingBufferWidth,h.drawingBufferHeight,0),y}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const h=this.style&&this.style.fog;return!!h&&h.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const h=this._backgroundTiles,y=this._backgroundTiles={},A=this.transform.coveringTiles({tileSize:512});for(const D of A)y[D.key]=h[D.key]||new Ym(D,512,this.transform.tileZoom,this,void 0,this.worldview);return y}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(h,y){return!(!h.is3D(!(!this.terrain||!this.terrain.enabled))||h.type!=="clip"&&h.type!=="building"&&(h.minzoom&&h.minzoom>this.transform.zoom||(this.style._clipLayerPresent||h.sourceLayer!=="building"&&h.sourceLayer!=="procedural_buildings")&&(!y||y.type!=="batched-model")))}isTileAffectedByFog(h){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let y=this._cachedTileFogOpacities[h.key];return y||(this._cachedTileFogOpacities[h.key]=y=this.style.fog.getOpacityForTile(h)),y[0]>=gs||y[1]>=gs}setupDepthForOcclusion(h,y,A){const D=this.context,F=D.gl,z=!!A;var W;A||(A={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),D.activeTexture.set(F.TEXTURE3),h&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(F.NEAREST,F.CLAMP_TO_EDGE),A.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],A.u_depth_range_unpack=[2/((W=this.depthRangeFor3D)[1]-W[0]),-1-2*W[0]/(W[1]-W[0])],A.u_occluder_half_size=.5*this.occlusionParams.occluderSize,A.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(F.NEAREST,F.CLAMP_TO_EDGE),D.activeTexture.set(F.TEXTURE0),z||y.setTerrainUniformValues(D,A)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const h=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=h?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function M3(T,h){let y=!1,A=null;const D=()=>{A=null,y&&(T(),A=setTimeout(D,h),y=!1)};return()=>(y=!0,A||D(),A)}class k6{constructor(h){this._hashName=h&&encodeURIComponent(h),i.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=M3(this._updateHashUnthrottled.bind(this),300)}addTo(h){return this._map=h,window.addEventListener("hashchange",this._onHashChange,!1),h.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const h=this._map;if(!h)return"";const y=Bl(h);if(this._hashName){const A=this._hashName;let D=!1;const F=location.hash.slice(1).split("&").map(z=>{const W=z.split("=")[0];return W===A?(D=!0,`${W}=${y}`):z}).filter(z=>z);return D||F.push(`${A}=${y}`),`#${F.join("&")}`}return`#${y}`}_getCurrentHash(){const h=location.hash.replace("#","");if(this._hashName){let y;return h.split("&").map(A=>A.split("=")).forEach(A=>{A[0]===this._hashName&&(y=A)}),(y&&y[1]||"").split("/")}return h.split("/")}_onHashChange(){const h=this._map;if(!h)return!1;const y=this._getCurrentHash();if(y.length>=3&&!y.some(A=>isNaN(Number(A)))){const A=h.dragRotate.isEnabled()&&h.touchZoomRotate.isEnabled()?+(y[3]||0):h.getBearing();return h.jumpTo({center:[+y[2],+y[1]],zoom:+y[0],bearing:A,pitch:+(y[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function Bl(T,h){const y=T.getCenter(),A=Math.round(100*T.getZoom())/100,D=Math.ceil((A*Math.LN2+Math.log(512/360/.5))/Math.LN10),F=Math.pow(10,D),z=Math.round(y.lng*F)/F,W=Math.round(y.lat*F)/F,J=T.getBearing(),ne=T.getPitch();let le=h?`/${z}/${W}/${A}`:`${A}/${W}/${z}`;return(J||ne)&&(le+="/"+Math.round(10*J)/10),ne&&(le+=`/${Math.round(ne)}`),le}const pb={linearity:.3,easing:i.eT(0,0,.3,1)},S6=Object.assign({deceleration:2500,maxSpeed:1400},pb),C6=Object.assign({deceleration:20,maxSpeed:1400},pb),mv=Object.assign({deceleration:1e3,maxSpeed:360},pb),M6=Object.assign({deceleration:1e3,maxSpeed:90},pb);class T6{constructor(h){this._map=h,this.clear()}clear(){this._inertiaBuffer=[]}record(h){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.o.now(),settings:h})}_drainInertiaBuffer(){const h=this._inertiaBuffer,y=i.o.now();for(;h.length>0&&y-h[0].time>160;)h.shift()}_onMoveEnd(h){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const y={zoom:0,bearing:0,pitch:0,pan:new i.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:F}of this._inertiaBuffer)y.zoom+=F.zoomDelta||0,y.bearing+=F.bearingDelta||0,y.pitch+=F.pitchDelta||0,F.panDelta&&y.pan._add(F.panDelta),F.around&&(y.around=F.around),F.pinchAround&&(y.pinchAround=F.pinchAround);const A=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,D={};if(y.pan.mag()){const F=Hf(y.pan.mag(),A,Object.assign({},S6,h||{}));D.offset=y.pan.mult(F.amount/y.pan.mag()),D.center=this._map.transform.center,fb(D,F)}if(y.zoom){const F=Hf(y.zoom,A,C6);D.zoom=this._map.transform.zoom+F.amount,fb(D,F)}if(y.bearing){const F=Hf(y.bearing,A,mv);D.bearing=this._map.transform.bearing+i.aA(F.amount,-179,179),fb(D,F)}if(y.pitch){const F=Hf(y.pitch,A,M6);D.pitch=this._map.transform.pitch+F.amount,fb(D,F)}if(D.zoom||D.bearing){const F=y.pinchAround===void 0?y.around:y.pinchAround;D.around=F?this._map.unproject(F):this._map.getCenter()}return this.clear(),D.noMoveStart=!0,D}}function fb(T,h){(!T.duration||T.durationy.unproject(J)),W=F.reduce((J,ne,le,_e)=>J.add(ne.div(_e.length)),new i.P(0,0));super(h,{points:F,point:W,lngLats:z,lngLat:y.unproject(W),originalEvent:A}),this._defaultPrevented=!1}}class A6 extends i.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(h,y){super("wheel",{originalEvent:y}),this._defaultPrevented=!1}}class T3{constructor(h,y){this._map=h,this._clickTolerance=y.clickTolerance}reset(){this._mousedownPos=void 0}wheel(h){return this._firePreventable(new A6(this._map,h))}mousedown(h,y){return this._mousedownPos=y,this._firePreventable(new hh(h.type,this._map,h))}mouseup(h){this._map.fire(new hh(h.type,this._map,h))}preclick(h){const y=new MouseEvent("preclick",h);this._map.fire(new hh(y.type,this._map,y))}click(h,y){this._mousedownPos&&this._mousedownPos.dist(y)>=this._clickTolerance||(this.preclick(h),this._map.fire(new hh(h.type,this._map,h)))}dblclick(h){return this._firePreventable(new hh(h.type,this._map,h))}mouseover(h){this._map.fire(new hh(h.type,this._map,h))}mouseout(h){this._map.fire(new hh(h.type,this._map,h))}touchstart(h){return this._firePreventable(new Ly(h.type,this._map,h))}touchmove(h){this._map.fire(new Ly(h.type,this._map,h))}touchend(h){this._map.fire(new Ly(h.type,this._map,h))}touchcancel(h){this._map.fire(new Ly(h.type,this._map,h))}_firePreventable(h){if(this._map.fire(h),h.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class E6{constructor(h){this._map=h}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(h){this._map.fire(new hh(h.type,this._map,h))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new hh("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(h){this._delayContextMenu?this._contextMenuEvent=h:this._map.fire(new hh(h.type,this._map,h)),this._map.listens("contextmenu")&&h.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class A3{constructor(h,y){this._map=h,this._el=h.getCanvasContainer(),this._container=h.getContainer(),this._clickTolerance=y.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(h,y){this.isEnabled()&&h.shiftKey&&h.button===0&&(L(),this._startPos=this._lastPos=y,this._active=!0)}mousemoveWindow(h,y){if(!this._active)return;const A=y,D=this._startPos,F=this._lastPos;if(!D||!F||F.equals(A)||!this._box&&A.dist(D){this._box&&(this._box.style.transform=`translate(${z}px,${J}px)`,this._box.style.width=W-z+"px",this._box.style.height=ne-J+"px")})}mouseupWindow(h,y){if(!this._active)return;const A=this._startPos,D=y;if(A&&h.button===0){if(this.reset(),q(),A.x!==D.x||A.y!==D.y)return this._map.fire(new i.z("boxzoomend",{originalEvent:h})),{cameraAnimation:F=>F.fitScreenCoordinates(A,D,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",h)}}keydown(h){this._active&&h.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",h))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),I(),delete this._startPos,delete this._lastPos}_fireEvent(h,y){return this._map.fire(new i.z(h,{originalEvent:y}))}}function E3(T,h){const y={};for(let A=0;Athis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=h.timeStamp),A.length===this.numTouches&&(this.centroid=function(D){const F=new i.P(0,0);for(const z of D)F._add(z);return F.div(D.length)}(y),this.touches=E3(A,y)))}touchmove(h,y,A){if(this.aborted||!this.centroid)return;const D=E3(A,y);for(const F in this.touches){const z=D[F];(!z||z.dist(this.touches[F])>30)&&(this.aborted=!0)}}touchend(h,y,A){if((!this.centroid||h.timeStamp-this.startTime>500)&&(this.aborted=!0),A.length===0){const D=!this.aborted&&this.centroid;if(this.reset(),D)return D}}}class P3{constructor(h){this.singleTap=new xF(h),this.numTaps=h.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(h,y,A){this.singleTap.touchstart(h,y,A)}touchmove(h,y,A){this.singleTap.touchmove(h,y,A)}touchend(h,y,A){const D=this.singleTap.touchend(h,y,A);if(D){const F=h.timeStamp-this.lastTime<500,z=!this.lastTap||this.lastTap.dist(D)<30;if(F&&z||this.reset(),this.count++,this.lastTime=h.timeStamp,this.lastTap=D,this.count===this.numTaps)return this.reset(),D}}}class gF{constructor(){this._zoomIn=new P3({numTouches:1,numTaps:2}),this._zoomOut=new P3({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(h,y,A){this._zoomIn.touchstart(h,y,A),this._zoomOut.touchstart(h,y,A)}touchmove(h,y,A){this._zoomIn.touchmove(h,y,A),this._zoomOut.touchmove(h,y,A)}touchend(h,y,A){const D=this._zoomIn.touchend(h,y,A),F=this._zoomOut.touchend(h,y,A);return D?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:z=>z.easeTo({duration:300,zoom:z.getZoom()+1,around:z.unproject(D)},{originalEvent:h})}):F?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:z=>z.easeTo({duration:300,zoom:z.getZoom()-1,around:z.unproject(F)},{originalEvent:h})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const yF={0:1,2:2},P6={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class I3{constructor(h){this.reset(),this._clickTolerance=h.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(h,y){return!1}_move(h,y){return{}}mousedown(h,y){if(this._lastPoint)return;const A=V(h);this._correctButton(h,A)&&(this._lastPoint=y,this._eventButton=A)}mousemoveWindow(h,y){const A=this._lastPoint;if(A){if(h.preventDefault(),this._eventButton!=null&&function(D,F){const z=yF[F];return D.buttons===void 0||(D.buttons&z)!==z}(h,this._eventButton))this.reset();else if(this._moved||!(y.dist(A)0&&(this._active=!0);const D=E3(A,y),F=new i.P(0,0),z=new i.P(0,0);let W=0;for(const ne in D){const le=D[ne],_e=this._touches[ne];_e&&(F._add(le),z._add(le.sub(_e)),W++,D[ne]=le)}if(this._touches=D,W{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class L3{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(h){}_move(h,y,A){return{}}touchstart(h,y,A){this._firstTwoTouches||A.length<2||(this._firstTwoTouches=[A[0].identifier,A[1].identifier],this._start([y[0],y[1]]))}touchmove(h,y,A){const D=this._firstTwoTouches;if(!D)return;h.preventDefault();const[F,z]=D,W=g2(A,y,F),J=g2(A,y,z);if(!W||!J)return;const ne=this._aroundCenter?null:W.add(J).div(2);return this._move([W,J],ne,h)}touchend(h,y,A){if(!this._firstTwoTouches)return;const[D,F]=this._firstTwoTouches,z=g2(A,y,D),W=g2(A,y,F);z&&W||(this._active&&q(),this.reset())}touchcancel(){this.reset()}enable(h){this._enabled=!0,this._aroundCenter=!!h&&h.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function g2(T,h,y){for(let A=0;AMath.abs(T.x)}class Wme extends L3{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,D3(h[0].sub(h[1]))&&(this._valid=!1)}_move(h,y,A){const D=this._lastPoints;if(!D)return;const F=h[0].sub(D[0]),z=h[1].sub(D[1]);return this._map._cooperativeGestures&&!i.eU()&&A.touches.length<3||(this._valid=this.gestureBeginsVertically(F,z,A.timeStamp),!this._valid)?void 0:(this._lastPoints=h,this._active=!0,{pitchDelta:(F.y+z.y)/2*-.5})}gestureBeginsVertically(h,y,A){if(this._valid!==void 0)return this._valid;const D=h.mag()>=2,F=y.mag()>=2;if(!D&&!F)return;if(!D||!F)return this._firstMove==null&&(this._firstMove=A),A-this._firstMove<100&&void 0;const z=h.y>0==y.y>0;return D3(h)&&D3(y)&&z}}const Gme={panStep:100,bearingStep:15,pitchStep:10};class Kme{constructor(){const h=Gme;this._panStep=h.panStep,this._bearingStep=h.bearingStep,this._pitchStep=h.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(h){if(h.altKey||h.ctrlKey||h.metaKey)return;let y=0,A=0,D=0,F=0,z=0;switch(h.keyCode){case 61:case 107:case 171:case 187:y=1;break;case 189:case 109:case 173:y=-1;break;case 37:h.shiftKey?A=-1:(h.preventDefault(),F=-1);break;case 39:h.shiftKey?A=1:(h.preventDefault(),F=1);break;case 38:h.shiftKey?D=1:(h.preventDefault(),z=-1);break;case 40:h.shiftKey?D=-1:(h.preventDefault(),z=1);break;default:return}return this._rotationDisabled&&(A=0,D=0),{cameraAnimation:W=>{const J=W.getZoom();W.easeTo({duration:300,easeId:"keyboardHandler",easing:y2,zoom:y?Math.round(J)+y*(h.shiftKey?2:1):J,bearing:W.getBearing()+A*this._bearingStep,pitch:W.getPitch()+D*this._pitchStep,offset:[-F*this._panStep,-z*this._panStep],center:W.getCenter()},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function y2(T){return T*(2-T)}const D6=4.000244140625,O6=1/450;class O3{constructor(h,y){this._map=h,this._el=h.getCanvasContainer(),this._handler=y,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=O6,i.aY(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(h){this._defaultZoomRate=h}setWheelZoomRate(h){this._wheelZoomRate=h}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(h){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!h&&h.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(h){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(h.ctrlKey||h.metaKey||this.isZooming()||i.eU()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let y=h.deltaMode===WheelEvent.DOM_DELTA_LINE?40*h.deltaY:h.deltaY;const A=i.o.now(),D=A-(this._lastWheelEventTime||0);this._lastWheelEventTime=A,y!==0&&y%D6==0?this._type="wheel":y!==0&&Math.abs(y)<4?this._type="trackpad":D>400?(this._type=null,this._lastValue=y,this._timeout=window.setTimeout(this._onTimeout,40,h)):this._type||(this._type=Math.abs(D*y)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,y+=this._lastValue)),h.shiftKey&&y&&(y/=4),this._type&&(this._lastWheelEvent=h,this._delta-=y,this._active||this._start(h)),h.preventDefault()}_onTimeout(h){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(h)}_start(h){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const y=U(this._el,h);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:y,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const h=this._map.transform;this._type==="wheel"&&h.projection.wrap&&(h._center.lng>=180||h._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const y=()=>h._terrainEnabled()&&this._aroundCoord?h.computeZoomRelativeTo(this._aroundCoord):h.zoom;if(this._delta!==0){const ne=this._type==="wheel"&&Math.abs(this._delta)>D6?this._wheelZoomRate:this._defaultZoomRate;let le=2/(1+Math.exp(-Math.abs(this._delta*ne)));this._delta<0&&le!==0&&(le=1/le);const _e=y(),ye=Math.pow(2,_e),we=typeof this._targetZoom=="number"?h.zoomScale(this._targetZoom):ye;this._targetZoom=Math.min(h.maxZoom,Math.max(h.minZoom,h.scaleZoom(we*le))),this._type==="wheel"&&(this._startZoom=_e,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const A=typeof this._targetZoom=="number"?this._targetZoom:y(),D=this._startZoom,F=this._easing;let z,W=!1;if(this._type==="wheel"&&D&&F){const ne=Math.min((i.o.now()-this._lastWheelEventTime)/200,1),le=F(ne);z=i.ak(D,A,le),ne<1?this._frameId||(this._frameId=!0):W=!0}else z=A,W=!0;this._active=!0,W&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let J=z-y();return J*this._lastDelta<0&&(J=0),{noInertia:!0,needsRenderFrame:!W,zoomDelta:J,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(h){let y=i.eV;if(this._prevEase){const A=this._prevEase,D=(i.o.now()-A.start)/A.duration,F=A.easing(D+.01)-A.easing(D),z=.27/Math.sqrt(F*F+1e-4)*.01,W=Math.sqrt(.0729-z*z);y=i.eT(z,W,.25,1)}return this._prevEase={start:i.o.now(),duration:h,easing:y},y}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=j("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class lg{constructor(h,y){this._clickZoom=h,this._tapZoom=y}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class R3{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(h,y){return h.preventDefault(),{cameraAnimation:A=>{A.easeTo({duration:300,zoom:A.getZoom()+(h.shiftKey?-1:1),around:A.unproject(y)},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class $l{constructor(){this._tap=new P3({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(h,y,A){this._swipePoint||(this._tapTime&&h.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?A.length>0&&(this._swipePoint=y[0],this._swipeTouch=A[0].identifier):this._tap.touchstart(h,y,A))}touchmove(h,y,A){if(this._tapTime){if(this._swipePoint){if(A[0].identifier!==this._swipeTouch)return;const D=y[0],F=D.y-this._swipePoint.y;return this._swipePoint=D,h.preventDefault(),this._active=!0,{zoomDelta:F/128}}}else this._tap.touchmove(h,y,A)}touchend(h,y,A){this._tapTime?this._swipePoint&&A.length===0&&this.reset():this._tap.touchend(h,y,A)&&(this._tapTime=h.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Wf{constructor(h,y,A){this._el=h,this._mousePan=y,this._touchPan=A}enable(h){this._inertiaOptions=h||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class v2{constructor(h,y,A){this._pitchWithRotate=h.pitchWithRotate,this._mouseRotate=y,this._mousePitch=A}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class F3{constructor(h,y,A,D){this._el=h,this._touchZoom=y,this._touchRotate=A,this._tapDragZoom=D,this._rotationDisabled=!1,this._enabled=!0}enable(h){this._touchZoom.enable(h),this._rotationDisabled||this._touchRotate.enable(h),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const b2=T=>T.zoom||T.drag||T.pitch||T.rotate;class Zme extends i.z{}class _2{constructor(){this.constants=[1,1,.01],this.radius=0}setup(h,y){const A=i.av([],y,h);this.radius=i.ag(A[2]<0?i.eX([],A,this.constants):[A[0],A[1],0])}projectRay(h){i.eX(h,h,this.constants),i.aw(h,h),i.eY(h,h,this.constants);const y=i.c5([],h,this.radius);if(y[2]>0){const A=i.c5([],[0,0,1],i.bJ(y,[0,0,1])),D=i.c5([],i.aw([],[y[0],y[1],0]),this.radius),F=i.d8([],y,i.c5([],i.av([],i.d8([],D,A),y),2));y[0]=F[0],y[1]=F[1]}return y}}function z3(T){return T.panDelta&&T.panDelta.mag()||T.zoomDelta||T.bearingDelta||T.pitchDelta}class Yme{constructor(h,y){this._map=h,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new T6(h),this._bearingSnap=y.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new _2,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(y),i.aY(["handleEvent","handleWindowEvent"],this);const A=this._el;this._listeners=[[A,"touchstart",{passive:!0}],[A,"touchmove",{passive:!1}],[A,"touchend",void 0],[A,"touchcancel",void 0],[A,"mousedown",void 0],[A,"mousemove",void 0],[A,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[A,"mouseover",void 0],[A,"mouseout",void 0],[A,"dblclick",void 0],[A,"click",void 0],[A,"keydown",{capture:!1}],[A,"keyup",void 0],[A,"wheel",{passive:!1}],[A,"contextmenu",void 0],[window,"blur",void 0]];for(const[D,F,z]of this._listeners){const W=D===document?this.handleWindowEvent:this.handleEvent;D.addEventListener(F,W,z)}}destroy(){for(const[h,y,A]of this._listeners){const D=h===document?this.handleWindowEvent:this.handleEvent;h.removeEventListener(y,D,A)}}_addDefaultHandlers(h){const y=this._map,A=y.getCanvasContainer();this._add("mapEvent",new T3(y,h));const D=y.boxZoom=new A3(y,h);this._add("boxZoom",D);const F=new gF,z=new R3;y.doubleClickZoom=new lg(z,F),this._add("tapZoom",F),this._add("clickZoom",z);const W=new $l;this._add("tapDragZoom",W);const J=y.touchPitch=new Wme(y);this._add("touchPitch",J);const ne=new I6(h),le=new L6(h);y.dragRotate=new v2(h,ne,le),this._add("mouseRotate",ne,["mousePitch"]),this._add("mousePitch",le,["mouseRotate"]);const _e=new vF(h),ye=new bF(y,h);y.dragPan=new Wf(A,_e,ye),this._add("mousePan",_e),this._add("touchPan",ye,["touchZoom","touchRotate"]);const we=new bo,Le=new Hme;y.touchZoomRotate=new F3(A,Le,we,W),this._add("touchRotate",we,["touchPan","touchZoom"]),this._add("touchZoom",Le,["touchPan","touchRotate"]),this._add("blockableMapEvent",new E6(y));const Ie=y.scrollZoom=new O3(y,this);this._add("scrollZoom",Ie,["mousePan"]);const We=y.keyboard=new Kme;this._add("keyboard",We);for(const Ue of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])h.interactive&&h[Ue]&&y[Ue].enable(h[Ue])}_add(h,y,A){this._handlers.push({handlerName:h,handler:y,allowed:A}),this._handlersById[h]=y}stop(h){if(!this._updatingCamera){for(const{handler:y}of this._handlers)y.reset();this._inertia.clear(),this._fireEvents({},{},h),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:h}of this._handlers)if(h.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!b2(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(h,y,A){for(const D in h)if(D!==A&&(!y||y.indexOf(D)<0))return!0;return!1}handleWindowEvent(h){this.handleEvent(h,`${h.type}Window`)}_getMapTouches(h){const y=[];for(const A of h)this._el.contains(A.target)&&y.push(A);return y}handleEvent(h,y){this._updatingCamera=!0;const A=h.type==="renderFrame",D=A?void 0:h,F={needsRenderFrame:!1},z={},W={},J=h.touches?this._getMapTouches(h.touches):void 0,ne=J?B(this._el,J):A?void 0:U(this._el,h);for(const{handlerName:ye,handler:we,allowed:Le}of this._handlers){if(!we.isEnabled())continue;let Ie;this._blockedByActive(W,Le,ye)?we.reset():we[y||h.type]&&(Ie=we[y||h.type](h,ne,J),this.mergeHandlerResult(F,z,Ie,ye,D),Ie&&Ie.needsRenderFrame&&this._triggerRenderFrame()),(Ie||we.isActive())&&(W[ye]=we)}const le={};for(const ye in this._previousActiveHandlers)W[ye]||(le[ye]=D);this._previousActiveHandlers=W,(Object.keys(le).length||z3(F))&&(this._changes.push([F,z,le]),this._triggerRenderFrame()),(Object.keys(W).length||z3(F))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:_e}=F;_e&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],_e(this._map))}mergeHandlerResult(h,y,A,D,F){if(!A)return;Object.assign(h,A);const z={handlerName:D,originalEvent:A.originalEvent||F};A.zoomDelta!==void 0&&(y.zoom=z),A.panDelta!==void 0&&(y.drag=z),A.pitchDelta!==void 0&&(y.pitch=z),A.bearingDelta!==void 0&&(y.rotate=z)}_applyChanges(){const h={},y={},A={};for(const[D,F,z]of this._changes)D.panDelta&&(h.panDelta=(h.panDelta||new i.P(0,0))._add(D.panDelta)),D.zoomDelta&&(h.zoomDelta=(h.zoomDelta||0)+D.zoomDelta),D.bearingDelta&&(h.bearingDelta=(h.bearingDelta||0)+D.bearingDelta),D.pitchDelta&&(h.pitchDelta=(h.pitchDelta||0)+D.pitchDelta),D.around!==void 0&&(h.around=D.around),D.aroundCoord!==void 0&&(h.aroundCoord=D.aroundCoord),D.pinchAround!==void 0&&(h.pinchAround=D.pinchAround),D.noInertia&&(h.noInertia=D.noInertia),Object.assign(y,F),Object.assign(A,z);this._updateMapTransform(h,y,A),this._changes=[]}_updateMapTransform(h,y,A){const D=this._map,F=D.transform,z=st=>[st.x,st.y,st.z];if((st=>{const ut=this._eventsInProgress.drag;return ut&&!this._handlersById[ut.handlerName].isActive()})()&&!z3(h)){const st=F.zoom;F.cameraElevationReference="sea",this._originalZoom!=null&&F._orthographicProjectionAtLowPitch&&F.projection.name!=="globe"&&F.pitch===0?(F.cameraElevationReference="ground",F.zoom=this._originalZoom):(F.recenterOnTerrain(),F.cameraElevationReference="ground"),st!==F.zoom&&this._map._update(!0)}if(F._isCameraConstrained&&D._stop(!0),!z3(h))return void this._fireEvents(y,A,!0);let{panDelta:W,zoomDelta:J,bearingDelta:ne,pitchDelta:le,around:_e,aroundCoord:ye,pinchAround:we}=h;F._isCameraConstrained&&(J>0&&(J=0),F._isCameraConstrained=!1),we!==void 0&&(_e=we),(J||(st=>y[st]&&!this._eventsInProgress[st])("drag"))&&_e&&(this._dragOrigin=z(F.pointCoordinate3D(_e)),this._originalZoom=F.zoom,this._trackingEllipsoid.setup(F._camera.position,this._dragOrigin)),F.cameraElevationReference="sea",D._stop(!0),_e=_e||D.transform.centerPoint,ne&&(F.bearing+=ne),le&&(F.pitch+=le),F._updateCameraState();const Le=[0,0,0];if(W)if(F.projection.name==="mercator"){const st=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(_e).dir),ut=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(_e.sub(W)).dir);Le[0]=ut[0]-st[0],Le[1]=ut[1]-st[1]}else{const st=F.pointCoordinate(_e);if(F.projection.name==="globe"){W=W.rotate(-F.angle);const ut=F._pixelsPerMercatorPixel/F.worldSize;Le[0]=-W.x*i.eW(i.a$(st.y))*ut,Le[1]=-W.y*i.eW(F.center.lat)*ut}else{const ut=F.pointCoordinate(_e.sub(W));st&&ut&&(Le[0]=ut.x-st.x,Le[1]=ut.y-st.y)}}const Ie=F.zoom,We=[0,0,0];if(J){const st=z(ye||F.pointCoordinate3D(_e)),ut={dir:i.aw([],i.av([],st,F._camera.position))};if(ut.dir[2]<0){const ot=F.zoomDeltaToMovement(st,J);i.c5(We,ut.dir,ot)}}const Ue=i.d8(Le,Le,We);F._translateCameraConstrained(Ue),J&&Math.abs(F.zoom-Ie)>1e-4&&F.recenterOnTerrain(),F.cameraElevationReference="ground",this._map._update(),h.noInertia||this._inertia.record(h),this._fireEvents(y,A,!0)}_fireEvents(h,y,A){const D=b2(this._eventsInProgress),F=b2(h),z={};for(const le in h){const{originalEvent:_e}=h[le];this._eventsInProgress[le]||(z[`${le}start`]=_e),this._eventsInProgress[le]=h[le]}!D&&F&&this._fireEvent("movestart",F.originalEvent);for(const le in z)this._fireEvent(le,z[le]);F&&this._fireEvent("move",F.originalEvent);for(const le in h){const{originalEvent:_e}=h[le];this._fireEvent(le,_e)}const W={};let J;for(const le in this._eventsInProgress){const{handlerName:_e,originalEvent:ye}=this._eventsInProgress[le];this._handlersById[_e].isActive()||(delete this._eventsInProgress[le],J=y[_e]||ye,W[`${le}end`]=J)}for(const le in W)this._fireEvent(le,W[le]);const ne=b2(this._eventsInProgress);if(A&&(D||F)&&!ne){this._updatingCamera=!0;const le=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),_e=ye=>ye!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Zme("renderFrame",{timeStamp:h})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const B3="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class R6 extends i.E{constructor(h,y){super(),this._moving=!1,this._zooming=!1,this.transform=h,this._bearingSnap=y.bearingSnap,this._respectPrefersReducedMotion=y.respectPrefersReducedMotion!==!1,i.aY(["_renderFrameCallback"],this)}getCenter(){return new i.aT(this.transform.center.lng,this.transform.center.lat)}setCenter(h,y){return this.jumpTo({center:h},y)}panBy(h,y,A){return h=i.P.convert(h).mult(-1),this.panTo(this.transform.center,Object.assign({offset:h},y),A)}panTo(h,y,A){return this.easeTo(Object.assign({center:h},y),A)}getZoom(){return this.transform.zoom}setZoom(h,y){return this.jumpTo({zoom:h},y),this}zoomTo(h,y,A){return this.easeTo(Object.assign({zoom:h},y),A)}zoomIn(h,y){return this.zoomTo(this.getZoom()+1,h,y),this}zoomOut(h,y){return this.zoomTo(this.getZoom()-1,h,y),this}getBearing(){return this.transform.bearing}setBearing(h,y){return this.jumpTo({bearing:h},y),this}getPadding(){return this.transform.padding}setPadding(h,y){return this.jumpTo({padding:h},y),this}rotateTo(h,y,A){return this.easeTo(Object.assign({bearing:h},y),A)}resetNorth(h,y){return this.rotateTo(0,Object.assign({duration:1e3},h),y),this}resetNorthPitch(h,y){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},h),y),this}snapToNorth(h,y){return Math.abs(this.getBearing())h.aspect?A/(2*Math.tan(.5*h.fovX)*h.aspect):D/(2*Math.tan(.5*h.fovY)*h.aspect)}_cameraForBoundsOnGlobe(h,y,A,D,F,z){const W=h.clone(),J=this._extendCameraOptions(z);W.bearing=D,W.pitch=F;const ne=i.aT.convert(y),le=i.aT.convert(A),_e=.5*(ne.lat+le.lat),ye=.5*(ne.lng+le.lng),we=i.eZ(_e,ye),Le=i.aw([],we),Ie=i.aw([],i.bI([],Le,[0,1,0])),We=i.bI([],Ie,Le),Ue=[Ie[0],Ie[1],Ie[2],0,We[0],We[1],We[2],0,Le[0],Le[1],Le[2],0,0,0,0,1],st=[we,i.eZ(ne.lat,ne.lng),i.eZ(le.lat,ne.lng),i.eZ(le.lat,le.lng),i.eZ(ne.lat,le.lng),i.eZ(_e,ne.lng),i.eZ(_e,le.lng),i.eZ(ne.lat,ye),i.eZ(le.lat,ye)];let ut=i.d9.fromPoints(st.map(Jt=>[i.bJ(Ie,Jt),i.bJ(We,Jt),i.bJ(Le,Jt)]));const ot=i.af([],ut.center,Ue);i.e_(ot)===0&&i.e$(ot,0,0,1),i.aw(ot,ot),i.c5(ot,ot,i.aD),W.center=i.f0(ot);const Et=W.getWorldToCameraMatrix(),Nt=i.bl(new Float64Array(16),Et);ut=i.d9.applyTransform(ut,i.aB([],Et,Ue));const Tt=this._extendAABB(ut,W,J,D);if(!Tt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");ut=Tt,i.af(ot,ot,Et);const wt=.5*(ut.max[2]-ut.min[2]),yt=this._minimumAABBFrustumDistance(W,ut),Ot=i.c5([],[0,0,1],wt),Wt=i.d8(Ot,ot,Ot),Ht=yt+(W.pitch===0?0:i.bG(ot,Wt)),es=W.globeCenterInViewSpace,ts=i.av([],ot,[es[0],es[1],es[2]]);i.aw(ts,ts),i.c5(ts,ts,Ht);const xs=i.d8([],ot,ts);i.af(xs,xs,Nt);const qs=i.eM/i.aD,Yt=i.ag(xs),Bt=i.cf(Math.max(Yt*qs-i.eM,Number.EPSILON),0),as=Math.min(W.zoomFromMercatorZAdjusted(Bt),J.maxZoom);return as>.5*(i.c_+i.cL)?(W.setProjection({name:"mercator"}),W.zoom=as,this._cameraForBounds(W,y,A,D,F,z)):{center:W.center,zoom:as,bearing:D,pitch:F}}_extendAABB(h,y,A,D){const F=.5*((A.padding.left||0)+(A.padding.right||0)),z=.5*((A.padding.top||0)+(A.padding.bottom||0)),W=z,J=F,ne=F,le=z,_e=y.width-(J+ne),ye=y.height-(W+le),we=i.av([],h.max,h.min),Le=Math.min(_e/we[0],ye/we[1]),Ie=Math.min(y.scaleZoom(y.scale*Le),A.maxZoom);if(isNaN(Ie))return null;const We=y.scale/y.zoomScale(Ie),Ue=new i.d9([h.min[0]-J*We,h.min[1]-le*We,h.min[2]],[h.max[0]+ne*We,h.max[1]+W*We,h.max[2]]),st=(typeof A.offset.x=="number"&&typeof A.offset.y=="number"?new i.P(A.offset.x,A.offset.y):i.P.convert(A.offset)).rotate(-i.an(D));return Ue.center[0]-=st.x*We,Ue.center[1]+=st.y*We,Ue}queryTerrainElevation(h,y){const A=this.transform.elevation;return A?(y=Object.assign({},{exaggerated:!0},y),A.getAtPoint(i.ae.fromLngLat(h),null,y.exaggerated)):null}_cameraForBounds(h,y,A,D,F,z){if(h.projection.name==="globe")return this._cameraForBoundsOnGlobe(h,y,A,D,F,z);const W=h.clone(),J=this._extendCameraOptions(z);W.bearing=D,W.pitch=F;const ne=i.aT.convert(y),le=i.aT.convert(A),_e=new i.aT(ne.lng,le.lat),ye=new i.aT(le.lng,ne.lat),we=W.project(ne),Le=W.project(le),Ie=this.queryTerrainElevation(ne),We=this.queryTerrainElevation(le),Ue=this.queryTerrainElevation(_e),st=this.queryTerrainElevation(ye),ut=[[we.x,we.y,Math.min(Ie||0,We||0,Ue||0,st||0)],[Le.x,Le.y,Math.max(Ie||0,We||0,Ue||0,st||0)]];let ot=i.d9.fromPoints(ut);const Et=W.getWorldToCameraMatrix(),Nt=i.bl(new Float64Array(16),Et);ot=i.d9.applyTransform(ot,Et);const Tt=this._extendAABB(ot,W,J,D);if(!Tt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");ot=Tt;const wt=.5*i.av([],ot.max,ot.min)[2],yt=this._minimumAABBFrustumDistance(W,ot),Ot=[0,0,1,0];i.aC(Ot,Ot,Et),i.f1(Ot,Ot);const Wt=i.c5([],Ot,yt+wt),Ht=i.d8([],ot.center,Wt);i.af(ot.center,ot.center,Nt),i.af(Ht,Ht,Nt);const es=W.unproject(new i.P(ot.center[0],ot.center[1])),ts=i.f2(W.projection,es),xs=Math.pow(2,ts),qs=Math.min(W._zoomFromMercatorZ(Ht[2]*W.pixelsPerMeter*xs/W.worldSize),J.maxZoom);return W.mercatorFromTransition&&qs<.5*(i.c_+i.cL)?(W.setProjection({name:"globe"}),W.zoom=qs,this._cameraForBounds(W,y,A,D,F,z)):{center:es,zoom:qs,bearing:D,pitch:F}}fitBounds(h,y,A){const D=this.cameraForBounds(h,y);return this._fitInternal(D,y,A)}fitScreenCoordinates(h,y,A,D,F){const z=i.P.convert(h),W=i.P.convert(y),J=new i.P(Math.min(z.x,W.x),Math.min(z.y,W.y)),ne=new i.P(Math.max(z.x,W.x),Math.max(z.y,W.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(z,W))return this;const le=this.transform.pointLocation3D(J),_e=this.transform.pointLocation3D(ne),ye=this.transform.pointLocation3D(new i.P(J.x,ne.y)),we=this.transform.pointLocation3D(new i.P(ne.x,J.y)),Le=[Math.min(le.lng,_e.lng,ye.lng,we.lng),Math.min(le.lat,_e.lat,ye.lat,we.lat)],Ie=[Math.max(le.lng,_e.lng,ye.lng,we.lng),Math.max(le.lat,_e.lat,ye.lat,we.lat)],We=D&&D.pitch?D.pitch:this.getPitch(),Ue=this._cameraForBounds(this.transform,Le,Ie,A,We,D);return this._fitInternal(Ue,D,F)}_fitInternal(h,y,A){return h?(y=Object.assign(h,y)).linear?this.easeTo(y,A):this.flyTo(y,A):this}jumpTo(h,y){this.stop();const A=h.preloadOnly?this.transform.clone():this.transform;let D=!1,F=!1,z=!1;"zoom"in h&&A.zoom!==+h.zoom&&(D=!0,A.zoom=+h.zoom),h.center!==void 0&&(A.center=i.aT.convert(h.center)),"bearing"in h&&A.bearing!==+h.bearing&&(F=!0,A.bearing=+h.bearing),"pitch"in h&&A.pitch!==+h.pitch&&(z=!0,A.pitch=+h.pitch);const W=typeof h.padding=="number"?this._extendPadding(h.padding):h.padding;if(h.padding!=null&&!A.isPaddingEqual(W))if(h.retainPadding===!1){const J=A.clone();J.padding=W,A.setLocationAtPoint(A.center,J.centerPoint)}else A.padding=W;return h.preloadOnly?(this._preloadTiles(A),this):(this.fire(new i.z("movestart",y)).fire(new i.z("move",y)),D&&this.fire(new i.z("zoomstart",y)).fire(new i.z("zoom",y)).fire(new i.z("zoomend",y)),F&&this.fire(new i.z("rotatestart",y)).fire(new i.z("rotate",y)).fire(new i.z("rotateend",y)),z&&this.fire(new i.z("pitchstart",y)).fire(new i.z("pitch",y)).fire(new i.z("pitchend",y)),this.fire(new i.z("moveend",y)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||i.w(B3),this.transform.getFreeCameraOptions()}setFreeCameraOptions(h,y){const A=this.transform;if(!A.projection.supportsFreeCamera)return i.w(B3),this;this.stop();const D=A.zoom,F=A.pitch,z=A.bearing;A.setFreeCameraOptions(h);const W=D!==A.zoom,J=F!==A.pitch,ne=z!==A.bearing;return this.fire(new i.z("movestart",y)).fire(new i.z("move",y)),W&&this.fire(new i.z("zoomstart",y)).fire(new i.z("zoom",y)).fire(new i.z("zoomend",y)),ne&&this.fire(new i.z("rotatestart",y)).fire(new i.z("rotate",y)).fire(new i.z("rotateend",y)),J&&this.fire(new i.z("pitchstart",y)).fire(new i.z("pitch",y)).fire(new i.z("pitchend",y)),this.fire(new i.z("moveend",y)),this}easeTo(h,y){this._stop(!1,h.easeId),((h=Object.assign({offset:[0,0],duration:500,easing:i.eV},h)).animate===!1||this._prefersReducedMotion(h))&&(h.duration=0);const A=this.transform,D=this.getZoom(),F=this.getBearing(),z=this.getPitch(),W=this.getPadding(),J="zoom"in h?+h.zoom:D,ne="bearing"in h?this._normalizeBearing(h.bearing,F):F,le="pitch"in h?+h.pitch:z,_e=this._extendPadding(h.padding),ye=i.P.convert(h.offset);let we,Le,Ie;if(A.projection.name==="globe"){const Ot=i.ae.fromLngLat(A.center),Wt=ye.rotate(-A.angle);Ot.x+=Wt.x/A.worldSize,Ot.y+=Wt.y/A.worldSize;const Ht=Ot.toLngLat(),es=i.aT.convert(h.center||Ht);this._normalizeCenter(es),we=A.centerPoint.add(Wt),Le=new i.P(Ot.x,Ot.y).mult(A.worldSize),Ie=new i.P(i.aF(es.lng),i.aJ(es.lat)).mult(A.worldSize).sub(Le)}else{we=A.centerPoint.add(ye);const Ot=A.pointLocation(we),Wt=i.aT.convert(h.center||Ot);this._normalizeCenter(Wt),Le=A.project(Ot),Ie=A.project(Wt).sub(Le)}const We=A.zoomScale(J-D);let Ue,st;h.around&&(Ue=i.aT.convert(h.around),st=A.locationPoint(Ue));const ut=this._zooming||J!==D,ot=this._rotating||F!==ne,Et=this._pitching||le!==z,Nt=!A.isPaddingEqual(_e),Tt=h.retainPadding===!1?A.clone():A,wt=Ot=>Wt=>{if(ut&&(Ot.zoom=i.ak(D,J,Wt)),ot&&(Ot.bearing=i.ak(F,ne,Wt)),Et&&(Ot.pitch=i.ak(z,le,Wt)),Nt&&(Tt.interpolatePadding(W,_e,Wt),we=Tt.centerPoint.add(ye)),Ue)Ot.setLocationAtPoint(Ue,st);else{const Ht=Ot.zoomScale(Ot.zoom-D),es=J>D?Math.min(2,We):Math.max(.5,We),ts=Math.pow(es,1-Wt),xs=Ot.unproject(Le.add(Ie.mult(Wt*ts)).mult(Ht));Ot.setLocationAtPoint(Ot.renderWorldCopies?xs.wrap():xs,we)}return h.preloadOnly||this._fireMoveEvents(y),Ot};if(h.preloadOnly){const Ot=this._emulate(wt,h.duration,A);return this._preloadTiles(Ot),this}const yt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=ut,this._rotating=ot,this._pitching=Et,this._padding=Nt,this._easeId=h.easeId,this._prepareEase(y,h.noMoveStart,yt),this._ease(wt(A),Ot=>{A.cameraElevationReference==="sea"&&A.recenterOnTerrain(),this._afterEase(y,Ot)},h),this}_prepareEase(h,y,A={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),y||A.moving||this.fire(new i.z("movestart",h)),this._zooming&&!A.zooming&&this.fire(new i.z("zoomstart",h)),this._rotating&&!A.rotating&&this.fire(new i.z("rotatestart",h)),this._pitching&&!A.pitching&&this.fire(new i.z("pitchstart",h))}_fireMoveEvents(h){this.fire(new i.z("move",h)),this._zooming&&this.fire(new i.z("zoom",h)),this._rotating&&this.fire(new i.z("rotate",h)),this._pitching&&this.fire(new i.z("pitch",h))}_afterEase(h,y){if(this._easeId&&y&&this._easeId===y)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const A=this._zooming,D=this._rotating,F=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,A&&this.fire(new i.z("zoomend",h)),D&&this.fire(new i.z("rotateend",h)),F&&this.fire(new i.z("pitchend",h)),this.fire(new i.z("moveend",h))}flyTo(h,y){if(this._prefersReducedMotion(h)){const Jt=i.aH(h,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(Jt,y)}this.stop(),h=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:i.eV},h);const A=this.transform,D=this.getZoom(),F=this.getBearing(),z=this.getPitch(),W=this.getPadding(),J="zoom"in h?i.aA(+h.zoom,A.minZoom,A.maxZoom):D,ne="bearing"in h?this._normalizeBearing(h.bearing,F):F,le="pitch"in h?+h.pitch:z,_e=this._extendPadding(h.padding),ye=A.zoomScale(J-D),we=i.P.convert(h.offset);let Le=A.centerPoint.add(we);const Ie=A.pointLocation(Le),We=i.aT.convert(h.center||Ie);this._normalizeCenter(We);const Ue=A.project(Ie),st=A.project(We).sub(Ue);let ut=h.curve;const ot=Math.max(A.width,A.height),Et=ot/ye,Nt=st.mag();if("minZoom"in h){const Jt=i.aA(Math.min(h.minZoom,D,J),A.minZoom,A.maxZoom),Is=ot/A.zoomScale(Jt-D);ut=Math.sqrt(Is/Nt*2)}const Tt=ut*ut;function wt(Jt){const Is=(Et*Et-ot*ot+(Jt?-1:1)*Tt*Tt*Nt*Nt)/(2*(Jt?Et:ot)*Tt*Nt);return Math.log(Math.sqrt(Is*Is+1)-Is)}function yt(Jt){return(Math.exp(Jt)-Math.exp(-Jt))/2}function Ot(Jt){return(Math.exp(Jt)+Math.exp(-Jt))/2}const Wt=wt(0);let Ht=function(Jt){return Ot(Wt)/Ot(Wt+ut*Jt)},es=function(Jt){return ot*((Ot(Wt)*(yt(Is=Wt+ut*Jt)/Ot(Is))-yt(Wt))/Tt)/Nt;var Is},ts=(wt(1)-Wt)/ut;if(Math.abs(Nt)<1e-6||!isFinite(ts)){if(Math.abs(ot-Et)<1e-6)return this.easeTo(h,y);const Jt=Eth.maxDuration&&(h.duration=0);const xs=F!==ne,qs=le!==z,Yt=!A.isPaddingEqual(_e),Bt=h.retainPadding===!1?A.clone():A,as=Jt=>Is=>{const rr=Is*ts,yr=1/Ht(rr);Jt.zoom=Is===1?J:D+Jt.scaleZoom(yr),xs&&(Jt.bearing=i.ak(F,ne,Is)),qs&&(Jt.pitch=i.ak(z,le,Is)),Yt&&(Bt.interpolatePadding(W,_e,Is),Le=Bt.centerPoint.add(we));const Js=Is===1?We:Jt.unproject(Ue.add(st.mult(es(rr))).mult(yr));return Jt.setLocationAtPoint(Jt.renderWorldCopies?Js.wrap():Js,Le),Jt._updateCameraOnTerrain(),h.preloadOnly||this._fireMoveEvents(y),Jt};if(h.preloadOnly){const Jt=this._emulate(as,h.duration,A);return this._preloadTiles(Jt),this}return this._zooming=!0,this._rotating=xs,this._pitching=qs,this._padding=Yt,this._prepareEase(y,!1),this._ease(as(A),()=>this._afterEase(y),h),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(h){}_cancelRenderFrame(h){}_stop(h,y){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const A=this._onEaseEnd;this._onEaseEnd=void 0,A.call(this,y)}if(!h){const A=this.handlers;A&&A.stop(!1)}return this}_ease(h,y,A){A.animate===!1||A.duration===0?(h(1),y()):(this._easeStart=i.o.now(),this._easeOptions=A,this._onEaseFrame=h,this._onEaseEnd=y,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const h=Math.min((i.o.now()-this._easeStart)/this._easeOptions.duration,1),y=this._onEaseFrame;y&&y(this._easeOptions.easing(h)),h<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(h,y){h=i.bT(h,-180,180);const A=Math.abs(h-y);return Math.abs(h-360-y)180?-360:A<-180?360:0}_prefersReducedMotion(h){return this._respectPrefersReducedMotion&&i.o.prefersReducedMotion&&!(h&&h.essential)}_emulate(h,y,A){const D=Math.ceil(15*y/1e3),F=[],z=h(A.clone());for(let W=0;W<=D;W++){const J=z(W/D);F.push(J.clone())}return F}_preloadTiles(h,y){}}class w2{constructor(h={}){this.options=h,i.aY(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(h){const y=this.options&&this.options.compact,A=h._getUIString("AttributionControl.ToggleAttribution");this._map=h,this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=j("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",A);const D=j("span","mapboxgl-ctrl-icon",this._compactButton);return D.setAttribute("aria-hidden","true"),D.setAttribute("title",A),this._innerContainer=j("div","mapboxgl-ctrl-attrib-inner",this._container),y&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),y===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let h=this._editLink;h||(h=this._editLink=this._container.querySelector(".mapbox-improve-map"));const y=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||i.e.ACCESS_TOKEN}];if(h){const A=y.reduce((D,F,z)=>(F.value&&(D+=`${F.key}=${F.value}${zD.length-F.length),h=h.filter((D,F)=>{for(let z=F+1;z=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?h=[...this.options.customAttribution,...h]:h.unshift(this.options.customAttribution));const A=h.map(D=>function(F){const z=new DOMParser().parseFromString(F,"text/html");return Array.from(z.body.querySelectorAll("*")).forEach(W=>{const J=W.textContent||"";if(W.tagName!=="A")return void W.replaceWith(z.createTextNode(J));const ne=W.getAttribute("href");if(!ne||!/^(https?:|mailto:)/i.test(ne))return void W.replaceWith(z.createTextNode(J));const le=z.createElement("a");le.href=ne,le.textContent=J,le.rel="noopener nofollow";const _e=W.getAttribute("class");_e&&(le.className=_e),W.replaceWith(le)}),z.body.innerHTML}(D)).join(" | ");A!==this._attribHTML&&(this._attribHTML=A,h.length?(this._innerContainer.innerHTML=A,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class j2{constructor(){i.aY(["_updateLogo","_updateCompact"],this)}onAdd(h){this._map=h,this._container=j("div","mapboxgl-ctrl");const y=j("a","mapboxgl-ctrl-logo");return y.target="_blank",y.rel="noopener nofollow",y.href="https://www.mapbox.com/",y.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),y.setAttribute("rel","noopener nofollow"),this._container.appendChild(y),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(h){h&&h.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const h=this._map.style._sourceCaches;if(Object.entries(h).length===0)return!0;for(const y in h){const A=h[y].getSource();if(A.hasOwnProperty("mapbox_logo")&&!A.mapbox_logo)return!1}return!0}_updateCompact(){const h=this._container.children;if(h.length){const y=h[0];this._map.getCanvasContainer().offsetWidth<250?y.classList.add("mapboxgl-compact"):y.classList.remove("mapboxgl-compact")}}}class xb{constructor(){i.aY(["_onIndoorUpdate"],this)}onAdd(h){return this._map=h,this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",y=>this._onIndoorUpdate(y)),this._container}_createButton(h,y){const A=j("button",h,this._container);return A.type="button",A.addEventListener("click",y),A}_createSeparator(){return j("div","mapboxgl-ctrl-separator",this._container)}_setButtonTitle(h,y){this._map&&(h.setAttribute("aria-label",y),h.textContent=y)}onRemove(){this._container&&this._container.remove(),this._map&&this._map.indoor&&(this._map.indoor.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"right"}_onIndoorUpdate(h){if(!h||!h.floors)return this._model=h,void(this._container.style.display="none");const y=this._model;this._model=h,this._container.style.display="inline-block",this._container.style.borderRadius="8px",y&&Array.from(this._container.children).forEach(A=>A.remove()),h.floors.length>0&&(this.addBuildingsToggleButton(),this.addCurrentFloors(h.floors,h.activeFloorsVisible),this._updateBuildingsButtonState())}addBuildingsToggleButton(){const h=this._createButton("mapboxgl-ctrl-buildings-toggle",()=>{const y=this._map;this._model&&y&&y._setIndoorActiveFloorsVisibility(!this._model.activeFloorsVisible)});j("span","mapboxgl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.classList.add("mapboxgl-ctrl-level-button","mapboxgl-ctrl-buildings-toggle"),this._model&&!this._model.activeFloorsVisible&&h.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(h),this._createSeparator()}_updateBuildingsButtonState(){const h=this._container.querySelector(".mapboxgl-ctrl-buildings-toggle");h&&this._model&&(this._model.activeFloorsVisible?h.classList.remove("mapboxgl-ctrl-level-button-selected"):h.classList.add("mapboxgl-ctrl-level-button-selected"))}addCurrentFloors(h,y){for(let A=0;A{this._map._selectIndoorFloor(D.id)});this._setButtonTitle(F,D.zIndex.toString()),this._model&&D.id===this._model.selectedFloorId&&y&&F.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(F),A=this._endTime)return this._end;const y=i.dD((h-this._startTime)/(this._endTime-this._startTime));return this._start*(1-y)+this._end*y}isEasing(h){return h>=this._startTime&&h<=this._endTime}jumpTo(h){this._startTime=-1/0,this._endTime=-1/0,this._start=h,this._end=h}easeTo(h,y,A){this._start=this.getValue(y),this._end=h,this._startTime=y,this._endTime=y+A}}const ug={"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 Dy extends i.z{constructor(h,y,A,D){const{point:F,lngLat:z,originalEvent:W,target:J}=h;super(h.type,{point:F,lngLat:z,originalEvent:W,target:J}),this.preventDefault=()=>{h.preventDefault()},this.id=y,this.interaction=A,this.feature=D}}class qp{constructor(h){this.map=h,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map}add(h,y){if(this.typeById.has(h))throw new Error(`Interaction id "${h}" already exists.`);const A=y.filter;let D=y.type;A&&this.filters.set(h,i.b6(A)),D==="mouseover"&&(D="mouseenter"),D==="mouseout"&&(D="mouseleave");const F=this.interactionsByType.get(D)||new Map;D==="mouseenter"||D==="mouseleave"?(this.delegatedInteractions.size===0&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(h,y)):F.size===0&&this.map.on(D,this.handleType),F.size===0&&this.interactionsByType.set(D,F),F.set(h,y),this.typeById.set(h,D)}get(h){const y=this.typeById.get(h);if(!y)return;const A=this.interactionsByType.get(y);return A?A.get(h):void 0}remove(h){const y=this.typeById.get(h);if(!y)return;this.typeById.delete(h),this.filters.delete(h);const A=this.interactionsByType.get(y);A&&(A.delete(h),y==="mouseenter"||y==="mouseleave"?(this.delegatedInteractions.delete(h),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):A.size===0&&this.map.off(y,this.handleType))}queryTargets(h,y){const A=[];for(const[D,F]of y)F.target&&A.push({targetId:D,target:F.target,filter:this.filters.get(D)});return this.map.style.queryRenderedTargets(h,A,this.map.transform)}handleMove(h){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const y=this.queryTargets(h.point,Array.from(this.delegatedInteractions).reverse());y.length&&(h.type="mouseenter",this.handleType(h,y));const A=new Map;for(const[D,{feature:F}]of this.prevHoveredFeatures)this.hoveredFeatures.has(D)||A.set(F.id,F);A.size&&(h.type="mouseleave",this.handleType(h,Array.from(A.values())))}handleOut(h){const y=Array.from(this.hoveredFeatures.values()).map(({feature:A})=>A);y.length&&(h.type="mouseleave",this.handleType(h,y)),this.hoveredFeatures.clear()}handleType(h,y){const A=h.type==="mouseenter";if(A&&!this.interactionsByType.has(h.type))return void i.w("mouseenter interaction required for mouseleave to work.");const D=Array.from(this.interactionsByType.get(h.type)).reverse(),F=!!y;y=y||this.queryTargets(h.point,D);let z=!1;const W=new Set;for(const J of y){for(const[ne,le]of D){if(!le.target)continue;const _e=J.variants?J.variants[ne]:null;if(_e){for(const ye of _e){if(yy(ye,J,W,ne))continue;const we=new i.dx(J,ye),Le=Zx(ye,J,ne);F&&we.id!==void 0&&(we.state=this.map.getFeatureState(we));const Ie=A?this.prevHoveredFeatures.get(Le):null,We=new Dy(h,ne,le,we),Ue=Ie?Ie.stop:le.handler(We);if(A&&this.hoveredFeatures.set(Le,{feature:J,stop:Ue}),Ue!==!1){z=!0;break}}if(z)break}}if(z)break}if(!z)for(const[J,ne]of D){const{handler:le,target:_e}=ne;if(!_e&&le(new Dy(h,J,ne,null))!==!1)break}}}function Xme(T,h){if(Array.isArray(T)&&Array.isArray(h)){const y=new Set(T),A=new Set(h);return y.size===A.size&&T.every(D=>A.has(D))}return i.by(T,h)}const Qme={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"},Jme={showCompass:!0,showZoom:!0,visualizePitch:!1};class epe{constructor(h,y,A=!1){this._clickTolerance=10,this.element=y,this.mouseRotate=new I6({clickTolerance:h.dragRotate._mouseRotate._clickTolerance}),this.map=h,A&&(this.mousePitch=new L6({clickTolerance:h.dragRotate._mousePitch._clickTolerance})),i.aY(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),y.addEventListener("mousedown",this.mousedown),y.addEventListener("touchstart",this.touchstart,{passive:!1}),y.addEventListener("touchmove",this.touchmove),y.addEventListener("touchend",this.touchend),y.addEventListener("touchcancel",this.reset)}down(h,y){this.mouseRotate.mousedown(h,y),this.mousePitch&&this.mousePitch.mousedown(h,y),L()}move(h,y){const A=this.map,D=this.mouseRotate.mousemoveWindow(h,y),F=D&&D.bearingDelta;if(F&&A.setBearing(A.getBearing()+F),this.mousePitch){const z=this.mousePitch.mousemoveWindow(h,y),W=z&&z.pitchDelta;W&&A.setPitch(A.getPitch()+W)}}off(){const h=this.element;h.removeEventListener("mousedown",this.mousedown),h.removeEventListener("touchstart",this.touchstart),h.removeEventListener("touchmove",this.touchmove),h.removeEventListener("touchend",this.touchend),h.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){I(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(h){this.down(Object.assign({},h,{ctrlKey:!0,preventDefault:()=>h.preventDefault()}),U(this.element,h)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(h){this.move(h,U(this.element,h))}mouseup(h){this.mouseRotate.mouseupWindow(h),this.mousePitch&&this.mousePitch.mouseupWindow(h),this.offTemp()}touchstart(h){h.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=B(this.element,h.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>h.preventDefault()},this._startPos))}touchmove(h){h.targetTouches.length!==1?this.reset():(this._lastPos=B(this.element,h.targetTouches)[0],this.move({preventDefault:()=>h.preventDefault()},this._lastPos))}touchend(h){h.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)y.width||h.y>y.height;y.locationPoint3D(A).distSqr(h)180;){const A=y.locationPoint3D(T);if(A.x>=0&&A.y>=0&&A.x<=y.width&&A.y<=y.height)break;T.lng>y.center.lng?T.lng-=360:T.lng+=360}return T}const Ud={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"},sp={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class $3 extends i.E{constructor(h,y){super(),(h instanceof HTMLElement||y)&&(h=Object.assign({element:h},y)),i.aY(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:A="center",color:D="#3FB1CE",scale:F=1,draggable:z=!1,clickTolerance:W=0,rotation:J=sp.rotation,rotationAlignment:ne=sp.rotationAlignment,pitchAlignment:le=sp.pitchAlignment,occludedOpacity:_e=sp.occludedOpacity,altitude:ye=sp.altitude}=h||{};this._anchor=A,this._color=D,this._scale=F,this._draggable=z,this._clickTolerance=W,this._rotation=J,this._rotationAlignment=ne,this._pitchAlignment=le,this._occludedOpacity=_e,this._altitude=ye,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",Ie=>{Ie.preventDefault()}),this._element.addEventListener("mousedown",Ie=>{Ie.preventDefault()});const we=this._element.classList;for(const Ie in Ud)we.remove(`mapboxgl-marker-anchor-${Ie}`);we.add(`mapboxgl-marker-anchor-${this._anchor}`);const Le=h&&h.className?h.className.trim().split(/\s+/):[];we.add(...Le),this._popup=null}_createDefaultMarker(){const h=j("div"),y=w("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},h);if(this._altitude===0){const A=w("radialGradient",{id:"shadowGradient"},w("defs",{},y));w("stop",{offset:"10%","stop-opacity":.4},A),w("stop",{offset:"100%","stop-opacity":.05},A),w("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},y)}return w("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},y),w("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},y),w("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},y),h}addTo(h){return h===this._map||(this.remove(),this._map=h,h.getCanvasContainer().appendChild(this._element),h.on("move",this._updateMoving),h.on("moveend",this._update),h.on("remove",this._clearFadeTimer),h._addMarker(this),this.setDraggable(this._draggable),this._update(),h.on("click",this._onMapClick)),this}remove(){const h=this._map;return h&&(h.off("click",this._onMapClick),h.off("move",this._updateMoving),h.off("moveend",this._update),h.off("mousedown",this._addDragHandler),h.off("touchstart",this._addDragHandler),h.off("mouseup",this._onUp),h.off("touchend",this._onUp),h.off("mousemove",this._onMove),h.off("touchmove",this._onMove),h.off("remove",this._clearFadeTimer),h._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=i.aT.convert(h),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(h){return h===this._altitude||(this._defaultMarker&&(this._altitude===0&&h!==0||this._altitude!==0&&h===0)&&(this._element=this._createDefaultMarker()),this._altitude=h||sp.altitude,this._update()),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(h){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),h){if(!("offset"in h.options)){const D=Math.sqrt(Math.pow(13.5,2)/2);h.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[D,-1*(38.1-13.5+D)],"bottom-right":[-D,-1*(38.1-13.5+D)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=h,h._marker=this,h._altitude=this._altitude,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(h){const y=h.code,A=h.charCode||h.keyCode;y!=="Space"&&y!=="Enter"&&A!==32&&A!==13||this.togglePopup()}_onMapClick(h){const y=h.originalEvent.target,A=this._element;this._popup&&(y===A||A.contains(y))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const h=this._popup;return h?(h.isOpen()?(h.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(h.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const h=this._map,y=this._pos;if(!h||!y)return!1;const A=h.unproject(y,this._altitude),D=h.getFreeCameraOptions();if(!D.position)return!1;const F=D.position.toLngLat();return F.distanceTo(A)<.9*F.distanceTo(this._lngLat)}_evaluateOpacity(){const h=this._map;if(!h)return;const y=this._pos;if(!y||y.x<0||y.x>h.transform.width||y.y<0||y.y>h.transform.height)return void this._clearFadeTimer();const A=h.unproject(y,this._altitude);let D;h._showingGlobe()&&i.f5(h.transform,this._lngLat)?D=0:(D=1-h._queryFogOpacity(A),h.transform._terrainEnabled()&&h.getTerrain()&&this._behindTerrain()&&(D*=this._occludedOpacity)),this._element.style.opacity=`${D}`,this._element.style.pointerEvents=D>0?"auto":"none",this._popup&&this._popup._setOpacity(D),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const h=this._pos;if(!h||!this._map)return;const y=this._offset.mult(this._scale);this._element.style.transform=` translate(${h.x}px,${h.y}px) ${Ud[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${y.x}px,${y.y}px) `}_calculateXYTransform(){const h=this._pos,y=this._map,A=this.getPitchAlignment();if(!y||!h||A!=="map")return"";if(!y._showingGlobe()){const J=y.getPitch();return J?`rotateX(${J}deg)`:""}const D=i.cX(i.f6(y.transform,this._lngLat)),F=h.sub(i.f7(y.transform)),z=Math.abs(F.x)+Math.abs(F.y);if(z===0)return"";const W=D/z;return`rotateX(${-F.y*W}deg) rotateY(${F.x*W}deg)`}_calculateZTransform(){const h=this._pos,y=this._map;if(!y||!h)return"";let A=0;const D=this.getRotationAlignment();if(D==="map")if(y._showingGlobe()){const F=y.project(new i.aT(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),z=y.project(new i.aT(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(F);A=i.cX(Math.atan2(z.y,z.x))-90}else A=-y.getBearing();else if(D==="horizon"){const F=i.ah(4,6,y.getZoom()),z=i.f7(y.transform);z.y+=F*y.transform.height;const W=h.sub(z),J=i.cX(Math.atan2(W.y,W.x));A=(J>90?J-270:J+90)*(1-F)}return A+=this._rotation,A?`rotateZ(${A}deg)`:""}_update(h){cancelAnimationFrame(this._updateFrameId);const y=this._map;y&&(y.transform.renderWorldCopies&&(this._lngLat=F6(this._lngLat,this._pos,y.transform)),this._pos=y.project(this._lngLat,this._altitude),h===!0?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),y._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(y._showingGlobe()||y.getTerrain()||y.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(h){return this._offset=i.P.convert(h),this._update(),this}addClassName(h){return this._element.classList.add(h),this}removeClassName(h){return this._element.classList.remove(h),this}toggleClassName(h){return this._element.classList.toggle(h)}_onMove(h){const y=this._map;if(!y)return;const A=this._pointerdownPos,D=this._positionDelta;if(A&&D){if(!this._isDragging){const F=this._clickTolerance||y._clickTolerance;if(h.point.dist(A)T.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(T.minPitch!=null&&T.maxPitch!=null&&T.minPitch>T.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(T.minPitch!=null&&T.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(T.maxPitch!=null&&T.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(T.antialias&&i.f3(window)&&(T.antialias=!1,i.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new qE(T.minZoom,T.maxZoom,T.minPitch,T.maxPitch,T.renderWorldCopies,null,null),T),this._repaint=!!T.repaint,this._interactive=T.interactive,this._minTileCacheSize=T.minTileCacheSize,this._maxTileCacheSize=T.maxTileCacheSize,this._failIfMajorPerformanceCaveat=T.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=T.preserveDrawingBuffer,this._antialias=T.antialias,this._trackResize=T.trackResize,this._bearingSnap=T.bearingSnap,this._refreshExpiredTiles=T.refreshExpiredTiles,this._fadeDuration=T.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=T.crossSourceCollisions,this._collectResourceTiming=T.collectResourceTiming,this._language=this._parseLanguage(T.language),this._worldview=T.worldview,this._renderTaskQueue=new cg,this._domRenderTaskQueue=new cg,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.b2(),this._locale=Object.assign({},ug,T.locale),this._clickTolerance=T.clickTolerance,this._cooperativeGestures=T.cooperativeGestures,this._performanceMetricsCollection=T.performanceMetricsCollection,this._tessellationStep=T.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=T.precompilePrograms,this._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new dg(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=T.scaleFactor,this._requestManager=new Q(T.transformRequest,T.accessToken,T.testMode),this._silenceAuthErrors=!!T.testMode,this._contextCreateOptions=T.contextCreateOptions?Object.assign({},T.contextCreateOptions):{},typeof T.container=="string"){const y=document.getElementById(T.container);if(!y)throw new Error(`Container '${T.container.toString()}' not found.`);this._container=y}else{if(!(T.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=T.container}if(this._container.childNodes.length>0&&i.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),T.maxBounds&&this.setMaxBounds(T.maxBounds),this._spriteFormat=T.spriteFormat,i.aY(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new Yme(this,T),this._localFontFamily=T.localFontFamily,this._localIdeographFontFamily=T.localIdeographFontFamily,(T.style||!T.testMode)&&this.setStyle(T.style||i.e.DEFAULT_STYLE,{config:T.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),T.projection&&this.setProjection(T.projection),T.hash&&(this._hash=new k6(typeof T.hash=="string"&&T.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){h.center==null&&h.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:T.center,zoom:T.zoom,bearing:T.bearing,pitch:T.pitch});const y=T.bounds;y&&(this.resize(),this.fitBounds(y,Object.assign({},T.fitBoundsOptions,{duration:0})))}this.resize(),T.attributionControl&&this.addControl(new w2({customAttribution:T.customAttribution})),this._logoControl=new j2,this.addControl(this._logoControl,T.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent(),this._setupIndoor()}),this.on("data",y=>{this._update(y.dataType==="style"),this.fire(new i.z(`${y.dataType}data`,y))}),this.on("dataloading",y=>{this.fire(new i.z(`${y.dataType}dataloading`,y))}),this._interactions=new qp(this)}_getMapId(){return this._mapId}addControl(T,h){if(h===void 0&&(h=T.getDefaultPosition?T.getDefaultPosition():"top-right"),!T||!T.onAdd)return this.fire(new i.y(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const y=T.onAdd(this);this._controls.push(T);const A=this._controlPositions[h];return h.indexOf("bottom")!==-1?A.insertBefore(y,A.firstChild):A.appendChild(y),this}removeControl(T){if(!T||!T.onRemove)return this.fire(new i.y(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const h=this._controls.indexOf(T);return h>-1&&this._controls.splice(h,1),T.onRemove(this),this}hasControl(T){return this._controls.indexOf(T)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(T){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const h=!this._moving;return h&&this.fire(new i.z("movestart",T)).fire(new i.z("move",T)),this.fire(new i.z("resize",T)),h&&this.fire(new i.z("moveend",T)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(T){return this.transform.setMaxBounds(i.aI.convert(T)),this._update()}setMinZoom(T){if((T=T??-2)>=-2&&T<=this.transform.maxZoom)return this.transform.minZoom=T,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=T,this._update(),this.getZoom()>T?this.setZoom(T):this.fire(new i.z("zoomstart")).fire(new i.z("zoom")).fire(new i.z("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(T){if((T=T??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(T>=0&&T<=this.transform.maxPitch)return this.transform.minPitch=T,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(T>=this.transform.minPitch)return this.transform.maxPitch=T,this._update(),this.getPitch()>T?this.setPitch(T):this.fire(new i.z("pitchstart")).fire(new i.z("pitch")).fire(new i.z("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(T){return this._scaleFactor=T,this.painter.scaleFactor=T,this._scaleFactorChanged=!0,this.style._updateFilteredLayers(h=>h.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(T){return this.transform.renderWorldCopies=T,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(T){return T==="auto"?navigator.language:Array.isArray(T)?T.length===0?void 0:T.map(h=>h==="auto"?navigator.language:h):T}setLanguage(T){const h=this._parseLanguage(T);if(!this.style||h===this._language)return this;this._language=h,this.style.reloadSources();for(const y of this._controls)y._setLanguage&&y._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(T){return this.style&&T!==this._worldview?(this._worldview=T,this._styleDirty=!0,this.style.reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(T){return this._lazyInitEmptyStyle(),T?typeof T=="string"&&(T={name:T}):T=null,this._useExplicitProjection=!!T,this._prioritizeAndUpdateProjection(T,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const T=this.transform,h=T.projection.name;let y;h==="globe"&&T.zoom>=i.cL?(T.setMercatorFromTransition(),y=!0):h==="mercator"&&T.zoom=i.cL?this.transform.setMercatorFromTransition():this.transform.setProjection(T),this.style.applyProjectionUpdate();const A=this.transform.getProjection().name==="mercator"&&y!==this.transform.mercatorFromTransition;return(h||A)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(T,h){return this.transform.locationPoint3D(i.aT.convert(T),h)}unproject(T,h){return this.transform.pointLocation3D(i.P.convert(T),h)}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(T,h,y){const A=D=>{let F=[];if(Array.isArray(h)){const z=h.filter(W=>this.getLayer(W));F=z.length?this.queryRenderedFeatures(D,{layers:z}):[]}else F=this.queryRenderedFeatures(D,{target:h});return F};if(T==="mouseenter"||T==="mouseover"){let D=!1;return{listener:y,targets:h,delegates:{mousemove:z=>{const W=A(z.point);W.length?D||(D=!0,y.call(this,new hh(T,this,z.originalEvent,{features:W}))):D=!1},mouseout:()=>{D=!1}}}}if(T==="mouseleave"||T==="mouseout"){let D=!1;return{listener:y,targets:h,delegates:{mousemove:W=>{A(W.point).length?D=!0:D&&(D=!1,y.call(this,new hh(T,this,W.originalEvent)))},mouseout:W=>{D&&(D=!1,y.call(this,new hh(T,this,W.originalEvent)))}}}}{const D=F=>{const z=A(F.point);z.length&&(F.features=z,y.call(this,F),delete F.features)};return{listener:y,targets:h,delegates:{[T]:D}}}}on(T,h,y){if(typeof h=="function"||y===void 0)return super.on(T,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._createDelegatedListener(T,h,y);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[T]=this._delegatedListeners[T]||[],this._delegatedListeners[T].push(A);for(const D in A.delegates)this.on(D,A.delegates[D]);return this}once(T,h,y){if(typeof h=="function"||y===void 0)return super.once(T,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._createDelegatedListener(T,h,y);for(const D in A.delegates)this.once(D,A.delegates[D]);return this}off(T,h,y){if(typeof h=="function"||y===void 0)return super.off(T,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._delegatedListeners?this._delegatedListeners[T]:void 0;return A&&(D=>{for(let F=0;F{if(y){const D=typeof y=="string"?y:y instanceof Error?y.message:y.error;i.w(`Unable to perform style diff: ${D}. Rebuilding the style from scratch.`),this._updateStyle(T,h)}else A&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=h.localIdeographFontFamily,this._localFontFamily=h.localFontFamily,this._updateStyle(T,h))}_getUIString(T){const h=this._locale[T];if(h==null)throw new Error(`Missing UI string '${T}'`);return h}_updateStyle(T,h){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),T){const y=Object.assign({},h);h&&h.config&&(y.initialConfig=h.config,delete y.config),this.style=new tp(this,y).load(T),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new tp(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(i.w("There is no style added to the map."),!1)}_isValidId(T){return T==null?(this.fire(new i.y(new Error("IDs can't be empty."))),!1):!i.dr(T)||(this.fire(new i.y(new Error(`IDs can't contain special symbols: "${T}".`))),!1)}_isTargetValid(T){return"featuresetId"in T?this._isValidId("importId"in T?T.importId:T.featuresetId):"layerId"in T&&this._isValidId(T.layerId)}_areTargetsValid(T){if(Array.isArray(T)){for(const h of T)if(!this._isValidId(h))return!1;return!0}return this._isTargetValid(T)}addSource(T,h){return this._isValidId(T)?(this._lazyInitEmptyStyle(),this.style.addSource(T,h),this._update(!0)):this}isSourceLoaded(T){return!!this._isValidId(T)&&!!this.style&&this.style._isSourceCacheLoaded(T)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(T,h,y){this._lazyInitEmptyStyle(),this.style.addSourceType(T,h,y)}removeSource(T){return this._isValidId(T)?(this.style.removeSource(T),this._updateTerrain(),this._update(!0)):this}getSource(T){return this._isValidId(T)?this.style.getOwnSource(T):null}addImage(T,h,{pixelRatio:y=1,sdf:A=!1,stretchX:D,stretchY:F,content:z}={}){this._lazyInitEmptyStyle();const W=i.I.from(T);if(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap){const{width:J,height:ne,data:le}=i.o.getImageData(h);this.style.addImage(W,{data:new i.q({width:J,height:ne},le),pixelRatio:y,stretchX:D,stretchY:F,content:z,sdf:A,version:0,usvg:!1})}else if(h.width===void 0||h.height===void 0)this.fire(new i.y(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:J,height:ne}=h,le=h;this.style.addImage(W,{data:new i.q({width:J,height:ne},new Uint8Array(le.data)),pixelRatio:y,stretchX:D,stretchY:F,content:z,sdf:A,usvg:!1,version:0,userImage:le}),le.onAdd&&le.onAdd(this,T)}}updateImage(T,h){this._lazyInitEmptyStyle();const y=i.I.from(T),A=this.style.getImage(y);if(!A)return void this.fire(new i.y(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const D=h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap?i.o.getImageData(h):h,{width:F,height:z,data:W}=D;if(F===void 0||z===void 0)return void this.fire(new i.y(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(F!==(A.usvg?A.icon.usvg_tree.width:A.data.width)||z!==(A.usvg?A.icon.usvg_tree.height:A.data.height))return void this.fire(new i.y(new Error(`The width and height of the updated image (${F}, ${z}) must be that same as the previous version of the image (${A.data.width}, ${A.data.height})`)));const J=!(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap);let ne=!1;A.usvg?(A.data=new i.q({width:F,height:z},new Uint8Array(W)),A.usvg=!1,A.icon=void 0,ne=!0):A.data.replace(W,J),this.style.updateImage(y,A,ne)}hasImage(T){return T?!!this.style&&!!this.style.getImage(i.I.from(T)):(this.fire(new i.y(new Error("Missing required image id"))),!1)}removeImage(T){this.style.removeImage(i.I.from(T))}loadImage(T,h){i.n(this._requestManager.transformRequest(T,i.R.Image),(y,A)=>{h(y,A instanceof HTMLImageElement?i.o.getImageData(A):A)})}listImages(){return this.style.listImages().map(T=>T.name)}addModel(T,h){this._lazyInitEmptyStyle(),this.style.addModel(T,h)}hasModel(T){return T?this.style.hasModel(T):(this.fire(new i.y(new Error("Missing required model id"))),!1)}removeModel(T){this.style.removeModel(T)}listModels(){return this.style.listModels()}addLayer(T,h){return this._isValidId(T.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(T,h),this._update(!0)):this}getSlot(T){const h=this.getLayer(T);return h&&h.slot||null}setSlot(T,h){return this.style.setSlot(T,h),this.style.mergeLayers(),this._update(!0)}addImport(T,h){return this.style.addImport(T,h).catch(y=>this.fire(new i.y(new Error("Failed to add import",y)))),this}updateImport(T,h){return typeof h!="string"&&h.id!==T?(this.removeImport(T),this.addImport(h)):(this.style.updateImport(T,h),this._update(!0))}removeImport(T){return this.style.removeImport(T),this}moveImport(T,h){return this.style.moveImport(T,h),this._update(!0)}moveLayer(T,h){return this._isValidId(T)?(this.style.moveLayer(T,h),this._update(!0)):this}removeLayer(T){return this._isValidId(T)?(this.style.removeLayer(T),this._update(!0)):this}getLayer(T){if(!this._isValidId(T))return null;const h=this.style.getOwnLayer(T);return h?h.type==="custom"?h.implementation:h.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(T,h,y){return this._isValidId(T)?(this.style.setLayerZoomRange(T,h,y),this._update(!0)):this}setFilter(T,h,y={}){return this._isValidId(T)?(this.style.setFilter(T,h,y),this._update(!0)):this}getFilter(T){return this._isValidId(T)?this.style.getFilter(T):null}setPaintProperty(T,h,y,A={}){return this._isValidId(T)?(this.style.setPaintProperty(T,h,y,A),this._update(!0)):this}getPaintProperty(T,h){return this._isValidId(T)?this.style.getPaintProperty(T,h):null}setLayoutProperty(T,h,y,A={}){return this._isValidId(T)?(this.style.setLayoutProperty(T,h,y,A),this._update(!0)):this}getLayoutProperty(T,h){return this._isValidId(T)?this.style.getLayoutProperty(T,h):null}setLayerProperty(T,h,y,A={}){return this._isValidId(T)?(h==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(T,h,y,A),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(T){return this.style.setGlyphsUrl(T),this._update(!0)}getSchema(T){return this.style.getSchema(T)}setSchema(T,h){return this.style.setSchema(T,h),this._update(!0)}getConfig(T){return this.style.getConfig(T)}setConfig(T,h){return this.style.setConfig(T,h),this._update(!0)}getConfigProperty(T,h){return this.style.getConfigProperty(T,h)}setConfigProperty(T,h,y){return this.style.setConfigProperty(T,h,y),this._update(!0)}getFeaturesetDescriptors(T){return this.style.getFeaturesetDescriptors(T)}setLights(T){if(this._lazyInitEmptyStyle(),T&&T.length===1&&T[0].type==="flat"){const h=T[0];h.properties?this.style.setFlatLight(h.properties,h.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(T),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const T=this.style.getLights()||[];return T.length===0&&T.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),T}setLight(T,h={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:T}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(T){return this._lazyInitEmptyStyle(),!T&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(T),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(T){return this._lazyInitEmptyStyle(),this.style.setFog(T),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(T){return this._lazyInitEmptyStyle(),this.style.setSnow(T),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(T){return this._lazyInitEmptyStyle(),this.style.setRain(T),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(T){return this._lazyInitEmptyStyle(),this.style.setColorTheme(T),this._update(!0)}setImportColorTheme(T,h){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(T,h),this._update(!0)}setCamera(T){return this.style.setCamera(T),this._triggerCameraUpdate(T)}_triggerCameraUpdate(T){return this._update(this.transform.setOrthographicProjectionAtLowPitch(T["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(T){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.aT.convert(T),this.transform):0}setFeatureState(T,h){return T.source&&!this._isValidId(T.source)?this:(this.style.setFeatureState(T,h),this._update())}removeFeatureState(T,h){return T.source&&!this._isValidId(T.source)?this:(this.style.removeFeatureState(T,h),this._update())}getFeatureState(T){return T.source&&!this._isValidId(T.source)?null:this.style.getFeatureState(T)}_selectIndoorFloor(T){this.indoor.selectFloor(T)}_setIndoorActiveFloorsVisibility(T){this.indoor.setActiveFloorsVisibility(T)}_addIndoorControl(){this._indoorControl||(this._indoorControl=new xb),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;const T=this._container.getBoundingClientRect().width||400,h=this._container.getBoundingClientRect().height||300;let y,A,D,F=this._container;for(;F&&(!A||!D);){const z=window.getComputedStyle(F).transform;z&&z!=="none"&&(y=z.match(/matrix.*\((.+)\)/)[1].split(", "),y[0]&&y[0]!=="0"&&y[0]!=="1"&&(A=y[0]),y[3]&&y[3]!=="0"&&y[3]!=="1"&&(D=y[3])),F=F.parentElement}this._containerWidth=A?Math.abs(T/A):T,this._containerHeight=D?Math.abs(h/D):h}_detectMissingCSS(){window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&i.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupIndoor(){this.style.isIndoorEnabled()&&(this.indoor=new AR(this.style),this.on("load",()=>{this._addIndoorControl(),this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds()),this.on("move",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())}),this.on("idle",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())})}))}_setupContainer(){const T=this._container;T.classList.add("mapboxgl-map"),(this._missingCSSCanary=j("div","mapboxgl-canary",T)).style.visibility="hidden",this._detectMissingCSS();const h=this._canvasContainer=j("div","mapboxgl-canvas-container",T);this._canvas=j("canvas","mapboxgl-canvas",h),this._interactive&&(h.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const y=this._controlContainer=j("div","mapboxgl-control-container",T),A=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(D=>{A[D]=j("div",`mapboxgl-ctrl-${D}`,y)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(T,h){const y=i.o.devicePixelRatio||1;this._canvas.width=y*Math.ceil(T),this._canvas.height=y*Math.ceil(h),this._canvas.style.width=`${T}px`,this._canvas.style.height=`${h}px`}_addMarker(T){this._markers.push(T)}_removeMarker(T){const h=this._markers.indexOf(T);h!==-1&&this._markers.splice(h,1)}_addPopup(T){this._popups.push(T)}_removePopup(T){const h=this._popups.indexOf(T);h!==-1&&this._popups.splice(h,1)}_setupPainter(){const T=Object.assign({},_.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),h=this._canvas.getContext("webgl2",T);h?(et(h,!0),this.painter=new C3(h,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",y=>{y.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),i.k.testSupport(h)):this.fire(new i.y(new Error("Failed to initialize WebGL")))}_contextLost(T){T.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.z("webglcontextlost",{originalEvent:T}))}_contextRestored(T){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new i.z("webglcontextrestored",{originalEvent:T}))}_onMapScroll(T){if(T.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return!this.isMoving()&&this.loaded()}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(T){return this.style?(this._styleDirty=this._styleDirty||T,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(T){return this._update(),this._renderTaskQueue.add(T)}_cancelRenderFrame(T){this._renderTaskQueue.remove(T)}_requestDomTask(T){!this.loaded()||this.loaded()&&!this.isMoving()?T():this._domRenderTaskQueue.add(T)}_render(T){let h;this.fire(new i.z("renderstart")),++this._frameId;const y=this.painter.context.extTimerQuery,A=i.o.now(),D=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(h=D.createQuery(),D.beginQuery(y.TIME_ELAPSED_EXT,h)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(T),this._domRenderTaskQueue.run(T),this._removed)return;this._updateProjectionTransition();const F=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const ne=this.transform.zoom,le=this.transform.pitch,_e=i.o.now(),ye=new i.ac(ne,{now:_e,fadeDuration:F,pitch:le,transition:this.style.transition,worldview:this._worldview});this.style.update(ye)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let z=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),z=this._updateAverageElevation(A),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):z=this._updateAverageElevation(A);const W=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,F,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),W&&(this._placementDirty=W.needsRerender),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:F,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new i.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.mark(u.load),this.fire(new i.z("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),h){const ne=i.o.now()-A;D.endQuery(y.TIME_ELAPSED_EXT),setTimeout(()=>{const le=D.getQueryParameter(h,D.QUERY_RESULT)/1e6;D.deleteQuery(h),this.fire(new i.z("gpu-timing-frame",{cpuTime:ne,gpuTime:le}))},50)}if(this.listens("gpu-timing-layer")){const ne=this.painter.collectGpuTimers();setTimeout(()=>{const le=this.painter.queryGpuTimers(ne);this.fire(new i.z("gpu-timing-layer",{layerTimes:le}))},50)}if(this.listens("gpu-timing-deferred-render")){const ne=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const le=this.painter.queryGpuTimeDeferredRender(ne);this.fire(new i.z("gpu-timing-deferred-render",{gpuTime:le}))},50)}const J=this._sourcesDirty||this._styleDirty||this._placementDirty||z;if(J||this._repaint)this.triggerRepaint();else{const ne=this.idle();if(ne&&(z=this._updateAverageElevation(A,!0)),z)this.triggerRepaint();else if(this._triggerFrame(!1),ne&&(this.fire(new i.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const le=this._calculateSpeedIndex();this.fire(new i.z("speedindexcompleted",{speedIndex:le})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||J||(this._fullyLoaded=!0,p.mark(u.fullLoad),this._performanceMetricsCollection&&ft(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(T){for(const h of this._markers)T&&!this.getRenderWorldCopies()&&(h._lngLat=h._lngLat.wrap()),h._update();for(const h of this._popups)!T||this.getRenderWorldCopies()||h._trackPointer||(h._lngLat=h._lngLat.wrap()),h._update()}_updateAverageElevation(T,h=!1){const y=D=>(this.transform.averageElevation=D,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&y(0);const A=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(A||(h||T-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(T)){const D=this.transform.averageElevation;let F=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(F)?F=0:this._averageElevationLastSampledAt=T;const z=Math.abs(D-F);if(z>1){if(this._isInitialLoad||A)return this._averageElevation.jumpTo(F),y(F);this._averageElevation.easeTo(F,T,300)}else if(z>1e-4)return this._averageElevation.jumpTo(F),y(F)}return!!this._averageElevation.isEasing(T)&&y(this._averageElevation.getValue(T))}_authenticate(){Ve(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,T=>{if(T&&(T.message===ee||T.status===401)){const h=this.painter.context.gl;et(h,!1),this._logoControl instanceof j2&&this._logoControl._updateLogo(),h&&h.clear(h.DEPTH_BUFFER_BIT|h.COLOR_BUFFER_BIT|h.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new i.y(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),Ne(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&Oe(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&ke(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){nt(this._requestManager._customAccessToken)}_updateTerrain(){const T=this._isDragging();this.painter.updateTerrain(this.style,T)}_calculateSpeedIndex(){const T=this.painter.canvasCopy(),h=this.painter.getCanvasCopiesAndTimestamps();h.timeStamps.push(performance.now());const y=this.painter.context.gl,A=y.createFramebuffer();function D(F){y.framebufferTexture2D(y.FRAMEBUFFER,y.COLOR_ATTACHMENT0,y.TEXTURE_2D,F,0);const z=new Uint8Array(y.drawingBufferWidth*y.drawingBufferHeight*4);return y.readPixels(0,0,y.drawingBufferWidth,y.drawingBufferHeight,y.RGBA,y.UNSIGNED_BYTE,z),z}return y.bindFramebuffer(y.FRAMEBUFFER,A),this._canvasPixelComparison(D(T),h.canvasCopies.map(D),h.timeStamps)}_canvasPixelComparison(T,h,y){let A=y[1]-y[0];const D=T.length/4;for(let F=0;F{const y=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,y&&this._render(h)}))}_preloadTiles(T){const h=this.style?this.style.getSourceCaches():[];return i.bw(h,(y,A)=>y._preloadTiles(T,A),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(T){this._trackResize&&this.resize({originalEvent:T})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(T){this._showTileBoundaries!==T&&(this._showTileBoundaries=T,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(T){this._showParseStatus!==T&&(this._showParseStatus=T,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(T){this._showTerrainWireframe!==T&&(this._showTerrainWireframe=T,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(T){this._showLayers2DWireframe!==T&&(this._showLayers2DWireframe=T,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(T){this._showLayers3DWireframe!==T&&(this._showLayers3DWireframe=T,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(T){this._speedIndexTiming!==T&&(this._speedIndexTiming=T,this._update())}get showPadding(){return!!this._showPadding}set showPadding(T){this._showPadding!==T&&(this._showPadding=T,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(T){this._showCollisionBoxes!==T&&(this._showCollisionBoxes=T,this.style&&T?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(T){this._showOverdrawInspector!==T&&(this._showOverdrawInspector=T,this._update())}get repaint(){return!!this._repaint}set repaint(T){this._repaint!==T&&(this._repaint=T,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(T){this._vertices=T,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(T){this._showTileAABBs!==T&&(this._showTileAABBs=T,T&&this._update())}_setCacheLimits(T,h){i.f4(T,h)}get version(){return c}},NavigationControl:class{constructor(T={}){this.options=Object.assign({},Jme,T),this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",h=>h.preventDefault()),this.options.showZoom&&(i.aY(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",h=>{this._map&&this._map.zoomIn({},{originalEvent:h})}),j("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",h=>{this._map&&this._map.zoomOut({},{originalEvent:h})}),j("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.aY(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",h=>{const y=this._map;y&&(this.options.visualizePitch?y.resetNorthPitch({},{originalEvent:h}):y.resetNorth({},{originalEvent:h}))}),this._compassIcon=j("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const T=this._map;if(!T)return;const h=T.getZoom(),y=h===T.getMaxZoom(),A=h===T.getMinZoom();this._zoomInButton.disabled=y,this._zoomOutButton.disabled=A,this._zoomInButton.setAttribute("aria-disabled",y.toString()),this._zoomOutButton.setAttribute("aria-disabled",A.toString())}_rotateCompassArrow(){const T=this._map;if(!T)return;const h=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(T.transform.pitch*(Math.PI/180)),.5)}) rotateX(${T.transform.pitch}deg) rotateZ(${T.transform.angle*(180/Math.PI)}deg)`:`rotate(${T.transform.angle*(180/Math.PI)}deg)`;T._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=h)})}onAdd(T){return this._map=T,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),T.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&T.on("pitch",this._rotateCompassArrow),T.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new epe(T,this._compass,this.options.visualizePitch)),this._container}onRemove(){const T=this._map;T&&(this._container.remove(),this.options.showZoom&&T.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&T.off("pitch",this._rotateCompassArrow),T.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(T,h){const y=j("button",T,this._container);return y.type="button",y.addEventListener("click",h),y}_setButtonTitle(T,h){if(!this._map)return;const y=this._map._getUIString(`NavigationControl.${h}`);T.setAttribute("aria-label",y),T.firstElementChild&&T.firstElementChild.setAttribute("title",y)}},GeolocateControl:class extends i.E{constructor(T={}){super();const h=navigator.geolocation;this.options=Object.assign({geolocation:h},tpe,T),i.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=M3(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(T){return this._map=T,this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(T){const h=(y=!!this.options.geolocation)=>{this._supportsGeolocation=y,T(y)};this._supportsGeolocation!==void 0?T(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(y=>h(y.state!=="denied")).catch(()=>h()):h()}_isOutOfMapMaxBounds(T){const h=this._map.getMaxBounds(),y=T.coords;return!!h&&(y.longitudeh.getEast()||y.latitudeh.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(T){if(this._map){if(this._isOutOfMapMaxBounds(T))return this._setErrorState(),this.fire(new i.z("outofmaxbounds",T)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=T,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(T),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(T),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.z("geolocate",Object.assign({coords:T.coords,timestamp:T.timestamp},T.toJSON?{toJSON:T.toJSON.bind(T)}:{}))),this._finish()}}_updateCamera(T){const h=new i.aT(T.coords.longitude,T.coords.latitude),y=T.coords.accuracy,A=this._map.getBearing(),D=Object.assign({bearing:A},this.options.fitBoundsOptions);this._map.fitBounds(h.toBounds(y),D,{geolocateSource:!0})}_updateMarker(T){if(T){const h=new i.aT(T.coords.longitude,T.coords.latitude);this._accuracyCircleMarker.setLngLat(h).addTo(this._map),this._userLocationDotMarker.setLngLat(h).addTo(this._map),this._accuracy=T.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const T=this._map.transform,h=i.cf(1,T._center.lat)*T.worldSize,y=Math.ceil(2*this._accuracy*h);this._circleElement.style.width=`${y}px`,this._circleElement.style.height=`${y}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(T){if(this._map){if(this.options.trackUserLocation)if(T.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(T.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.z("error",T)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(T){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",h=>h.preventDefault()),this._geolocateButton=j("button","mapboxgl-ctrl-geolocate",this._container),j("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",T===!1){i.w("Geolocation support is not available so the GeolocateControl will be disabled.");const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h)}else{const h=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=j("div","mapboxgl-user-location"),this._dotElement.appendChild(j("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(j("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new $3({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=j("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new $3({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",h=>{h.geolocateSource||this._watchState!=="ACTIVE_LOCK"||h.originalEvent&&h.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new i.z("trackuserlocationend")))})}}_onDeviceOrientation(T){this._userLocationDotMarker&&(T.webkitCompassHeading?this._heading=T.webkitCompassHeading:T.absolute===!0&&(this._heading=-1*T.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return i.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new i.z("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new i.z("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new i.z("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let T;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(T={maximumAge:6e5,timeout:0},this._noTimeout=!0):(T=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,T),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const T=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};typeof DeviceMotionEvent<"u"&&typeof DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(h=>{h==="granted"&&T()}).catch(console.error):T()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:w2,ScaleControl:class{constructor(T={}){this.options=Object.assign({},gb,T),i.aY(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const T=this.options.maxWidth||100,h=this._map,y=h._containerHeight/2,A=h._containerWidth/2-T/2,D=h.unproject([A,y]),F=h.unproject([A+T,y]),z=D.distanceTo(F);if(this.options.unit==="imperial"){const W=3.2808*z;W>5280?this._setScale(T,W/5280,"mile"):this._setScale(T,W,"foot")}else this.options.unit==="nautical"?this._setScale(T,z/1852,"nautical-mile"):z>=1e3?this._setScale(T,z/1e3,"kilometer"):this._setScale(T,z,"meter")}_setScale(T,h,y){this._map._requestDomTask(()=>{const A=function(F){const z=Math.pow(10,`${Math.floor(F)}`.length-1);let W=F/z;return W=W>=10?10:W>=5?5:W>=3?3:W>=2?2:W>=1?1:function(J){const ne=Math.pow(10,Math.ceil(-Math.log(J)/Math.LN10));return Math.round(J*ne)/ne}(W),z*W}(h),D=A/h;this._container.innerHTML=y!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:y}).format(A):`${A} ${z6[y]}`,this._container.style.width=T*D+"px"})}onAdd(T){return this._map=T,this._language=T.getLanguage(),this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-scale",T.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(T){this._language=T,this._update()}setUnit(T){this.options.unit=T,this._update()}},FullscreenControl:class{constructor(T={}){this._fullscreen=!1,T&&T.container&&(T.container instanceof HTMLElement?this._container=T.container:i.w("Full screen control 'container' must be a DOM element.")),i.aY(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(T){return this._map=T,this._container||(this._container=this._map.getContainer()),this._controlContainer=j("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const T=this._fullscreenButton=j("button","mapboxgl-ctrl-fullscreen",this._controlContainer);j("span","mapboxgl-ctrl-icon",T).setAttribute("aria-hidden","true"),T.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const T=this._getTitle();this._fullscreenButton.setAttribute("aria-label",T),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",T)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},IndoorControl:xb,Popup:class extends i.E{constructor(T){super(),this.options=Object.assign(Object.create(rp),T),this._altitude=this.options.altitude,i.aY(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(T&&T.className?T.className.trim().split(/\s+/):[])}addTo(T){return this._map&&this.remove(),this._map=T,this.options.closeOnClick&&T.on("preclick",this._onClose),this.options.closeOnMove&&T.on("move",this._onClose),T.on("remove",this.remove),this._update(),T._addPopup(this),this._focusFirstElement(),this._trackPointer?(T.on("mousemove",this._onMouseEvent),T.on("mouseup",this._onMouseEvent),T._canvasContainer.classList.add("mapboxgl-track-pointer")):T.on("move",this._update),this.fire(new i.z("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const T=this._map;return T&&(T.off("move",this._update),T.off("move",this._onClose),T.off("preclick",this._onClose),T.off("click",this._onClose),T.off("remove",this.remove),T.off("mousemove",this._onMouseEvent),T.off("mouseup",this._onMouseEvent),T.off("drag",this._onMouseEvent),T._canvasContainer&&T._canvasContainer.classList.remove("mapboxgl-track-pointer"),T._removePopup(this),this._map=void 0),this.fire(new i.z("close")),this}getLngLat(){return this._lngLat}setLngLat(T){this._lngLat=i.aT.convert(T),this._pos=null,this._trackPointer=!1,this._update();const h=this._map;return h&&(h.on("move",this._update),h.off("mousemove",this._onMouseEvent),h._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(T){return this._altitude=T,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const T=this._map;return T&&(T.off("move",this._update),T.on("mousemove",this._onMouseEvent),T.on("drag",this._onMouseEvent),T._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(T){return this.setDOMContent(document.createTextNode(T))}setHTML(T){const h=document.createDocumentFragment(),y=document.createElement("body");let A;for(y.innerHTML=T;A=y.firstChild,A;)h.appendChild(A);return this.setDOMContent(h)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(T){return this.options.maxWidth=T,this._update(),this}setDOMContent(T){let h=this._content;if(h)for(;h.hasChildNodes();)h.firstChild&&h.removeChild(h.firstChild);else h=this._content=j("div","mapboxgl-popup-content",this._container||void 0);if(h.appendChild(T),this.options.closeButton){const y=this._closeButton=j("button","mapboxgl-popup-close-button",h);y.type="button",y.setAttribute("aria-label","Close popup"),y.innerHTML='',y.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(T){return this._classList.add(T),this._updateClassList(),this}removeClassName(T){return this._classList.delete(T),this._updateClassList(),this}setOffset(T){return this.options.offset=T,this._update(),this}toggleClassName(T){let h;return this._classList.delete(T)?h=!1:(this._classList.add(T),h=!0),this._updateClassList(),h}_onMouseEvent(T){this._update(T.point)}_getAnchor(T){if(this.options.anchor)return this.options.anchor;const h=this._map,y=this._container,A=this._pos;if(!h||!y||!A)return"bottom";const D=y.offsetWidth,F=y.offsetHeight,z=A.xh.transform.width-D/2;if(A.y+Th.transform.height-F){if(z)return"bottom-left";if(W)return"bottom-right"}return z?"left":W?"right":"bottom"}_updateClassList(){const T=this._container;if(!T)return;const h=[...this._classList];h.push("mapboxgl-popup"),this._anchor&&h.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&h.push("mapboxgl-popup-track-pointer"),T.className=h.join(" ")}_update(T){const h=this._map,y=this._content;if(!h||!this._lngLat&&!this._trackPointer||!y)return;let A=this._container;if(A||(A=this._container=j("div","mapboxgl-popup",h.getContainer()),this._tip=j("div","mapboxgl-popup-tip",A),A.appendChild(y)),this.options.maxWidth&&A.style.maxWidth!==this.options.maxWidth&&(A.style.maxWidth=this.options.maxWidth),h.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=F6(this._lngLat,this._pos,h.transform)),!this._trackPointer||T){const D=this._pos=this._trackPointer&&T instanceof i.P?T:h.project(this._lngLat,this._altitude),F=pv(this.options.offset),z=this._anchor=this._getAnchor(F.y),W=pv(this.options.offset,z),J=D.add(W).round();h._requestDomTask(()=>{this._container&&z&&(this._container.style.transform=`${Ud[z]} translate(${J.x}px,${J.y}px)`)})}if(!this._marker&&h._showingGlobe()){const D=i.f5(h.transform,this._lngLat)?0:1;this._setOpacity(D)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const T=this._container.querySelector(np);T&&T.focus()}_onClose(){this.remove()}_setOpacity(T){this._container&&(this._container.style.opacity=`${T}`),this._content&&(this._content.style.pointerEvents=T?"auto":"none")}},Marker:$3,Style:tp,LngLat:i.aT,LngLatBounds:i.aI,Point:i.P,MercatorCoordinate:i.ae,FreeCameraOptions:Ru,Evented:i.E,config:i.e,prewarm:i.f9,clearPrewarmedResources:i.f8,get accessToken(){return i.e.ACCESS_TOKEN},set accessToken(T){i.e.ACCESS_TOKEN=T},get baseApiUrl(){return i.e.API_URL},set baseApiUrl(T){i.e.API_URL=T},get workerCount(){return i.fi.workerCount},set workerCount(T){i.fi.workerCount=T},get maxParallelImageRequests(){return i.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(T){i.e.MAX_PARALLEL_IMAGE_REQUESTS=T},clearStorage(T){i.fh(T)},get workerUrl(){return i.fg.workerUrl},set workerUrl(T){i.fg.workerUrl=T},get workerClass(){return i.fg.workerClass},set workerClass(T){i.fg.workerClass=T},get workerParams(){return i.fg.workerParams},set workerParams(T){i.fg.workerParams=T},get dracoUrl(){return i.ff()},set dracoUrl(T){i.fe(T)},get meshoptUrl(){return i.fd()},set meshoptUrl(T){i.fc(T)},setNow:i.o.setNow,restoreNow:i.o.restoreNow}});var l=a;return l})})(pWe);var yNt=pWe.exports;const Ao=Po(yNt);function ys({className:t,...s}){return e.jsx("div",{className:It("animate-pulse rounded-md bg-muted",t),...s})}const t6e={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},s6e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function vNt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function bNt({listings:t,isLoading:s}){const r=fr(),n=N.useRef(null),a=N.useRef(null),o=N.useRef([]),[l,i]=N.useState(""),[c,u]=N.useState(!0);return N.useEffect(()=>{(async()=>{u(!0);try{const{data:g}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();g!=null&&g.value&&i(g.value)}catch(g){console.error("Error fetching mapbox token:",g)}u(!1)})()},[]),N.useEffect(()=>{if(!n.current||!l||a.current)return;Ao.accessToken=l;const f=t.filter(_=>_.latitude!=null&&_.longitude!=null);let g=[-98.5795,39.8283],b=4;if(f.length>0){const _=f.reduce((w,k)=>w+k.longitude,0)/f.length,j=f.reduce((w,k)=>w+k.latitude,0)/f.length;g=[_,j],b=f.length===1?12:10}return a.current=new Ao.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:b,center:g}),a.current.addControl(new Ao.NavigationControl,"top-right"),()=>{var _;(_=a.current)==null||_.remove(),a.current=null}},[l]),N.useEffect(()=>{if(!a.current||!l)return;o.current.forEach(g=>g.remove()),o.current=[];const f=t.filter(g=>g.latitude!=null&&g.longitude!=null);if(f.forEach(g=>{var L,I,O;const b=t6e[g.status]||"#10B981",_=((L=g.photos)==null?void 0:L.find(q=>q.is_primary))||((I=g.photos)==null?void 0:I[0]),w=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${g.slug||g.id}`:`/public/listing/${g.slug||g.id}`,k=document.createElement("div");k.className="cursor-pointer",k.innerHTML=`
`;const S=new Ao.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${_!=null&&_.photo_url?``:""}
${vNt(g.price)}
${g.property_address||""}
${g.city}, ${g.state}
${s6e[g.status]||g.status} ${g.bedrooms?`${g.bedrooms} bed`:""} ${g.bathrooms?`${g.bathrooms} bath`:""}
${(O=g.agent)!=null&&O.name?`
Listed by ${g.agent.name}
`:""}
Click to view details →
`),M=new Ao.Marker(k).setLngLat([g.longitude,g.latitude]).setPopup(S).addTo(a.current);o.current.push(M)}),f.length>1){const g=new Ao.LngLatBounds;f.forEach(b=>g.extend([b.longitude,b.latitude])),a.current.fitBounds(g,{padding:60,maxZoom:13})}else f.length===1&&a.current.flyTo({center:[f[0].longitude,f[0].latitude],zoom:12})},[t,l]),N.useEffect(()=>(window.__navigateToPublicListing__=f=>{r(f)},()=>{delete window.__navigateToPublicListing__}),[r]),c||s?e.jsx(ys,{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(t6e).map(([f,g])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:g}}),e.jsx("span",{className:"text-xs text-gray-600",children:s6e[f]})]},f))}),e.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function X8(t,[s,r]){return Math.min(r,Math.max(s,t))}function EO(t){const s=N.useRef({value:t,previous:t});return N.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var _Nt=[" ","Enter","ArrowUp","ArrowDown"],wNt=[" ","Enter"],BS="Select",[Vde,Hde,jNt]=fO(BS),[ZA]=ad(BS,[jNt,O0]),Wde=O0(),[NNt,Aw]=ZA(BS),[kNt,SNt]=ZA(BS),xWe=t=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:o,value:l,defaultValue:i,onValueChange:c,dir:u,name:p,autoComplete:f,disabled:g,required:b,form:_}=t,j=Wde(s),[w,k]=N.useState(null),[S,M]=N.useState(null),[L,I]=N.useState(!1),O=Mw(u),[q,U]=ah({prop:n,defaultProp:a??!1,onChange:o,caller:BS}),[B,V]=ah({prop:l,defaultProp:i,onChange:c,caller:BS}),Z=N.useRef(null),X=w?_||!!w.closest("form"):!0,[ee,Q]=N.useState(new Set),ie=Array.from(ee).map(re=>re.props.value).join(";");return e.jsx(vO,{...j,children:e.jsxs(NNt,{required:b,scope:s,trigger:w,onTriggerChange:k,valueNode:S,onValueNodeChange:M,valueNodeHasChildren:L,onValueNodeHasChildrenChange:I,contentId:Tu(),value:B,onValueChange:V,open:q,onOpenChange:U,dir:O,triggerPointerDownPosRef:Z,disabled:g,children:[e.jsx(Vde.Provider,{scope:s,children:e.jsx(kNt,{scope:t.__scopeSelect,onNativeOptionAdd:N.useCallback(re=>{Q(oe=>new Set(oe).add(re))},[]),onNativeOptionRemove:N.useCallback(re=>{Q(oe=>{const ce=new Set(oe);return ce.delete(re),ce})},[]),children:r})}),X?e.jsxs(BWe,{"aria-hidden":!0,required:b,tabIndex:-1,name:p,autoComplete:f,value:B,onChange:re=>V(re.target.value),disabled:g,form:_,children:[B===void 0?e.jsx("option",{value:""}):null,Array.from(ee)]},ie):null]})})};xWe.displayName=BS;var gWe="SelectTrigger",yWe=N.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=Wde(r),l=Aw(gWe,r),i=l.disabled||n,c=qa(s,l.onTriggerChange),u=Hde(r),p=N.useRef("touch"),[f,g,b]=qWe(j=>{const w=u().filter(M=>!M.disabled),k=w.find(M=>M.value===l.value),S=UWe(w,j,k);S!==void 0&&l.onValueChange(S.value)}),_=j=>{i||(l.onOpenChange(!0),b()),j&&(l.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})};return e.jsx($A,{asChild:!0,...o,children:e.jsx(nn.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":$We(l.value)?"":void 0,...a,ref:c,onClick:Ir(a.onClick,j=>{j.currentTarget.focus(),p.current!=="mouse"&&_(j)}),onPointerDown:Ir(a.onPointerDown,j=>{p.current=j.pointerType;const w=j.target;w.hasPointerCapture(j.pointerId)&&w.releasePointerCapture(j.pointerId),j.button===0&&j.ctrlKey===!1&&j.pointerType==="mouse"&&(_(j),j.preventDefault())}),onKeyDown:Ir(a.onKeyDown,j=>{const w=f.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&g(j.key),!(w&&j.key===" ")&&_Nt.includes(j.key)&&(_(),j.preventDefault())})})})});yWe.displayName=gWe;var vWe="SelectValue",bWe=N.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:l="",...i}=t,c=Aw(vWe,r),{onValueNodeHasChildrenChange:u}=c,p=o!==void 0,f=qa(s,c.onValueNodeChange);return wd(()=>{u(p)},[u,p]),e.jsx(nn.span,{...i,ref:f,style:{pointerEvents:"none"},children:$We(c.value)?e.jsx(e.Fragment,{children:l}):o})});bWe.displayName=vWe;var CNt="SelectIcon",_We=N.forwardRef((t,s)=>{const{__scopeSelect:r,children:n,...a}=t;return e.jsx(nn.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});_We.displayName=CNt;var MNt="SelectPortal",wWe=t=>e.jsx(RA,{asChild:!0,...t});wWe.displayName=MNt;var $S="SelectContent",jWe=N.forwardRef((t,s)=>{const r=Aw($S,t.__scopeSelect),[n,a]=N.useState();if(wd(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?yp.createPortal(e.jsx(NWe,{scope:t.__scopeSelect,children:e.jsx(Vde.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),o):null}return e.jsx(kWe,{...t,ref:s})});jWe.displayName=$S;var Tg=10,[NWe,Ew]=ZA($S),TNt="SelectContentImpl",ANt=ow("SelectContent.RemoveScroll"),kWe=N.forwardRef((t,s)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:i,sideOffset:c,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:g,collisionPadding:b,sticky:_,hideWhenDetached:j,avoidCollisions:w,...k}=t,S=Aw($S,r),[M,L]=N.useState(null),[I,O]=N.useState(null),q=qa(s,Oe=>L(Oe)),[U,B]=N.useState(null),[V,Z]=N.useState(null),X=Hde(r),[ee,Q]=N.useState(!1),ie=N.useRef(!1);N.useEffect(()=>{if(M)return Ode(M)},[M]),Ide();const re=N.useCallback(Oe=>{const[Te,...ke]=X().map(Ae=>Ae.ref.current),[Be]=ke.slice(-1),nt=document.activeElement;for(const Ae of Oe)if(Ae===nt||(Ae==null||Ae.scrollIntoView({block:"nearest"}),Ae===Te&&I&&(I.scrollTop=0),Ae===Be&&I&&(I.scrollTop=I.scrollHeight),Ae==null||Ae.focus(),document.activeElement!==nt))return},[X,I]),oe=N.useCallback(()=>re([U,M]),[re,U,M]);N.useEffect(()=>{ee&&oe()},[ee,oe]);const{onOpenChange:ce,triggerPointerDownPosRef:xe}=S;N.useEffect(()=>{if(M){let Oe={x:0,y:0};const Te=Be=>{var nt,Ae;Oe={x:Math.abs(Math.round(Be.pageX)-(((nt=xe.current)==null?void 0:nt.x)??0)),y:Math.abs(Math.round(Be.pageY)-(((Ae=xe.current)==null?void 0:Ae.y)??0))}},ke=Be=>{Oe.x<=10&&Oe.y<=10?Be.preventDefault():M.contains(Be.target)||ce(!1),document.removeEventListener("pointermove",Te),xe.current=null};return xe.current!==null&&(document.addEventListener("pointermove",Te),document.addEventListener("pointerup",ke,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Te),document.removeEventListener("pointerup",ke,{capture:!0})}}},[M,ce,xe]),N.useEffect(()=>{const Oe=()=>ce(!1);return window.addEventListener("blur",Oe),window.addEventListener("resize",Oe),()=>{window.removeEventListener("blur",Oe),window.removeEventListener("resize",Oe)}},[ce]);const[ge,ue]=qWe(Oe=>{const Te=X().filter(nt=>!nt.disabled),ke=Te.find(nt=>nt.ref.current===document.activeElement),Be=UWe(Te,Oe,ke);Be&&setTimeout(()=>Be.ref.current.focus())}),pe=N.useCallback((Oe,Te,ke)=>{const Be=!ie.current&&!ke;(S.value!==void 0&&S.value===Te||Be)&&(B(Oe),Be&&(ie.current=!0))},[S.value]),be=N.useCallback(()=>M==null?void 0:M.focus(),[M]),Me=N.useCallback((Oe,Te,ke)=>{const Be=!ie.current&&!ke;(S.value!==void 0&&S.value===Te||Be)&&Z(Oe)},[S.value]),Ne=n==="popper"?Sve:SWe,Pe=Ne===Sve?{side:i,sideOffset:c,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:g,collisionPadding:b,sticky:_,hideWhenDetached:j,avoidCollisions:w}:{};return e.jsx(NWe,{scope:r,content:M,viewport:I,onViewportChange:O,itemRefCallback:pe,selectedItem:U,onItemLeave:be,itemTextRefCallback:Me,focusSelectedItem:oe,selectedItemText:V,position:n,isPositioned:ee,searchRef:ge,children:e.jsx(kO,{as:ANt,allowPinchZoom:!0,children:e.jsx(jO,{asChild:!0,trapped:S.open,onMountAutoFocus:Oe=>{Oe.preventDefault()},onUnmountAutoFocus:Ir(a,Oe=>{var Te;(Te=S.trigger)==null||Te.focus({preventScroll:!0}),Oe.preventDefault()}),children:e.jsx(Nw,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Oe=>Oe.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:e.jsx(Ne,{role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:Oe=>Oe.preventDefault(),...k,...Pe,onPlaced:()=>Q(!0),ref:q,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:Ir(k.onKeyDown,Oe=>{const Te=Oe.ctrlKey||Oe.altKey||Oe.metaKey;if(Oe.key==="Tab"&&Oe.preventDefault(),!Te&&Oe.key.length===1&&ue(Oe.key),["ArrowUp","ArrowDown","Home","End"].includes(Oe.key)){let Be=X().filter(nt=>!nt.disabled).map(nt=>nt.ref.current);if(["ArrowUp","End"].includes(Oe.key)&&(Be=Be.slice().reverse()),["ArrowUp","ArrowDown"].includes(Oe.key)){const nt=Oe.target,Ae=Be.indexOf(nt);Be=Be.slice(Ae+1)}setTimeout(()=>re(Be)),Oe.preventDefault()}})})})})})})});kWe.displayName=TNt;var ENt="SelectItemAlignedPosition",SWe=N.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=Aw($S,r),l=Ew($S,r),[i,c]=N.useState(null),[u,p]=N.useState(null),f=qa(s,q=>p(q)),g=Hde(r),b=N.useRef(!1),_=N.useRef(!0),{viewport:j,selectedItem:w,selectedItemText:k,focusSelectedItem:S}=l,M=N.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&j&&w&&k){const q=o.trigger.getBoundingClientRect(),U=u.getBoundingClientRect(),B=o.valueNode.getBoundingClientRect(),V=k.getBoundingClientRect();if(o.dir!=="rtl"){const nt=V.left-U.left,Ae=B.left-nt,ft=q.left-Ae,fe=q.width+ft,Ve=Math.max(fe,U.width),at=window.innerWidth-Tg,et=X8(Ae,[Tg,Math.max(Tg,at-Ve)]);i.style.minWidth=fe+"px",i.style.left=et+"px"}else{const nt=U.right-V.right,Ae=window.innerWidth-B.right-nt,ft=window.innerWidth-q.right-Ae,fe=q.width+ft,Ve=Math.max(fe,U.width),at=window.innerWidth-Tg,et=X8(Ae,[Tg,Math.max(Tg,at-Ve)]);i.style.minWidth=fe+"px",i.style.right=et+"px"}const Z=g(),X=window.innerHeight-Tg*2,ee=j.scrollHeight,Q=window.getComputedStyle(u),ie=parseInt(Q.borderTopWidth,10),re=parseInt(Q.paddingTop,10),oe=parseInt(Q.borderBottomWidth,10),ce=parseInt(Q.paddingBottom,10),xe=ie+re+ee+ce+oe,ge=Math.min(w.offsetHeight*5,xe),ue=window.getComputedStyle(j),pe=parseInt(ue.paddingTop,10),be=parseInt(ue.paddingBottom,10),Me=q.top+q.height/2-Tg,Ne=X-Me,Pe=w.offsetHeight/2,Oe=w.offsetTop+Pe,Te=ie+re+Oe,ke=xe-Te;if(Te<=Me){const nt=Z.length>0&&w===Z[Z.length-1].ref.current;i.style.bottom="0px";const Ae=u.clientHeight-j.offsetTop-j.offsetHeight,ft=Math.max(Ne,Pe+(nt?be:0)+Ae+oe),fe=Te+ft;i.style.height=fe+"px"}else{const nt=Z.length>0&&w===Z[0].ref.current;i.style.top="0px";const ft=Math.max(Me,ie+j.offsetTop+(nt?pe:0)+Pe)+ke;i.style.height=ft+"px",j.scrollTop=Te-Me+j.offsetTop}i.style.margin=`${Tg}px 0`,i.style.minHeight=ge+"px",i.style.maxHeight=X+"px",n==null||n(),requestAnimationFrame(()=>b.current=!0)}},[g,o.trigger,o.valueNode,i,u,j,w,k,o.dir,n]);wd(()=>M(),[M]);const[L,I]=N.useState();wd(()=>{u&&I(window.getComputedStyle(u).zIndex)},[u]);const O=N.useCallback(q=>{q&&_.current===!0&&(M(),S==null||S(),_.current=!1)},[M,S]);return e.jsx(INt,{scope:r,contentWrapper:i,shouldExpandOnScrollRef:b,onScrollButtonChange:O,children:e.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:L},children:e.jsx(nn.div,{...a,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});SWe.displayName=ENt;var PNt="SelectPopperPosition",Sve=N.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=Tg,...o}=t,l=Wde(r);return e.jsx(bO,{...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)"}})});Sve.displayName=PNt;var[INt,cje]=ZA($S,{}),Cve="SelectViewport",CWe=N.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=Ew(Cve,r),l=cje(Cve,r),i=qa(s,o.onViewportChange),c=N.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),e.jsx(Vde.Slot,{scope:r,children:e.jsx(nn.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Ir(a.onScroll,u=>{const p=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:g}=l;if(g!=null&&g.current&&f){const b=Math.abs(c.current-p.scrollTop);if(b>0){const _=window.innerHeight-Tg*2,j=parseFloat(f.style.minHeight),w=parseFloat(f.style.height),k=Math.max(j,w);if(k<_){const S=k+b,M=Math.min(_,S),L=S-M;f.style.height=M+"px",f.style.bottom==="0px"&&(p.scrollTop=L>0?L:0,f.style.justifyContent="flex-end")}}}c.current=p.scrollTop})})})]})});CWe.displayName=Cve;var MWe="SelectGroup",[LNt,DNt]=ZA(MWe),ONt=N.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Tu();return e.jsx(LNt,{scope:r,id:a,children:e.jsx(nn.div,{role:"group","aria-labelledby":a,...n,ref:s})})});ONt.displayName=MWe;var TWe="SelectLabel",AWe=N.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=DNt(TWe,r);return e.jsx(nn.div,{id:a.id,...n,ref:s})});AWe.displayName=TWe;var _oe="SelectItem",[RNt,EWe]=ZA(_oe),PWe=N.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=Aw(_oe,r),c=Ew(_oe,r),u=i.value===n,[p,f]=N.useState(o??""),[g,b]=N.useState(!1),_=qa(s,S=>{var M;return(M=c.itemRefCallback)==null?void 0:M.call(c,S,n,a)}),j=Tu(),w=N.useRef("touch"),k=()=>{a||(i.onValueChange(n),i.onOpenChange(!1))};if(n==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return e.jsx(RNt,{scope:r,value:n,disabled:a,textId:j,isSelected:u,onItemTextChange:N.useCallback(S=>{f(M=>M||((S==null?void 0:S.textContent)??"").trim())},[]),children:e.jsx(Vde.ItemSlot,{scope:r,value:n,disabled:a,textValue:p,children:e.jsx(nn.div,{role:"option","aria-labelledby":j,"data-highlighted":g?"":void 0,"aria-selected":u&&g,"data-state":u?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:_,onFocus:Ir(l.onFocus,()=>b(!0)),onBlur:Ir(l.onBlur,()=>b(!1)),onClick:Ir(l.onClick,()=>{w.current!=="mouse"&&k()}),onPointerUp:Ir(l.onPointerUp,()=>{w.current==="mouse"&&k()}),onPointerDown:Ir(l.onPointerDown,S=>{w.current=S.pointerType}),onPointerMove:Ir(l.onPointerMove,S=>{var M;w.current=S.pointerType,a?(M=c.onItemLeave)==null||M.call(c):w.current==="mouse"&&S.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ir(l.onPointerLeave,S=>{var M;S.currentTarget===document.activeElement&&((M=c.onItemLeave)==null||M.call(c))}),onKeyDown:Ir(l.onKeyDown,S=>{var L;((L=c.searchRef)==null?void 0:L.current)!==""&&S.key===" "||(wNt.includes(S.key)&&k(),S.key===" "&&S.preventDefault())})})})})});PWe.displayName=_oe;var bI="SelectItemText",IWe=N.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=t,l=Aw(bI,r),i=Ew(bI,r),c=EWe(bI,r),u=SNt(bI,r),[p,f]=N.useState(null),g=qa(s,k=>f(k),c.onItemTextChange,k=>{var S;return(S=i.itemTextRefCallback)==null?void 0:S.call(i,k,c.value,c.disabled)}),b=p==null?void 0:p.textContent,_=N.useMemo(()=>e.jsx("option",{value:c.value,disabled:c.disabled,children:b},c.value),[c.disabled,c.value,b]),{onNativeOptionAdd:j,onNativeOptionRemove:w}=u;return wd(()=>(j(_),()=>w(_)),[j,w,_]),e.jsxs(e.Fragment,{children:[e.jsx(nn.span,{id:c.textId,...o,ref:g}),c.isSelected&&l.valueNode&&!l.valueNodeHasChildren?yp.createPortal(o.children,l.valueNode):null]})});IWe.displayName=bI;var LWe="SelectItemIndicator",DWe=N.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return EWe(LWe,r).isSelected?e.jsx(nn.span,{"aria-hidden":!0,...n,ref:s}):null});DWe.displayName=LWe;var Mve="SelectScrollUpButton",OWe=N.forwardRef((t,s)=>{const r=Ew(Mve,t.__scopeSelect),n=cje(Mve,t.__scopeSelect),[a,o]=N.useState(!1),l=qa(s,n.onScrollButtonChange);return wd(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=c.scrollTop>0;o(u)};const c=r.viewport;return i(),c.addEventListener("scroll",i),()=>c.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(FWe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:c}=r;i&&c&&(i.scrollTop=i.scrollTop-c.offsetHeight)}}):null});OWe.displayName=Mve;var Tve="SelectScrollDownButton",RWe=N.forwardRef((t,s)=>{const r=Ew(Tve,t.__scopeSelect),n=cje(Tve,t.__scopeSelect),[a,o]=N.useState(!1),l=qa(s,n.onScrollButtonChange);return wd(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=c.scrollHeight-c.clientHeight,p=Math.ceil(c.scrollTop)c.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(FWe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:c}=r;i&&c&&(i.scrollTop=i.scrollTop+c.offsetHeight)}}):null});RWe.displayName=Tve;var FWe=N.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=Ew("SelectScrollButton",r),l=N.useRef(null),i=Hde(r),c=N.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return N.useEffect(()=>()=>c(),[c]),wd(()=>{var p;const u=i().find(f=>f.ref.current===document.activeElement);(p=u==null?void 0:u.ref.current)==null||p.scrollIntoView({block:"nearest"})},[i]),e.jsx(nn.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Ir(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:Ir(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:Ir(a.onPointerLeave,()=>{c()})})}),FNt="SelectSeparator",zWe=N.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(nn.div,{"aria-hidden":!0,...n,ref:s})});zWe.displayName=FNt;var Ave="SelectArrow",zNt=N.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Wde(r),o=Aw(Ave,r),l=Ew(Ave,r);return o.open&&l.position==="popper"?e.jsx(_O,{...a,...n,ref:s}):null});zNt.displayName=Ave;var BNt="SelectBubbleInput",BWe=N.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=N.useRef(null),o=qa(n,a),l=EO(s);return N.useEffect(()=>{const i=a.current;if(!i)return;const c=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(c,"value").set;if(l!==s&&p){const f=new Event("change",{bubbles:!0});p.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(nn.select,{...r,style:{...R$e,...r.style},ref:o,defaultValue:s})});BWe.displayName=BNt;function $We(t){return t===""||t===void 0}function qWe(t){const s=yd(t),r=N.useRef(""),n=N.useRef(0),a=N.useCallback(l=>{const i=r.current+l;s(i),function c(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>c(""),1e3))}(i)},[s]),o=N.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return N.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,o]}function UWe(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=$Nt(t,Math.max(o,0));a.length===1&&(l=l.filter(u=>u!==r));const c=l.find(u=>u.textValue.toLowerCase().startsWith(a.toLowerCase()));return c!==r?c:void 0}function $Nt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var qNt=xWe,VWe=yWe,UNt=bWe,VNt=_We,HNt=wWe,HWe=jWe,WNt=CWe,WWe=AWe,GWe=PWe,GNt=IWe,KNt=DWe,KWe=OWe,ZWe=RWe,YWe=zWe;const Zs=qNt,Xs=UNt,Ws=N.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(VWe,{ref:n,className:It("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...r,children:[s,e.jsx(VNt,{asChild:!0,children:e.jsx(Eo,{className:"h-4 w-4 opacity-50"})})]}));Ws.displayName=VWe.displayName;const XWe=N.forwardRef(({className:t,...s},r)=>e.jsx(KWe,{ref:r,className:It("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(pf,{className:"h-4 w-4"})}));XWe.displayName=KWe.displayName;const QWe=N.forwardRef(({className:t,...s},r)=>e.jsx(ZWe,{ref:r,className:It("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Eo,{className:"h-4 w-4"})}));QWe.displayName=ZWe.displayName;const Gs=N.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx(HNt,{children:e.jsxs(HWe,{ref:a,className:It("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,...n,children:[e.jsx(XWe,{}),e.jsx(WNt,{className:It("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(QWe,{})]})}));Gs.displayName=HWe.displayName;const ZNt=N.forwardRef(({className:t,...s},r)=>e.jsx(WWe,{ref:r,className:It("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));ZNt.displayName=WWe.displayName;const Mt=N.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(GWe,{ref:n,className:It("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(KNt,{children:e.jsx(va,{className:"h-4 w-4"})})}),e.jsx(GNt,{children:s})]}));Mt.displayName=GWe.displayName;const YNt=N.forwardRef(({className:t,...s},r)=>e.jsx(YWe,{ref:r,className:It("-mx-1 my-1 h-px bg-muted",t),...s}));YNt.displayName=YWe.displayName;const XNt=t=>mt({queryKey:["public-listings",t],queryFn:async()=>{let s=H.from("listings").select(` id, slug, agent_id, property_address, city, state, neighborhood, price, property_type, status, bedrooms, bathrooms, square_footage, lot_size, year_built, has_hoa, description, latitude, longitude, created_at, updated_at, photos:listing_photos(id, photo_url, is_primary), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("is_public",!0).order("created_at",{ascending:!1});t!=null&&t.status&&(s=s.eq("status",t.status)),t!=null&&t.propertyType&&(s=s.eq("property_type",t.propertyType)),t!=null&&t.city&&(s=s.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(s=s.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(s=s.lte("price",t.maxPrice));const{data:r,error:n}=await s;if(n)throw n;return r}}),JWe=t=>mt({queryKey:["public-listing",t],queryFn:async()=>{const s=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t);let r=H.from("listings").select(` id, slug, agent_id, property_address, city, state, neighborhood, price, property_type, status, bedrooms, bathrooms, square_footage, lot_size, year_built, has_hoa, description, agent_notes, agent_notes_public, mls_link, video_link, video_id, latitude, longitude, created_at, updated_at, photos:listing_photos(id, photo_url, is_primary, sort_order), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage:brokerages(name)), video:agent_videos!listings_video_id_fkey(id, playback_url, thumbnail_url, title, duration_seconds, bunny_video_id) `).eq("is_approved",!0).eq("is_public",!0);s?r=r.eq("id",t):r=r.eq("slug",t);const{data:n,error:a}=await r.single();if(a)throw a;return n},enabled:!!t}),eGe=()=>Dt({mutationFn:async({listingId:t,agentId:s,firstName:r,lastName:n,email:a,phone:o,shareToken:l})=>{let i=null,c=null;if(l){const{data:g}=await H.from("listing_shares").select("id, sharing_agent_id").eq("share_token",l).eq("listing_id",t).maybeSingle();g&&(i=g.id,c=g.sharing_agent_id)}const{data:u,error:p}=await H.from("listing_leads").insert({listing_id:t,agent_id:c||s,first_name:r,last_name:n,email:a,phone:o,share_id:i,referred_by_agent_id:c}).select().single();if(p)throw p;const{error:f}=await H.functions.invoke("process-listing-lead",{body:{leadId:u.id}});return f&&console.error("Error processing lead:",f),u}}),QNt=()=>Dt({mutationFn:async t=>{const{error:s}=await H.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),JNt={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},r6e={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},ekt={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function tGe(){const[t,s]=N.useState(""),[r,n]=N.useState(!1),[a,o]=N.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=XNt({city:t||void 0,status:a.status||void 0,propertyType:a.propertyType||void 0,minPrice:a.minPrice?Number(a.minPrice):void 0,maxPrice:a.maxPrice?Number(a.maxPrice):void 0}),c=f=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(f),u=()=>{o({status:"",propertyType:"",minPrice:"",maxPrice:""}),s("")},p=t||a.status||a.propertyType||a.minPrice||a.maxPrice;return e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{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(Pi,{to:"/public/listings",className:"flex items-center",children:e.jsx("img",{src:mWe,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(${gNt})`},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(cn,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx(ze,{placeholder:"Enter an address, neighborhood, city, or ZIP code",value:t,onChange:f=>s(f.target.value),className:"pl-12 h-14 md:h-16 text-base md:text-lg border-0 focus-visible:ring-0 rounded-none bg-white"})]}),e.jsx(K,{className:"h-14 md:h-16 px-6 md:px-8 rounded-none bg-blue-600 hover:bg-blue-700",children:e.jsx(cn,{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(H_,{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(Zs,{value:a.status||"all",onValueChange:f=>o({...a,status:f==="all"?"":f}),children:[e.jsx(Ws,{className:"bg-white",children:e.jsx(Xs,{placeholder:"Any status"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"Any status"}),Object.entries(r6e).map(([f,g])=>e.jsx(Mt,{value:f,children:g},f))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Property Type"}),e.jsxs(Zs,{value:a.propertyType||"all",onValueChange:f=>o({...a,propertyType:f==="all"?"":f}),children:[e.jsx(Ws,{className:"bg-white",children:e.jsx(Xs,{placeholder:"Any type"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"Any type"}),Object.entries(ekt).map(([f,g])=>e.jsx(Mt,{value:f,children:g},f))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Min Price"}),e.jsx(ze,{type:"number",placeholder:"No min",value:a.minPrice,onChange:f=>o({...a,minPrice:f.target.value}),className:"bg-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Max Price"}),e.jsx(ze,{type:"number",placeholder:"No max",value:a.maxPrice,onChange:f=>o({...a,maxPrice:f.target.value}),className:"bg-white"})]})]}),p&&e.jsx("div",{className:"flex justify-end mt-4",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:u,className:"gap-1 text-gray-500",children:[e.jsx(Rr,{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(bNt,{listings:l,isLoading:i})]})}),e.jsx("section",{className:"py-8",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4",children:i?e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5",children:[...Array(8)].map((f,g)=>e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm",children:[e.jsx(ys,{className:"aspect-[4/3]"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(ys,{className:"h-7 w-28"}),e.jsx(ys,{className:"h-4 w-full"}),e.jsx(ys,{className:"h-4 w-3/4"})]})]},g))}):l&&l.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("h2",{className:"text-xl font-semibold text-gray-900",children:[l.length," ",l.length===1?"Home":"Homes"," Available"]})}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5",children:l.map(f=>{var j,w,k;const g=((j=f.photos)==null?void 0:j.find(S=>S.is_primary))||((w=f.photos)==null?void 0:w[0]),_=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${f.slug||f.id}`:`/public/listing/${f.slug||f.id}`;return e.jsx(Pi,{to:_,children:e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm hover:shadow-lg transition-shadow cursor-pointer group border border-gray-100",children:[e.jsxs("div",{className:"aspect-[4/3] relative overflow-hidden bg-gray-100",children:[g?e.jsx("img",{src:g.photo_url,alt:f.property_address||f.city,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(bn,{className:"h-12 w-12 text-gray-300"})}),e.jsx(tt,{className:`absolute top-2 left-2 ${JNt[f.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:r6e[f.status]}),e.jsx("button",{className:"absolute top-2 right-2 p-2 rounded-full bg-white/80 hover:bg-white transition-colors",onClick:S=>S.preventDefault(),children:e.jsx(ni,{className:"h-5 w-5 text-gray-600"})})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("p",{className:"text-xl font-bold text-gray-900 mb-1",children:c(f.price)}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-700 mb-2",children:[f.bedrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.bedrooms}),e.jsx("span",{className:"text-gray-500",children:"bds"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),f.bathrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.bathrooms}),e.jsx("span",{className:"text-gray-500",children:"ba"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),f.square_footage&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.square_footage.toLocaleString()}),e.jsx("span",{className:"text-gray-500",children:"sqft"})]})]}),f.property_address&&e.jsx("p",{className:"text-sm text-gray-700 truncate",children:f.property_address}),e.jsxs("p",{className:"text-sm text-gray-500 truncate",children:[f.city,", ",f.state]}),f.agent&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100",children:[e.jsx("p",{className:"text-xs text-gray-500 truncate",children:f.agent.name}),((k=f.agent.brokerage)==null?void 0:k.name)&&e.jsx("p",{className:"text-xs text-gray-400 truncate",children:f.agent.brokerage.name})]})]})]})},f.id)})})]}):e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-4 rounded-full bg-gray-100 flex items-center justify-center",children:e.jsx(bn,{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:lje,alt:"LevelUp",className:"h-6"})}),e.jsxs("p",{className:"text-gray-400 text-sm",children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"text-gray-400 hover:text-white text-sm transition-colors",children:"relevelup.com"})]})})})]})]})}const Ee=N.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Ee.displayName="Card";const Pt=N.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("flex flex-col space-y-1.5 p-6",t),...s}));Pt.displayName="CardHeader";const Rt=N.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:It("text-2xl font-semibold leading-none tracking-tight",t),...s}));Rt.displayName="CardTitle";const gr=N.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:It("text-sm text-muted-foreground",t),...s}));gr.displayName="CardDescription";const De=N.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("p-6 pt-0",t),...s}));De.displayName="CardContent";const $L=N.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("flex items-center p-6 pt-0",t),...s}));$L.displayName="CardFooter";var tkt="Label",sGe=N.forwardRef((t,s)=>e.jsx(nn.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())}}));sGe.displayName=tkt;var rGe=sGe;const skt=mC("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ve=N.forwardRef(({className:t,...s},r)=>e.jsx(rGe,{ref:r,className:It(skt(),t),...s}));ve.displayName=rGe.displayName;const woe="/assets/levelup-logo-color-D3mY9gCJ.png";function rkt(){const t=zd(),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(tGe,{}):n.startsWith("public/")?null:e.jsx(nkt,{slug:n})}function nkt({slug:t}){return e.jsx(okt,{slug:t})}const akt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},ikt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},n6e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function okt({slug:t}){var B,V;const{data:s,isLoading:r}=JWe(t),n=eGe(),[a,o]=N.useState(""),[l,i]=N.useState(""),[c,u]=N.useState(""),[p,f]=N.useState(""),[g,b]=N.useState(!1),[_,j]=N.useState(!1),[w,k]=N.useState(null),S=Z=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Z),M=async Z=>{if(Z.preventDefault(),!(!a.trim()||!c.trim()||!s)){b(!0);try{await n.mutateAsync({listingId:s.id,agentId:s.agent_id,firstName:a.trim(),lastName:l.trim(),email:c.trim(),phone:p.trim()}),j(!0),me.success("Thanks! The agent will be in touch soon.")}catch(X){console.error("Lead submission error:",X),me.error(`Failed to submit: ${X.message||"Please try again"}`)}finally{b(!1)}}},L=(s==null?void 0:s.photos)||[],I=L.find(Z=>Z.is_primary)||L[0],O=()=>{w!==null&&k(w===0?L.length-1:w-1)},q=()=>{w!==null&&k(w===L.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(ys,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(ys,{className:"h-10 w-48 mb-6"}),e.jsx(ys,{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(ys,{className:"h-12 w-48"}),e.jsx(ys,{className:"h-6 w-full"}),e.jsx(ys,{className:"h-6 w-3/4"})]}),e.jsx(ys,{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:woe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(bn,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing may no longer be available."}),e.jsx(K,{asChild:!0,children:e.jsx("a",{href:"/",children:"Browse All Listings"})})]})]});const U=s.property_address?`${s.property_address} - ${s.city}, ${s.state}`:`${s.city}, ${s.state} Home for Sale`;return e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsxs("title",{children:[U," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${S(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft":""} ${n6e[s.property_type]} in ${s.city}, ${s.state}. ${((B=s.description)==null?void 0:B.slice(0,150))||""}`}),e.jsx("meta",{property:"og:title",content:U}),e.jsx("meta",{property:"og:description",content:`${S(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA in ${s.city}, ${s.state}`}),e.jsx("meta",{property:"og:type",content:"website"}),I&&e.jsx("meta",{property:"og:image",content:I.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:woe,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(Ja,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),L.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>k(0),children:e.jsx("img",{src:I==null?void 0:I.photo_url,alt:"Primary",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:L.slice(1,5).map((Z,X)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>k(X+1),children:[e.jsx("img",{src:Z.photo_url,alt:`Photo ${X+2}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),X===3&&L.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",L.length-5," more"]})]},Z.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx(tt,{className:`${akt[s.status]} text-white border-0`,children:ikt[s.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:S(s.price)}),s.property_address&&e.jsx("p",{className:"text-xl font-medium",children:s.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ma,{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(Im,{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(Ju,{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(y0,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.square_footage.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),s.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.year_built}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(tt,{variant:"secondary",children:[e.jsx(ka,{className:"h-3 w-3 mr-1"}),n6e[s.property_type]]}),s.lot_size&&e.jsxs(tt,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&e.jsx(tt,{variant:"secondary",children:"HOA"})]}),s.description&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"About This Property"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})]}),s.agent_notes&&s.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.agent_notes})]}),s.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:s.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[s.agent&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(to,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(De,{children:[e.jsx("p",{className:"font-semibold text-lg",children:s.agent.name}),((V=s.agent.brokerage)==null?void 0:V.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.agent.brokerage.name})]})]}),e.jsxs(Ee,{className:"border-primary",children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(De,{children:_?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:e.jsx(cr,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The listing agent will contact you soon."})]}):e.jsxs("form",{onSubmit:M,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"firstName",children:"First Name *"}),e.jsx(ze,{id:"firstName",type:"text",placeholder:"John",value:a,onChange:Z=>o(Z.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lastName",children:"Last Name"}),e.jsx(ze,{id:"lastName",type:"text",placeholder:"Doe",value:l,onChange:Z=>i(Z.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email *"}),e.jsx(ze,{id:"email",type:"email",placeholder:"you@example.com",value:c,onChange:Z=>u(Z.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:p,onChange:Z=>f(Z.target.value)})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:g,children:g?"Submitting...":"Get More Info"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})})]})]})]})]}),e.jsx(fs,{open:w!==null,onOpenChange:()=>k(null),children:e.jsxs(ps,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(_s,{className:"sr-only",children:e.jsx(vs,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>k(null),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Rr,{className:"h-5 w-5"})}),w!==null&&L[w]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:L[w].photo_url,alt:`Photo ${w+1}`,className:"w-full max-h-[80vh] object-contain"}),L.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:O,className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(cl,{className:"h-6 w-6"})}),e.jsx("button",{onClick:q,className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(da,{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," / ",L.length]})]})]})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function Gde({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 nGe=t=>mt({queryKey:["agent-card-public",t],queryFn:async()=>{if(!t)throw new Error("No slug provided");const{data:s,error:r}=await H.from("agent_cards").select("*").eq("slug",t).eq("is_published",!0).single();if(r)throw r;const{data:n}=await H.from("profiles").select("name, email, phone, brokerage_id").eq("id",s.user_id).single();let a=null;if(n!=null&&n.brokerage_id){const{data:i}=await H.from("brokerages").select("name").eq("id",n.brokerage_id).single();a=(i==null?void 0:i.name)||null}let o=null;try{const{data:i}=await H.from("profiles").select("avatar_url").eq("id",s.user_id).single();if(i!=null&&i.avatar_url)o=i.avatar_url;else{const{data:c}=await H.storage.from("avatars").list(`${s.user_id}`);if(c&&c.length>0){const{data:u}=H.storage.from("avatars").getPublicUrl(`${s.user_id}/${c[0].name}`);o=`${u.publicUrl}?t=${Date.now()}`}}}catch{}const l={...n||{name:null,email:null,phone:null,brokerage_id:null},email:s.display_email||(n==null?void 0:n.email)||null};return{...s,social_links:s.social_links||[],profile:l,brokerage_name:s.brokerage_display_name||a,avatar_url:o}},enabled:!!t}),lkt=()=>mt({queryKey:["agent-cards-admin"],queryFn:async()=>{const{data:t,error:s}=await H.from("agent_cards").select("*").order("created_at",{ascending:!1});if(s)throw s;return t}}),ckt=t=>mt({queryKey:["agent-card",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("agent_cards").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),aGe=()=>{const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("agent_cards").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-cards-admin"]}),t.invalidateQueries({queryKey:["agent-card"]}),me.success("Agent card created")},onError:s=>me.error(s.message)})},iGe=()=>{const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("agent_cards").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["agent-cards-admin"]}),t.invalidateQueries({queryKey:["agent-card"]}),me.success("Agent card updated")},onError:s=>me.error(s.message)})},fo=async(t,s,r,n)=>{const a=new URLSearchParams(window.location.search);await H.from("agent_card_interactions").insert({card_id:t,interaction_type:s,interaction_detail:r||null,referrer:document.referrer||null,user_agent:navigator.userAgent||null,utm_source:a.get("utm_source")||null,utm_medium:a.get("utm_medium")||null,utm_campaign:a.get("utm_campaign")||null,metadata:{}})},dkt=async(t,s)=>{const{error:r}=await H.from("agent_card_leads").insert({card_id:t,...s});if(r)throw r},oGe=t=>mt({queryKey:["agent-card-analytics",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("agent_card_interactions").select("interaction_type, interaction_detail, created_at").eq("card_id",t).order("created_at",{ascending:!1}).limit(500);if(r)throw r;const{data:n,error:a}=await H.from("agent_card_leads").select("*").eq("card_id",t).order("created_at",{ascending:!1});if(a)throw a;const o=(s==null?void 0:s.filter(c=>c.interaction_type==="card_view").length)||0,l=(s==null?void 0:s.filter(c=>c.interaction_type==="button_click").length)||0,i=(s==null?void 0:s.filter(c=>c.interaction_type==="contact_saved").length)||0;return{views:o,clicks:l,saves:i,leads:n||[],interactions:s||[]}},enabled:!!t});function Kde({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=N.useState(""),[i,c]=N.useState(""),[u,p]=N.useState(""),[f,g]=N.useState(""),[b,_]=N.useState(""),[j,w]=N.useState(!1),k=async S=>{if(S.preventDefault(),!o.trim()){me.error("Please enter your name");return}w(!0);try{await dkt(r,{lead_type:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:b.trim()||void 0,intent:f||void 0}),fo(r,"lead_submitted",n),H.functions.invoke("card-lead-notify",{body:{cardId:r,leadType:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:b.trim()||void 0,intent:f||void 0}}).catch(M=>console.error("Card lead notify failed:",M)),me.success(n==="booking"?"Request sent! They'll be in touch soon.":n==="connect"?"Info shared! They'll be in touch soon.":"Referral submitted! Thank you."),s(!1),l(""),c(""),p(""),g(""),_("")}catch{me.error("Something went wrong. Please try again.")}finally{w(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md rounded-2xl",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:n==="booking"?"Book a Call":n==="connect"?"Connect with Me":"Refer a Friend"}),e.jsx(Gr,{children:n==="booking"?`Let ${a} know you'd like to connect.`:n==="connect"?`Share your info and ${a} will reach out.`:`Know someone who could use ${a}'s help?`})]}),e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lead-name",children:"Name *"}),e.jsx(ze,{id:"lead-name",value:o,onChange:S=>l(S.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lead-phone",children:"Phone"}),e.jsx(ze,{id:"lead-phone",type:"tel",value:u,onChange:S=>p(S.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lead-email",children:"Email"}),e.jsx(ze,{id:"lead-email",type:"email",value:i,onChange:S=>c(S.target.value),placeholder:"you@example.com"})]}),n==="booking"&&e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lead-intent",children:"I'm looking to..."}),e.jsxs(Zs,{value:f,onValueChange:g,children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select one"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"buy",children:"Buy a home"}),e.jsx(Mt,{value:"sell",children:"Sell my home"}),e.jsx(Mt,{value:"both",children:"Buy & Sell"}),e.jsx(Mt,{value:"other",children:"Something else"})]})]})]}),n!=="connect"&&e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),e.jsx(ze,{id:"lead-message",value:b,onChange:S=>_(S.target.value),placeholder:n==="referral"?"Their name, phone, situation...":"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full rounded-2xl",disabled:j,children:j?"Sending...":"Submit"})]})]})})}const ukt=t=>mt({queryKey:["card-blocks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("card_blocks").select("*").eq("card_id",t).eq("is_visible",!0).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),hkt=t=>mt({queryKey:["card-blocks-all",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("card_blocks").select("*").eq("card_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),mkt=()=>{const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("card_blocks").insert(s).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["card-blocks",r.card_id]}),t.invalidateQueries({queryKey:["card-blocks-all",r.card_id]}),me.success("Block added")},onError:s=>me.error(s.message)})},pkt=()=>{const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("card_blocks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),me.success("Block updated")},onError:s=>me.error(s.message)})},fkt=()=>{const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("card_blocks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),me.success("Block removed")},onError:s=>me.error(s.message)})};function xkt(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 gkt(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 ykt={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 vkt({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=gkt(r.video_url),o=n||!!a,l=n?xkt(r.video_url):a||r.video_url;return e.jsx("div",{className:ykt[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 bkt={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 _kt({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=N.useState(0);if(n.length===0)return null;const l=bkt[s],i=n[a];return e.jsxs("div",{className:l.container,children:[e.jsxs("div",{className:l.card,children:[e.jsx(V_,{className:"h-4 w-4 mb-2 opacity-30"}),e.jsxs("p",{className:`${l.quote} mb-3`,children:['"',i.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:l.name,children:i.name}),i.role&&e.jsx("p",{className:l.role,children:i.role})]})]}),n.length>1&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[e.jsx("button",{onClick:()=>o(c=>(c-1+n.length)%n.length),className:l.nav,children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex gap-1.5",children:n.map((c,u)=>e.jsx("div",{className:`h-1.5 w-1.5 rounded-full transition-colors cursor-pointer ${u===a?l.dot:l.dotInactive}`,onClick:()=>o(u)},u))}),e.jsx("button",{onClick:()=>o(c=>(c+1)%n.length),className:l.nav,children:e.jsx(da,{className:"h-4 w-4"})})]})]})}const wkt={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 jkt({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=wkt[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const Nkt={standard:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-2xl bg-slate-50 hover:bg-slate-100 border border-slate-100 transition-colors text-sm font-medium text-slate-700",icon:"text-primary"},luxury:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-xl bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/10 transition-colors text-sm font-medium text-[#e2e8f0]",icon:"text-[#c9a84c]"},bold:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-2xl bg-gray-50 hover:bg-gray-100 transition-colors text-sm font-bold text-[#1a1a2e]",icon:"text-[#ff5722]"},classic:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-lg bg-white hover:bg-[#f5f1eb] border border-[#d4cfc5] shadow-sm transition-colors text-sm font-medium text-[#1b3a4b]",icon:"text-[#5a7a6f]"}};function kkt({block:t,cardId:s,variant:r}){const a=t.config.links||[];if(a.length===0)return null;const o=Nkt[r];return e.jsx("div",{className:o.container,children:a.map((l,i)=>e.jsxs("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(s,"button_click",`custom_link_${l.label}`),className:o.link,children:[e.jsx("span",{children:l.label}),e.jsx(tn,{className:`h-4 w-4 ${o.icon}`})]},i))})}const Eve={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 Skt({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 Ckt={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 Mkt({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=Ckt[r];return a.length===0?null:e.jsxs("div",{className:o.container,children:[e.jsx("h3",{className:o.title,children:"Follow Me"}),e.jsx("div",{className:"flex flex-wrap gap-3 justify-center",children:a.map((l,i)=>{const c=Eve[l.platform.toLowerCase()];return!c||!l.url?null:e.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(s,"button_click",`social_${l.platform}`),className:o.linkClass,title:c.label,children:e.jsx(Skt,{path:c.icon,color:c.color})},i)})})]})}function Zde({cardId:t,variant:s}){const{data:r}=ukt(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(vkt,{block:l,variant:s},l.id);case"testimonials":return e.jsx(_kt,{block:l,variant:s},l.id);case"specialties":return e.jsx(jkt,{block:l,variant:s},l.id);case"custom_links":return e.jsx(kkt,{block:l,cardId:t,variant:s},l.id);default:return null}}),o&&e.jsx(Mkt,{block:o,cardId:t,variant:s})]})}async function Tkt(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 Akt(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 Yde(t){const{first:s,last:r}=Akt(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 Tkt(t.avatarUrl);if(i){const u={"image/jpeg":"JPEG","image/jpg":"JPEG","image/png":"PNG","image/gif":"GIF","image/webp":"JPEG"}[i.mimeType]||"JPEG";n.push(`PHOTO;ENCODING=b;TYPE=${u}:${i.base64}`)}}n.push("END:VCARD");const a=new Blob([n.join(`\r `)],{type:"text/vcard"}),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=`${t.name.replace(/\s+/g,"_")}.vcf`,l.click(),URL.revokeObjectURL(o),me.success("Contact saved!")}function Ekt({card:t}){var k;const[s,r]=N.useState(!1),[n,a]=N.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,M)=>{fo(t.id,"button_click",S),M()},c=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),p=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:me.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),fo(t.id,"button_click","book"))},g=()=>{var S,M;fo(t.id,"contact_saved"),Yde({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(M=t.profile)==null?void 0:M.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},b=async()=>{if(fo(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o} - Real Estate Agent`,text:t.positioning_statement||`Connect with ${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),me.success("Link copied!")},_=()=>{a("referral"),r(!0),fo(t.id,"button_click","refer")},j=()=>{a("connect"),r(!0),fo(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-white to-slate-50",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(Nn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx($a,{src:t.avatar_url||void 0,alt:o}),e.jsx(kn,{className:"text-2xl font-semibold bg-primary text-primary-foreground",children:l})]}),e.jsx("h1",{className:"text-2xl font-bold text-slate-900 mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-primary mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-slate-500 mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-slate-400 mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-slate-600 italic leading-relaxed max-w-xs mx-auto",children:['"',t.positioning_statement,'"']})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs(K,{onClick:c,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(Un,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Call"})]}),e.jsxs(K,{onClick:u,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(so,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Text"})]}),e.jsxs(K,{onClick:p,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(cr,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),e.jsxs(K,{onClick:f,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[e.jsx(hn,{className:"h-5 w-5 mr-2"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm text-slate-600",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Jn,{className:"h-4 w-4 text-amber-500 fill-amber-500"}),e.jsx("span",{className:"font-bold text-slate-900",children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"bg-slate-50 rounded-2xl p-4 mb-6 border border-slate-100",children:e.jsxs("p",{className:"text-sm text-slate-600 italic text-center",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-2",children:"About Me"}),e.jsx("p",{className:"text-sm text-slate-600 leading-relaxed",children:t.bio})]}),e.jsx(Gde,{card:t,variant:"standard"}),e.jsx(Zde,{cardId:t.id,variant:"standard"}),e.jsxs("div",{className:"space-y-2 mb-6",children:[t.show_save_contact&&e.jsxs(K,{variant:"ghost",onClick:g,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(yi,{className:"h-4 w-4 mr-3 text-primary"}),"Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs(K,{variant:"ghost",onClick:()=>{fo(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Jn,{className:"h-4 w-4 mr-3 text-amber-500"}),"Leave a Review"]}),t.show_refer_friend&&e.jsxs(K,{variant:"ghost",onClick:_,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(pr,{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(Tl,{className:"h-4 w-4 mr-3 text-primary"}),"Connect with Me"]}),e.jsxs(K,{variant:"ghost",onClick:b,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(_d,{className:"h-4 w-4 mr-3 text-primary"}),"Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,M)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-lg transition-colors",children:w[S.platform.toLowerCase()]||"🔗"},M))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),e.jsx(Kde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Pkt({card:t}){var k;const[s,r]=N.useState(!1),[n,a]=N.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,M)=>{fo(t.id,"button_click",S),M()},c=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),p=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:me.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),fo(t.id,"button_click","book"))},g=()=>{var S,M;fo(t.id,"contact_saved"),Yde({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(M=t.profile)==null?void 0:M.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},b=async()=>{if(fo(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o} - Real Estate Agent`,text:t.positioning_statement||`Connect with ${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),me.success("Link copied!")},_=()=>{a("referral"),r(!0),fo(t.id,"button_click","refer")},j=()=>{a("connect"),r(!0),fo(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-[#0f1419] via-[#1a1f2e] to-[#0f1419]",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsx("div",{className:"w-16 h-0.5 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] mx-auto mb-8"}),e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(Nn,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[e.jsx($a,{src:t.avatar_url||void 0,alt:o}),e.jsx(kn,{className:"text-2xl font-serif bg-[#c9a84c]/20 text-[#e8d48b]",children:l})]}),e.jsx("h1",{className:"text-2xl font-serif font-bold text-white tracking-wide mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-[#e8d48b] mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-[#c9a84c] tracking-widest uppercase mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-[#a0aec0] mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-[#a0aec0] italic leading-relaxed max-w-xs mx-auto font-serif",children:['"',t.positioning_statement,'"']})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Un,label:"Call",handler:c},{icon:so,label:"Text",handler:u},{icon:cr,label:"Email",handler:p}].map(({icon:S,label:M,handler:L})=>e.jsxs("button",{onClick:L,className:"flex flex-col items-center gap-1.5 py-4 bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/20 rounded-xl transition-colors",children:[e.jsx(S,{className:"h-5 w-5 text-[#c9a84c]"}),e.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children:M})]},M))}),e.jsxs("button",{onClick:f,className:"w-full h-12 text-base font-semibold rounded-xl mb-6 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] text-[#0f1419] hover:opacity-90 transition-opacity flex items-center justify-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Jn,{className:"h-4 w-4 text-[#c9a84c] fill-[#c9a84c]"}),e.jsx("span",{className:"font-bold text-white",children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"bg-[#1e2636] rounded-xl p-4 mb-6 border border-[#c9a84c]/10",children:e.jsxs("p",{className:"text-sm text-[#a0aec0] italic text-center font-serif",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-[#c9a84c] mb-2 tracking-wide uppercase",children:"About"}),e.jsx("p",{className:"text-sm text-[#a0aec0] leading-relaxed",children:t.bio})]}),e.jsx(Gde,{card:t,variant:"luxury"}),e.jsx(Zde,{cardId:t.id,variant:"luxury"}),e.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:g,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(yi,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{fo(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(Jn,{className:"h-4 w-4 text-[#c9a84c]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(pr,{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(Tl,{className:"h-4 w-4 text-[#c9a84c]"})," Connect with Me"]}),e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(_d,{className:"h-4 w-4 text-[#c9a84c]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,M)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-[#1e2636] border border-[#c9a84c]/20 hover:border-[#c9a84c]/50 flex items-center justify-center text-lg transition-colors",children:w[S.platform.toLowerCase()]||"🔗"},M))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),e.jsx(Kde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Ikt({card:t}){var M,L,I,O;const[s,r]=N.useState(!1),[n,a]=N.useState("booking"),o=((M=t.profile)==null?void 0:M.name)||"Agent",l=o.split(" ").map(q=>q[0]).join("").toUpperCase().slice(0,2),i={accent:((L=t.bold_theme_colors)==null?void 0:L.accent)||"#ff5722",dark:((I=t.bold_theme_colors)==null?void 0:I.dark)||"#1a1a2e",button:((O=t.bold_theme_colors)==null?void 0:O.button)||"#ff5722"},c=(q,U)=>{const B=parseInt(q.replace("#",""),16),V=Math.max(0,(B>>16)-U),Z=Math.max(0,(B>>8&255)-U),X=Math.max(0,(B&255)-U);return`#${(V<<16|Z<<8|X).toString(16).padStart(6,"0")}`};c(i.accent,25),c(i.dark,-20),c(i.button,25);const u=(q,U)=>{fo(t.id,"button_click",q),U()},p=()=>u("call",()=>{var q;(q=t.profile)!=null&&q.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),f=()=>u("text",()=>{var q;(q=t.profile)!=null&&q.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),g=()=>u("email",()=>{var q;(q=t.profile)!=null&&q.email?window.location.href=`mailto:${t.profile.email}`:me.error("Email not available")}),b=()=>{t.booking_url?u("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),fo(t.id,"button_click","book"))},_=()=>{var q,U;fo(t.id,"contact_saved"),Yde({name:o,phone:(q=t.profile)==null?void 0:q.phone,email:(U=t.profile)==null?void 0:U.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},j=async()=>{if(fo(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),me.success("Link copied!")},w=()=>{a("referral"),r(!0),fo(t.id,"button_click","refer")},k=()=>{a("connect"),r(!0),fo(t.id,"button_click","connect")},S={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:i.accent},children:[e.jsxs("div",{className:"px-5 pt-10 pb-14 text-center relative",style:{backgroundColor:i.dark},children:[t.show_photo&&e.jsxs(Nn,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${i.accent}`},children:[e.jsx($a,{src:t.avatar_url||void 0,alt:o}),e.jsx(kn,{className:"text-2xl font-black text-white",style:{backgroundColor:i.accent},children:l})]}),e.jsx("h1",{className:"text-3xl font-black text-white tracking-tight mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-bold mb-1",style:{color:`${i.accent}cc`},children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-bold uppercase tracking-wider mb-1",style:{color:i.accent},children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-bold text-white/60 uppercase tracking-wider",children:t.team_name})]}),e.jsxs("div",{className:"max-w-md mx-auto px-5 -mt-6",children:[e.jsxs("div",{className:"bg-white rounded-3xl shadow-2xl px-5 py-8",children:[t.positioning_statement&&e.jsx("p",{className:"text-center font-bold text-lg leading-snug mb-6 max-w-xs mx-auto",style:{color:i.dark},children:t.positioning_statement}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Un,label:"Call",handler:p},{icon:so,label:"Text",handler:f},{icon:cr,label:"Email",handler:g}].map(({icon:q,label:U,handler:B})=>e.jsxs("button",{onClick:B,className:"flex flex-col items-center gap-1.5 py-4 text-white rounded-2xl transition-opacity font-bold hover:opacity-85",style:{backgroundColor:i.dark},children:[e.jsx(q,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:U})]},U))}),e.jsxs("button",{onClick:b,className:"w-full h-14 text-base font-black rounded-2xl mb-6 text-white transition-opacity hover:opacity-90 flex items-center justify-center gap-2 uppercase tracking-wide",style:{backgroundColor:i.button},children:[e.jsx(hn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-5 mb-6",children:t.review_snippet&&e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Jn,{className:"h-5 w-5",style:{color:i.accent,fill:i.accent}}),e.jsx("span",{className:"font-black text-2xl",style:{color:i.dark},children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"rounded-2xl p-4 mb-6",style:{backgroundColor:`${i.accent}15`},children:e.jsxs("p",{className:"text-sm font-medium text-center",style:{color:i.dark},children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xs font-black mb-2 uppercase tracking-wider",style:{color:i.accent},children:"About Me"}),e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed",children:t.bio})]}),e.jsx(Gde,{card:t,variant:"bold"}),e.jsx(Zde,{cardId:t.id,variant:"bold"}),e.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(yi,{className:"h-4 w-4",style:{color:i.accent}})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{fo(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(Jn,{className:"h-4 w-4",style:{color:i.accent}})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(pr,{className:"h-4 w-4",style:{color:i.accent}})," Refer a Friend"]}),e.jsxs("button",{onClick:k,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(Tl,{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(_d,{className:"h-4 w-4",style:{color:i.accent}})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-6",children:t.social_links.slice(0,3).map((q,U)=>e.jsx("a",{href:q.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(t.id,"button_click",`social_${q.platform}`),className:"h-10 w-10 rounded-full flex items-center justify-center text-lg transition-opacity hover:opacity-85",style:{backgroundColor:i.dark},children:S[q.platform.toLowerCase()]||"🔗"},U))})]}),e.jsx("div",{className:"text-center py-6",children:e.jsx("p",{className:"text-xs text-white/50",children:"Powered by LevelUp"})})]}),e.jsx(Kde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Lkt({card:t}){var k;const[s,r]=N.useState(!1),[n,a]=N.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,M)=>{fo(t.id,"button_click",S),M()},c=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),p=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:me.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),fo(t.id,"button_click","book"))},g=()=>{var S,M;fo(t.id,"contact_saved"),Yde({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(M=t.profile)==null?void 0:M.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},b=async()=>{if(fo(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),me.success("Link copied!")},_=()=>{a("referral"),r(!0),fo(t.id,"button_click","refer")},j=()=>{a("connect"),r(!0),fo(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-[#f5f1eb]",children:[e.jsx("div",{className:"bg-[#1b3a4b] h-2"}),e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(Nn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx($a,{src:t.avatar_url||void 0,alt:o}),e.jsx(kn,{className:"text-2xl font-serif bg-[#1b3a4b] text-white",children:l})]}),e.jsx("h1",{className:"text-2xl font-serif font-bold text-[#1b3a4b] mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-[#5a7a6f] mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-[#5a7a6f] mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-[#a0aec0] mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-[#4a5568] italic leading-relaxed max-w-xs mx-auto font-serif",children:['"',t.positioning_statement,'"']})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Un,label:"Call",handler:c},{icon:so,label:"Text",handler:u},{icon:cr,label:"Email",handler:p}].map(({icon:S,label:M,handler:L})=>e.jsxs("button",{onClick:L,className:"flex flex-col items-center gap-1.5 py-4 bg-white hover:bg-[#e8e3db] border border-[#d4cfc5] rounded-lg transition-colors shadow-sm",children:[e.jsx(S,{className:"h-5 w-5 text-[#1b3a4b]"}),e.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children:M})]},M))}),e.jsxs("button",{onClick:f,className:"w-full h-12 text-base font-semibold rounded-lg mb-6 bg-[#1b3a4b] hover:bg-[#264d61] text-white transition-colors flex items-center justify-center gap-2 shadow-sm",children:[e.jsx(hn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:e.jsx("div",{className:"flex items-center justify-center gap-6",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Jn,{className:"h-4 w-4 text-[#d4a843] fill-[#d4a843]"}),e.jsx("span",{className:"font-bold text-[#1b3a4b] font-serif",children:"5.0"})]})})}),t.review_snippet&&e.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:e.jsxs("p",{className:"text-sm text-[#4a5568] italic text-center font-serif",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-[#1b3a4b] mb-2 font-serif",children:"About"}),e.jsx("p",{className:"text-sm text-[#4a5568] leading-relaxed",children:t.bio})]}),e.jsx(Gde,{card:t,variant:"classic"}),e.jsx(Zde,{cardId:t.id,variant:"classic"}),e.jsxs("div",{className:"bg-white rounded-lg border border-[#d4cfc5] shadow-sm divide-y divide-[#e8e3db] mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:g,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(yi,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{fo(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(Jn,{className:"h-4 w-4 text-[#d4a843]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(pr,{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(Tl,{className:"h-4 w-4 text-[#5a7a6f]"})," Connect with Me"]}),e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(_d,{className:"h-4 w-4 text-[#5a7a6f]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,M)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-white border border-[#d4cfc5] hover:bg-[#e8e3db] flex items-center justify-center text-lg transition-colors shadow-sm",children:w[S.platform.toLowerCase()]||"🔗"},M))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),e.jsx(Kde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function dje({card:t}){switch(t.theme){case"luxury":return e.jsx(Pkt,{card:t});case"bold":return e.jsx(Ikt,{card:t});case"classic":return e.jsx(Lkt,{card:t});case"standard":default:return e.jsx(Ekt,{card:t})}}function Dkt(){const t=zd();N.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]);const s=t.pathname.slice(1);return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Agent Cards"}),e.jsx("p",{className:"text-slate-500",children:"Visit a specific agent's card URL to view their digital business card."})]})}):e.jsx(Okt,{slug:s})}function Okt({slug:t}){return e.jsx(Rkt,{slug:t})}function Rkt({slug:t}){var o;const{data:s,isLoading:r,error:n}=nGe(t);if(N.useEffect(()=>{s!=null&&s.id&&fo(s.id,"card_view")},[s==null?void 0:s.id]),r)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md mx-auto p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(ys,{className:"h-28 w-28 rounded-full"}),e.jsx(ys,{className:"h-6 w-48"}),e.jsx(ys,{className:"h-4 w-36"})]}),e.jsx(ys,{className:"h-12 w-full"}),e.jsx(ys,{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(Sc,{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(dje,{card:s})]})}function lGe({presentationId:t,ctaLabel:s,agentName:r,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=N.useState(n||""),[c,u]=N.useState(a||""),[p,f]=N.useState(o||""),[g,b]=N.useState(""),[_,j]=N.useState(""),[w,k]=N.useState(!1),[S,M]=N.useState(!1),L=async I=>{if(I.preventDefault(),!l.trim()){me.error("Please enter your name");return}k(!0);try{const{error:O}=await H.from("smart_presentation_leads").insert({presentation_id:t,name:l.trim(),email:c.trim()||null,phone:p.trim()||null,intent:g||null,message:_.trim()||null});if(O)throw O;try{await H.rpc("log_presentation_view",{p_presentation_id:t,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}H.functions.invoke("presentation-lead-notify",{body:{presentationId:t,name:l.trim(),email:c.trim()||void 0,phone:p.trim()||void 0,intent:g||void 0,message:_.trim()||void 0}}).catch(q=>console.error("Presentation lead notify failed:",q)),M(!0)}catch{me.error("Something went wrong. Please try again.")}finally{k(!1)}};return S?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(va,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Thank you!"}),e.jsx("p",{className:"text-gray-500",children:r?`${r} will be in touch soon.`:"We'll be in touch soon."})]}):e.jsxs("form",{onSubmit:L,className:"space-y-4 max-w-md mx-auto",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"pres-lead-name",children:"Name *"}),e.jsx(ze,{id:"pres-lead-name",value:l,onChange:I=>i(I.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"pres-lead-phone",children:"Phone"}),e.jsx(ze,{id:"pres-lead-phone",type:"tel",value:p,onChange:I=>f(I.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"pres-lead-email",children:"Email"}),e.jsx(ze,{id:"pres-lead-email",type:"email",value:c,onChange:I=>u(I.target.value),placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),e.jsxs(Zs,{value:g,onValueChange:b,children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select one"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"buy",children:"Buy a home"}),e.jsx(Mt,{value:"sell",children:"Sell my home"}),e.jsx(Mt,{value:"both",children:"Buy & Sell"}),e.jsx(Mt,{value:"other",children:"Something else"})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"pres-lead-message",children:"Message (optional)"}),e.jsx(ze,{id:"pres-lead-message",value:_,onChange:I=>j(I.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 Fkt(){const t=zd();N.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]);const s=t.pathname.slice(1);return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Smart Presentations"}),e.jsx("p",{className:"text-slate-500",children:"Visit a specific presentation URL to view it."})]})}):e.jsx(zkt,{shareToken:s})}function zkt({shareToken:t}){var _;const[s,r]=N.useState(null),[n,a]=N.useState(!0),[o,l]=N.useState(0),[i,c]=N.useState(!1);N.useEffect(()=>{u()},[t]);const u=async()=>{const{data:j,error:w}=await H.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(w||!j){c(!0),a(!1);return}const{data:k}=await H.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",j.owner_user_id).single();let S;if(k!=null&&k.brokerage_id){const{data:L}=await H.from("brokerages").select("name").eq("id",k.brokerage_id).single();S=(L==null?void 0:L.name)||void 0}let M=null;if(j.contact_id){const{data:L}=await H.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",j.contact_id).single();M=L}r({...j,owner_name:k==null?void 0:k.name,owner_email:k==null?void 0:k.email,owner_phone:k==null?void 0:k.phone,owner_avatar:k==null?void 0:k.avatar_url,owner_title:(k==null?void 0:k.title)||void 0,brokerage_name:S,contact_name:M?[M.first_name,M.last_name].filter(Boolean).join(" "):void 0,contact_email:(M==null?void 0:M.email)||void 0,contact_phone:(M==null?void 0:M.phone)||void 0}),a(!1);try{await H.rpc("log_presentation_view",{p_presentation_id:j.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await H.rpc("log_presentation_view",{p_presentation_id:s.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}s.cta_url&&window.open(s.cta_url,"_blank")}},f=j=>{const w=j.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(w)return`https://www.youtube.com/embed/${w[1]}?rel=0`;if(j.includes("iframe.mediadelivery.net/play/")){const M=j.replace("/play/","/embed/"),L=M.includes("?")?"&":"?";return`${M}${L}responsive=true`}if(j.includes("iframe.mediadelivery.net")){const M=j.includes("?")?"&":"?";return`${j}${M}responsive=true`}const k=j.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(k)return`https://www.loom.com/embed/${k[1]}`;const S=j.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return S?`https://iframe.mediadelivery.net/embed/${S[1]}/${S[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(ys,{className:"h-12 w-3/4 mx-auto"}),e.jsx(ys,{className:"h-64 w-full"}),e.jsx(ys,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!s)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const g=s.sections.filter(j=>j.is_visible!==!1),b=g[o];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsx("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-end",children:e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[b!=null&&b.video_url?e.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:f(b.video_url),className:"absolute inset-0 w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,loading:"lazy"})}):b!=null&&b.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:b.image_url,alt:b.title,className:"w-full h-auto object-cover",loading:"lazy"})}):e.jsxs("div",{className:"aspect-video bg-gradient-to-br from-blue-50 to-slate-100 rounded-xl flex flex-col items-center justify-center shadow-lg",children:[e.jsx("span",{className:"text-5xl mb-3",children:b==null?void 0:b.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:b==null?void 0:b.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:b==null?void 0:b.description})]}),(b==null?void 0:b.text)&&e.jsx("div",{className:"mt-4 p-4 bg-white rounded-lg border text-gray-700 text-sm leading-relaxed prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:b.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:g.map((j,w)=>e.jsx("button",{onClick:()=>l(w),className:It("w-full text-left p-4 rounded-xl border transition-all",o===w?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(w+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:j.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:j.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:j.description})]})]})},w))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),(_=s.cta_url)!=null&&_.trim()?e.jsxs(K,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(tn,{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(lGe,{presentationId:s.id,ctaLabel:s.cta_label,agentName:s.owner_name||void 0,prefillName:s.contact_name,prefillEmail:s.contact_email,prefillPhone:s.contact_phone})})]})]}),e.jsx("footer",{className:"border-t border-gray-100 bg-white mt-12 py-6 text-center text-xs text-gray-400",children:"Powered by LevelUp"})]})}const Bx=()=>{const t=ci();return mt({queryKey:["user-team",t],queryFn:async()=>{const{data:s,error:r}=await H.from("team_members").select("id, team_id, role").eq("user_id",t).maybeSingle();if(console.log("[useUserTeam] membership query:",{userId:t,membership:s,error:r}),r)throw r;if(!s)return null;const{data:n,error:a}=await H.from("teams").select("*").eq("id",s.team_id).single();if(a)throw a;return{membershipId:s.id,teamId:s.team_id,role:s.role,team:n}},enabled:!!t,staleTime:5*60*1e3})};function Bkt(){const{user:t}=Ds(),s=ci(),{data:r}=Bx();return mt({queryKey:["open-houses",s,r==null?void 0:r.teamId,r==null?void 0:r.role],queryFn:async()=>{const{data:n,error:a}=await H.from("open_houses").select("*").eq("agent_id",s).order("event_date",{ascending:!1});if(a)throw a;let o=n||[];if((r==null?void 0:r.role)==="team_leader"&&r.teamId){const{data:l,error:i}=await H.rpc("get_team_open_houses",{_user_id:s});if(!i&&l){const c=[...new Set(l.map(f=>f.agent_id))],u={};if(c.length>0){const{data:f}=await H.from("profiles").select("id, name").in("id",c);f==null||f.forEach(g=>{g.name&&(u[g.id]=g.name)})}const p=l.map(f=>({...f,agent_name:u[f.agent_id]||void 0}));o=[...o,...p]}}return o.sort((l,i)=>i.event_date.localeCompare(l.event_date)),o},enabled:!!t&&!!s})}function LMs(t){const{user:s}=Ds();return mt({queryKey:["open-house",t],queryFn:async()=>{const{data:r,error:n}=await H.from("open_houses").select("*").eq("id",t).single();if(n)throw n;return r},enabled:!!s&&!!t})}function cGe(t){const{user:s}=Ds(),r=Qt();return N.useEffect(()=>{if(!t)return;const n=H.channel(`visitors-${t}`).on("postgres_changes",{event:"*",schema:"public",table:"open_house_visitors",filter:`open_house_id=eq.${t}`},()=>{r.invalidateQueries({queryKey:["open-house-visitors",t]}),r.invalidateQueries({queryKey:["open-houses"]})}).subscribe();return()=>{H.removeChannel(n)}},[t,r]),mt({queryKey:["open-house-visitors",t],queryFn:async()=>{const{data:n,error:a}=await H.from("open_house_visitors").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(a)throw a;return n},enabled:!!s&&!!t})}function $kt(){const t=Qt(),s=ci();return Dt({mutationFn:async r=>{const{data:n,error:a}=await H.from("open_houses").insert({...r,agent_id:s}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),wn({title:"Open house created!"})},onError:r=>{wn({title:"Error",description:r.message,variant:"destructive"})}})}function dGe(){const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{error:n}=await H.from("open_houses").update(r).eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["open-houses"]}),t.invalidateQueries({queryKey:["open-house",r.id]})}})}function qkt(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("open_houses").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),wn({title:"Open house deleted"})}})}function Ukt(t){return mt({queryKey:["public-open-house",t],queryFn:async()=>{const{data:s,error:r}=await H.from("open_houses").select("*, profiles:agent_id(name, avatar_url, title)").eq("slug",t).eq("is_active",!0).single();if(r)throw r;let n=null;if(s.agent_id){const{data:a}=await H.from("agent_cards").select("slug").eq("user_id",s.agent_id).eq("is_published",!0).maybeSingle();a&&(n=a.slug)}return{...s,agent_card_slug:n}},enabled:!!t})}function Vkt(t){const{user:s}=Ds();return mt({queryKey:["survey-questions",t],queryFn:async()=>{const{data:r,error:n}=await H.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;return r},enabled:!!s&&!!t})}function Hkt(t){return mt({queryKey:["public-survey-questions",t],queryFn:async()=>{const{data:s,error:r}=await H.from("open_house_survey_questions").select("*").eq("open_house_id",t).eq("is_active",!0).order("sort_order");if(r)throw r;return s},enabled:!!t})}function Wkt(){return Dt({mutationFn:async t=>{const{error:s}=await H.from("open_house_survey_responses").insert(t);if(s)throw s}})}function Gkt(t){const{user:s}=Ds();return mt({queryKey:["survey-responses",t],queryFn:async()=>{const{data:r,error:n}=await H.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;const a=(r||[]).map(i=>i.id);if(a.length===0)return{questions:[],responses:[]};const{data:o,error:l}=await H.from("open_house_survey_responses").select("*").in("question_id",a).order("created_at",{ascending:!1});if(l)throw l;return{questions:r,responses:o||[]}},enabled:!!s&&!!t})}function Kkt(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("open_house_survey_questions").insert(s).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function Zkt(){const t=Qt();return Dt({mutationFn:async({id:s,open_house_id:r,...n})=>{const{error:a}=await H.from("open_house_survey_questions").update(n).eq("id",s);if(a)throw a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function Ykt(){const t=Qt();return Dt({mutationFn:async({id:s,open_house_id:r})=>{const{error:n}=await H.from("open_house_survey_questions").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function Xkt(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.rpc("seed_default_survey_questions",{_open_house_id:s});if(r)throw r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r]})}})}function Qkt(){return Dt({mutationFn:async t=>{const{data:s,error:r}=await H.from("open_house_visitors").insert(t).select("id").single();if(r)throw r;return s}})}var Xde="Switch",[Jkt]=ad(Xde),[e4t,t4t]=Jkt(Xde),uGe=N.forwardRef((t,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:c="on",onCheckedChange:u,form:p,...f}=t,[g,b]=N.useState(null),_=qa(s,M=>b(M)),j=N.useRef(!1),w=g?p||!!g.closest("form"):!0,[k,S]=ah({prop:a,defaultProp:o??!1,onChange:u,caller:Xde});return e.jsxs(e4t,{scope:r,checked:k,disabled:i,children:[e.jsx(nn.button,{type:"button",role:"switch","aria-checked":k,"aria-required":l,"data-state":fGe(k),"data-disabled":i?"":void 0,disabled:i,value:c,...f,ref:_,onClick:Ir(t.onClick,M=>{S(L=>!L),w&&(j.current=M.isPropagationStopped(),j.current||M.stopPropagation())})}),w&&e.jsx(pGe,{control:g,bubbles:!j.current,name:n,value:c,checked:k,required:l,disabled:i,form:p,style:{transform:"translateX(-100%)"}})]})});uGe.displayName=Xde;var hGe="SwitchThumb",mGe=N.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=t4t(hGe,r);return e.jsx(nn.span,{"data-state":fGe(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});mGe.displayName=hGe;var s4t="SwitchBubbleInput",pGe=N.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=N.useRef(null),i=qa(l,o),c=EO(r),u=yO(s);return N.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==r&&b){const _=new Event("click",{bubbles:n});b.call(p,r),p.dispatchEvent(_)}},[c,r,n]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:i,style:{...a.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});pGe.displayName=s4t;function fGe(t){return t?"checked":"unchecked"}var xGe=uGe,r4t=mGe;const qr=N.forwardRef(({className:t,...s},r)=>e.jsx(xGe,{className:It("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",t),...s,ref:r,children:e.jsx(r4t,{className:It("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));qr.displayName=xGe.displayName;function ra(t){const s=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&s==="[object Date]"?new t.constructor(+t):typeof t=="number"||s==="[object Number]"||typeof t=="string"||s==="[object String]"?new Date(t):new Date(NaN)}function xl(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function El(t,s){const r=ra(t);return isNaN(s)?xl(t,NaN):(s&&r.setDate(r.getDate()+s),r)}function Bm(t,s){const r=ra(t);if(isNaN(s))return xl(t,NaN);if(!s)return r;const n=r.getDate(),a=xl(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 gGe(t,s){const r=+ra(t);return xl(t,r+s)}const uje=6048e5,n4t=864e5,Qde=6e4,PO=36e5,a4t=1e3,ez=43200,a6e=1440;function i6e(t,s){return gGe(t,s*PO)}let i4t={};function Pw(){return i4t}function Xh(t,s){var i,c,u,p;const r=Pw(),n=(s==null?void 0:s.weekStartsOn)??((c=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.weekStartsOn)??0,a=ra(t),o=a.getDay(),l=(o=a.getTime()?r+1:s.getTime()>=l.getTime()?r:r-1}function $m(t){const s=ra(t);return s.setHours(0,0,0,0),s}function uw(t){const s=ra(t),r=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()));return r.setUTCFullYear(s.getFullYear()),+t-+r}function hf(t,s){const r=$m(t),n=$m(s),a=+r-uw(r),o=+n-uw(n);return Math.round((a-o)/n4t)}function o4t(t){const s=yGe(t),r=xl(t,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),T1(r)}function aM(t,s){return gGe(t,s*Qde)}function g4(t,s){const r=s*7;return El(t,r)}function l4t(t,s){return Bm(t,s*12)}function c4t(t){let s;return t.forEach(function(r){const n=ra(r);(s===void 0||s{const n=ra(r);(!s||s>n||isNaN(+n))&&(s=n)}),s||new Date(NaN)}function uie(t,s){const r=ra(t),n=ra(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function hje(t){return xl(t,Date.now())}function Cl(t,s){const r=$m(t),n=$m(s);return+r==+n}function mje(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Pve(t){if(!mje(t)&&typeof t!="number")return!1;const s=ra(t);return!isNaN(Number(s))}function DT(t,s){const r=ra(t),n=ra(s),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function u4t(t,s,r){const n=Xh(t,r),a=Xh(s,r),o=+n-uw(n),l=+a-uw(a);return Math.round((o-l)/uje)}function oy(t,s){const r=ra(t),n=ra(s),a=o6e(r,n),o=Math.abs(hf(r,n));r.setDate(r.getDate()-a*o);const l=+(o6e(r,n)===-a),i=a*(o-l);return i===0?0:i}function o6e(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 vGe(t){return s=>{const n=(t?Math[t]:Math.trunc)(s);return n===0?0:n}}function bGe(t,s){return+ra(t)-+ra(s)}function h4t(t,s,r){const n=bGe(t,s)/PO;return vGe(r==null?void 0:r.roundingMethod)(n)}function m4t(t){const s=ra(t);return s.setHours(23,59,59,999),s}function lx(t){const s=ra(t),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function p4t(t){const s=ra(t);return+m4t(s)==+lx(s)}function f4t(t,s){const r=ra(t),n=ra(s),a=uie(r,n),o=Math.abs(DT(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=uie(r,n)===-a;p4t(ra(t))&&o===1&&uie(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function x4t(t,s,r){const n=bGe(t,s)/1e3;return vGe(r==null?void 0:r.roundingMethod)(n)}function g4t(t,s){const r=ra(t.start),n=ra(t.end);let a=+r>+n;const o=a?+r:+n,l=a?n:r;l.setHours(0,0,0,0);let i=1;const c=[];for(;+l<=o;)c.push(ra(l)),l.setDate(l.getDate()+i),l.setHours(0,0,0,0);return a?c.reverse():c}function Fc(t){const s=ra(t);return s.setDate(1),s.setHours(0,0,0,0),s}function _Ge(t){const s=ra(t),r=xl(t,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function Jde(t,s){var i,c,u,p;const r=Pw(),n=(s==null?void 0:s.weekStartsOn)??((c=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.weekStartsOn)??0,a=ra(t),o=a.getDay(),l=(o{let n;const a=y4t[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 kxe(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const b4t={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},_4t={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},w4t={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},j4t={date:kxe({formats:b4t,defaultWidth:"full"}),time:kxe({formats:_4t,defaultWidth:"full"}),dateTime:kxe({formats:w4t,defaultWidth:"full"})},N4t={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},k4t=(t,s,r,n)=>N4t[t];function BP(t){return(s,r)=>{const n=r!=null&&r.context?String(r.context):"standalone";let a;if(n==="formatting"&&t.formattingValues){const l=t.defaultFormattingWidth||t.defaultWidth,i=r!=null&&r.width?String(r.width):l;a=t.formattingValues[i]||t.formattingValues[l]}else{const l=t.defaultWidth,i=r!=null&&r.width?String(r.width):t.defaultWidth;a=t.values[i]||t.values[l]}const o=t.argumentCallback?t.argumentCallback(s):s;return a[o]}}const S4t={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},C4t={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},M4t={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"]},T4t={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"]},A4t={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"}},E4t={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"}},P4t=(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"},I4t={ordinalNumber:P4t,era:BP({values:S4t,defaultWidth:"wide"}),quarter:BP({values:C4t,defaultWidth:"wide",argumentCallback:t=>t-1}),month:BP({values:M4t,defaultWidth:"wide"}),day:BP({values:T4t,defaultWidth:"wide"}),dayPeriod:BP({values:A4t,defaultWidth:"wide",formattingValues:E4t,defaultFormattingWidth:"wide"})};function $P(t){return(s,r={})=>{const n=r.width,a=n&&t.matchPatterns[n]||t.matchPatterns[t.defaultMatchWidth],o=s.match(a);if(!o)return null;const l=o[0],i=n&&t.parsePatterns[n]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(i)?D4t(i,f=>f.test(l)):L4t(i,f=>f.test(l));let u;u=t.valueCallback?t.valueCallback(c):c,u=r.valueCallback?r.valueCallback(u):u;const p=s.slice(l.length);return{value:u,rest:p}}}function L4t(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function D4t(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 R4t=/^(\d+)(th|st|nd|rd)?/i,F4t=/\d+/i,z4t={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},B4t={any:[/^b/i,/^(a|c)/i]},$4t={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},q4t={any:[/1/i,/2/i,/3/i,/4/i]},U4t={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},V4t={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]},H4t={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},W4t={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]},G4t={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},K4t={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}},Z4t={ordinalNumber:O4t({matchPattern:R4t,parsePattern:F4t,valueCallback:t=>parseInt(t,10)}),era:$P({matchPatterns:z4t,defaultMatchWidth:"wide",parsePatterns:B4t,defaultParseWidth:"any"}),quarter:$P({matchPatterns:$4t,defaultMatchWidth:"wide",parsePatterns:q4t,defaultParseWidth:"any",valueCallback:t=>t+1}),month:$P({matchPatterns:U4t,defaultMatchWidth:"wide",parsePatterns:V4t,defaultParseWidth:"any"}),day:$P({matchPatterns:H4t,defaultMatchWidth:"wide",parsePatterns:W4t,defaultParseWidth:"any"}),dayPeriod:$P({matchPatterns:G4t,defaultMatchWidth:"any",parsePatterns:K4t,defaultParseWidth:"any"})},eue={code:"en-US",formatDistance:v4t,formatLong:j4t,formatRelative:k4t,localize:I4t,match:Z4t,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Y4t(t){const s=ra(t);return hf(s,_Ge(s))+1}function pje(t){const s=ra(t),r=+T1(s)-+o4t(s);return Math.round(r/uje)+1}function fje(t,s){var p,f,g,b;const r=ra(t),n=r.getFullYear(),a=Pw(),o=(s==null?void 0:s.firstWeekContainsDate)??((f=(p=s==null?void 0:s.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??a.firstWeekContainsDate??((b=(g=a.locale)==null?void 0:g.options)==null?void 0:b.firstWeekContainsDate)??1,l=xl(t,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=Xh(l,s),c=xl(t,0);c.setFullYear(n,0,o),c.setHours(0,0,0,0);const u=Xh(c,s);return r.getTime()>=i.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function X4t(t,s){var i,c,u,p;const r=Pw(),n=(s==null?void 0:s.firstWeekContainsDate)??((c=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:c.firstWeekContainsDate)??r.firstWeekContainsDate??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.firstWeekContainsDate)??1,a=fje(t,s),o=xl(t,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),Xh(o,s)}function xje(t,s){const r=ra(t),n=+Xh(r,s)-+X4t(r,s);return Math.round(n/uje)+1}function fl(t,s){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(s,"0");return r+n}const Ib={y(t,s){const r=t.getFullYear(),n=r>0?r:1-r;return fl(s==="yy"?n%100:n,s.length)},M(t,s){const r=t.getMonth();return s==="M"?String(r+1):fl(r+1,2)},d(t,s){return fl(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 fl(t.getHours()%12||12,s.length)},H(t,s){return fl(t.getHours(),s.length)},m(t,s){return fl(t.getMinutes(),s.length)},s(t,s){return fl(t.getSeconds(),s.length)},S(t,s){const r=s.length,n=t.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return fl(a,s.length)}},b5={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},l6e={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 Ib.y(t,s)},Y:function(t,s,r,n){const a=fje(t,n),o=a>0?a:1-a;if(s==="YY"){const l=o%100;return fl(l,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):fl(o,s.length)},R:function(t,s){const r=yGe(t);return fl(r,s.length)},u:function(t,s){const r=t.getFullYear();return fl(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 fl(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 fl(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 Ib.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 fl(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=xje(t,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):fl(a,s.length)},I:function(t,s,r){const n=pje(t);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):fl(n,s.length)},d:function(t,s,r){return s==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):Ib.d(t,s)},D:function(t,s,r){const n=Y4t(t);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):fl(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 fl(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 fl(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 fl(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=b5.noon:n===0?a=b5.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=b5.evening:n>=12?a=b5.afternoon:n>=4?a=b5.morning:a=b5.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 Ib.h(t,s)},H:function(t,s,r){return s==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):Ib.H(t,s)},K:function(t,s,r){const n=t.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):fl(n,s.length)},k:function(t,s,r){let n=t.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):fl(n,s.length)},m:function(t,s,r){return s==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):Ib.m(t,s)},s:function(t,s,r){return s==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):Ib.s(t,s)},S:function(t,s){return Ib.S(t,s)},X:function(t,s,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return d6e(n);case"XXXX":case"XX":return r4(n);case"XXXXX":case"XXX":default:return r4(n,":")}},x:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"x":return d6e(n);case"xxxx":case"xx":return r4(n);case"xxxxx":case"xxx":default:return r4(n,":")}},O:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+c6e(n,":");case"OOOO":default:return"GMT"+r4(n,":")}},z:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+c6e(n,":");case"zzzz":default:return"GMT"+r4(n,":")}},t:function(t,s,r){const n=Math.trunc(t.getTime()/1e3);return fl(n,s.length)},T:function(t,s,r){const n=t.getTime();return fl(n,s.length)}};function c6e(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+fl(o,2)}function d6e(t,s){return t%60===0?(t>0?"-":"+")+fl(Math.abs(t)/60,2):r4(t,s)}function r4(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=fl(Math.trunc(n/60),2),o=fl(n%60,2);return r+a+s+o}const u6e=(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"})}},jGe=(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"})}},Q4t=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return u6e(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}}",u6e(n,s)).replace("{{time}}",jGe(a,s))},Ive={p:jGe,P:Q4t},J4t=/^D+$/,eSt=/^Y+$/,tSt=["D","DD","YY","YYYY"];function NGe(t){return J4t.test(t)}function kGe(t){return eSt.test(t)}function Lve(t,s,r){const n=sSt(t,s,r);if(console.warn(n),tSt.includes(t))throw new RangeError(n)}function sSt(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 rSt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,nSt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,aSt=/^'([^]*?)'?$/,iSt=/''/g,oSt=/[a-zA-Z]/;function ms(t,s,r){var p,f,g,b,_,j,w,k;const n=Pw(),a=(r==null?void 0:r.locale)??n.locale??eue,o=(r==null?void 0:r.firstWeekContainsDate)??((f=(p=r==null?void 0:r.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??n.firstWeekContainsDate??((b=(g=n.locale)==null?void 0:g.options)==null?void 0:b.firstWeekContainsDate)??1,l=(r==null?void 0:r.weekStartsOn)??((j=(_=r==null?void 0:r.locale)==null?void 0:_.options)==null?void 0:j.weekStartsOn)??n.weekStartsOn??((k=(w=n.locale)==null?void 0:w.options)==null?void 0:k.weekStartsOn)??0,i=ra(t);if(!Pve(i))throw new RangeError("Invalid time value");let c=s.match(nSt).map(S=>{const M=S[0];if(M==="p"||M==="P"){const L=Ive[M];return L(S,a.formatLong)}return S}).join("").match(rSt).map(S=>{if(S==="''")return{isToken:!1,value:"'"};const M=S[0];if(M==="'")return{isToken:!1,value:lSt(S)};if(l6e[M])return{isToken:!0,value:S};if(M.match(oSt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+M+"`");return{isToken:!1,value:S}});a.localize.preprocessor&&(c=a.localize.preprocessor(i,c));const u={firstWeekContainsDate:o,weekStartsOn:l,locale:a};return c.map(S=>{if(!S.isToken)return S.value;const M=S.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&kGe(M)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&NGe(M))&&Lve(M,s,String(t));const L=l6e[M[0]];return L(i,M,a.localize,u)}).join("")}function lSt(t){const s=t.match(aSt);return s?s[1].replace(iSt,"'"):t}function cSt(t,s,r){const n=Pw(),a=(r==null?void 0:r.locale)??n.locale??eue,o=2520,l=uie(t,s);if(isNaN(l))throw new RangeError("Invalid time value");const i=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:l});let c,u;l>0?(c=ra(s),u=ra(t)):(c=ra(t),u=ra(s));const p=x4t(u,c),f=(uw(u)-uw(c))/1e3,g=Math.round((p-f)/60);let b;if(g<2)return r!=null&&r.includeSeconds?p<5?a.formatDistance("lessThanXSeconds",5,i):p<10?a.formatDistance("lessThanXSeconds",10,i):p<20?a.formatDistance("lessThanXSeconds",20,i):p<40?a.formatDistance("halfAMinute",0,i):p<60?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",1,i):g===0?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",g,i);if(g<45)return a.formatDistance("xMinutes",g,i);if(g<90)return a.formatDistance("aboutXHours",1,i);if(gn.getTime()}function US(t,s){const r=ra(t),n=ra(s);return+r<+n}function xSt(t){return+ra(t)>Date.now()}function gSt(t,s){const r=s instanceof Date?xl(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 ySt=10;class SGe{constructor(){Mn(this,"subPriority",0)}validate(s,r){return!0}}class vSt extends SGe{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 bSt extends SGe{constructor(){super(...arguments);Mn(this,"priority",ySt);Mn(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:xl(r,gSt(r,Date))}}class al{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new vSt(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class _St extends al{constructor(){super(...arguments);Mn(this,"priority",140);Mn(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}/},s0={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function Ld(t,s){return t&&{value:s(t.value),rest:t.rest}}function Jc(t,s){const r=s.match(t);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function r0(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*PO+o*Qde+l*a4t),rest:s.slice(r[0].length)}}function CGe(t){return Jc(Id.anyDigitsSigned,t)}function jd(t,s){switch(t){case 1:return Jc(Id.singleDigit,s);case 2:return Jc(Id.twoDigits,s);case 3:return Jc(Id.threeDigits,s);case 4:return Jc(Id.fourDigits,s);default:return Jc(new RegExp("^\\d{1,"+t+"}"),s)}}function joe(t,s){switch(t){case 1:return Jc(Id.singleDigitSigned,s);case 2:return Jc(Id.twoDigitsSigned,s);case 3:return Jc(Id.threeDigitsSigned,s);case 4:return Jc(Id.fourDigitsSigned,s);default:return Jc(new RegExp("^-?\\d{1,"+t+"}"),s)}}function gje(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 MGe(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 TGe(t){return t%400===0||t%4===0&&t%100!==0}class wSt extends al{constructor(){super(...arguments);Mn(this,"priority",130);Mn(this,"incompatibleTokens",["Y","R","u","w","I","i","e","c","t","T"])}parse(r,n,a){const o=l=>({year:l,isTwoDigitYear:n==="yy"});switch(n){case"y":return Ld(jd(4,r),o);case"yo":return Ld(a.ordinalNumber(r,{unit:"year"}),o);default:return Ld(jd(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a){const o=r.getFullYear();if(a.isTwoDigitYear){const i=MGe(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 jSt extends al{constructor(){super(...arguments);Mn(this,"priority",130);Mn(this,"incompatibleTokens",["y","R","u","Q","q","M","L","I","d","D","i","t","T"])}parse(r,n,a){const o=l=>({year:l,isTwoDigitYear:n==="YY"});switch(n){case"Y":return Ld(jd(4,r),o);case"Yo":return Ld(a.ordinalNumber(r,{unit:"year"}),o);default:return Ld(jd(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,o){const l=fje(r,o);if(a.isTwoDigitYear){const c=MGe(a.year,l);return r.setFullYear(c,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),Xh(r,o)}const i=!("era"in n)||n.era===1?a.year:1-a.year;return r.setFullYear(i,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),Xh(r,o)}}class NSt extends al{constructor(){super(...arguments);Mn(this,"priority",130);Mn(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return joe(n==="R"?4:n.length,r)}set(r,n,a){const o=xl(r,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),T1(o)}}class kSt extends al{constructor(){super(...arguments);Mn(this,"priority",130);Mn(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return joe(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class SSt extends al{constructor(){super(...arguments);Mn(this,"priority",120);Mn(this,"incompatibleTokens",["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"Q":case"QQ":return jd(n.length,r);case"Qo":return a.ordinalNumber(r,{unit:"quarter"});case"QQQ":return a.quarter(r,{width:"abbreviated",context:"formatting"})||a.quarter(r,{width:"narrow",context:"formatting"});case"QQQQQ":return a.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return a.quarter(r,{width:"wide",context:"formatting"})||a.quarter(r,{width:"abbreviated",context:"formatting"})||a.quarter(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=1&&n<=4}set(r,n,a){return r.setMonth((a-1)*3,1),r.setHours(0,0,0,0),r}}class CSt extends al{constructor(){super(...arguments);Mn(this,"priority",120);Mn(this,"incompatibleTokens",["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"q":case"qq":return jd(n.length,r);case"qo":return a.ordinalNumber(r,{unit:"quarter"});case"qqq":return a.quarter(r,{width:"abbreviated",context:"standalone"})||a.quarter(r,{width:"narrow",context:"standalone"});case"qqqqq":return a.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return a.quarter(r,{width:"wide",context:"standalone"})||a.quarter(r,{width:"abbreviated",context:"standalone"})||a.quarter(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=1&&n<=4}set(r,n,a){return r.setMonth((a-1)*3,1),r.setHours(0,0,0,0),r}}class MSt extends al{constructor(){super(...arguments);Mn(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);Mn(this,"priority",110)}parse(r,n,a){const o=l=>l-1;switch(n){case"M":return Ld(Jc(Id.month,r),o);case"MM":return Ld(jd(2,r),o);case"Mo":return Ld(a.ordinalNumber(r,{unit:"month"}),o);case"MMM":return a.month(r,{width:"abbreviated",context:"formatting"})||a.month(r,{width:"narrow",context:"formatting"});case"MMMMM":return a.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return a.month(r,{width:"wide",context:"formatting"})||a.month(r,{width:"abbreviated",context:"formatting"})||a.month(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.setMonth(a,1),r.setHours(0,0,0,0),r}}class TSt extends al{constructor(){super(...arguments);Mn(this,"priority",110);Mn(this,"incompatibleTokens",["Y","R","q","Q","M","w","I","D","i","e","c","t","T"])}parse(r,n,a){const o=l=>l-1;switch(n){case"L":return Ld(Jc(Id.month,r),o);case"LL":return Ld(jd(2,r),o);case"Lo":return Ld(a.ordinalNumber(r,{unit:"month"}),o);case"LLL":return a.month(r,{width:"abbreviated",context:"standalone"})||a.month(r,{width:"narrow",context:"standalone"});case"LLLLL":return a.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return a.month(r,{width:"wide",context:"standalone"})||a.month(r,{width:"abbreviated",context:"standalone"})||a.month(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.setMonth(a,1),r.setHours(0,0,0,0),r}}function ASt(t,s,r){const n=ra(t),a=xje(n,r)-s;return n.setDate(n.getDate()-a*7),n}class ESt extends al{constructor(){super(...arguments);Mn(this,"priority",100);Mn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,a){switch(n){case"w":return Jc(Id.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return jd(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,o){return Xh(ASt(r,a,o),o)}}function PSt(t,s){const r=ra(t),n=pje(r)-s;return r.setDate(r.getDate()-n*7),r}class ISt extends al{constructor(){super(...arguments);Mn(this,"priority",100);Mn(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 Jc(Id.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return jd(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return T1(PSt(r,a))}}const LSt=[31,28,31,30,31,30,31,31,30,31,30,31],DSt=[31,29,31,30,31,30,31,31,30,31,30,31];class OSt extends al{constructor(){super(...arguments);Mn(this,"priority",90);Mn(this,"subPriority",1);Mn(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"d":return Jc(Id.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return jd(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=TGe(a),l=r.getMonth();return o?n>=1&&n<=DSt[l]:n>=1&&n<=LSt[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class RSt extends al{constructor(){super(...arguments);Mn(this,"priority",90);Mn(this,"subpriority",1);Mn(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 Jc(Id.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return jd(n.length,r)}}validate(r,n){const a=r.getFullYear();return TGe(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 yje(t,s,r){var f,g,b,_;const n=Pw(),a=(r==null?void 0:r.weekStartsOn)??((g=(f=r==null?void 0:r.locale)==null?void 0:f.options)==null?void 0:g.weekStartsOn)??n.weekStartsOn??((_=(b=n.locale)==null?void 0:b.options)==null?void 0:_.weekStartsOn)??0,o=ra(t),l=o.getDay(),c=(s%7+7)%7,u=7-a,p=s<0||s>6?s-(l+u)%7:(c+u)%7-(l+u)%7;return El(o,p)}class FSt extends al{constructor(){super(...arguments);Mn(this,"priority",90);Mn(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=yje(r,a,o),r.setHours(0,0,0,0),r}}class zSt extends al{constructor(){super(...arguments);Mn(this,"priority",90);Mn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"])}parse(r,n,a,o){const l=i=>{const c=Math.floor((i-1)/7)*7;return(i+o.weekStartsOn+6)%7+c};switch(n){case"e":case"ee":return Ld(jd(n.length,r),l);case"eo":return Ld(a.ordinalNumber(r,{unit:"day"}),l);case"eee":return a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"eeeee":return a.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"eeee":default:return a.day(r,{width:"wide",context:"formatting"})||a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=6}set(r,n,a,o){return r=yje(r,a,o),r.setHours(0,0,0,0),r}}class BSt extends al{constructor(){super(...arguments);Mn(this,"priority",90);Mn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"])}parse(r,n,a,o){const l=i=>{const c=Math.floor((i-1)/7)*7;return(i+o.weekStartsOn+6)%7+c};switch(n){case"c":case"cc":return Ld(jd(n.length,r),l);case"co":return Ld(a.ordinalNumber(r,{unit:"day"}),l);case"ccc":return a.day(r,{width:"abbreviated",context:"standalone"})||a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"});case"ccccc":return a.day(r,{width:"narrow",context:"standalone"});case"cccccc":return a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"});case"cccc":default:return a.day(r,{width:"wide",context:"standalone"})||a.day(r,{width:"abbreviated",context:"standalone"})||a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=0&&n<=6}set(r,n,a,o){return r=yje(r,a,o),r.setHours(0,0,0,0),r}}function $St(t,s){const r=ra(t),n=hSt(r),a=s-n;return El(r,a)}class qSt extends al{constructor(){super(...arguments);Mn(this,"priority",90);Mn(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"])}parse(r,n,a){const o=l=>l===0?7:l;switch(n){case"i":case"ii":return jd(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return Ld(a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiii":return Ld(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return Ld(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return Ld(a.day(r,{width:"wide",context:"formatting"})||a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o)}}validate(r,n){return n>=1&&n<=7}set(r,n,a){return r=$St(r,a),r.setHours(0,0,0,0),r}}class USt extends al{constructor(){super(...arguments);Mn(this,"priority",80);Mn(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(gje(a),0,0,0),r}}class VSt extends al{constructor(){super(...arguments);Mn(this,"priority",80);Mn(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(gje(a),0,0,0),r}}class HSt extends al{constructor(){super(...arguments);Mn(this,"priority",80);Mn(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(gje(a),0,0,0),r}}class WSt extends al{constructor(){super(...arguments);Mn(this,"priority",70);Mn(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return Jc(Id.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return jd(n.length,r)}}validate(r,n){return n>=1&&n<=12}set(r,n,a){const o=r.getHours()>=12;return o&&a<12?r.setHours(a+12,0,0,0):!o&&a===12?r.setHours(0,0,0,0):r.setHours(a,0,0,0),r}}class GSt extends al{constructor(){super(...arguments);Mn(this,"priority",70);Mn(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,a){switch(n){case"H":return Jc(Id.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return jd(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class KSt extends al{constructor(){super(...arguments);Mn(this,"priority",70);Mn(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return Jc(Id.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return jd(n.length,r)}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.getHours()>=12&&a<12?r.setHours(a+12,0,0,0):r.setHours(a,0,0,0),r}}class ZSt extends al{constructor(){super(...arguments);Mn(this,"priority",70);Mn(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,a){switch(n){case"k":return Jc(Id.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return jd(n.length,r)}}validate(r,n){return n>=1&&n<=24}set(r,n,a){const o=a<=24?a%24:a;return r.setHours(o,0,0,0),r}}class YSt extends al{constructor(){super(...arguments);Mn(this,"priority",60);Mn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return Jc(Id.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return jd(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class XSt extends al{constructor(){super(...arguments);Mn(this,"priority",50);Mn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return Jc(Id.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return jd(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class QSt extends al{constructor(){super(...arguments);Mn(this,"priority",30);Mn(this,"incompatibleTokens",["t","T"])}parse(r,n){const a=o=>Math.trunc(o*Math.pow(10,-n.length+3));return Ld(jd(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class JSt extends al{constructor(){super(...arguments);Mn(this,"priority",10);Mn(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return r0(s0.basicOptionalMinutes,r);case"XX":return r0(s0.basic,r);case"XXXX":return r0(s0.basicOptionalSeconds,r);case"XXXXX":return r0(s0.extendedOptionalSeconds,r);case"XXX":default:return r0(s0.extended,r)}}set(r,n,a){return n.timestampIsSet?r:xl(r,r.getTime()-uw(r)-a)}}class eCt extends al{constructor(){super(...arguments);Mn(this,"priority",10);Mn(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return r0(s0.basicOptionalMinutes,r);case"xx":return r0(s0.basic,r);case"xxxx":return r0(s0.basicOptionalSeconds,r);case"xxxxx":return r0(s0.extendedOptionalSeconds,r);case"xxx":default:return r0(s0.extended,r)}}set(r,n,a){return n.timestampIsSet?r:xl(r,r.getTime()-uw(r)-a)}}class tCt extends al{constructor(){super(...arguments);Mn(this,"priority",40);Mn(this,"incompatibleTokens","*")}parse(r){return CGe(r)}set(r,n,a){return[xl(r,a*1e3),{timestampIsSet:!0}]}}class sCt extends al{constructor(){super(...arguments);Mn(this,"priority",20);Mn(this,"incompatibleTokens","*")}parse(r){return CGe(r)}set(r,n,a){return[xl(r,a),{timestampIsSet:!0}]}}const rCt={G:new _St,y:new wSt,Y:new jSt,R:new NSt,u:new kSt,Q:new SSt,q:new CSt,M:new MSt,L:new TSt,w:new ESt,I:new ISt,d:new OSt,D:new RSt,E:new FSt,e:new zSt,c:new BSt,i:new qSt,a:new USt,b:new VSt,B:new HSt,h:new WSt,H:new GSt,K:new KSt,k:new ZSt,m:new YSt,s:new XSt,S:new QSt,X:new JSt,x:new eCt,t:new tCt,T:new sCt},nCt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,aCt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,iCt=/^'([^]*?)'?$/,oCt=/''/g,lCt=/\S/,cCt=/[a-zA-Z]/;function vje(t,s,r,n){var j,w,k,S;const a=uSt(),o=a.locale??eue,l=a.firstWeekContainsDate??((w=(j=a.locale)==null?void 0:j.options)==null?void 0:w.firstWeekContainsDate)??1,i=a.weekStartsOn??((S=(k=a.locale)==null?void 0:k.options)==null?void 0:S.weekStartsOn)??0;if(s==="")return t===""?ra(r):xl(r,NaN);const c={firstWeekContainsDate:l,weekStartsOn:i,locale:o},u=[new bSt],p=s.match(aCt).map(M=>{const L=M[0];if(L in Ive){const I=Ive[L];return I(M,o.formatLong)}return M}).join("").match(nCt),f=[];for(let M of p){kGe(M)&&Lve(M,s,t),NGe(M)&&Lve(M,s,t);const L=M[0],I=rCt[L];if(I){const{incompatibleTokens:O}=I;if(Array.isArray(O)){const U=f.find(B=>O.includes(B.token)||B.token===L);if(U)throw new RangeError(`The format string mustn't contain \`${U.fullToken}\` and \`${M}\` at the same time`)}else if(I.incompatibleTokens==="*"&&f.length>0)throw new RangeError(`The format string mustn't contain \`${M}\` and any other token at the same time`);f.push({token:L,fullToken:M});const q=I.run(t,M,o.match,c);if(!q)return xl(r,NaN);u.push(q.setter),t=q.rest}else{if(L.match(cCt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+L+"`");if(M==="''"?M="'":L==="'"&&(M=dCt(M)),t.indexOf(M)===0)t=t.slice(M.length);else return xl(r,NaN)}}if(t.length>0&&lCt.test(t))return xl(r,NaN);const g=u.map(M=>M.priority).sort((M,L)=>L-M).filter((M,L,I)=>I.indexOf(M)===L).map(M=>u.filter(L=>L.priority===M).sort((L,I)=>I.subPriority-L.subPriority)).map(M=>M[0]);let b=ra(r);if(isNaN(b.getTime()))return xl(r,NaN);const _={};for(const M of g){if(!M.validate(b,c))return xl(r,NaN);const L=M.set(b,_,c);Array.isArray(L)?(b=L[0],Object.assign(_,L[1])):b=L}return xl(r,b)}function dCt(t){return t.match(iCt)[1].replace(oCt,"'")}function b0(t){return+ra(t)o-l);return r>=n&&r<=a}function hie(t,s){return El(t,-s)}function jm(t,s){const n=gCt(t);let a;if(n.date){const c=yCt(n.date,2);a=vCt(c.restDateString,c.year)}if(!a||isNaN(a.getTime()))return new Date(NaN);const o=a.getTime();let l=0,i;if(n.time&&(l=bCt(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=_Ct(n.timezone),isNaN(i))return new Date(NaN)}else{const c=new Date(o+l),u=new Date(0);return u.setFullYear(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),u.setHours(c.getUTCHours(),c.getUTCMinutes(),c.getUTCSeconds(),c.getUTCMilliseconds()),u}return new Date(o+l+i)}const tz={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},pCt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,fCt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,xCt=/^([+-])(\d{2})(?::?(\d{2}))?$/;function gCt(t){const s={},r=t.split(tz.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],tz.timeZoneDelimiter.test(s.date)&&(s.date=t.split(tz.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=tz.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function yCt(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 vCt(t,s){if(s===null)return new Date(NaN);const r=t.match(pCt);if(!r)return new Date(NaN);const n=!!r[4],a=qP(r[1]),o=qP(r[2])-1,l=qP(r[3]),i=qP(r[4]),c=qP(r[5])-1;if(n)return SCt(s,i,c)?wCt(s,i,c):new Date(NaN);{const u=new Date(0);return!NCt(s,o,l)||!kCt(s,a)?new Date(NaN):(u.setUTCFullYear(s,o,Math.max(a,l)),u)}}function qP(t){return t?parseInt(t):1}function bCt(t){const s=t.match(fCt);if(!s)return NaN;const r=Sxe(s[1]),n=Sxe(s[2]),a=Sxe(s[3]);return CCt(r,n,a)?r*PO+n*Qde+a*1e3:NaN}function Sxe(t){return t&&parseFloat(t.replace(",","."))||0}function _Ct(t){if(t==="Z")return 0;const s=t.match(xCt);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return MCt(n,a)?r*(n*PO+a*Qde):NaN}function wCt(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 jCt=[31,null,31,30,31,30,31,31,30,31,30,31];function AGe(t){return t%400===0||t%4===0&&t%100!==0}function NCt(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(jCt[s]||(AGe(t)?29:28))}function kCt(t,s){return s>=1&&s<=(AGe(t)?366:365)}function SCt(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function CCt(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function MCt(t,s){return s>=0&&s<=59}function Cxe(t,s){const r=ra(t),n=r.getFullYear(),a=r.getDate(),o=xl(t,0);o.setFullYear(n,s,15),o.setHours(0,0,0,0);const l=dSt(o);return r.setMonth(s,Math.min(a,l)),r}function qL(t,s){const r=ra(t);return r.setHours(s),r}function UL(t,s){const r=ra(t);return r.setMinutes(s),r}function m6e(t,s){const r=ra(t);return isNaN(+r)?xl(t,NaN):(r.setFullYear(s),r)}function y4(t,s){return Bm(t,-s)}var Ko;(function(t){t.assertEqual=a=>{};function s(a){}t.assertIs=s;function r(a){throw new Error}t.assertNever=r,t.arrayToEnum=a=>{const o={};for(const l of a)o[l]=l;return o},t.getValidEnumValues=a=>{const o=t.objectKeys(a).filter(i=>typeof a[a[i]]!="number"),l={};for(const i of o)l[i]=a[i];return t.objectValues(l)},t.objectValues=a=>t.objectKeys(a).map(function(o){return a[o]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const o=[];for(const l in a)Object.prototype.hasOwnProperty.call(a,l)&&o.push(l);return o},t.find=(a,o)=>{for(const l of a)if(o(l))return l},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,o=" | "){return a.map(l=>typeof l=="string"?`'${l}'`:l).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(a,o)=>typeof o=="bigint"?o.toString():o})(Ko||(Ko={}));var p6e;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})(p6e||(p6e={}));const ha=Ko.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Wb=t=>{switch(typeof t){case"undefined":return ha.undefined;case"string":return ha.string;case"number":return Number.isNaN(t)?ha.nan:ha.number;case"boolean":return ha.boolean;case"function":return ha.function;case"bigint":return ha.bigint;case"symbol":return ha.symbol;case"object":return Array.isArray(t)?ha.array:t===null?ha.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?ha.promise:typeof Map<"u"&&t instanceof Map?ha.map:typeof Set<"u"&&t instanceof Set?ha.set:typeof Date<"u"&&t instanceof Date?ha.date:ha.object;default:return ha.unknown}},on=Ko.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class C0 extends Error{get errors(){return this.issues}constructor(s){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=s}format(s){const r=s||function(o){return o.message},n={_errors:[]},a=o=>{for(const l of o.issues)if(l.code==="invalid_union")l.unionErrors.map(a);else if(l.code==="invalid_return_type")a(l.returnTypeError);else if(l.code==="invalid_arguments")a(l.argumentsError);else if(l.path.length===0)n._errors.push(r(l));else{let i=n,c=0;for(;cr.message){const r={},n=[];for(const a of this.issues)if(a.path.length>0){const o=a.path[0];r[o]=r[o]||[],r[o].push(s(a))}else n.push(s(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}C0.create=t=>new C0(t);const Dve=(t,s)=>{let r;switch(t.code){case on.invalid_type:t.received===ha.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case on.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Ko.jsonStringifyReplacer)}`;break;case on.unrecognized_keys:r=`Unrecognized key(s) in object: ${Ko.joinValues(t.keys,", ")}`;break;case on.invalid_union:r="Invalid input";break;case on.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Ko.joinValues(t.options)}`;break;case on.invalid_enum_value:r=`Invalid enum value. Expected ${Ko.joinValues(t.options)}, received '${t.received}'`;break;case on.invalid_arguments:r="Invalid function arguments";break;case on.invalid_return_type:r="Invalid function return type";break;case on.invalid_date:r="Invalid date";break;case on.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Ko.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case on.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 on.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 on.custom:r="Invalid input";break;case on.invalid_intersection_types:r="Intersection results could not be merged";break;case on.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case on.not_finite:r="Number must be finite";break;default:r=s.defaultError,Ko.assertNever(t)}return{message:r}};let TCt=Dve;function ACt(){return TCt}const ECt=t=>{const{data:s,path:r,errorMaps:n,issueData:a}=t,o=[...r,...a.path||[]],l={...a,path:o};if(a.message!==void 0)return{...a,path:o,message:a.message};let i="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)i=u(l,{data:s,defaultError:i}).message;return{...a,path:o,message:i}};function Xn(t,s){const r=ACt(),n=ECt({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Dve?void 0:Dve].filter(a=>!!a)});t.common.issues.push(n)}class Cf{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(s,r){const n=[];for(const a of r){if(a.status==="aborted")return Fi;a.status==="dirty"&&s.dirty(),n.push(a.value)}return{status:s.value,value:n}}static async mergeObjectAsync(s,r){const n=[];for(const a of r){const o=await a.key,l=await a.value;n.push({key:o,value:l})}return Cf.mergeObjectSync(s,n)}static mergeObjectSync(s,r){const n={};for(const a of r){const{key:o,value:l}=a;if(o.status==="aborted"||l.status==="aborted")return Fi;o.status==="dirty"&&s.dirty(),l.status==="dirty"&&s.dirty(),o.value!=="__proto__"&&(typeof l.value<"u"||a.alwaysSet)&&(n[o.value]=l.value)}return{status:s.value,value:n}}}const Fi=Object.freeze({status:"aborted"}),_I=t=>({status:"dirty",value:t}),$x=t=>({status:"valid",value:t}),f6e=t=>t.status==="aborted",x6e=t=>t.status==="dirty",OT=t=>t.status==="valid",Noe=t=>typeof Promise<"u"&&t instanceof Promise;var Na;(function(t){t.errToObj=s=>typeof s=="string"?{message:s}:s||{},t.toString=s=>typeof s=="string"?s:s==null?void 0:s.message})(Na||(Na={}));class hw{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 g6e=(t,s)=>{if(OT(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 C0(t.common.issues);return this._error=r,this._error}}};function io(t){if(!t)return{};const{errorMap:s,invalid_type_error:r,required_error:n,description:a}=t;if(s&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return s?{errorMap:s,description:a}:{errorMap:(l,i)=>{const{message:c}=t;return l.code==="invalid_enum_value"?{message:c??i.defaultError}:typeof i.data>"u"?{message:c??n??i.defaultError}:l.code!=="invalid_type"?{message:i.defaultError}:{message:c??r??i.defaultError}},description:a}}class Vo{get description(){return this._def.description}_getType(s){return Wb(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:Wb(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new Cf,ctx:{common:s.parent.common,data:s.data,parsedType:Wb(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(Noe(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:Wb(s)},a=this._parseSync({data:s,path:n.path,parent:n});return g6e(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:Wb(s)};if(!this["~standard"].async)try{const o=this._parseSync({data:s,path:[],parent:r});return OT(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=>OT(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:Wb(s)},a=this._parse({data:s,path:n.path,parent:n}),o=await(Noe(a)?a:Promise.resolve(a));return g6e(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:on.custom,...n(a)});return typeof Promise<"u"&&l instanceof Promise?l.then(c=>c?!0:(i(),!1)):l?!0:(i(),!1)})}refinement(s,r){return this._refinement((n,a)=>s(n)?!0:(a.addIssue(typeof r=="function"?r(n,a):r),!1))}_refinement(s){return new zT({schema:this,typeName:zi.ZodEffects,effect:{type:"refinement",refinement:s}})}superRefine(s){return this._refinement(s)}constructor(s){this.spa=this.safeParseAsync,this._def=s,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Y_.create(this,this._def)}nullable(){return BT.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return _0.create(this)}promise(){return Moe.create(this,this._def)}or(s){return Soe.create([this,s],this._def)}and(s){return Coe.create(this,s,this._def)}transform(s){return new zT({...io(this._def),schema:this,typeName:zi.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new zve({...io(this._def),innerType:this,defaultValue:r,typeName:zi.ZodDefault})}brand(){return new e3t({typeName:zi.ZodBranded,type:this,...io(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new Bve({...io(this._def),innerType:this,catchValue:r,typeName:zi.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return bje.create(this,s)}readonly(){return $ve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const PCt=/^c[^\s-]{8,}$/i,ICt=/^[0-9a-z]+$/,LCt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,DCt=/^[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,OCt=/^[a-z0-9_-]{21}$/i,RCt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,FCt=/^[-+]?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)?)??$/,zCt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,BCt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Mxe;const $Ct=/^(?:(?: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])$/,qCt=/^(?:(?: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])$/,UCt=/^(([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]))$/,VCt=/^(([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])$/,HCt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,WCt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,EGe="((\\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])))",GCt=new RegExp(`^${EGe}$`);function PGe(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 KCt(t){return new RegExp(`^${PGe(t)}$`)}function ZCt(t){let s=`${EGe}T${PGe(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 YCt(t,s){return!!((s==="v4"||!s)&&$Ct.test(t)||(s==="v6"||!s)&&UCt.test(t))}function XCt(t,s){if(!RCt.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 QCt(t,s){return!!((s==="v4"||!s)&&qCt.test(t)||(s==="v6"||!s)&&VCt.test(t))}class w_ extends Vo{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==ha.string){const o=this._getOrReturnCtx(s);return Xn(o,{code:on.invalid_type,expected:ha.string,received:o.parsedType}),Fi}const n=new Cf;let a;for(const o of this._def.checks)if(o.kind==="min")s.data.lengtho.value&&(a=this._getOrReturnCtx(s,a),Xn(a,{code:on.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:on.invalid_string,...Na.errToObj(n)})}_addCheck(s){return new w_({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...Na.errToObj(s)})}url(s){return this._addCheck({kind:"url",...Na.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...Na.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...Na.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...Na.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...Na.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...Na.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...Na.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...Na.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",...Na.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",...Na.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...Na.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",...Na.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,...Na.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,...Na.errToObj(s==null?void 0:s.message)})}duration(s){return this._addCheck({kind:"duration",...Na.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,...Na.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r==null?void 0:r.position,...Na.errToObj(r==null?void 0:r.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,...Na.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,...Na.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,...Na.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,...Na.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,...Na.errToObj(r)})}nonempty(s){return this.min(1,Na.errToObj(s))}trim(){return new w_({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new w_({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new w_({...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 w_({checks:[],typeName:zi.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...io(t)});function JCt(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 RT extends Vo{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(s){if(this._def.coerce&&(s.data=Number(s.data)),this._getType(s)!==ha.number){const o=this._getOrReturnCtx(s);return Xn(o,{code:on.invalid_type,expected:ha.number,received:o.parsedType}),Fi}let n;const a=new Cf;for(const o of this._def.checks)o.kind==="int"?Ko.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),Xn(n,{code:on.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),Xn(n,{code:on.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?JCt(s.data,o.value)!==0&&(n=this._getOrReturnCtx(s,n),Xn(n,{code:on.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),Xn(n,{code:on.not_finite,message:o.message}),a.dirty()):Ko.assertNever(o);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,Na.toString(r))}gt(s,r){return this.setLimit("min",s,!1,Na.toString(r))}lte(s,r){return this.setLimit("max",s,!0,Na.toString(r))}lt(s,r){return this.setLimit("max",s,!1,Na.toString(r))}setLimit(s,r,n,a){return new RT({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:Na.toString(a)}]})}_addCheck(s){return new RT({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:Na.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Na.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Na.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Na.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Na.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:Na.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:Na.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Na.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Na.toString(s)})}get minValue(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxValue(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.values.kind==="int"||s.kind==="multipleOf"&&Ko.isInteger(s.value))}get isFinite(){let s=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(s===null||n.valuenew RT({checks:[],typeName:zi.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...io(t)});class Q8 extends Vo{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(s){if(this._def.coerce)try{s.data=BigInt(s.data)}catch{return this._getInvalidInput(s)}if(this._getType(s)!==ha.bigint)return this._getInvalidInput(s);let n;const a=new Cf;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),Xn(n,{code:on.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),Xn(n,{code:on.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):Ko.assertNever(o);return{status:a.value,value:s.data}}_getInvalidInput(s){const r=this._getOrReturnCtx(s);return Xn(r,{code:on.invalid_type,expected:ha.bigint,received:r.parsedType}),Fi}gte(s,r){return this.setLimit("min",s,!0,Na.toString(r))}gt(s,r){return this.setLimit("min",s,!1,Na.toString(r))}lte(s,r){return this.setLimit("max",s,!0,Na.toString(r))}lt(s,r){return this.setLimit("max",s,!1,Na.toString(r))}setLimit(s,r,n,a){return new Q8({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:Na.toString(a)}]})}_addCheck(s){return new Q8({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Na.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Na.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Na.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Na.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:Na.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 Q8({checks:[],typeName:zi.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...io(t)});class Ove extends Vo{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==ha.boolean){const n=this._getOrReturnCtx(s);return Xn(n,{code:on.invalid_type,expected:ha.boolean,received:n.parsedType}),Fi}return $x(s.data)}}Ove.create=t=>new Ove({typeName:zi.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...io(t)});class koe extends Vo{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==ha.date){const o=this._getOrReturnCtx(s);return Xn(o,{code:on.invalid_type,expected:ha.date,received:o.parsedType}),Fi}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return Xn(o,{code:on.invalid_date}),Fi}const n=new Cf;let a;for(const o of this._def.checks)o.kind==="min"?s.data.getTime()o.value&&(a=this._getOrReturnCtx(s,a),Xn(a,{code:on.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Ko.assertNever(o);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new koe({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:Na.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:Na.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 koe({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:zi.ZodDate,...io(t)});class y6e extends Vo{_parse(s){if(this._getType(s)!==ha.symbol){const n=this._getOrReturnCtx(s);return Xn(n,{code:on.invalid_type,expected:ha.symbol,received:n.parsedType}),Fi}return $x(s.data)}}y6e.create=t=>new y6e({typeName:zi.ZodSymbol,...io(t)});class v6e extends Vo{_parse(s){if(this._getType(s)!==ha.undefined){const n=this._getOrReturnCtx(s);return Xn(n,{code:on.invalid_type,expected:ha.undefined,received:n.parsedType}),Fi}return $x(s.data)}}v6e.create=t=>new v6e({typeName:zi.ZodUndefined,...io(t)});class b6e extends Vo{_parse(s){if(this._getType(s)!==ha.null){const n=this._getOrReturnCtx(s);return Xn(n,{code:on.invalid_type,expected:ha.null,received:n.parsedType}),Fi}return $x(s.data)}}b6e.create=t=>new b6e({typeName:zi.ZodNull,...io(t)});class _6e extends Vo{constructor(){super(...arguments),this._any=!0}_parse(s){return $x(s.data)}}_6e.create=t=>new _6e({typeName:zi.ZodAny,...io(t)});class w6e extends Vo{constructor(){super(...arguments),this._unknown=!0}_parse(s){return $x(s.data)}}w6e.create=t=>new w6e({typeName:zi.ZodUnknown,...io(t)});class mw extends Vo{_parse(s){const r=this._getOrReturnCtx(s);return Xn(r,{code:on.invalid_type,expected:ha.never,received:r.parsedType}),Fi}}mw.create=t=>new mw({typeName:zi.ZodNever,...io(t)});class j6e extends Vo{_parse(s){if(this._getType(s)!==ha.undefined){const n=this._getOrReturnCtx(s);return Xn(n,{code:on.invalid_type,expected:ha.void,received:n.parsedType}),Fi}return $x(s.data)}}j6e.create=t=>new j6e({typeName:zi.ZodVoid,...io(t)});class _0 extends Vo{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==ha.array)return Xn(r,{code:on.invalid_type,expected:ha.array,received:r.parsedType}),Fi;if(a.exactLength!==null){const l=r.data.length>a.exactLength.value,i=r.data.lengtha.maxLength.value&&(Xn(r,{code:on.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 hw(r,l,r.path,i)))).then(l=>Cf.mergeArray(n,l));const o=[...r.data].map((l,i)=>a.type._parseSync(new hw(r,l,r.path,i)));return Cf.mergeArray(n,o)}get element(){return this._def.type}min(s,r){return new _0({...this._def,minLength:{value:s,message:Na.toString(r)}})}max(s,r){return new _0({...this._def,maxLength:{value:s,message:Na.toString(r)}})}length(s,r){return new _0({...this._def,exactLength:{value:s,message:Na.toString(r)}})}nonempty(s){return this.min(1,s)}}_0.create=(t,s)=>new _0({type:t,minLength:null,maxLength:null,exactLength:null,typeName:zi.ZodArray,...io(s)});function F5(t){if(t instanceof Yd){const s={};for(const r in t.shape){const n=t.shape[r];s[r]=Y_.create(F5(n))}return new Yd({...t._def,shape:()=>s})}else return t instanceof _0?new _0({...t._def,type:F5(t.element)}):t instanceof Y_?Y_.create(F5(t.unwrap())):t instanceof BT?BT.create(F5(t.unwrap())):t instanceof VS?VS.create(t.items.map(s=>F5(s))):t}class Yd extends Vo{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const s=this._def.shape(),r=Ko.objectKeys(s);return this._cached={shape:s,keys:r},this._cached}_parse(s){if(this._getType(s)!==ha.object){const u=this._getOrReturnCtx(s);return Xn(u,{code:on.invalid_type,expected:ha.object,received:u.parsedType}),Fi}const{status:n,ctx:a}=this._processInputParams(s),{shape:o,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof mw&&this._def.unknownKeys==="strip"))for(const u in a.data)l.includes(u)||i.push(u);const c=[];for(const u of l){const p=o[u],f=a.data[u];c.push({key:{status:"valid",value:u},value:p._parse(new hw(a,f,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof mw){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of i)c.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(u==="strict")i.length>0&&(Xn(a,{code:on.unrecognized_keys,keys:i}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const p of i){const f=a.data[p];c.push({key:{status:"valid",value:p},value:u._parse(new hw(a,f,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of c){const f=await p.key,g=await p.value;u.push({key:f,value:g,alwaysSet:p.alwaysSet})}return u}).then(u=>Cf.mergeObjectSync(n,u)):Cf.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(s){return Na.errToObj,new Yd({...this._def,unknownKeys:"strict",...s!==void 0?{errorMap:(r,n)=>{var o,l;const a=((l=(o=this._def).errorMap)==null?void 0:l.call(o,r,n).message)??n.defaultError;return r.code==="unrecognized_keys"?{message:Na.errToObj(s).message??a}:{message:a}}}:{}})}strip(){return new Yd({...this._def,unknownKeys:"strip"})}passthrough(){return new Yd({...this._def,unknownKeys:"passthrough"})}extend(s){return new Yd({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new Yd({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:zi.ZodObject})}setKey(s,r){return this.augment({[s]:r})}catchall(s){return new Yd({...this._def,catchall:s})}pick(s){const r={};for(const n of Ko.objectKeys(s))s[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Yd({...this._def,shape:()=>r})}omit(s){const r={};for(const n of Ko.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new Yd({...this._def,shape:()=>r})}deepPartial(){return F5(this)}partial(s){const r={};for(const n of Ko.objectKeys(this.shape)){const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}return new Yd({...this._def,shape:()=>r})}required(s){const r={};for(const n of Ko.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof Y_;)o=o._def.innerType;r[n]=o}return new Yd({...this._def,shape:()=>r})}keyof(){return IGe(Ko.objectKeys(this.shape))}}Yd.create=(t,s)=>new Yd({shape:()=>t,unknownKeys:"strip",catchall:mw.create(),typeName:zi.ZodObject,...io(s)});Yd.strictCreate=(t,s)=>new Yd({shape:()=>t,unknownKeys:"strict",catchall:mw.create(),typeName:zi.ZodObject,...io(s)});Yd.lazycreate=(t,s)=>new Yd({shape:t,unknownKeys:"strip",catchall:mw.create(),typeName:zi.ZodObject,...io(s)});class Soe extends Vo{_parse(s){const{ctx:r}=this._processInputParams(s),n=this._def.options;function a(o){for(const i of o)if(i.result.status==="valid")return i.result;for(const i of o)if(i.result.status==="dirty")return r.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(i=>new C0(i.ctx.common.issues));return Xn(r,{code:on.invalid_union,unionErrors:l}),Fi}if(r.common.async)return Promise.all(n.map(async o=>{const l={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:l}),ctx:l}})).then(a);{let o;const l=[];for(const c of n){const u={...r,common:{...r.common,issues:[]},parent:null},p=c._parseSync({data:r.data,path:r.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!o&&(o={result:p,ctx:u}),u.common.issues.length&&l.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;const i=l.map(c=>new C0(c));return Xn(r,{code:on.invalid_union,unionErrors:i}),Fi}}get options(){return this._def.options}}Soe.create=(t,s)=>new Soe({options:t,typeName:zi.ZodUnion,...io(s)});function Rve(t,s){const r=Wb(t),n=Wb(s);if(t===s)return{valid:!0,data:t};if(r===ha.object&&n===ha.object){const a=Ko.objectKeys(s),o=Ko.objectKeys(t).filter(i=>a.indexOf(i)!==-1),l={...t,...s};for(const i of o){const c=Rve(t[i],s[i]);if(!c.valid)return{valid:!1};l[i]=c.data}return{valid:!0,data:l}}else if(r===ha.array&&n===ha.array){if(t.length!==s.length)return{valid:!1};const a=[];for(let o=0;o{if(f6e(o)||f6e(l))return Fi;const i=Rve(o.value,l.value);return i.valid?((x6e(o)||x6e(l))&&r.dirty(),{status:r.value,value:i.data}):(Xn(n,{code:on.invalid_intersection_types}),Fi)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,l])=>a(o,l)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Coe.create=(t,s,r)=>new Coe({left:t,right:s,typeName:zi.ZodIntersection,...io(r)});class VS extends Vo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ha.array)return Xn(n,{code:on.invalid_type,expected:ha.array,received:n.parsedType}),Fi;if(n.data.lengththis._def.items.length&&(Xn(n,{code:on.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const o=[...n.data].map((l,i)=>{const c=this._def.items[i]||this._def.rest;return c?c._parse(new hw(n,l,n.path,i)):null}).filter(l=>!!l);return n.common.async?Promise.all(o).then(l=>Cf.mergeArray(r,l)):Cf.mergeArray(r,o)}get items(){return this._def.items}rest(s){return new VS({...this._def,rest:s})}}VS.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new VS({items:t,typeName:zi.ZodTuple,rest:null,...io(s)})};class N6e extends Vo{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ha.map)return Xn(n,{code:on.invalid_type,expected:ha.map,received:n.parsedType}),Fi;const a=this._def.keyType,o=this._def.valueType,l=[...n.data.entries()].map(([i,c],u)=>({key:a._parse(new hw(n,i,n.path,[u,"key"])),value:o._parse(new hw(n,c,n.path,[u,"value"]))}));if(n.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const c of l){const u=await c.key,p=await c.value;if(u.status==="aborted"||p.status==="aborted")return Fi;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}})}else{const i=new Map;for(const c of l){const u=c.key,p=c.value;if(u.status==="aborted"||p.status==="aborted")return Fi;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}}}}N6e.create=(t,s,r)=>new N6e({valueType:s,keyType:t,typeName:zi.ZodMap,...io(r)});class J8 extends Vo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ha.set)return Xn(n,{code:on.invalid_type,expected:ha.set,received:n.parsedType}),Fi;const a=this._def;a.minSize!==null&&n.data.sizea.maxSize.value&&(Xn(n,{code:on.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const o=this._def.valueType;function l(c){const u=new Set;for(const p of c){if(p.status==="aborted")return Fi;p.status==="dirty"&&r.dirty(),u.add(p.value)}return{status:r.value,value:u}}const i=[...n.data.values()].map((c,u)=>o._parse(new hw(n,c,n.path,u)));return n.common.async?Promise.all(i).then(c=>l(c)):l(i)}min(s,r){return new J8({...this._def,minSize:{value:s,message:Na.toString(r)}})}max(s,r){return new J8({...this._def,maxSize:{value:s,message:Na.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}J8.create=(t,s)=>new J8({valueType:t,minSize:null,maxSize:null,typeName:zi.ZodSet,...io(s)});class k6e extends Vo{get schema(){return this._def.getter()}_parse(s){const{ctx:r}=this._processInputParams(s);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}k6e.create=(t,s)=>new k6e({getter:t,typeName:zi.ZodLazy,...io(s)});class Fve extends Vo{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return Xn(r,{received:r.data,code:on.invalid_literal,expected:this._def.value}),Fi}return{status:"valid",value:s.data}}get value(){return this._def.value}}Fve.create=(t,s)=>new Fve({value:t,typeName:zi.ZodLiteral,...io(s)});function IGe(t,s){return new FT({values:t,typeName:zi.ZodEnum,...io(s)})}class FT extends Vo{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return Xn(r,{expected:Ko.joinValues(n),received:r.parsedType,code:on.invalid_type}),Fi}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(s.data)){const r=this._getOrReturnCtx(s),n=this._def.values;return Xn(r,{received:r.data,code:on.invalid_enum_value,options:n}),Fi}return $x(s.data)}get options(){return this._def.values}get enum(){const s={};for(const r of this._def.values)s[r]=r;return s}get Values(){const s={};for(const r of this._def.values)s[r]=r;return s}get Enum(){const s={};for(const r of this._def.values)s[r]=r;return s}extract(s,r=this._def){return FT.create(s,{...this._def,...r})}exclude(s,r=this._def){return FT.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}FT.create=IGe;class S6e extends Vo{_parse(s){const r=Ko.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==ha.string&&n.parsedType!==ha.number){const a=Ko.objectValues(r);return Xn(n,{expected:Ko.joinValues(a),received:n.parsedType,code:on.invalid_type}),Fi}if(this._cache||(this._cache=new Set(Ko.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=Ko.objectValues(r);return Xn(n,{received:n.data,code:on.invalid_enum_value,options:a}),Fi}return $x(s.data)}get enum(){return this._def.values}}S6e.create=(t,s)=>new S6e({values:t,typeName:zi.ZodNativeEnum,...io(s)});class Moe extends Vo{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==ha.promise&&r.common.async===!1)return Xn(r,{code:on.invalid_type,expected:ha.promise,received:r.parsedType}),Fi;const n=r.parsedType===ha.promise?r.data:Promise.resolve(r.data);return $x(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Moe.create=(t,s)=>new Moe({type:t,typeName:zi.ZodPromise,...io(s)});class zT extends Vo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===zi.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(s){const{status:r,ctx:n}=this._processInputParams(s),a=this._def.effect||null,o={addIssue:l=>{Xn(n,l),l.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),a.type==="preprocess"){const l=a.transform(n.data,o);if(n.common.async)return Promise.resolve(l).then(async i=>{if(r.value==="aborted")return Fi;const c=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return c.status==="aborted"?Fi:c.status==="dirty"||r.value==="dirty"?_I(c.value):c});{if(r.value==="aborted")return Fi;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?Fi:i.status==="dirty"||r.value==="dirty"?_I(i.value):i}}if(a.type==="refinement"){const l=i=>{const c=a.refinement(i,o);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Fi:(i.status==="dirty"&&r.dirty(),l(i.value),{status:r.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?Fi:(i.status==="dirty"&&r.dirty(),l(i.value).then(()=>({status:r.value,value:i.value}))))}if(a.type==="transform")if(n.common.async===!1){const l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!OT(l))return Fi;const i=a.transform(l.value,o);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>OT(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):Fi);Ko.assertNever(a)}}zT.create=(t,s,r)=>new zT({schema:t,typeName:zi.ZodEffects,effect:s,...io(r)});zT.createWithPreprocess=(t,s,r)=>new zT({schema:s,effect:{type:"preprocess",transform:t},typeName:zi.ZodEffects,...io(r)});class Y_ extends Vo{_parse(s){return this._getType(s)===ha.undefined?$x(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}Y_.create=(t,s)=>new Y_({innerType:t,typeName:zi.ZodOptional,...io(s)});class BT extends Vo{_parse(s){return this._getType(s)===ha.null?$x(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}BT.create=(t,s)=>new BT({innerType:t,typeName:zi.ZodNullable,...io(s)});class zve extends Vo{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===ha.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}zve.create=(t,s)=>new zve({innerType:t,typeName:zi.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...io(s)});class Bve extends Vo{_parse(s){const{ctx:r}=this._processInputParams(s),n={...r,common:{...r.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Noe(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new C0(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new C0(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Bve.create=(t,s)=>new Bve({innerType:t,typeName:zi.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...io(s)});class C6e extends Vo{_parse(s){if(this._getType(s)!==ha.nan){const n=this._getOrReturnCtx(s);return Xn(n,{code:on.invalid_type,expected:ha.nan,received:n.parsedType}),Fi}return{status:"valid",value:s.data}}}C6e.create=t=>new C6e({typeName:zi.ZodNaN,...io(t)});class e3t extends Vo{_parse(s){const{ctx:r}=this._processInputParams(s),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class bje extends Vo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Fi:o.status==="dirty"?(r.dirty(),_I(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Fi:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(s,r){return new bje({in:s,out:r,typeName:zi.ZodPipeline})}}class $ve extends Vo{_parse(s){const r=this._def.innerType._parse(s),n=a=>(OT(a)&&(a.value=Object.freeze(a.value)),a);return Noe(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}$ve.create=(t,s)=>new $ve({innerType:t,typeName:zi.ZodReadonly,...io(s)});var zi;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(zi||(zi={}));const gc=w_.create,VL=RT.create,t3t=Ove.create;mw.create;_0.create;const gC=Yd.create;Soe.create;Coe.create;VS.create;const Toe=Fve.create,LGe=FT.create;Moe.create;Y_.create;BT.create;const Er=N.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{className:It("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...s}));Er.displayName="Textarea";const s3t=["Excellent","Good","Neutral","Bad","Very Bad"],r3t=[5,4,3,2,1];function n3t({questions:t,visitorId:s,onComplete:r,onSkip:n}){const a=Wkt(),[o,l]=N.useState({}),i=t.filter(g=>g.question_type==="rating"),c=t.filter(g=>g.question_type!=="rating"),u=(g,b)=>{l(_=>({..._,[g]:{rating_value:b}}))},p=(g,b)=>{l(_=>({..._,[g]:{text_value:b}}))},f=async()=>{const g=Object.entries(o).filter(([,b])=>b.rating_value!=null||b.text_value&&b.text_value.trim()).map(([b,_])=>{var j;return{visitor_id:s,question_id:b,rating_value:_.rating_value??null,text_value:((j=_.text_value)==null?void 0:j.trim())||null}});if(g.length>0)try{await a.mutateAsync(g)}catch{}r()};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"Quick Feedback"}),e.jsx("button",{onClick:n,className:"text-sm text-slate-400 hover:text-slate-600 underline",children:"Skip"})]}),e.jsx("p",{className:"text-sm text-slate-500 -mt-2",children:"Your feedback helps the agent — totally optional!"}),i.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"flex-1"}),s3t.map(g=>e.jsx("div",{className:"w-12 text-center",children:e.jsx("span",{className:"text-[10px] text-slate-400 leading-tight block",children:g})},g))]}),i.map(g=>e.jsxs("div",{className:"flex items-center gap-1 py-1.5 border-b border-slate-100 last:border-0",children:[e.jsx("span",{className:"flex-1 text-sm text-slate-700 pr-2",children:g.question_text}),r3t.map(b=>{var _;return e.jsx("div",{className:"w-12 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>u(g.id,b),className:`w-6 h-6 rounded-full border-2 transition-all ${((_=o[g.id])==null?void 0:_.rating_value)===b?"bg-slate-900 border-slate-900":"border-slate-300 hover:border-slate-500"}`})},b)})]},g.id))]}),c.map(g=>{var b;return e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 block mb-1",children:g.question_text}),e.jsx(Er,{value:((b=o[g.id])==null?void 0:b.text_value)||"",onChange:_=>p(g.id,_.target.value),placeholder:"Your thoughts...",className:"h-16 text-sm resize-none rounded-xl border-slate-200"})]},g.id)}),e.jsx(K,{onClick:f,disabled:a.isPending,className:"w-full h-12 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:a.isPending?e.jsx(ws,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}const a3t=gC({first_name:gc().trim().min(1,"First name is required").max(50),last_name:gc().trim().max(50).optional(),email:gc().trim().email("Please enter a valid email").max(255).optional().or(Toe("")),phone:gc().trim().max(20).optional().or(Toe(""))}),i3t=[{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 DGe({slug:t}={}){var re;const s=yo(),r=t||s.slug,{data:n,isLoading:a,error:o}=Ukt(r),l=Qkt(),[i,c]=N.useState("welcome"),[u,p]=N.useState(null),[f,g]=N.useState({first_name:"",last_name:"",email:"",phone:""}),[b,_]=N.useState(""),[j,w]=N.useState(!1),[k,S]=N.useState(!1),[M,L]=N.useState(""),[I,O]=N.useState(""),{data:q,isLoading:U}=Hkt(n==null?void 0:n.id),B=!!(n!=null&&n.enable_survey);N.useEffect(()=>{i==="pending_survey"&&(U||c(B&&((q==null?void 0:q.length)??0)>0?"survey":"done"))},[i,U,B,q]);const V=oe=>{if(!oe)return"";const[ce,xe]=oe.split(":"),ge=parseInt(ce),ue=ge>=12?"PM":"AM";return`${ge>12?ge-12:ge||12}:${xe} ${ue}`},Z=()=>{O("");const oe=a3t.safeParse(f);if(!oe.success){O(oe.error.issues[0].message);return}if(!f.email&&!f.phone){O("Please provide either an email or phone number");return}c("intent")},X=async oe=>{_(oe);try{const ce=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:oe,wants_market_updates:j,has_agent:k,working_with_agent_name:k&&M.trim()?M.trim():void 0});p(ce.id),B?!U&&q&&q.length>0?c("survey"):c("pending_survey"):c("done")}catch{O("Something went wrong. Please try again.")}};if(a)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center",children:e.jsx("div",{className:"w-10 h-10 border-4 border-white/20 border-t-white rounded-full animate-spin"})});if(o||!n)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(bn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Open House Not Found"}),e.jsx("p",{className:"text-white/60",children:"This sign-in page doesn't exist or is no longer active."})]})});const ee=n.profiles,Q=((re=ee==null?void 0:ee.name)==null?void 0:re.split(" ").map(oe=>oe[0]).join("").slice(0,2))||"?",ie=n.event_type==="community";return e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsxs("title",{children:[ie?"Community Event":"Open House"," | ",n.property_address]}),e.jsx("meta",{name:"description",content:`Sign in to the ${ie?"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(Nn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[e.jsx($a,{src:(ee==null?void 0:ee.avatar_url)||"",alt:(ee==null?void 0:ee.name)||""}),e.jsx(kn,{className:"bg-white/10 text-white text-lg",children:Q})]}),e.jsx("p",{className:"text-white/60 text-sm",children:ee==null?void 0:ee.name}),(ee==null?void 0:ee.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:ee.title})]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl overflow-hidden",children:[n.photo_url&&e.jsxs("div",{className:"relative h-44 sm:h-52 overflow-hidden",children:[e.jsx("img",{src:n.photo_url,alt:n.property_address,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-900/80 via-slate-900/20 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 px-6 pb-4",children:[e.jsx("h1",{className:"text-white font-bold text-lg leading-tight drop-shadow-md",children:n.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-1.5 text-white/70 text-xs",children:[n.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"}),n.city,n.state?`, ${n.state}`:""," ",n.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(n.event_date+"T00:00:00"),"MMM d, yyyy")]}),n.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),V(n.start_time),n.end_time?` – ${V(n.end_time)}`:""]})]})]})]}),!n.photo_url&&e.jsx("div",{className:"bg-gradient-to-r from-slate-800 to-slate-700 px-6 py-5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/10 flex items-center justify-center shrink-0 mt-0.5",children:ie?e.jsx(ka,{className:"h-5 w-5 text-white"}):e.jsx(bn,{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(ma,{className:"h-3 w-3"}),n.city,n.state?`, ${n.state}`:""," ",n.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(n.event_date+"T00:00:00"),"MMM d, yyyy")]}),n.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),V(n.start_time),n.end_time?` – ${V(n.end_time)}`:""]})]})]})]})}),e.jsxs("div",{className:"p-6",children:[i==="welcome"&&e.jsxs("div",{className:"text-center space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-slate-900 mb-2",children:"Welcome!"}),e.jsx("p",{className:"text-slate-500 text-sm",children:n.agent_greeting||"Please sign in below."})]}),e.jsxs(K,{onClick:()=>c("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",e.jsx(Qa,{className:"h-5 w-5 ml-2"})]}),e.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),i==="info"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{onClick:()=>c("welcome"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Ja,{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(ze,{value:f.first_name,onChange:oe=>g(ce=>({...ce,first_name:oe.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(ze,{value:f.last_name,onChange:oe=>g(ce=>({...ce,last_name:oe.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(ze,{type:"email",value:f.email,onChange:oe=>g(ce=>({...ce,email:oe.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(ze,{type:"tel",value:f.phone,onChange:oe=>g(ce=>({...ce,phone:oe.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:oe=>w(oe.target.checked),className:"rounded border-slate-300 text-slate-900 focus:ring-slate-500"}),e.jsx("span",{className:"text-sm text-slate-600",children:"Send me market updates for this area"})]}),e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-slate-600",children:"Already working with an agent?"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-slate-400",children:k?"Yes":"No"}),e.jsx(qr,{checked:k,onCheckedChange:S})]})]}),k&&e.jsx(ze,{value:M,onChange:oe=>L(oe.target.value),placeholder:"Agent's name",className:"mt-1 h-10 rounded-xl border-slate-200 text-sm"})]}),I&&e.jsx("p",{className:"text-destructive text-sm",children:I}),e.jsxs(K,{onClick:Z,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(Qa,{className:"h-5 w-5 ml-2"})]})]}),i==="intent"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{onClick:()=>c("info"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Ja,{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:i3t.map(oe=>e.jsxs("button",{onClick:()=>X(oe.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:oe.emoji}),e.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:oe.label})]},oe.value))}),I&&e.jsx("p",{className:"text-destructive text-sm text-center",children:I})]}),i==="pending_survey"&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-3",children:[e.jsx("div",{className:"w-8 h-8 border-[3px] border-slate-200 border-t-slate-900 rounded-full animate-spin"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading survey..."})]}),i==="survey"&&u&&q&&e.jsx(n3t,{questions:q,visitorId:u,onComplete:()=>c("done"),onSkip:()=>c("done")}),i==="done"&&e.jsxs("div",{className:"text-center space-y-4 py-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-green-100 flex items-center justify-center mx-auto",children:e.jsx(sa,{className:"h-8 w-8 text-green-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-slate-900",children:"You're all set!"}),e.jsxs("p",{className:"text-slate-500 text-sm mt-1",children:["Thanks for signing in, ",f.first_name,". ",ie?"Enjoy the event!":"Enjoy the open house!"]})]}),(ee==null?void 0:ee.name)&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:ee.name})]})]})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function DMs(t){const{user:s}=Ds();return mt({queryKey:["cohost-tokens",t],queryFn:async()=>{const{data:r,error:n}=await H.from("open_house_cohost_tokens").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(n)throw n;return r},enabled:!!s&&!!t})}function OMs(){const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async({openHouseId:r,label:n})=>{const{data:a,error:o}=await H.from("open_house_cohost_tokens").insert({open_house_id:r,label:n||null,created_by:s.id,expires_at:new Date(Date.now()+864e5).toISOString()}).select().single();if(o)throw o;return a},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["cohost-tokens",n.openHouseId]})}})}function RMs(){const t=Qt();return Dt({mutationFn:async({id:s,openHouseId:r})=>{const{error:n}=await H.from("open_house_cohost_tokens").update({is_active:!1}).eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["cohost-tokens",r.openHouseId]})}})}function o3t(t){return mt({queryKey:["cohost-validate",t],queryFn:async()=>{const{data:s,error:r}=await H.from("open_house_cohost_tokens").select("*, open_houses(*)").eq("token",t).eq("is_active",!0).single();if(r)throw r;if(s.expires_at&&new Date(s.expires_at)s[r][n]??r,t)}var _je="ScrollArea",[OGe]=ad(_je),[c3t,qx]=OGe(_je),RGe=N.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,c]=N.useState(null),[u,p]=N.useState(null),[f,g]=N.useState(null),[b,_]=N.useState(null),[j,w]=N.useState(null),[k,S]=N.useState(0),[M,L]=N.useState(0),[I,O]=N.useState(!1),[q,U]=N.useState(!1),B=qa(s,Z=>c(Z)),V=Mw(a);return e.jsx(c3t,{scope:r,type:n,dir:V,scrollHideDelay:o,scrollArea:i,viewport:u,onViewportChange:p,content:f,onContentChange:g,scrollbarX:b,onScrollbarXChange:_,scrollbarXEnabled:I,onScrollbarXEnabledChange:O,scrollbarY:j,onScrollbarYChange:w,scrollbarYEnabled:q,onScrollbarYEnabledChange:U,onCornerWidthChange:S,onCornerHeightChange:L,children:e.jsx(nn.div,{dir:V,...l,ref:B,style:{position:"relative","--radix-scroll-area-corner-width":k+"px","--radix-scroll-area-corner-height":M+"px",...t.style}})})});RGe.displayName=_je;var FGe="ScrollAreaViewport",zGe=N.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=qx(FGe,r),i=N.useRef(null),c=qa(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(nn.div,{"data-radix-scroll-area-viewport":"",...o,ref:c,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...t.style},children:e.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});zGe.displayName=FGe;var F0="ScrollAreaScrollbar",wje=N.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=qx(F0,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=t.orientation==="horizontal";return N.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?e.jsx(d3t,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(u3t,{...n,ref:s,forceMount:r}):a.type==="auto"?e.jsx(BGe,{...n,ref:s,forceMount:r}):a.type==="always"?e.jsx(jje,{...n,ref:s}):null});wje.displayName=F0;var d3t=N.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=qx(F0,t.__scopeScrollArea),[o,l]=N.useState(!1);return N.useEffect(()=>{const i=a.scrollArea;let c=0;if(i){const u=()=>{window.clearTimeout(c),l(!0)},p=()=>{c=window.setTimeout(()=>l(!1),a.scrollHideDelay)};return i.addEventListener("pointerenter",u),i.addEventListener("pointerleave",p),()=>{window.clearTimeout(c),i.removeEventListener("pointerenter",u),i.removeEventListener("pointerleave",p)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(Fd,{present:r||o,children:e.jsx(BGe,{"data-state":o?"visible":"hidden",...n,ref:s})})}),u3t=N.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=qx(F0,t.__scopeScrollArea),o=t.orientation==="horizontal",l=rue(()=>c("SCROLL_END"),100),[i,c]=l3t("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return N.useEffect(()=>{if(i==="idle"){const u=window.setTimeout(()=>c("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,a.scrollHideDelay,c]),N.useEffect(()=>{const u=a.viewport,p=o?"scrollLeft":"scrollTop";if(u){let f=u[p];const g=()=>{const b=u[p];f!==b&&(c("SCROLL"),l()),f=b};return u.addEventListener("scroll",g),()=>u.removeEventListener("scroll",g)}},[a.viewport,o,c,l]),e.jsx(Fd,{present:r||i!=="hidden",children:e.jsx(jje,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:Ir(t.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Ir(t.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),BGe=N.forwardRef((t,s)=>{const r=qx(F0,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=N.useState(!1),i=t.orientation==="horizontal",c=rue(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=qx(F0,t.__scopeScrollArea),o=N.useRef(null),l=N.useRef(0),[i,c]=N.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=HGe(i.viewport,i.content),p={...n,sizes:i,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:g=>o.current=g,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:g=>l.current=g};function f(g,b){return g3t(g,l.current,i,b)}return r==="horizontal"?e.jsx(h3t,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const g=a.viewport.scrollLeft,b=M6e(g,i,a.dir);o.current.style.transform=`translate3d(${b}px, 0, 0)`}},onWheelScroll:g=>{a.viewport&&(a.viewport.scrollLeft=g)},onDragScroll:g=>{a.viewport&&(a.viewport.scrollLeft=f(g,a.dir))}}):r==="vertical"?e.jsx(m3t,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const g=a.viewport.scrollTop,b=M6e(g,i);o.current.style.transform=`translate3d(0, ${b}px, 0)`}},onWheelScroll:g=>{a.viewport&&(a.viewport.scrollTop=g)},onDragScroll:g=>{a.viewport&&(a.viewport.scrollTop=f(g))}}):null}),h3t=N.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=qx(F0,t.__scopeScrollArea),[l,i]=N.useState(),c=N.useRef(null),u=qa(s,c,o.onScrollbarXChange);return N.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),e.jsx(qGe,{"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":sue(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,f)=>{if(o.viewport){const g=o.viewport.scrollLeft+p.deltaX;t.onWheelScroll(g),GGe(g,f)&&p.preventDefault()}},onResize:()=>{c.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Eoe(l.paddingLeft),paddingEnd:Eoe(l.paddingRight)}})}})}),m3t=N.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=qx(F0,t.__scopeScrollArea),[l,i]=N.useState(),c=N.useRef(null),u=qa(s,c,o.onScrollbarYChange);return N.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),e.jsx(qGe,{"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":sue(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,f)=>{if(o.viewport){const g=o.viewport.scrollTop+p.deltaY;t.onWheelScroll(g),GGe(g,f)&&p.preventDefault()}},onResize:()=>{c.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Eoe(l.paddingTop),paddingEnd:Eoe(l.paddingBottom)}})}})}),[p3t,$Ge]=OGe(F0),qGe=N.forwardRef((t,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:p,onResize:f,...g}=t,b=qx(F0,r),[_,j]=N.useState(null),w=qa(s,B=>j(B)),k=N.useRef(null),S=N.useRef(""),M=b.viewport,L=n.content-n.viewport,I=yd(p),O=yd(c),q=rue(f,10);function U(B){if(k.current){const V=B.clientX-k.current.left,Z=B.clientY-k.current.top;u({x:V,y:Z})}}return N.useEffect(()=>{const B=V=>{const Z=V.target;(_==null?void 0:_.contains(Z))&&I(V,L)};return document.addEventListener("wheel",B,{passive:!1}),()=>document.removeEventListener("wheel",B,{passive:!1})},[M,_,L,I]),N.useEffect(O,[n,O]),$T(_,q),$T(b.content,q),e.jsx(p3t,{scope:r,scrollbar:_,hasThumb:a,onThumbChange:yd(o),onThumbPointerUp:yd(l),onThumbPositionChange:O,onThumbPointerDown:yd(i),children:e.jsx(nn.div,{...g,ref:w,style:{position:"absolute",...g.style},onPointerDown:Ir(t.onPointerDown,B=>{B.button===0&&(B.target.setPointerCapture(B.pointerId),k.current=_.getBoundingClientRect(),S.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",b.viewport&&(b.viewport.style.scrollBehavior="auto"),U(B))}),onPointerMove:Ir(t.onPointerMove,U),onPointerUp:Ir(t.onPointerUp,B=>{const V=B.target;V.hasPointerCapture(B.pointerId)&&V.releasePointerCapture(B.pointerId),document.body.style.webkitUserSelect=S.current,b.viewport&&(b.viewport.style.scrollBehavior=""),k.current=null})})})}),Aoe="ScrollAreaThumb",UGe=N.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=$Ge(Aoe,t.__scopeScrollArea);return e.jsx(Fd,{present:r||a.hasThumb,children:e.jsx(f3t,{ref:s,...n})})}),f3t=N.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=qx(Aoe,r),l=$Ge(Aoe,r),{onThumbPositionChange:i}=l,c=qa(s,f=>l.onThumbChange(f)),u=N.useRef(void 0),p=rue(()=>{u.current&&(u.current(),u.current=void 0)},100);return N.useEffect(()=>{const f=o.viewport;if(f){const g=()=>{if(p(),!u.current){const b=y3t(f,i);u.current=b,i()}};return i(),f.addEventListener("scroll",g),()=>f.removeEventListener("scroll",g)}},[o.viewport,p,i]),e.jsx(nn.div,{"data-state":l.hasThumb?"visible":"hidden",...a,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Ir(t.onPointerDownCapture,f=>{const b=f.target.getBoundingClientRect(),_=f.clientX-b.left,j=f.clientY-b.top;l.onThumbPointerDown({x:_,y:j})}),onPointerUp:Ir(t.onPointerUp,l.onThumbPointerUp)})});UGe.displayName=Aoe;var Nje="ScrollAreaCorner",VGe=N.forwardRef((t,s)=>{const r=qx(Nje,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(x3t,{...t,ref:s}):null});VGe.displayName=Nje;var x3t=N.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=qx(Nje,r),[o,l]=N.useState(0),[i,c]=N.useState(0),u=!!(o&&i);return $T(a.scrollbarX,()=>{var f;const p=((f=a.scrollbarX)==null?void 0:f.offsetHeight)||0;a.onCornerHeightChange(p),c(p)}),$T(a.scrollbarY,()=>{var f;const p=((f=a.scrollbarY)==null?void 0:f.offsetWidth)||0;a.onCornerWidthChange(p),l(p)}),u?e.jsx(nn.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 Eoe(t){return t?parseInt(t,10):0}function HGe(t,s){const r=t/s;return isNaN(r)?0:r}function sue(t){const s=HGe(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*s;return Math.max(n,18)}function g3t(t,s,r,n="ltr"){const a=sue(r),o=a/2,l=s||o,i=a-l,c=r.scrollbar.paddingStart+l,u=r.scrollbar.size-r.scrollbar.paddingEnd-i,p=r.content-r.viewport,f=n==="ltr"?[0,p]:[p*-1,0];return WGe([c,u],f)(t)}function M6e(t,s,r="ltr"){const n=sue(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,o=s.scrollbar.size-a,l=s.content-s.viewport,i=o-n,c=r==="ltr"?[0,l]:[l*-1,0],u=X8(t,c);return WGe([0,l],[0,i])(u)}function WGe(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 GGe(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 rue(t,s){const r=yd(t),n=N.useRef(0);return N.useEffect(()=>()=>window.clearTimeout(n.current),[]),N.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function $T(t,s){const r=yd(s);wd(()=>{let n=0;if(t){const a=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return a.observe(t),()=>{window.cancelAnimationFrame(n),a.unobserve(t)}}},[t,r])}var KGe=RGe,v3t=zGe,b3t=VGe;const Gi=N.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(KGe,{ref:n,className:It("relative overflow-hidden",t),...r,children:[e.jsx(v3t,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(nue,{}),e.jsx(b3t,{})]}));Gi.displayName=KGe.displayName;const nue=N.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(wje,{ref:n,orientation:s,className:It("flex touch-none select-none transition-colors",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:e.jsx(UGe,{className:"relative flex-1 rounded-full bg-border"})}));nue.displayName=wje.displayName;const kje=N.createContext({});function Sje(t){const s=N.useRef(null);return s.current===null&&(s.current=t()),s.current}const _3t=typeof window<"u",ZGe=_3t?N.useLayoutEffect:N.useEffect,aue=N.createContext(null);function Cje(t,s){t.indexOf(s)===-1&&t.push(s)}function Poe(t,s){const r=t.indexOf(s);r>-1&&t.splice(r,1)}const M0=(t,s,r)=>r>s?s:r{};const pw={},YGe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function XGe(t){return typeof t=="object"&&t!==null}const QGe=t=>/^0[^.\s]+$/u.test(t);function JGe(t){let s;return()=>(s===void 0&&(s=t()),s)}const Tx=t=>t,w3t=(t,s)=>r=>s(t(r)),IO=(...t)=>t.reduce(w3t),eD=(t,s,r)=>{const n=s-t;return n===0?1:(r-t)/n};class Tje{constructor(){this.subscriptions=[]}add(s){return Cje(this.subscriptions,s),()=>Poe(this.subscriptions,s)}notify(s,r,n){const a=this.subscriptions.length;if(a)if(a===1)this.subscriptions[0](s,r,n);else for(let o=0;ot*1e3,bx=t=>t/1e3;function eKe(t,s){return s?t*(1e3/s):0}const tKe=(t,s,r)=>(((1-3*r+3*s)*t+(3*r-6*s))*t+3*s)*t,j3t=1e-7,N3t=12;function k3t(t,s,r,n,a){let o,l,i=0;do l=s+(r-s)/2,o=tKe(l,n,a)-t,o>0?r=l:s=l;while(Math.abs(o)>j3t&&++ik3t(o,0,1,t,r);return o=>o===0||o===1?o:tKe(a(o),s,n)}const sKe=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,rKe=t=>s=>1-t(1-s),nKe=LO(.33,1.53,.69,.99),Aje=rKe(nKe),aKe=sKe(Aje),iKe=t=>t>=1?1:(t*=2)<1?.5*Aje(t):.5*(2-Math.pow(2,-10*(t-1))),Eje=t=>1-Math.sin(Math.acos(t)),oKe=rKe(Eje),lKe=sKe(Eje),S3t=LO(.42,0,1,1),C3t=LO(0,0,.58,1),cKe=LO(.42,0,.58,1),M3t=t=>Array.isArray(t)&&typeof t[0]!="number",dKe=t=>Array.isArray(t)&&typeof t[0]=="number",T3t={linear:Tx,easeIn:S3t,easeInOut:cKe,easeOut:C3t,circIn:Eje,circInOut:lKe,circOut:oKe,backIn:Aje,backInOut:aKe,backOut:nKe,anticipate:iKe},A3t=t=>typeof t=="string",T6e=t=>{if(dKe(t)){Mje(t.length===4);const[s,r,n,a]=t;return LO(s,r,n,a)}else if(A3t(t))return T3t[t];return t},sz=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function E3t(t,s){let r=new Set,n=new Set,a=!1,o=!1;const l=new WeakSet;let i={delta:0,timestamp:0,isProcessing:!1};function c(p){l.has(p)&&(u.schedule(p),t()),p(i)}const u={schedule:(p,f=!1,g=!1)=>{const _=g&&a?r:n;return f&&l.add(p),_.add(p),p},cancel:p=>{n.delete(p),l.delete(p)},process:p=>{if(i=p,a){o=!0;return}a=!0;const f=r;r=n,n=f,r.forEach(c),r.clear(),a=!1,o&&(o=!1,u.process(p))}};return u}const P3t=40;function uKe(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=sz.reduce((M,L)=>(M[L]=E3t(o),M),{}),{setup:i,read:c,resolveKeyframes:u,preUpdate:p,update:f,preRender:g,render:b,postRender:_}=l,j=()=>{const M=pw.useManualTiming,L=M?a.timestamp:performance.now();r=!1,M||(a.delta=n?1e3/60:Math.max(Math.min(L-a.timestamp,P3t),1)),a.timestamp=L,a.isProcessing=!0,i.process(a),c.process(a),u.process(a),p.process(a),f.process(a),g.process(a),b.process(a),_.process(a),a.isProcessing=!1,r&&s&&(n=!1,t(j))},w=()=>{r=!0,n=!0,a.isProcessing||t(j)};return{schedule:sz.reduce((M,L)=>{const I=l[L];return M[L]=(O,q=!1,U=!1)=>(r||w(),I.schedule(O,q,U)),M},{}),cancel:M=>{for(let L=0;L(mie===void 0&&Nm.set(vh.isProcessing||pw.useManualTiming?vh.timestamp:performance.now()),mie),set:t=>{mie=t,queueMicrotask(I3t)}},hKe=t=>s=>typeof s=="string"&&s.startsWith(t),mKe=hKe("--"),L3t=hKe("var(--"),Pje=t=>L3t(t)?D3t.test(t.split("/*")[0].trim()):!1,D3t=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function A6e(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const YA={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},tD={...YA,transform:t=>M0(0,1,t)},rz={...YA,default:1},HL=t=>Math.round(t*1e5)/1e5,Ije=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function O3t(t){return t==null}const R3t=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Lje=(t,s)=>r=>!!(typeof r=="string"&&R3t.test(r)&&r.startsWith(t)||s&&!O3t(r)&&Object.prototype.hasOwnProperty.call(r,s)),pKe=(t,s,r)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(Ije);return{[t]:parseFloat(a),[s]:parseFloat(o),[r]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},F3t=t=>M0(0,255,t),Axe={...YA,transform:t=>Math.round(F3t(t))},v4={test:Lje("rgb","red"),parse:pKe("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+Axe.transform(t)+", "+Axe.transform(s)+", "+Axe.transform(r)+", "+HL(tD.transform(n))+")"};function z3t(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 qve={test:Lje("#"),parse:z3t,transform:v4.transform},DO=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),Bb=DO("deg"),w0=DO("%"),ia=DO("px"),B3t=DO("vh"),$3t=DO("vw"),E6e={...w0,parse:t=>w0.parse(t)/100,transform:t=>w0.transform(t*100)},iM={test:Lje("hsl","hue"),parse:pKe("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+w0.transform(HL(s))+", "+w0.transform(HL(r))+", "+HL(tD.transform(n))+")"},Xd={test:t=>v4.test(t)||qve.test(t)||iM.test(t),parse:t=>v4.test(t)?v4.parse(t):iM.test(t)?iM.parse(t):qve.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?v4.transform(t):iM.transform(t),getAnimatableNone:t=>{const s=Xd.parse(t);return s.alpha=0,Xd.transform(s)}},q3t=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function U3t(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(Ije))==null?void 0:s.length)||0)+(((r=t.match(q3t))==null?void 0:r.length)||0)>0}const fKe="number",xKe="color",V3t="var",H3t="var(",P6e="${}",W3t=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function qT(t){const s=t.toString(),r=[],n={color:[],number:[],var:[]},a=[];let o=0;const i=s.replace(W3t,c=>(Xd.test(c)?(n.color.push(o),a.push(xKe),r.push(Xd.parse(c))):c.startsWith(H3t)?(n.var.push(o),a.push(V3t),r.push(c)):(n.number.push(o),a.push(fKe),r.push(parseFloat(c))),++o,P6e)).split(P6e);return{values:r,split:i,indexes:n,types:a}}function G3t(t){return qT(t).values}function gKe({split:t,types:s}){const r=t.length;return n=>{let a="";for(let o=0;otypeof t=="number"?0:Xd.test(t)?Xd.getAnimatableNone(t):t,Y3t=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:Z3t(t);function X3t(t){const s=qT(t);return gKe(s)(s.values.map((n,a)=>Y3t(n,s.split[a])))}const ty={test:U3t,parse:G3t,createTransformer:K3t,getAnimatableNone:X3t};function Exe(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 Q3t({hue:t,saturation:s,lightness:r,alpha:n}){t/=360,s/=100,r/=100;let a=0,o=0,l=0;if(!s)a=o=l=r;else{const i=r<.5?r*(1+s):r+s-r*s,c=2*r-i;a=Exe(c,i,t+1/3),o=Exe(c,i,t),l=Exe(c,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function Ioe(t,s){return r=>r>0?s:t}const wc=(t,s,r)=>t+(s-t)*r,Pxe=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},J3t=[qve,v4,iM],e5t=t=>J3t.find(s=>s.test(t));function I6e(t){const s=e5t(t);if(!s)return!1;let r=s.parse(t);return s===iM&&(r=Q3t(r)),r}const L6e=(t,s)=>{const r=I6e(t),n=I6e(s);if(!r||!n)return Ioe(t,s);const a={...r};return o=>(a.red=Pxe(r.red,n.red,o),a.green=Pxe(r.green,n.green,o),a.blue=Pxe(r.blue,n.blue,o),a.alpha=wc(r.alpha,n.alpha,o),v4.transform(a))},Uve=new Set(["none","hidden"]);function t5t(t,s){return Uve.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function s5t(t,s){return r=>wc(t,s,r)}function Dje(t){return typeof t=="number"?s5t:typeof t=="string"?Pje(t)?Ioe:Xd.test(t)?L6e:a5t:Array.isArray(t)?yKe:typeof t=="object"?Xd.test(t)?L6e:r5t:Ioe}function yKe(t,s){const r=[...t],n=r.length,a=t.map((o,l)=>Dje(o)(o,s[l]));return o=>{for(let l=0;l{for(const o in n)r[o]=n[o](a);return r}}function n5t(t,s){const r=[],n={color:0,var:0,number:0};for(let a=0;a{const r=ty.createTransformer(s),n=qT(t),a=qT(s);return n.indexes.var.length===a.indexes.var.length&&n.indexes.color.length===a.indexes.color.length&&n.indexes.number.length>=a.indexes.number.length?Uve.has(t)&&!a.values.length||Uve.has(s)&&!n.values.length?t5t(t,s):IO(yKe(n5t(n,a),a.values),r):Ioe(t,s)};function vKe(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?wc(t,s,r):Dje(t)(t,s)}const i5t=t=>{const s=({timestamp:r})=>t(r);return{start:(r=!0)=>Ll.update(s,r),stop:()=>fw(s),now:()=>vh.isProcessing?vh.timestamp:Nm.now()}},bKe=(t,s,r=10)=>{let n="";const a=Math.max(Math.round(s/r),2);for(let o=0;o=Loe?1/0:s}function o5t(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(Oje(n),Loe);return{type:"keyframes",ease:o=>n.next(a*o).value/s,duration:bx(a)}}const hd={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 Vve(t,s){return t*Math.sqrt(1-s*s)}const l5t=12;function c5t(t,s,r){let n=r;for(let a=1;a{const p=u*l,f=p*t,g=p-r,b=Vve(u,l),_=Math.exp(-f);return Ixe-g/b*_},o=u=>{const f=u*l*t,g=f*r+r,b=Math.pow(l,2)*Math.pow(u,2)*t,_=Math.exp(-f),j=Vve(Math.pow(u,2),l);return(-a(u)+Ixe>0?-1:1)*((g-b)*_)/j}):(a=u=>{const p=Math.exp(-u*t),f=(u-r)*t+1;return-Ixe+p*f},o=u=>{const p=Math.exp(-u*t),f=(r-u)*(t*t);return p*f});const i=5/t,c=c5t(a,o,i);if(t=xf(t),isNaN(c))return{stiffness:hd.stiffness,damping:hd.damping,duration:t};{const u=Math.pow(c,2)*n;return{stiffness:u,damping:l*2*Math.sqrt(n*u),duration:t}}}const u5t=["duration","bounce"],h5t=["stiffness","damping","mass"];function D6e(t,s){return s.some(r=>t[r]!==void 0)}function m5t(t){let s={velocity:hd.velocity,stiffness:hd.stiffness,damping:hd.damping,mass:hd.mass,isResolvedFromDuration:!1,...t};if(!D6e(t,h5t)&&D6e(t,u5t))if(s.velocity=0,t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),a=n*n,o=2*M0(.05,1,1-(t.bounce||0))*Math.sqrt(a);s={...s,mass:hd.mass,stiffness:a,damping:o}}else{const r=d5t({...t,velocity:0});s={...s,...r,mass:hd.mass},s.isResolvedFromDuration=!0}return s}function Doe(t=hd.visualDuration,s=hd.bounce){const r=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:s}:t;let{restSpeed:n,restDelta:a}=r;const o=r.keyframes[0],l=r.keyframes[r.keyframes.length-1],i={done:!1,value:o},{stiffness:c,damping:u,mass:p,duration:f,velocity:g,isResolvedFromDuration:b}=m5t({...r,velocity:-bx(r.velocity||0)}),_=g||0,j=u/(2*Math.sqrt(c*p)),w=l-o,k=bx(Math.sqrt(c/p)),S=Math.abs(w)<5;n||(n=S?hd.restSpeed.granular:hd.restSpeed.default),a||(a=S?hd.restDelta.granular:hd.restDelta.default);let M,L,I,O,q,U;if(j<1)I=Vve(k,j),O=(_+j*k*w)/I,M=V=>{const Z=Math.exp(-j*k*V);return l-Z*(O*Math.sin(I*V)+w*Math.cos(I*V))},q=j*k*O+w*I,U=j*k*w-O*I,L=V=>Math.exp(-j*k*V)*(q*Math.sin(I*V)+U*Math.cos(I*V));else if(j===1){M=Z=>l-Math.exp(-k*Z)*(w+(_+k*w)*Z);const V=_+k*w;L=Z=>Math.exp(-k*Z)*(k*V*Z-_)}else{const V=k*Math.sqrt(j*j-1);M=Q=>{const ie=Math.exp(-j*k*Q),re=Math.min(V*Q,300);return l-ie*((_+j*k*w)*Math.sinh(re)+V*w*Math.cosh(re))/V};const Z=(_+j*k*w)/V,X=j*k*Z-w*V,ee=j*k*w-Z*V;L=Q=>{const ie=Math.exp(-j*k*Q),re=Math.min(V*Q,300);return ie*(X*Math.sinh(re)+ee*Math.cosh(re))}}const B={calculatedDuration:b&&f||null,velocity:V=>xf(L(V)),next:V=>{if(!b&&j<1){const X=Math.exp(-j*k*V),ee=Math.sin(I*V),Q=Math.cos(I*V),ie=l-X*(O*ee+w*Q),re=xf(X*(q*ee+U*Q));return i.done=Math.abs(re)<=n&&Math.abs(l-ie)<=a,i.value=i.done?l:ie,i}const Z=M(V);if(b)i.done=V>=f;else{const X=xf(L(V));i.done=Math.abs(X)<=n&&Math.abs(l-Z)<=a}return i.value=i.done?l:Z,i},toString:()=>{const V=Math.min(Oje(B),Loe),Z=bKe(X=>B.next(V*X).value,V,30);return V+"ms "+Z},toTransition:()=>{}};return B}Doe.applyToOptions=t=>{const s=o5t(t,100,Doe);return t.ease=s.ease,t.duration=xf(s.duration),t.type="keyframes",t};const p5t=5;function _Ke(t,s,r){const n=Math.max(s-p5t,0);return eKe(r-t(n),s-n)}function Hve({keyframes:t,velocity:s=0,power:r=.8,timeConstant:n=325,bounceDamping:a=10,bounceStiffness:o=500,modifyTarget:l,min:i,max:c,restDelta:u=.5,restSpeed:p}){const f=t[0],g={done:!1,value:f},b=U=>i!==void 0&&Uc,_=U=>i===void 0?c:c===void 0||Math.abs(i-U)-j*Math.exp(-U/n),M=U=>k+S(U),L=U=>{const B=S(U),V=M(U);g.done=Math.abs(B)<=u,g.value=g.done?k:V};let I,O;const q=U=>{b(g.value)&&(I=U,O=Doe({keyframes:[g.value,_(g.value)],velocity:_Ke(M,U,g.value),damping:a,stiffness:o,restDelta:u,restSpeed:p}))};return q(0),{calculatedDuration:null,next:U=>{let B=!1;return!O&&I===void 0&&(B=!0,L(U),q(U)),I!==void 0&&U>=I?O.next(U-I):(!B&&L(U),g)}}}function f5t(t,s,r){const n=[],a=r||pw.mix||vKe,o=t.length-1;for(let l=0;ls[0];if(o===2&&s[0]===s[1])return()=>s[1];const l=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),s=[...s].reverse());const i=f5t(s,n,a),c=i.length,u=p=>{if(l&&p1)for(;fu(M0(t[0],t[o-1],p)):u}function g5t(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=eD(0,s,n);t.push(wc(r,1,a))}}function y5t(t){const s=[0];return g5t(s,t.length-1),s}function v5t(t,s){return t.map(r=>r*s)}function b5t(t,s){return t.map(()=>s||cKe).splice(0,t.length-1)}function WL({duration:t=300,keyframes:s,times:r,ease:n="easeInOut"}){const a=M3t(n)?n.map(T6e):T6e(n),o={done:!1,value:s[0]},l=v5t(r&&r.length===s.length?r:y5t(s),t),i=x5t(l,s,{ease:Array.isArray(a)?a:b5t(s,a)});return{calculatedDuration:t,next:c=>(o.value=i(c),o.done=c>=t,o)}}const _5t=t=>t!==null;function iue(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(_5t),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const w5t={decay:Hve,inertia:Hve,tween:WL,keyframes:WL,spring:Doe};function wKe(t){typeof t.type=="string"&&(t.type=w5t[t.type])}class Rje{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 j5t=t=>t/100;class Ooe extends Rje{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!==Nm.now()&&this.tick(Nm.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;wKe(s);const{type:r=WL,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=s;let{keyframes:i}=s;const c=r||WL;c!==WL&&typeof i[0]!="number"&&(this.mixKeyframes=IO(j5t,vKe(i[0],i[1])),i=[0,100]);const u=c({...s,keyframes:i});o==="mirror"&&(this.mirroredGenerator=c({...s,keyframes:[...i].reverse(),velocity:-l})),u.calculatedDuration===null&&(u.calculatedDuration=Oje(u));const{calculatedDuration:p}=u;this.calculatedDuration=p,this.resolvedDuration=p+a,this.totalDuration=this.resolvedDuration*(n+1)-a,this.generator=u}updateTime(s){const r=Math.round(s-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=r}tick(s,r=!1){const{generator:n,totalDuration:a,mixKeyframes:o,mirroredGenerator:l,resolvedDuration:i,calculatedDuration:c}=this;if(this.startTime===null)return n.next(0);const{delay:u=0,keyframes:p,repeat:f,repeatType:g,repeatDelay:b,type:_,onUpdate:j,finalKeyframe:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-a/this.speed,this.startTime)),r?this.currentTime=s:this.updateTime(s);const k=this.currentTime-u*(this.playbackSpeed>=0?1:-1),S=this.playbackSpeed>=0?k<0:k>a;this.currentTime=Math.max(k,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let M=this.currentTime,L=n;if(f){const U=Math.min(this.currentTime,a)/i;let B=Math.floor(U),V=U%1;!V&&U>=1&&(V=1),V===1&&B--,B=Math.min(B,f+1),!!(B%2)&&(g==="reverse"?(V=1-V,b&&(V-=b/i)):g==="mirror"&&(L=l)),M=M0(0,1,V)*i}let I;S?(this.delayState.value=p[0],I=this.delayState):I=L.next(M),o&&!S&&(I.value=o(I.value));let{done:O}=I;!S&&c!==null&&(O=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const q=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&O);return q&&_!==Hve&&(I.value=iue(p,this.options,w,this.speed)),j&&j(I.value),q&&this.finish(),I}then(s,r){return this.finished.then(s,r)}get duration(){return bx(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+bx(s)}get time(){return bx(this.currentTime)}set time(s){s=xf(s),this.currentTime=s,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=s:this.driver&&(this.startTime=this.driver.now()-s/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=s,this.tick(s))}getGeneratorVelocity(){const s=this.currentTime;if(s<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(s);const r=this.generator.next(s).value;return _Ke(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(Nm.now()),this.playbackSpeed=s,r&&this.driver&&(this.time=bx(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:s=i5t,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(Nm.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 N5t(t){for(let s=1;st*180/Math.PI,Wve=t=>{const s=b4(Math.atan2(t[1],t[0]));return Gve(s)},k5t={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Wve,rotateZ:Wve,skewX:t=>b4(Math.atan(t[1])),skewY:t=>b4(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Gve=t=>(t=t%360,t<0&&(t+=360),t),O6e=Wve,R6e=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),F6e=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),S5t={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:R6e,scaleY:F6e,scale:t=>(R6e(t)+F6e(t))/2,rotateX:t=>Gve(b4(Math.atan2(t[6],t[5]))),rotateY:t=>Gve(b4(Math.atan2(-t[2],t[0]))),rotateZ:O6e,rotate:O6e,skewX:t=>b4(Math.atan(t[4])),skewY:t=>b4(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Kve(t){return t.includes("scale")?1:0}function Zve(t,s){if(!t||t==="none")return Kve(s);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(r)n=S5t,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=k5t,a=i}if(!a)return Kve(s);const o=n[s],l=a[1].split(",").map(M5t);return typeof o=="function"?o(l):l[o]}const C5t=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return Zve(r,s)};function M5t(t){return parseFloat(t.trim())}const XA=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],QA=new Set(XA),z6e=t=>t===YA||t===ia,T5t=new Set(["x","y","z"]),A5t=XA.filter(t=>!T5t.has(t));function E5t(t){const s=[];return A5t.forEach(r=>{const n=t.getValue(r);n!==void 0&&(s.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),s}const j_={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})=>Zve(s,"x"),y:(t,{transform:s})=>Zve(s,"y")};j_.translateX=j_.x;j_.translateY=j_.y;const gS=new Set;let Yve=!1,Xve=!1,Qve=!1;function jKe(){if(Xve){const t=Array.from(gS).filter(n=>n.needsMeasurement),s=new Set(t.map(n=>n.element)),r=new Map;s.forEach(n=>{const a=E5t(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)})}Xve=!1,Yve=!1,gS.forEach(t=>t.complete(Qve)),gS.clear()}function NKe(){gS.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Xve=!0)})}function P5t(){Qve=!0,NKe(),jKe(),Qve=!1}class Fje{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?(gS.add(this),Yve||(Yve=!0,Ll.read(NKe),Ll.resolveKeyframes(jKe))):(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])}N5t(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(s=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,s),gS.delete(this)}cancel(){this.state==="scheduled"&&(gS.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const I5t=t=>t.startsWith("--");function kKe(t,s,r){I5t(s)?t.style.setProperty(s,r):t.style[s]=r}const L5t={};function SKe(t,s){const r=JGe(t);return()=>L5t[s]??r()}const D5t=SKe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),CKe=SKe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),wI=([t,s,r,n])=>`cubic-bezier(${t}, ${s}, ${r}, ${n})`,B6e={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:wI([0,.65,.55,1]),circOut:wI([.55,0,1,.45]),backIn:wI([.31,.01,.66,-.59]),backOut:wI([.33,1.53,.69,.99])};function MKe(t,s){if(t)return typeof t=="function"?CKe()?bKe(t,s):"ease-out":dKe(t)?wI(t):Array.isArray(t)?t.map(r=>MKe(r,s)||B6e.easeOut):B6e[t]}function O5t(t,s,r,{delay:n=0,duration:a=300,repeat:o=0,repeatType:l="loop",ease:i="easeOut",times:c}={},u=void 0){const p={[s]:r};c&&(p.offset=c);const f=MKe(i,a);Array.isArray(f)&&(p.easing=f);const g={delay:n,duration:a,easing:Array.isArray(f)?"linear":f,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return u&&(g.pseudoElement=u),t.animate(p,g)}function TKe(t){return typeof t=="function"&&"applyToOptions"in t}function R5t({type:t,...s}){return TKe(t)&&CKe()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class AKe extends Rje{constructor(s){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!s)return;const{element:r,name:n,keyframes:a,pseudoElement:o,allowFlatten:l=!1,finalKeyframe:i,onComplete:c}=s;this.isPseudoElement=!!o,this.allowFlatten=l,this.options=s,Mje(typeof s.type!="string");const u=R5t(s);this.animation=O5t(r,n,a,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=iue(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(p),kKe(r,n,p),this.animation.cancel()}c==null||c(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var s,r;(r=(s=this.animation).finish)==null||r.call(s)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:s}=this;s==="idle"||s==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var r,n,a;const s=(r=this.options)==null?void 0:r.element;!this.isPseudoElement&&(s!=null&&s.isConnected)&&((a=(n=this.animation).commitStyles)==null||a.call(n))}get duration(){var r,n;const s=((n=(r=this.animation.effect)==null?void 0:r.getComputedTiming)==null?void 0:n.call(r).duration)||0;return bx(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+bx(s)}get time(){return bx(Number(this.animation.currentTime)||0)}set time(s){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=xf(s),r&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(s){s<0&&(this.finishedTime=null),this.animation.playbackRate=s}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(s){this.manualStartTime=this.animation.startTime=s}attachTimeline({timeline:s,rangeStart:r,rangeEnd:n,observe:a}){var o;return this.allowFlatten&&((o=this.animation.effect)==null||o.updateTiming({easing:"linear"})),this.animation.onfinish=null,s&&D5t()?(this.animation.timeline=s,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),Tx):a(this)}}const EKe={anticipate:iKe,backInOut:aKe,circInOut:lKe};function F5t(t){return t in EKe}function z5t(t){typeof t.ease=="string"&&F5t(t.ease)&&(t.ease=EKe[t.ease])}const Lxe=10;class B5t extends AKe{constructor(s){z5t(s),wKe(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 Ooe({...l,autoplay:!1}),c=Math.max(Lxe,Nm.now()-this.startTime),u=M0(0,Lxe,c-Lxe),p=i.sample(c).value,{name:f}=this.options;o&&f&&kKe(o,f,p),r.setWithVelocity(i.sample(Math.max(0,c-u)).value,p,u),i.stop()}}const $6e=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(ty.test(t)||t==="0")&&!t.startsWith("url("));function $5t(t){const s=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function G5t(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 W5t()&&r&&(PKe.has(r)||H5t.has(r)&&V5t(i))&&(r!=="transform"||!p)&&!u&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const K5t=40;class Z5t extends Rje{constructor({autoplay:s=!0,delay:r=0,type:n="keyframes",repeat:a=0,repeatDelay:o=0,repeatType:l="loop",keyframes:i,name:c,motionValue:u,element:p,...f}){var _;super(),this.stop=()=>{var j,w;this._animation&&(this._animation.stop(),(j=this.stopTimeline)==null||j.call(this)),(w=this.keyframeResolver)==null||w.cancel()},this.createdAt=Nm.now();const g={autoplay:s,delay:r,type:n,repeat:a,repeatDelay:o,repeatType:l,name:c,motionValue:u,element:p,...f},b=(p==null?void 0:p.KeyframeResolver)||Fje;this.keyframeResolver=new b(i,(j,w,k)=>this.onKeyframesResolved(j,w,g,!k),c,u,p),(_=this.keyframeResolver)==null||_.scheduleResolve()}onKeyframesResolved(s,r,n,a){var k,S;this.keyframeResolver=void 0;const{name:o,type:l,velocity:i,delay:c,isHandoff:u,onUpdate:p}=n;this.resolvedAt=Nm.now();let f=!0;q5t(s,o,l,i)||(f=!1,(pw.instantAnimations||!c)&&(p==null||p(iue(s,n,r))),s[0]=s[s.length-1],Jve(n),n.repeat=0);const b={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>K5t?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},_=f&&!u&&G5t(b),j=(S=(k=b.motionValue)==null?void 0:k.owner)==null?void 0:S.current;let w;if(_)try{w=new B5t({...b,element:j})}catch{w=new Ooe(b)}else w=new Ooe(b);w.finished.then(()=>{this.notifyFinished()}).catch(Tx),this.pendingTimeline&&(this.stopTimeline=w.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=w}get finished(){return this._animation?this.animation.finished:this._finished}then(s,r){return this.finished.finally(s).then(()=>{})}get animation(){var s;return this._animation||((s=this.keyframeResolver)==null||s.resume(),P5t()),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 IKe(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 Y5t=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function X5t(t){const s=Y5t.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}function LKe(t,s,r=1){const[n,a]=X5t(t);if(!n)return;const o=window.getComputedStyle(s).getPropertyValue(n);if(o){const l=o.trim();return YGe(l)?parseFloat(l):l}return Pje(a)?LKe(a,s,r+1):a}const Q5t={type:"spring",stiffness:500,damping:25,restSpeed:10},J5t=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),eMt={type:"keyframes",duration:.8},tMt={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},sMt=(t,{keyframes:s})=>s.length>2?eMt:QA.has(t)?t.startsWith("scale")?J5t(s[1]):Q5t:tMt;function DKe(t,s){if(t!=null&&t.inherit&&s){const{inherit:r,...n}=t;return{...s,...n}}return t}function zje(t,s){const r=(t==null?void 0:t[s])??(t==null?void 0:t.default)??t;return r!==t?DKe(r,t):r}const rMt=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function nMt(t){for(const s in t)if(!rMt.has(s))return!0;return!1}const Bje=(t,s,r,n={},a,o)=>l=>{const i=zje(n,t)||{},c=i.delay||n.delay||0;let{elapsed:u=0}=n;u=u-xf(c);const p={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:s.getVelocity(),...i,delay:-u,onUpdate:g=>{s.set(g),i.onUpdate&&i.onUpdate(g)},onComplete:()=>{l(),i.onComplete&&i.onComplete()},name:t,motionValue:s,element:o?void 0:a};nMt(i)||Object.assign(p,sMt(t,p)),p.duration&&(p.duration=xf(p.duration)),p.repeatDelay&&(p.repeatDelay=xf(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let f=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(Jve(p),p.delay===0&&(f=!0)),(pw.instantAnimations||pw.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(f=!0,Jve(p),p.delay=0),p.allowFlatten=!i.type&&!i.ease,f&&!o&&s.get()!==void 0){const g=iue(p.keyframes,i);if(g!==void 0){Ll.update(()=>{p.onUpdate(g),p.onComplete()});return}}return i.isSync?new Ooe(p):new Z5t(p)};function q6e(t){const s=[{},{}];return t==null||t.values.forEach((r,n)=>{s[0][n]=r.get(),s[1][n]=r.getVelocity()}),s}function $je(t,s,r,n){if(typeof s=="function"){const[a,o]=q6e(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]=q6e(n);s=s(r!==void 0?r:t.custom,a,o)}return s}function yS(t,s,r){const n=t.getProps();return $je(n,s,r!==void 0?r:n.custom,t)}const OKe=new Set(["width","height","top","left","right","bottom",...XA]),U6e=30,aMt=t=>!isNaN(parseFloat(t));class iMt{constructor(s,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=Nm.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=Nm.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=aMt(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 Tje);const n=this.events[s].add(r);return s==="change"?()=>{n(),Ll.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=Nm.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>U6e)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,U6e);return eKe(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 UT(t,s){return new iMt(t,s)}const e1e=t=>Array.isArray(t);function oMt(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,UT(r))}function lMt(t){return e1e(t)?t[t.length-1]||0:t}function cMt(t,s){const r=yS(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=lMt(o[l]);oMt(t,l,i)}}const jh=t=>!!(t&&t.getVelocity);function dMt(t){return!!(jh(t)&&t.add)}function t1e(t,s){const r=t.getValue("willChange");if(dMt(r))return r.add(s);if(!r&&pw.WillChange){const n=new pw.WillChange("auto");t.addValue("willChange",n),n.add(s)}}function qje(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const uMt="framerAppearId",RKe="data-"+qje(uMt);function FKe(t){return t.props[RKe]}function hMt({protectedKeys:t,needsAnimating:s},r){const n=t.hasOwnProperty(r)&&s[r]!==!0;return s[r]=!1,n}function zKe(t,s,{delay:r=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=s;const c=t.getDefaultTransition();o=o?DKe(o,c):c;const u=o==null?void 0:o.reduceMotion;n&&(o=n);const p=[],f=a&&t.animationState&&t.animationState.getState()[a];for(const g in i){const b=t.getValue(g,t.latestValues[g]??null),_=i[g];if(_===void 0||f&&hMt(f,g))continue;const j={delay:r,...zje(o||{},g)},w=b.get();if(w!==void 0&&!b.isAnimating()&&!Array.isArray(_)&&_===w&&!j.velocity){Ll.update(()=>b.set(_));continue}let k=!1;if(window.MotionHandoffAnimation){const L=FKe(t);if(L){const I=window.MotionHandoffAnimation(L,g,Ll);I!==null&&(j.startTime=I,k=!0)}}t1e(t,g);const S=u??t.shouldReduceMotion;b.start(Bje(g,b,_,S&&OKe.has(g)?{type:!1}:j,t,k));const M=b.animation;M&&p.push(M)}if(l){const g=()=>Ll.update(()=>{l&&cMt(t,l)});p.length?Promise.all(p).then(g):g()}return p}function s1e(t,s,r={}){var c;const n=yS(t,s,r.type==="exit"?(c=t.presenceContext)==null?void 0:c.custom:void 0);let{transition:a=t.getDefaultTransition()||{}}=n||{};r.transitionOverride&&(a=r.transitionOverride);const o=n?()=>Promise.all(zKe(t,n,r)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:p=0,staggerChildren:f,staggerDirection:g}=a;return mMt(t,s,u,p,f,g,r)}:()=>Promise.resolve(),{when:i}=a;if(i){const[u,p]=i==="beforeChildren"?[o,l]:[l,o];return u().then(()=>p())}else return Promise.all([o(),l(r.delay)])}function mMt(t,s,r=0,n=0,a=0,o=1,l){const i=[];for(const c of t.variantChildren)c.notify("AnimationStart",s),i.push(s1e(c,s,{...l,delay:r+(typeof n=="function"?0:n)+IKe(t.variantChildren,c,n,a,o)}).then(()=>c.notify("AnimationComplete",s)));return Promise.all(i)}function pMt(t,s,r={}){t.notify("AnimationStart",s);let n;if(Array.isArray(s)){const a=s.map(o=>s1e(t,o,r));n=Promise.all(a)}else if(typeof s=="string")n=s1e(t,s,r);else{const a=typeof s=="function"?yS(t,s,r.custom):s;n=Promise.all(zKe(t,a,r))}return n.then(()=>{t.notify("AnimationComplete",s)})}const fMt={test:t=>t==="auto",parse:t=>t},BKe=t=>s=>s.test(t),$Ke=[YA,ia,w0,Bb,$3t,B3t,fMt],V6e=t=>$Ke.find(BKe(t));function xMt(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||QGe(t):!0}const gMt=new Set(["brightness","contrast","saturate","opacity"]);function yMt(t){const[s,r]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[n]=r.match(Ije)||[];if(!n)return t;const a=r.replace(n,"");let o=gMt.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const vMt=/\b([a-z-]*)\(.*?\)/gu,r1e={...ty,getAnimatableNone:t=>{const s=t.match(vMt);return s?s.map(yMt).join(" "):t}},n1e={...ty,getAnimatableNone:t=>{const s=ty.parse(t);return ty.createTransformer(t)(s.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},H6e={...YA,transform:Math.round},bMt={rotate:Bb,rotateX:Bb,rotateY:Bb,rotateZ:Bb,scale:rz,scaleX:rz,scaleY:rz,scaleZ:rz,skew:Bb,skewX:Bb,skewY:Bb,distance:ia,translateX:ia,translateY:ia,translateZ:ia,x:ia,y:ia,z:ia,perspective:ia,transformPerspective:ia,opacity:tD,originX:E6e,originY:E6e,originZ:ia},Uje={borderWidth:ia,borderTopWidth:ia,borderRightWidth:ia,borderBottomWidth:ia,borderLeftWidth:ia,borderRadius:ia,borderTopLeftRadius:ia,borderTopRightRadius:ia,borderBottomRightRadius:ia,borderBottomLeftRadius:ia,width:ia,maxWidth:ia,height:ia,maxHeight:ia,top:ia,right:ia,bottom:ia,left:ia,inset:ia,insetBlock:ia,insetBlockStart:ia,insetBlockEnd:ia,insetInline:ia,insetInlineStart:ia,insetInlineEnd:ia,padding:ia,paddingTop:ia,paddingRight:ia,paddingBottom:ia,paddingLeft:ia,paddingBlock:ia,paddingBlockStart:ia,paddingBlockEnd:ia,paddingInline:ia,paddingInlineStart:ia,paddingInlineEnd:ia,margin:ia,marginTop:ia,marginRight:ia,marginBottom:ia,marginLeft:ia,marginBlock:ia,marginBlockStart:ia,marginBlockEnd:ia,marginInline:ia,marginInlineStart:ia,marginInlineEnd:ia,fontSize:ia,backgroundPositionX:ia,backgroundPositionY:ia,...bMt,zIndex:H6e,fillOpacity:tD,strokeOpacity:tD,numOctaves:H6e},_Mt={...Uje,color:Xd,backgroundColor:Xd,outlineColor:Xd,fill:Xd,stroke:Xd,borderColor:Xd,borderTopColor:Xd,borderRightColor:Xd,borderBottomColor:Xd,borderLeftColor:Xd,filter:r1e,WebkitFilter:r1e,mask:n1e,WebkitMask:n1e},qKe=t=>_Mt[t],wMt=new Set([r1e,n1e]);function UKe(t,s){let r=qKe(t);return wMt.has(r)||(r=ty),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const jMt=new Set(["auto","none","0"]);function NMt(t,s,r){let n=0,a;for(;n{s.getValue(c).set(u)}),this.resolveNoneKeyframes()}}function Vje(t,s,r){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){const a=document.querySelectorAll(t);return a?Array.from(a):[]}return Array.from(t).filter(n=>n!=null)}const VKe=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function pie(t){return XGe(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:Hje}=uKe(queueMicrotask,!1),Ag={x:!1,y:!1};function HKe(){return Ag.x||Ag.y}function SMt(t){return t==="x"||t==="y"?Ag[t]?null:(Ag[t]=!0,()=>{Ag[t]=!1}):Ag.x||Ag.y?null:(Ag.x=Ag.y=!0,()=>{Ag.x=Ag.y=!1})}function WKe(t,s){const r=Vje(t),n=new AbortController,a={passive:!0,...s,signal:n.signal};return[r,a,()=>n.abort()]}function CMt(t){return!(t.pointerType==="touch"||HKe())}function MMt(t,s,r={}){const[n,a,o]=WKe(t,r);return n.forEach(l=>{let i=!1,c=!1,u;const p=()=>{l.removeEventListener("pointerleave",_)},f=w=>{u&&(u(w),u=void 0),p()},g=w=>{i=!1,window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g),c&&(c=!1,f(w))},b=()=>{i=!0,window.addEventListener("pointerup",g,a),window.addEventListener("pointercancel",g,a)},_=w=>{if(w.pointerType!=="touch"){if(i){c=!0;return}f(w)}},j=w=>{if(!CMt(w))return;c=!1;const k=s(l,w);typeof k=="function"&&(u=k,l.addEventListener("pointerleave",_,a))};l.addEventListener("pointerenter",j,a),l.addEventListener("pointerdown",b,a)}),o}const GKe=(t,s)=>s?t===s?!0:GKe(t,s.parentElement):!1,Wje=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,TMt=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function AMt(t){return TMt.has(t.tagName)||t.isContentEditable===!0}const EMt=new Set(["INPUT","SELECT","TEXTAREA"]);function PMt(t){return EMt.has(t.tagName)||t.isContentEditable===!0}const fie=new WeakSet;function W6e(t){return s=>{s.key==="Enter"&&t(s)}}function Dxe(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const IMt=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=W6e(()=>{if(fie.has(r))return;Dxe(r,"down");const a=W6e(()=>{Dxe(r,"up")}),o=()=>Dxe(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 G6e(t){return Wje(t)&&!HKe()}const K6e=new WeakSet;function LMt(t,s,r={}){const[n,a,o]=WKe(t,r),l=i=>{const c=i.currentTarget;if(!G6e(i)||K6e.has(i))return;fie.add(c),r.stopPropagation&&K6e.add(i);const u=s(c,i),p=(b,_)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",g),fie.has(c)&&fie.delete(c),G6e(b)&&typeof u=="function"&&u(b,{success:_})},f=b=>{p(b,c===window||c===document||r.useGlobalTarget||GKe(c,b.target))},g=b=>{p(b,!1)};window.addEventListener("pointerup",f,a),window.addEventListener("pointercancel",g,a)};return n.forEach(i=>{(r.useGlobalTarget?window:i).addEventListener("pointerdown",l,a),pie(i)&&(i.addEventListener("focus",u=>IMt(u,a)),!AMt(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function Gje(t){return XGe(t)&&"ownerSVGElement"in t}const xie=new WeakMap;let $b;const KKe=(t,s,r)=>(n,a)=>a&&a[0]?a[0][t+"Size"]:Gje(n)&&"getBBox"in n?n.getBBox()[s]:n[r],DMt=KKe("inline","width","offsetWidth"),OMt=KKe("block","height","offsetHeight");function RMt({target:t,borderBoxSize:s}){var r;(r=xie.get(t))==null||r.forEach(n=>{n(t,{get width(){return DMt(t,s)},get height(){return OMt(t,s)}})})}function FMt(t){t.forEach(RMt)}function zMt(){typeof ResizeObserver>"u"||($b=new ResizeObserver(FMt))}function BMt(t,s){$b||zMt();const r=Vje(t);return r.forEach(n=>{let a=xie.get(n);a||(a=new Set,xie.set(n,a)),a.add(s),$b==null||$b.observe(n)}),()=>{r.forEach(n=>{const a=xie.get(n);a==null||a.delete(s),a!=null&&a.size||$b==null||$b.unobserve(n)})}}const gie=new Set;let oM;function $Mt(){oM=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};gie.forEach(s=>s(t))},window.addEventListener("resize",oM)}function qMt(t){return gie.add(t),oM||$Mt(),()=>{gie.delete(t),!gie.size&&typeof oM=="function"&&(window.removeEventListener("resize",oM),oM=void 0)}}function Z6e(t,s){return typeof t=="function"?qMt(t):BMt(t,s)}function UMt(t){return Gje(t)&&t.tagName==="svg"}const VMt=[...$Ke,Xd,ty],HMt=t=>VMt.find(BKe(t)),Y6e=()=>({translate:0,scale:1,origin:0,originPoint:0}),lM=()=>({x:Y6e(),y:Y6e()}),X6e=()=>({min:0,max:0}),fu=()=>({x:X6e(),y:X6e()}),WMt=new WeakMap;function oue(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function sD(t){return typeof t=="string"||Array.isArray(t)}const Kje=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Zje=["initial",...Kje];function lue(t){return oue(t.animate)||Zje.some(s=>sD(t[s]))}function ZKe(t){return!!(lue(t)||t.variants)}function GMt(t,s,r){for(const n in s){const a=s[n],o=r[n];if(jh(a))t.addValue(n,a);else if(jh(o))t.addValue(n,UT(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,UT(l!==void 0?l:a,{owner:t}))}}for(const n in r)s[n]===void 0&&t.removeValue(n);return s}const a1e={current:null},YKe={current:!1},KMt=typeof window<"u";function ZMt(){if(YKe.current=!0,!!KMt)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>a1e.current=t.matches;t.addEventListener("change",s),s()}else a1e.current=!1}const Q6e=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Roe={};function XKe(t){Roe=t}function YMt(){return Roe}class XMt{scrapeMotionValuesFromProps(s,r,n){return{}}constructor({parent:s,props:r,presenceContext:n,reducedMotionConfig:a,skipAnimations:o,blockInitialAnimation:l,visualState:i},c={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Fje,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const b=Nm.now();this.renderScheduledAtthis.bindToMotionValue(o,a)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(YKe.current||ZMt(),this.shouldReduceMotion=a1e.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(),fw(this.notifyUpdate),fw(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&&PKe.has(s)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:c,ease:u,duration:p}=r.accelerate,f=new AKe({element:this.current,name:s,keyframes:i,times:c,ease:u,duration:xf(p)}),g=l(f);this.valueSubscriptions.set(s,()=>{g(),f.cancel()});return}const n=QA.has(s);n&&this.onBindTransform&&this.onBindTransform();const a=r.on("change",l=>{this.latestValues[s]=l,this.props.onUpdate&&Ll.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 Roe){const r=Roe[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):fu()}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=UT(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"&&(YGe(n)||QGe(n))?n=parseFloat(n):!HMt(n)&&ty.test(r)&&(n=UKe(s,r)),this.setBaseTarget(s,jh(n)?n.get():n)),jh(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=$je(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&&!jh(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 Tje),this.events[s].add(r)}notify(s,...r){this.events[s]&&this.events[s].notify(...r)}scheduleRenderMicrotask(){Hje.render(this.render)}}class QKe extends XMt{constructor(){super(...arguments),this.KeyframeResolver=kMt}sortInstanceNodePosition(s,r){return s.compareDocumentPosition(r)&2?1:-1}getBaseTargetFromProps(s,r){const n=s.style;return n?n[r]:void 0}removeValueFromRenderState(s,{vars:r,style:n}){delete r[s],delete n[s]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:s}=this.props;jh(s)&&(this.childSubscription=s.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class Iw{constructor(s){this.isMounted=!1,this.node=s}update(){}}function JKe({top:t,left:s,right:r,bottom:n}){return{x:{min:s,max:r},y:{min:t,max:n}}}function QMt({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function JMt(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 Oxe(t){return t===void 0||t===1}function i1e({scale:t,scaleX:s,scaleY:r}){return!Oxe(t)||!Oxe(s)||!Oxe(r)}function n4(t){return i1e(t)||eZe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function eZe(t){return J6e(t.x)||J6e(t.y)}function J6e(t){return t&&t!=="0%"}function Foe(t,s,r){const n=t-r,a=s*n;return r+a}function ePe(t,s,r,n,a){return a!==void 0&&(t=Foe(t,a,n)),Foe(t,r,n)+s}function o1e(t,s=0,r=1,n,a){t.min=ePe(t.min,s,r,n,a),t.max=ePe(t.max,s,r,n,a)}function tZe(t,{x:s,y:r}){o1e(t.x,s.translate,s.scale,s.originPoint),o1e(t.y,r.translate,r.scale,r.originPoint)}const tPe=.999999999999,sPe=1.0000000000001;function eTt(t,s,r,n=!1){var i;const a=r.length;if(!a)return;s.x=s.y=1;let o,l;for(let c=0;ctPe&&(s.x=1),s.ytPe&&(s.y=1)}function e0(t,s){t.min+=s,t.max+=s}function rPe(t,s,r,n,a=.5){const o=wc(t.min,t.max,a);o1e(t,s,r,o,n)}function nPe(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function yie(t,s,r){const n=r??t;rPe(t.x,nPe(s.x,n.x),s.scaleX,s.scale,s.originX),rPe(t.y,nPe(s.y,n.y),s.scaleY,s.scale,s.originY)}function sZe(t,s){return JKe(JMt(t.getBoundingClientRect(),s))}function tTt(t,s,r){const n=sZe(t,r),{scroll:a}=s;return a&&(e0(n.x,a.offset.x),e0(n.y,a.offset.y)),n}const sTt={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},rTt=XA.length;function nTt(t,s,r){let n="",a=!0;for(let o=0;o{if(!s.target)return t;if(typeof t=="string")if(ia.test(t))t=parseFloat(t);else return t;const r=aPe(t,s.target.x),n=aPe(t,s.target.y);return`${r}% ${n}%`}},aTt={correct:(t,{treeScale:s,projectionDelta:r})=>{const n=t,a=ty.parse(t);if(a.length>5)return n;const o=ty.createTransformer(t),l=typeof a[0]!="number"?1:0,i=r.x.scale*s.x,c=r.y.scale*s.y;a[0+l]/=i,a[1+l]/=c;const u=wc(i,c,.5);return typeof a[2+l]=="number"&&(a[2+l]/=u),typeof a[3+l]=="number"&&(a[3+l]/=u),o(a)}},l1e={borderRadius:{...UP,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:UP,borderTopRightRadius:UP,borderBottomLeftRadius:UP,borderBottomRightRadius:UP,boxShadow:aTt};function nZe(t,{layout:s,layoutId:r}){return QA.has(t)||t.startsWith("origin")||(s||r!==void 0)&&(!!l1e[t]||t==="opacity")}function Xje(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)(jh(n[i])||a&&jh(a[i])||nZe(i,t)||((l=r==null?void 0:r.getValue(i))==null?void 0:l.liveStyle)!==void 0)&&(o[i]=n[i]);return o}function iTt(t){return window.getComputedStyle(t)}class oTt extends QKe{constructor(){super(...arguments),this.type="html",this.renderInstance=rZe}readValueFromInstance(s,r){var n;if(QA.has(r))return(n=this.projection)!=null&&n.isProjecting?Kve(r):C5t(s,r);{const a=iTt(s),o=(mKe(r)?a.getPropertyValue(r):a[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(s,{transformPagePoint:r}){return sZe(s,r)}build(s,r,n){Yje(s,r,n.transformTemplate)}scrapeMotionValuesFromProps(s,r,n){return Xje(s,r,n)}}const lTt={offset:"stroke-dashoffset",array:"stroke-dasharray"},cTt={offset:"strokeDashoffset",array:"strokeDasharray"};function dTt(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?lTt:cTt;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const uTt=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function aZe(t,{attrX:s,attrY:r,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},c,u,p){if(Yje(t,i,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:f,style:g}=t;f.transform&&(g.transform=f.transform,delete f.transform),(g.transform||f.transformOrigin)&&(g.transformOrigin=f.transformOrigin??"50% 50%",delete f.transformOrigin),g.transform&&(g.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete f.transformBox);for(const b of uTt)f[b]!==void 0&&(g[b]=f[b],delete f[b]);s!==void 0&&(f.x=s),r!==void 0&&(f.y=r),n!==void 0&&(f.scale=n),a!==void 0&&dTt(f,a,o,l,!1)}const iZe=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"]),oZe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function hTt(t,s,r,n){rZe(t,s,void 0,n);for(const a in s.attrs)t.setAttribute(iZe.has(a)?a:qje(a),s.attrs[a])}function lZe(t,s,r){const n=Xje(t,s,r);for(const a in t)if(jh(t[a])||jh(s[a])){const o=XA.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=t[a]}return n}class mTt extends QKe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=fu}getBaseTargetFromProps(s,r){return s[r]}readValueFromInstance(s,r){if(QA.has(r)){const n=qKe(r);return n&&n.default||0}return r=iZe.has(r)?r:qje(r),s.getAttribute(r)}scrapeMotionValuesFromProps(s,r,n){return lZe(s,r,n)}build(s,r,n){aZe(s,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(s,r,n,a){hTt(s,r,n,a)}mount(s){this.isSVGTag=oZe(s.tagName),super.mount(s)}}const pTt=Zje.length;function cZe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?cZe(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})=>pMt(t,r,n)))}function yTt(t){let s=gTt(t),r=iPe(),n=!0,a=!1;const o=u=>(p,f)=>{var b;const g=yS(t,f,u==="exit"?(b=t.presenceContext)==null?void 0:b.custom:void 0);if(g){const{transition:_,transitionEnd:j,...w}=g;p={...p,...w,...j}}return p};function l(u){s=u(t)}function i(u){const{props:p}=t,f=cZe(t.parent)||{},g=[],b=new Set;let _={},j=1/0;for(let k=0;kj&&I,V=!1;const Z=Array.isArray(L)?L:[L];let X=Z.reduce(o(S),{});O===!1&&(X={});const{prevResolvedValues:ee={}}=M,Q={...ee,...X},ie=ce=>{B=!0,b.has(ce)&&(V=!0,b.delete(ce)),M.needsAnimating[ce]=!0;const xe=t.getValue(ce);xe&&(xe.liveStyle=!1)};for(const ce in Q){const xe=X[ce],ge=ee[ce];if(_.hasOwnProperty(ce))continue;let ue=!1;e1e(xe)&&e1e(ge)?ue=!dZe(xe,ge):ue=xe!==ge,ue?xe!=null?ie(ce):b.add(ce):xe!==void 0&&b.has(ce)?ie(ce):M.protectedKeys[ce]=!0}M.prevProp=L,M.prevResolvedValues=X,M.isActive&&(_={..._,...X}),(n||a)&&t.blockInitialAnimation&&(B=!1);const re=q&&U;B&&(!re||V)&&g.push(...Z.map(ce=>{const xe={type:S};if(typeof ce=="string"&&(n||a)&&!re&&t.manuallyAnimateOnMount&&t.parent){const{parent:ge}=t,ue=yS(ge,ce);if(ge.enteringChildren&&ue){const{delayChildren:pe}=ue.transition||{};xe.delay=IKe(ge.enteringChildren,t,pe)}}return{animation:ce,options:xe}}))}if(b.size){const k={};if(typeof p.initial!="boolean"){const S=yS(t,Array.isArray(p.initial)?p.initial[0]:p.initial);S&&S.transition&&(k.transition=S.transition)}b.forEach(S=>{const M=t.getBaseTarget(S),L=t.getValue(S);L&&(L.liveStyle=!0),k[S]=M??null}),g.push({animation:k})}let w=!!g.length;return n&&(p.initial===!1||p.initial===p.animate)&&!t.manuallyAnimateOnMount&&(w=!1),n=!1,a=!1,w?s(g):Promise.resolve()}function c(u,p){var g;if(r[u].isActive===p)return Promise.resolve();(g=t.variantChildren)==null||g.forEach(b=>{var _;return(_=b.animationState)==null?void 0:_.setActive(u,p)}),r[u].isActive=p;const f=i(u);for(const b in r)r[b].protectedKeys={};return f}return{animateChanges:i,setActive:c,setAnimateFunction:l,getState:()=>r,reset:()=>{r=iPe(),a=!0}}}function vTt(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!dZe(s,t):!1}function F2(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function iPe(){return{animate:F2(!0),whileInView:F2(),whileHover:F2(),whileTap:F2(),whileDrag:F2(),whileFocus:F2(),exit:F2()}}function c1e(t,s){t.min=s.min,t.max=s.max}function Ng(t,s){c1e(t.x,s.x),c1e(t.y,s.y)}function oPe(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const uZe=1e-4,bTt=1-uZe,_Tt=1+uZe,hZe=.01,wTt=0-hZe,jTt=0+hZe;function km(t){return t.max-t.min}function NTt(t,s,r){return Math.abs(t-s)<=r}function lPe(t,s,r,n=.5){t.origin=n,t.originPoint=wc(s.min,s.max,t.origin),t.scale=km(r)/km(s),t.translate=wc(r.min,r.max,t.origin)-t.originPoint,(t.scale>=bTt&&t.scale<=_Tt||isNaN(t.scale))&&(t.scale=1),(t.translate>=wTt&&t.translate<=jTt||isNaN(t.translate))&&(t.translate=0)}function GL(t,s,r,n){lPe(t.x,s.x,r.x,n?n.originX:void 0),lPe(t.y,s.y,r.y,n?n.originY:void 0)}function cPe(t,s,r,n=0){const a=n?wc(r.min,r.max,n):r.min;t.min=a+s.min,t.max=t.min+km(s)}function kTt(t,s,r,n){cPe(t.x,s.x,r.x,n==null?void 0:n.x),cPe(t.y,s.y,r.y,n==null?void 0:n.y)}function dPe(t,s,r,n=0){const a=n?wc(r.min,r.max,n):r.min;t.min=s.min-a,t.max=t.min+km(s)}function zoe(t,s,r,n){dPe(t.x,s.x,r.x,n==null?void 0:n.x),dPe(t.y,s.y,r.y,n==null?void 0:n.y)}function uPe(t,s,r,n,a){return t-=s,t=Foe(t,1/r,n),a!==void 0&&(t=Foe(t,1/a,n)),t}function STt(t,s=0,r=1,n=.5,a,o=t,l=t){if(w0.test(s)&&(s=parseFloat(s),s=wc(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=wc(o.min,o.max,n);t===o&&(i-=s),t.min=uPe(t.min,s,r,i,a),t.max=uPe(t.max,s,r,i,a)}function hPe(t,s,[r,n,a],o,l){STt(t,s[r],s[n],s[a],s.scale,o,l)}const CTt=["x","scaleX","originX"],MTt=["y","scaleY","originY"];function mPe(t,s,r,n){hPe(t.x,s,CTt,r?r.x:void 0,n?n.x:void 0),hPe(t.y,s,MTt,r?r.y:void 0,n?n.y:void 0)}function pPe(t){return t.translate===0&&t.scale===1}function mZe(t){return pPe(t.x)&&pPe(t.y)}function fPe(t,s){return t.min===s.min&&t.max===s.max}function TTt(t,s){return fPe(t.x,s.x)&&fPe(t.y,s.y)}function xPe(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function pZe(t,s){return xPe(t.x,s.x)&&xPe(t.y,s.y)}function gPe(t){return km(t.x)/km(t.y)}function yPe(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function Hy(t){return[t("x"),t("y")]}function ATt(t,s,r){let n="";const a=t.x.translate/s.x,o=t.y.translate/s.y,l=(r==null?void 0:r.z)||0;if((a||o||l)&&(n=`translate3d(${a}px, ${o}px, ${l}px) `),(s.x!==1||s.y!==1)&&(n+=`scale(${1/s.x}, ${1/s.y}) `),r){const{transformPerspective:u,rotate:p,rotateX:f,rotateY:g,skewX:b,skewY:_}=r;u&&(n=`perspective(${u}px) ${n}`),p&&(n+=`rotate(${p}deg) `),f&&(n+=`rotateX(${f}deg) `),g&&(n+=`rotateY(${g}deg) `),b&&(n+=`skewX(${b}deg) `),_&&(n+=`skewY(${_}deg) `)}const i=t.x.scale*s.x,c=t.y.scale*s.y;return(i!==1||c!==1)&&(n+=`scale(${i}, ${c})`),n||"none"}const fZe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],ETt=fZe.length,vPe=t=>typeof t=="string"?parseFloat(t):t,bPe=t=>typeof t=="number"||ia.test(t);function PTt(t,s,r,n,a,o){a?(t.opacity=wc(0,r.opacity??1,ITt(n)),t.opacityExit=wc(s.opacity??1,0,LTt(n))):o&&(t.opacity=wc(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(eD(t,s,n))}function DTt(t,s,r){const n=jh(t)?t:UT(t);return n.start(Bje("",n,s,r)),n.animation}function rD(t,s,r,n={passive:!0}){return t.addEventListener(s,r,n),()=>t.removeEventListener(s,r)}const OTt=(t,s)=>t.depth-s.depth;class RTt{constructor(){this.children=[],this.isDirty=!1}add(s){Cje(this.children,s),this.isDirty=!0}remove(s){Poe(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(OTt),this.isDirty=!1,this.children.forEach(s)}}function FTt(t,s){const r=Nm.now(),n=({timestamp:a})=>{const o=a-r;o>=s&&(fw(n),t(o-s))};return Ll.setup(n,!0),()=>fw(n)}function vie(t){return jh(t)?t.get():t}class zTt{constructor(){this.members=[]}add(s){Cje(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&&(Poe(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(Poe(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 bie={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Rxe=["","X","Y","Z"],BTt=1e3;let $Tt=0;function Fxe(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function gZe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const r=FKe(s);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",Ll,!(a||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&gZe(n)}function yZe({attachResizeListener:t,defaultParent:s,measureScroll:r,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=s==null?void 0:s()){this.id=$Tt++,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(VTt),this.nodes.forEach(YTt),this.nodes.forEach(XTt),this.nodes.forEach(HTt)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=l,this.root=i?i.root||i:this,this.path=i?[...i.path,i]:[],this.parent=i,this.depth=i?i.depth+1:0;for(let c=0;cthis.root.updateBlockedByResize=!1;Ll.read(()=>{f=window.innerWidth}),t(l,()=>{const b=window.innerWidth;b!==f&&(f=b,this.root.updateBlockedByResize=!0,p&&p(),p=FTt(g,250),bie.hasAnimatedSinceResize&&(bie.hasAnimatedSinceResize=!1,this.nodes.forEach(NPe)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&u&&(i||c)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:f,hasRelativeLayoutChanged:g,layout:b})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const _=this.options.transition||u.getDefaultTransition()||sAt,{onLayoutAnimationStart:j,onLayoutAnimationComplete:w}=u.getProps(),k=!this.targetLayout||!pZe(this.targetLayout,b),S=!f&&g;if(this.options.layoutRoot||this.resumeFrom||S||f&&(k||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const M={...zje(_,"layout"),onPlay:j,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(M.delay=0,M.type=!1),this.startAnimation(M),this.setAnimationOrigin(p,S)}else f||NPe(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=b})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const l=this.getStack();l&&l.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),fw(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(QTt),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&&gZe(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&&!km(this.snapshot.measuredBox.x)&&!km(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c{const I=L/1e3;kPe(f.x,l.x,I),kPe(f.y,l.y,I),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(zoe(g,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),eAt(this.relativeTarget,this.relativeTargetOrigin,g,I),M&&TTt(this.relativeTarget,M)&&(this.isProjectionDirty=!1),M||(M=fu()),Ng(M,this.relativeTarget)),j&&(this.animationValues=p,PTt(p,u,this.latestValues,I,S,k)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=I},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){var i,c,u;this.notifyListeners("animationStart"),(i=this.currentAnimation)==null||i.stop(),(u=(c=this.resumingFrom)==null?void 0:c.currentAnimation)==null||u.stop(),this.pendingAnimation&&(fw(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Ll.update(()=>{bie.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=UT(0)),this.motionValue.jump(0,!1),this.currentAnimation=DTt(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(BTt),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:i,target:c,layout:u,latestValues:p}=l;if(!(!i||!c||!u)){if(this!==l&&this.layout&&u&&vZe(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||fu();const f=km(this.layout.layoutBox.x);c.x.min=l.target.x.min,c.x.max=c.x.min+f;const g=km(this.layout.layoutBox.y);c.y.min=l.target.y.min,c.y.max=c.y.min+g}Ng(i,c),yie(i,p),GL(this.projectionDeltaWithTransform,this.layoutCorrected,i,p)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new zTt),this.sharedNodes.get(l).add(i);const u=i.options.initialPromotionConfig;i.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(i):void 0})}isLead(){const l=this.getStack();return l?l.lead===this:!0}getLead(){var i;const{layoutId:l}=this.options;return l?((i=this.getStack())==null?void 0:i.lead)||this:this}getPrevLead(){var i;const{layoutId:l}=this.options;return l?(i=this.getStack())==null?void 0:i.prevLead:void 0}getStack(){const{layoutId:l}=this.options;if(l)return this.root.sharedNodes.get(l)}promote({needsReset:l,transition:i,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),l&&(this.projectionDelta=void 0,this.needsReset=!0),i&&this.setOptions({transition:i})}relegate(){const l=this.getStack();return l?l.relegate(this):!1}resetSkewAndRotation(){const{visualElement:l}=this.options;if(!l)return;let i=!1;const{latestValues:c}=l;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(i=!0),!i)return;const u={};c.z&&Fxe("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(wPe),this.root.sharedNodes.clear()}}}function qTt(t){t.updateLayout()}function UTt(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")Hy(f=>{const g=l?s.measuredBox[f]:s.layoutBox[f],b=km(g);g.min=n[f].min,g.max=g.min+b});else if(o==="x"||o==="y"){const f=o==="x"?"y":"x";c1e(l?s.measuredBox[f]:s.layoutBox[f],n[f])}else vZe(o,s.layoutBox,n)&&Hy(f=>{const g=l?s.measuredBox[f]:s.layoutBox[f],b=km(n[f]);g.max=g.min+b,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[f].max=t.relativeTarget[f].min+b)});const i=lM();GL(i,n,s.layoutBox);const c=lM();l?GL(c,t.applyTransform(a,!0),s.measuredBox):GL(c,n,s.layoutBox);const u=!mZe(i);let p=!1;if(!t.resumeFrom){const f=t.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:g,layout:b}=f;if(g&&b){const _=t.options.layoutAnchor||void 0,j=fu();zoe(j,s.layoutBox,g.layoutBox,_);const w=fu();zoe(w,n,b.layoutBox,_),pZe(j,w)||(p=!0),f.options.layoutRoot&&(t.relativeTarget=w,t.relativeTargetOrigin=j,t.relativeParent=f)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:s,delta:c,layoutDelta:i,hasLayoutChanged:u,hasRelativeLayoutChanged:p})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function VTt(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 HTt(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function WTt(t){t.clearSnapshot()}function wPe(t){t.clearMeasurements()}function GTt(t){t.isLayoutDirty=!0,t.updateLayout()}function jPe(t){t.isLayoutDirty=!1}function KTt(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function ZTt(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function NPe(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function YTt(t){t.resolveTargetDelta()}function XTt(t){t.calcProjection()}function QTt(t){t.resetSkewAndRotation()}function JTt(t){t.removeLeadSnapshot()}function kPe(t,s,r){t.translate=wc(s.translate,0,r),t.scale=wc(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function SPe(t,s,r,n){t.min=wc(s.min,r.min,n),t.max=wc(s.max,r.max,n)}function eAt(t,s,r,n){SPe(t.x,s.x,r.x,n),SPe(t.y,s.y,r.y,n)}function tAt(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const sAt={duration:.45,ease:[.4,0,.1,1]},CPe=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),MPe=CPe("applewebkit/")&&!CPe("chrome/")?Math.round:Tx;function TPe(t){t.min=MPe(t.min),t.max=MPe(t.max)}function rAt(t){TPe(t.x),TPe(t.y)}function vZe(t,s,r){return t==="position"||t==="preserve-aspect"&&!NTt(gPe(s),gPe(r),.2)}function nAt(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const aAt=yZe({attachResizeListener:(t,s)=>rD(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}),zxe={current:void 0},bZe=yZe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!zxe.current){const t=new aAt({});t.mount(window),t.setOptions({layoutScroll:!0}),zxe.current=t}return zxe.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Qje=N.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function APe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function iAt(...t){return s=>{let r=!1;const n=t.map(a=>{const o=APe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{width:b,height:_,top:j,left:w,right:k,bottom:S}=c.current;if(s||o===!1||!i.current||!b||!_)return;const M=r==="left"?`left: ${w}`:`right: ${k}`,L=n==="bottom"?`bottom: ${S}`:`top: ${j}`;i.current.dataset.motionPopId=l;const I=document.createElement("style");u&&(I.nonce=u);const O=a??document.head;return O.appendChild(I),I.sheet&&I.sheet.insertRule(` [data-motion-pop-id="${l}"] { position: absolute !important; width: ${b}px !important; height: ${_}px !important; ${M}px !important; ${L}px !important; } `),()=>{var q;(q=i.current)==null||q.removeAttribute("data-motion-pop-id"),O.contains(I)&&O.removeChild(I)}},[s]),e.jsx(lAt,{isPresent:s,childRef:i,sizeRef:c,pop:o,children:o===!1?t:N.cloneElement(t,{ref:f})})}const dAt=({children:t,initial:s,isPresent:r,onExitComplete:n,custom:a,presenceAffectsLayout:o,mode:l,anchorX:i,anchorY:c,root:u})=>{const p=Sje(uAt),f=N.useId();let g=!0,b=N.useMemo(()=>(g=!1,{id:f,initial:s,isPresent:r,custom:a,onExitComplete:_=>{p.set(_,!0);for(const j of p.values())if(!j)return;n&&n()},register:_=>(p.set(_,!1),()=>p.delete(_))}),[r,p,n]);return o&&g&&(b={...b}),N.useMemo(()=>{p.forEach((_,j)=>p.set(j,!1))},[r]),N.useEffect(()=>{!r&&!p.size&&n&&n()},[r]),t=e.jsx(cAt,{pop:l==="popLayout",isPresent:r,anchorX:i,anchorY:c,root:u,children:t}),e.jsx(aue.Provider,{value:b,children:t})};function uAt(){return new Map}function _Ze(t=!0){const s=N.useContext(aue);if(s===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:a}=s,o=N.useId();N.useEffect(()=>{if(t)return a(o)},[t]);const l=N.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,l]:[!0]}const nz=t=>t.key||"";function EPe(t){const s=[];return N.Children.forEach(t,r=>{N.isValidElement(r)&&s.push(r)}),s}const wZe=({children:t,custom:s,initial:r=!0,onExitComplete:n,presenceAffectsLayout:a=!0,mode:o="sync",propagate:l=!1,anchorX:i="left",anchorY:c="top",root:u})=>{const[p,f]=_Ze(l),g=N.useMemo(()=>EPe(t),[t]),b=l&&!p?[]:g.map(nz),_=N.useRef(!0),j=N.useRef(g),w=Sje(()=>new Map),k=N.useRef(new Set),[S,M]=N.useState(g),[L,I]=N.useState(g);ZGe(()=>{_.current=!1,j.current=g;for(let U=0;U{const B=nz(U),V=l&&!p?!1:g===L||b.includes(B),Z=()=>{if(k.current.has(B))return;if(w.has(B))k.current.add(B),w.set(B,!0);else return;let X=!0;w.forEach(ee=>{ee||(X=!1)}),X&&(q==null||q(),I(j.current),l&&(f==null||f()),n&&n())};return e.jsx(dAt,{isPresent:V,initial:!_.current||r?void 0:!1,custom:s,presenceAffectsLayout:a,mode:o,root:u,onExitComplete:V?void 0:Z,anchorX:i,anchorY:c,children:U},B)})})},jZe=N.createContext({strict:!1}),PPe={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 IPe=!1;function hAt(){if(IPe)return;const t={};for(const s in PPe)t[s]={isEnabled:r=>PPe[s].some(n=>!!r[n])};XKe(t),IPe=!0}function NZe(){return hAt(),YMt()}function mAt(t){const s=NZe();for(const r in t)s[r]={...s[r],...t[r]};XKe(s)}const pAt=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 Boe(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||pAt.has(t)}let kZe=t=>!Boe(t);function fAt(t){typeof t=="function"&&(kZe=s=>s.startsWith("on")?!Boe(s):t(s))}try{fAt(require("@emotion/is-prop-valid").default)}catch{}function xAt(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||jh(t[a])||(kZe(a)||r===!0&&Boe(a)||!s&&!Boe(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const cue=N.createContext({});function gAt(t,s){if(lue(t)){const{initial:r,animate:n}=t;return{initial:r===!1||sD(r)?r:void 0,animate:sD(n)?n:void 0}}return t.inherit!==!1?s:{}}function yAt(t){const{initial:s,animate:r}=gAt(t,N.useContext(cue));return N.useMemo(()=>({initial:s,animate:r}),[LPe(s),LPe(r)])}function LPe(t){return Array.isArray(t)?t.join(" "):t}const Jje=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function SZe(t,s,r){for(const n in s)!jh(s[n])&&!nZe(n,r)&&(t[n]=s[n])}function vAt({transformTemplate:t},s){return N.useMemo(()=>{const r=Jje();return Yje(r,s,t),Object.assign({},r.vars,r.style)},[s])}function bAt(t,s){const r=t.style||{},n={};return SZe(n,r,t),Object.assign(n,vAt(t,s)),n}function _At(t,s){const r={},n=bAt(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 CZe=()=>({...Jje(),attrs:{}});function wAt(t,s,r,n){const a=N.useMemo(()=>{const o=CZe();return aZe(o,s,oZe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};SZe(o,t.style,t),a.style={...o,...a.style}}return a}const jAt=["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 eNe(t){return typeof t!="string"||t.includes("-")?!1:!!(jAt.indexOf(t)>-1||/[A-Z]/u.test(t))}function NAt(t,s,r,{latestValues:n},a,o=!1,l){const c=(l??eNe(t)?wAt:_At)(s,n,a,t),u=xAt(s,typeof t=="string",o),p=t!==N.Fragment?{...u,...c,ref:r}:{},{children:f}=s,g=N.useMemo(()=>jh(f)?f.get():f,[f]);return N.createElement(t,{...p,children:g})}function kAt({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:SAt(r,n,a,t),renderState:s()}}function SAt(t,s,r,n){const a={},o=n(t,{});for(const g in o)a[g]=vie(o[g]);let{initial:l,animate:i}=t;const c=lue(t),u=ZKe(t);s&&u&&!c&&t.inherit!==!1&&(l===void 0&&(l=s.initial),i===void 0&&(i=s.animate));let p=r?r.initial===!1:!1;p=p||l===!1;const f=p?i:l;if(f&&typeof f!="boolean"&&!oue(f)){const g=Array.isArray(f)?f:[f];for(let b=0;b(s,r)=>{const n=N.useContext(cue),a=N.useContext(aue),o=()=>kAt(t,s,n,a);return r?o():Sje(o)},CAt=MZe({scrapeMotionValuesFromProps:Xje,createRenderState:Jje}),MAt=MZe({scrapeMotionValuesFromProps:lZe,createRenderState:CZe}),TAt=Symbol.for("motionComponentSymbol");function AAt(t,s,r){const n=N.useRef(r);N.useInsertionEffect(()=>{n.current=r});const a=N.useRef(null);return N.useCallback(o=>{var i;o&&((i=t.onMount)==null||i.call(t,o));const l=n.current;if(typeof l=="function")if(o){const c=l(o);typeof c=="function"&&(a.current=c)}else a.current?(a.current(),a.current=null):l(o);else l&&(l.current=o);s&&(o?s.mount(o):s.unmount())},[s])}const TZe=N.createContext({});function z5(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function EAt(t,s,r,n,a,o){var M,L;const{visualElement:l}=N.useContext(cue),i=N.useContext(jZe),c=N.useContext(aue),u=N.useContext(Qje),p=u.reducedMotion,f=u.skipAnimations,g=N.useRef(null),b=N.useRef(!1);n=n||i.renderer,!g.current&&n&&(g.current=n(t,{visualState:s,parent:l,props:r,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:p,skipAnimations:f,isSVG:o}),b.current&&g.current&&(g.current.manuallyAnimateOnMount=!0));const _=g.current,j=N.useContext(TZe);_&&!_.projection&&a&&(_.type==="html"||_.type==="svg")&&PAt(g.current,r,a,j);const w=N.useRef(!1);N.useInsertionEffect(()=>{_&&w.current&&_.update(r,c)});const k=r[RKe],S=N.useRef(!!k&&typeof window<"u"&&!((M=window.MotionHandoffIsComplete)!=null&&M.call(window,k))&&((L=window.MotionHasOptimisedAnimation)==null?void 0:L.call(window,k)));return ZGe(()=>{b.current=!0,_&&(w.current=!0,window.MotionIsMounted=!0,_.updateFeatures(),_.scheduleRenderMicrotask(),S.current&&_.animationState&&_.animationState.animateChanges())}),N.useEffect(()=>{_&&(!S.current&&_.animationState&&_.animationState.animateChanges(),S.current&&(queueMicrotask(()=>{var I;(I=window.MotionHandoffMarkAsComplete)==null||I.call(window,k)}),S.current=!1),_.enteringChildren=void 0)}),_}function PAt(t,s,r,n){const{layoutId:a,layout:o,drag:l,dragConstraints:i,layoutScroll:c,layoutRoot:u,layoutAnchor:p,layoutCrossfade:f}=s;t.projection=new r(t.latestValues,s["data-framer-portal-id"]?void 0:AZe(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&z5(i),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:f,layoutScroll:c,layoutRoot:u,layoutAnchor:p})}function AZe(t){if(t)return t.options.allowProjection!==!1?t.projection:AZe(t.parent)}function Bxe(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&mAt(n);const o=r?r==="svg":eNe(t),l=o?MAt:CAt;function i(u,p){let f;const g={...N.useContext(Qje),...u,layoutId:IAt(u)},{isStatic:b}=g,_=yAt(u),j=l(u,b);if(!b&&typeof window<"u"){LAt();const w=DAt(g);f=w.MeasureLayout,_.visualElement=EAt(t,j,g,a,w.ProjectionNode,o)}return e.jsxs(cue.Provider,{value:_,children:[f&&_.visualElement?e.jsx(f,{visualElement:_.visualElement,...g}):null,NAt(t,u,AAt(j,_.visualElement,p),j,b,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const c=N.forwardRef(i);return c[TAt]=t,c}function IAt({layoutId:t}){const s=N.useContext(kje).id;return s&&t!==void 0?s+"-"+t:t}function LAt(t,s){N.useContext(jZe).strict}function DAt(t){const s=NZe(),{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 OAt(t,s){if(typeof Proxy>"u")return Bxe;const r=new Map,n=(o,l)=>Bxe(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,Bxe(l,void 0,t,s)),r.get(l))})}const RAt=(t,s)=>s.isSVG??eNe(t)?new mTt(s):new oTt(s,{allowProjection:t!==N.Fragment});class FAt extends Iw{constructor(s){super(s),s.animationState||(s.animationState=yTt(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();oue(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 zAt=0;class BAt extends Iw{constructor(){super(...arguments),this.id=zAt++,this.isExitComplete=!1}update(){var o;if(!this.node.presenceContext)return;const{isPresent:s,onExitComplete:r}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||s===n)return;if(s&&n===!1){if(this.isExitComplete){const{initial:l,custom:i}=this.node.getProps();if(typeof l=="string"){const c=yS(this.node,l,i);if(c){const{transition:u,transitionEnd:p,...f}=c;for(const g in f)(o=this.node.getValue(g))==null||o.jump(f[g])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const a=this.node.animationState.setActive("exit",!s);r&&!s&&a.then(()=>{this.isExitComplete=!0,r(this.id)})}mount(){const{register:s,onExitComplete:r}=this.node.presenceContext||{};r&&r(this.id),s&&(this.unmount=s(this.id))}unmount(){}}const $At={animation:{Feature:FAt},exit:{Feature:BAt}};function OO(t){return{point:{x:t.pageX,y:t.pageY}}}const qAt=t=>s=>Wje(s)&&t(s,OO(s));function KL(t,s,r,n){return rD(t,s,qAt(r),n)}const EZe=({current:t})=>t?t.ownerDocument.defaultView:null,DPe=(t,s)=>Math.abs(t-s);function UAt(t,s){const r=DPe(t.x,s.x),n=DPe(t.y,s.y);return Math.sqrt(r**2+n**2)}const OPe=new Set(["auto","scroll"]);class PZe{constructor(s,r,{transformPagePoint:n,contextWindow:a=window,dragSnapToOrigin:o=!1,distanceThreshold:l=3,element:i}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=b=>{this.handleScroll(b.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=az(this.lastRawMoveEventInfo,this.transformPagePoint));const b=$xe(this.lastMoveEventInfo,this.history),_=this.startEvent!==null,j=UAt(b.offset,{x:0,y:0})>=this.distanceThreshold;if(!_&&!j)return;const{point:w}=b,{timestamp:k}=vh;this.history.push({...w,timestamp:k});const{onStart:S,onMove:M}=this.handlers;_||(S&&S(this.lastMoveEvent,b),this.startEvent=this.lastMoveEvent),M&&M(this.lastMoveEvent,b)},this.handlePointerMove=(b,_)=>{this.lastMoveEvent=b,this.lastRawMoveEventInfo=_,this.lastMoveEventInfo=az(_,this.transformPagePoint),Ll.update(this.updatePoint,!0)},this.handlePointerUp=(b,_)=>{this.end();const{onEnd:j,onSessionEnd:w,resumeAnimation:k}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&k&&k(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=$xe(b.type==="pointercancel"?this.lastMoveEventInfo:az(_,this.transformPagePoint),this.history);this.startEvent&&j&&j(b,S),w&&w(b,S)},!Wje(s))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const c=OO(s),u=az(c,this.transformPagePoint),{point:p}=u,{timestamp:f}=vh;this.history=[{...p,timestamp:f}];const{onSessionStart:g}=r;g&&g(s,$xe(u,this.history)),this.removeListeners=IO(KL(this.contextWindow,"pointermove",this.handlePointerMove),KL(this.contextWindow,"pointerup",this.handlePointerUp),KL(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(s){let r=s.parentElement;for(;r;){const n=getComputedStyle(r);(OPe.has(n.overflowX)||OPe.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),Ll.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),fw(this.updatePoint)}}function az(t,s){return s?{point:s(t.point)}:t}function RPe(t,s){return{x:t.x-s.x,y:t.y-s.y}}function $xe({point:t},s){return{point:t,delta:RPe(t,IZe(s)),offset:RPe(t,VAt(s)),velocity:HAt(s,.1)}}function VAt(t){return t[0]}function IZe(t){return t[t.length-1]}function HAt(t,s){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const a=IZe(t);for(;r>=0&&(n=t[r],!(a.timestamp-n.timestamp>xf(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>xf(s)*2&&(n=t[1]);const o=bx(a.timestamp-n.timestamp);if(o===0)return{x:0,y:0};const l={x:(a.x-n.x)/o,y:(a.y-n.y)/o};return l.x===1/0&&(l.x=0),l.y===1/0&&(l.y=0),l}function WAt(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?wc(r,t,n.max):Math.min(t,r)),t}function FPe(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 GAt(t,{top:s,left:r,bottom:n,right:a}){return{x:FPe(t.x,r,a),y:FPe(t.y,s,n)}}function zPe(t,s){let r=s.min-t.min,n=s.max-t.max;return s.max-s.minn?r=eD(s.min,s.max-n,t.min):n>a&&(r=eD(t.min,t.max-a,s.min)),M0(0,1,r)}function YAt(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 d1e=.35;function XAt(t=d1e){return t===!1?t=0:t===!0&&(t=d1e),{x:BPe(t,"left","right"),y:BPe(t,"top","bottom")}}function BPe(t,s,r){return{min:$Pe(t,s),max:$Pe(t,r)}}function $Pe(t,s){return typeof t=="number"?t:t[s]||0}const QAt=new WeakMap;class JAt{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=fu(),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(OO(f).point),this.stopAnimation()},l=(f,g)=>{const{drag:b,dragPropagation:_,onDragStart:j}=this.getProps();if(b&&!_&&(this.openDragLock&&this.openDragLock(),this.openDragLock=SMt(b),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=g,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Hy(k=>{let S=this.getAxisMotionValue(k).get()||0;if(w0.test(S)){const{projection:M}=this.visualElement;if(M&&M.layout){const L=M.layout.layoutBox[k];L&&(S=km(L)*(parseFloat(S)/100))}}this.originPoint[k]=S}),j&&Ll.update(()=>j(f,g),!1,!0),t1e(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},i=(f,g)=>{this.latestPointerEvent=f,this.latestPanInfo=g;const{dragPropagation:b,dragDirectionLock:_,onDirectionLock:j,onDrag:w}=this.getProps();if(!b&&!this.openDragLock)return;const{offset:k}=g;if(_&&this.currentDirection===null){this.currentDirection=tEt(k),this.currentDirection!==null&&j&&j(this.currentDirection);return}this.updateAxis("x",g.point,k),this.updateAxis("y",g.point,k),this.visualElement.render(),w&&Ll.update(()=>w(f,g),!1,!0)},c=(f,g)=>{this.latestPointerEvent=f,this.latestPanInfo=g,this.stop(f,g),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:f}=this.getProps();(f||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new PZe(s,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:n,contextWindow:EZe(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&&Ll.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||!iz(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=WAt(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&&z5(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&n?this.constraints=GAt(n.layoutBox,s):this.constraints=!1,this.elastic=XAt(r),a!==this.constraints&&!z5(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&Hy(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=YAt(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:r}=this.getProps();if(!s||!z5(s))return!1;const n=s.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=tTt(n,a.root,this.visualElement.getTransformPagePoint());let l=KAt(a.layout.layoutBox,o);if(r){const i=r(QMt(l));this.hasMutatedConstraints=!!i,i&&(l=JKe(i))}return l}startAnimation(s){const{drag:r,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),c=this.constraints||{},u=Hy(p=>{if(!iz(p,r,this.currentDirection))return;let f=c&&c[p]||{};(l===!0||l===p)&&(f={min:0,max:0});const g=a?200:1e6,b=a?40:1e7,_={type:"inertia",velocity:n?s[p]:0,bounceStiffness:g,bounceDamping:b,timeConstant:750,restDelta:1,restSpeed:10,...o,...f};return this.startAxisValueAnimation(p,_)});return Promise.all(u).then(i)}startAxisValueAnimation(s,r){const n=this.getAxisMotionValue(s);return t1e(this.visualElement,s),n.start(Bje(s,n,0,r,this.visualElement,!1))}stopAnimation(){Hy(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){Hy(r=>{const{drag:n}=this.getProps();if(!iz(r,n,this.currentDirection))return;const{projection:a}=this.visualElement,o=this.getAxisMotionValue(r);if(a&&a.layout){const{min:l,max:i}=a.layout.layoutBox[r],c=o.get()||0;o.set(s[r]-wc(l,i,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!z5(r)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Hy(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const c=i.get();a[l]=ZAt({min:c,max:c},this.constraints[l])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),Hy(l=>{if(!iz(l,s,null))return;const i=this.getAxisMotionValue(l),{min:c,max:u}=this.constraints[l];i.set(wc(c,u,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;QAt.set(this.visualElement,this);const s=this.visualElement.current,r=KL(s,"pointerdown",u=>{const{drag:p,dragListener:f=!0}=this.getProps(),g=u.target,b=g!==s&&PMt(g);p&&f&&!b&&this.start(u)});let n;const a=()=>{const{dragConstraints:u}=this.getProps();z5(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),n||(n=eEt(s,u.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),Ll.read(a);const i=rD(window,"resize",()=>this.scalePositionWithinConstraints()),c=o.addEventListener("didUpdate",({delta:u,hasLayoutChanged:p})=>{this.isDragging&&p&&(Hy(f=>{const g=this.getAxisMotionValue(f);g&&(this.originPoint[f]+=u[f].translate,g.set(g.get()+u[f].translate))}),this.visualElement.render())});return()=>{i(),r(),l(),c&&c(),n&&n()}}getProps(){const s=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:a=!1,dragConstraints:o=!1,dragElastic:l=d1e,dragMomentum:i=!0}=s;return{...s,drag:r,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function qPe(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function eEt(t,s,r){const n=Z6e(t,qPe(r)),a=Z6e(s,qPe(r));return()=>{n(),a()}}function iz(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function tEt(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class sEt extends Iw{constructor(s){super(s),this.removeGroupControls=Tx,this.removeListeners=Tx,this.controls=new JAt(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Tx}update(){const{dragControls:s}=this.node.getProps(),{dragControls:r}=this.node.prevProps||{};s!==r&&(this.removeGroupControls(),s&&(this.removeGroupControls=s.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const qxe=t=>(s,r)=>{t&&Ll.update(()=>t(s,r),!1,!0)};class rEt extends Iw{constructor(){super(...arguments),this.removePointerDownListener=Tx}onPointerDown(s){this.session=new PZe(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:EZe(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:r,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:qxe(s),onStart:qxe(r),onMove:qxe(n),onEnd:(o,l)=>{delete this.session,a&&Ll.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=KL(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 Uxe=!1;class nEt extends N.Component{componentDidMount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n,layoutId:a}=this.props,{projection:o}=s;o&&(r.group&&r.group.add(o),n&&n.register&&a&&n.register(o),Uxe&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),bie.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}),Uxe=!0,a||s.layoutDependency!==r||r===void 0||s.isPresent!==o?l.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?l.promote():l.relegate()||Ll.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(),Hje.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:a}=s;Uxe=!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 LZe(t){const[s,r]=_Ze(),n=N.useContext(kje);return e.jsx(nEt,{...t,layoutGroup:n,switchLayoutGroup:N.useContext(TZe),isPresent:s,safeToRemove:r})}const aEt={pan:{Feature:rEt},drag:{Feature:sEt,ProjectionNode:bZe,MeasureLayout:LZe}};function UPe(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&&Ll.postRender(()=>o(s,OO(s)))}class iEt extends Iw{mount(){const{current:s}=this.node;s&&(this.unmount=MMt(s,(r,n)=>(UPe(this.node,n,"Start"),a=>UPe(this.node,a,"End"))))}unmount(){}}class oEt extends Iw{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=IO(rD(this.node.current,"focus",()=>this.onFocus()),rD(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function VPe(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&&Ll.postRender(()=>o(s,OO(s)))}class lEt extends Iw{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=LMt(s,(a,o)=>(VPe(this.node,o,"Start"),(l,{success:i})=>VPe(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const u1e=new WeakMap,Vxe=new WeakMap,cEt=t=>{const s=u1e.get(t.target);s&&s(t)},dEt=t=>{t.forEach(cEt)};function uEt({root:t,...s}){const r=t||document;Vxe.has(r)||Vxe.set(r,{});const n=Vxe.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(dEt,{root:t,...s})),n[a]}function hEt(t,s,r){const n=uEt(s);return u1e.set(t,r),n.observe(t),()=>{u1e.delete(t),n.unobserve(t)}}const mEt={some:0,all:1};class pEt extends Iw{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var c;(c=this.stopObserver)==null||c.call(this);const{viewport:s={}}=this.node.getProps(),{root:r,margin:n,amount:a="some",once:o}=s,l={root:r?r.current:void 0,rootMargin:n,threshold:typeof a=="number"?a:mEt[a]},i=u=>{const{isIntersecting:p}=u;if(this.isInView===p||(this.isInView=p,o&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:f,onViewportLeave:g}=this.node.getProps(),b=p?f:g;b&&b(u)};this.stopObserver=hEt(this.node.current,l,i)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:s,prevProps:r}=this.node;["amount","margin","root"].some(fEt(s,r))&&this.startObserver()}unmount(){var s;(s=this.stopObserver)==null||s.call(this),this.hasEnteredView=!1,this.isInView=!1}}function fEt({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const xEt={inView:{Feature:pEt},tap:{Feature:lEt},focus:{Feature:oEt},hover:{Feature:iEt}},gEt={layout:{ProjectionNode:bZe,MeasureLayout:LZe}},yEt={...$At,...xEt,...aEt,...gEt},Hs=OAt(yEt,RAt),vEt={some:0,all:1};function bEt(t,s,{root:r,margin:n,amount:a="some"}={}){const o=Vje(t),l=new WeakMap,i=u=>{u.forEach(p=>{const f=l.get(p.target);if(p.isIntersecting!==!!f)if(p.isIntersecting){const g=s(p.target,p);typeof g=="function"?l.set(p.target,g):c.unobserve(p.target)}else typeof f=="function"&&(f(p),l.delete(p.target))})},c=new IntersectionObserver(i,{root:r,rootMargin:n,threshold:typeof a=="number"?a:vEt[a]});return o.forEach(u=>c.observe(u)),()=>c.disconnect()}function _Et(t,{root:s,margin:r,amount:n,once:a=!1,initial:o=!1}={}){const[l,i]=N.useState(o);return N.useEffect(()=>{if(!t.current||a&&l)return;const c=()=>(i(!0),a?void 0:()=>i(!1)),u={root:s&&s.current||void 0,margin:r,amount:n};return bEt(t.current,c,u)},[s,t,r,a,n]),l}function wEt(t){switch(t){case"buying":return{label:"Buying",emoji:"🏠",color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30"};case"selling":return{label:"Selling",emoji:"📋",color:"bg-blue-500/15 text-blue-400 border-blue-500/30"};case"neighbor":return{label:"Neighbor",emoji:"👋",color:"bg-amber-500/15 text-amber-400 border-amber-500/30"};case"browsing":return{label:"Browsing",emoji:"👀",color:"bg-slate-500/15 text-slate-300 border-slate-500/30"};default:return{label:"Visitor",emoji:"🙂",color:"bg-slate-500/15 text-slate-300 border-slate-500/30"}}}function HPe(t){return t.visitor_intent==="buying"&&!t.has_agent}function jEt({token:t}={}){var _;const s=yo(),r=t||s.token,{data:n,isLoading:a,isError:o}=o3t(r),l=Qt(),i=(_=n==null?void 0:n.open_houses)==null?void 0:_.id,{data:c}=mt({queryKey:["cohost-visitors",i],queryFn:async()=>{const{data:j,error:w}=await H.from("open_house_visitors").select("*").eq("open_house_id",i).order("created_at",{ascending:!1});if(w)throw w;return j},enabled:!!i});if(N.useEffect(()=>{if(!i)return;const j=H.channel(`cohost-visitors-${i}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"open_house_visitors",filter:`open_house_id=eq.${i}`},()=>{l.invalidateQueries({queryKey:["cohost-visitors",i]})}).subscribe();return()=>{H.removeChannel(j)}},[i,l]),a)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center",children:e.jsx("div",{className:"animate-pulse text-white/40",children:"Validating access..."})});if(o||!n)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx("h1",{className:"text-xl font-bold mb-2",children:"Link Expired or Invalid"}),e.jsx("p",{className:"text-white/40 text-sm",children:"This co-host link is no longer active. Ask the host for a new one."})]})});const u=n.open_houses,p=(c==null?void 0:c.length)||0,f=(c==null?void 0:c.filter(j=>j.visitor_intent==="buying").length)||0,g=(c==null?void 0:c.filter(HPe).length)||0,b=j=>{if(!j)return"";const[w,k]=j.split(":"),S=parseInt(w);return`${S>12?S-12:S||12}:${k} ${S>=12?"PM":"AM"}`};return e.jsxs("div",{className:"fixed inset-0 bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex flex-col",children:[e.jsxs("div",{className:"border-b border-white/10 px-4 sm:px-6 py-3 flex items-center justify-between bg-black/30 backdrop-blur-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{className:"text-xs font-medium text-emerald-400 uppercase tracking-wider",children:"Live · Co-Host View"})]}),e.jsx("h1",{className:"text-white font-bold text-sm sm:text-base truncate",children:u.property_address})]}),e.jsxs("div",{className:"flex items-center gap-4 sm:gap-6 text-white/70",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(pr,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:p})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-orange-400",children:[e.jsx(eh,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:g})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(bn,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:f})]})]})]}),e.jsxs("div",{className:"px-4 sm:px-6 py-2 flex items-center gap-4 text-xs text-white/40 border-b border-white/5",children:[e.jsx("span",{children:ms(new Date(u.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy")}),u.start_time&&e.jsxs("span",{children:[b(u.start_time),u.end_time?` – ${b(u.end_time)}`:""]})]}),e.jsx(Gi,{className:"flex-1 p-4 sm:p-6",children:c!=null&&c.length?e.jsx("div",{className:"space-y-2 max-w-3xl mx-auto",children:e.jsx(wZe,{children:c.map((j,w)=>{var M;const k=wEt(j.visitor_intent),S=HPe(j);return e.jsxs(Hs.div,{initial:{opacity:0,x:-40,scale:.95},animate:{opacity:1,x:0,scale:1},transition:{duration:.4,delay:w*.05},className:`flex items-center gap-4 p-4 rounded-xl border ${S?"bg-orange-500/10 border-orange-500/30":"bg-white/5 border-white/10"}`,children:[e.jsx("div",{className:`w-11 h-11 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${S?"bg-gradient-to-br from-orange-500 to-amber-500 text-white":"bg-white/10 text-white/80"}`,children:(M=j.first_name[0])==null?void 0:M.toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"font-semibold text-white truncate",children:[j.first_name," ",j.last_name||""]}),S&&e.jsx(tt,{className:"bg-orange-500/20 text-orange-300 border-orange-500/40 text-[10px] px-1.5 py-0",children:"🔥 HOT"}),j.has_agent&&e.jsx(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-yellow-500/40 text-yellow-400",children:"⚠️ Has Agent"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsxs(tt,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${k.color}`,children:[k.emoji," ",k.label]}),e.jsx("span",{className:"text-white/30 text-xs",children:ms(new Date(j.created_at),"h:mm a")})]})]})]},j.id)})})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center py-20",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-white/5 flex items-center justify-center mb-4",children:e.jsx(d1,{className:"h-10 w-10 text-white/20"})}),e.jsx("h2",{className:"text-xl font-bold text-white/60 mb-1",children:"Waiting for visitors..."}),e.jsx("p",{className:"text-white/30 text-sm",children:"New sign-ins will appear here in real-time"})]})})]})}function NEt(){const s=zd().pathname.slice(1);if(N.useEffect(()=>(document.body.classList.add("guestbook-page"),()=>{document.body.classList.remove("guestbook-page")}),[]),s.startsWith("live/")){const r=s.slice(5);if(r)return e.jsx(jEt,{token:r})}return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Guest Book"}),e.jsx("p",{className:"text-white/60",children:"The modern open house sign-in experience."}),e.jsx("p",{className:"text-white/40 text-sm mt-2",children:"Visit a specific open house link to sign in."})]})}):e.jsx(DGe,{slug:s})}function kEt({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(bn,{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(ma,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:a})]}),r&&e.jsx("p",{className:"mt-4 text-sm text-white/70 leading-relaxed max-w-sm mx-auto",children:r})]})]}),s&&e.jsx("div",{className:"max-w-lg mx-auto px-4 -mt-8 relative z-10",children:e.jsx("div",{className:"bg-white rounded-2xl shadow-lg border border-slate-100 p-4",children:e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[s.phone&&e.jsxs("a",{href:`tel:${s.phone}`,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-[#406E71]/10 hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(Un,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Call"})]}),s.email&&e.jsxs("a",{href:`mailto:${s.email}`,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-[#406E71]/10 hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(cr,{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($c,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function SEt({journeyStages:t,currentIndex:s}){return t.length===0?null:e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-base font-semibold text-slate-800 mb-1",children:"Your Home Journey"}),e.jsx("p",{className:"text-xs text-slate-400 mb-5",children:"Follow along as your transaction progresses"}),e.jsx("div",{className:"relative",children:t.map((r,n)=>{const a=ns;return e.jsxs("div",{className:"flex items-start gap-3.5 relative",children:[n{var l,i;if(o.includes("youtube.com/watch")){const c=new URL(o).searchParams.get("v");return c?`https://www.youtube.com/embed/${c}`:null}if(o.includes("youtu.be/")){const c=(l=o.split("youtu.be/")[1])==null?void 0:l.split("?")[0];return c?`https://www.youtube.com/embed/${c}`:null}if(o.includes("loom.com/share/")){const c=(i=o.split("loom.com/share/")[1])==null?void 0:i.split("?")[0];return c?`https://www.loom.com/embed/${c}`:null}return o};return e.jsxs("div",{className:"bg-gradient-to-br from-[#406E71]/5 via-white to-[#406E71]/5 rounded-2xl border border-[#406E71]/15 overflow-hidden",children:[e.jsx("div",{className:"bg-[#406E71] px-5 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qa,{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 Dl(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 TEt(t,s){const r=ms(s,"yyyyMMdd");return`https://calendar.google.com/calendar/render?${new URLSearchParams({action:"TEMPLATE",text:t,dates:`${r}/${r}`,details:"Added from your Client Portal"}).toString()}`}function AEt(t,s){const r=ms(s,"yyyyMMdd");return`data:text/calendar;charset=utf-8,${encodeURIComponent(`BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT DTSTART;VALUE=DATE:${r} DTEND;VALUE=DATE:${r} SUMMARY:${t} DESCRIPTION:Added from your Client Portal END:VEVENT END:VCALENDAR`)}`}function EEt({targetCloseDate:t,contractDate:s,inspectionDate:r,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:s,icon:CM,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:r,icon:cn,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:bn,color:"text-purple-600 bg-purple-50"},{label:a?"Closed":"Target Close",date:a||t,icon:hn,color:"text-emerald-600 bg-emerald-50"}].filter(i=>i.date);if(o.length===0)return null;const l=(i,c,u)=>{const p=Dl(c);if(u==="google")window.open(TEt(i,p),"_blank");else{const f=AEt(i,p),g=document.createElement("a");g.href=f,g.download=`${i.replace(/\s+/g,"-").toLowerCase()}.ics`,g.click()}};return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-3",children:"Key Dates"}),e.jsx("div",{className:"space-y-3",children:o.map(({label:i,date:c,icon:u,color:p})=>{const f=Dl(c),g=b0(f)&&!bu(f),b=bu(f),_=!g&&!b;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${p}`,children:e.jsx(u,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs text-slate-500",children:i}),e.jsxs("p",{className:`text-sm font-medium ${b?"text-emerald-600":g?"text-slate-400":"text-slate-800"}`,children:[ms(f,"MMM d, yyyy"),b&&e.jsx("span",{className:"ml-1.5 text-xs bg-emerald-100 text-emerald-700 px-1.5 py-0.5 rounded-full",children:"Today"})]})]}),g&&e.jsx("span",{className:"text-xs text-slate-400",children:"✓"}),_&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>l(i,c,"google"),className:"text-xs text-slate-400 hover:text-blue-500 transition-colors px-1.5 py-1 rounded hover:bg-blue-50",title:"Add to Google Calendar",children:e.jsx(O_,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>l(i,c,"apple"),className:"text-[10px] text-slate-400 hover:text-slate-600 transition-colors px-1.5 py-1 rounded hover:bg-slate-100",title:"Download .ics file",children:".ics"})]})]},i)})})]})}function PEt({documents:t}){const s=n=>n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(0)} KB`:`${(n/1048576).toFixed(1)} MB`,r=async n=>{const{data:a}=await H.storage.from("deal-files").createSignedUrl(n.storage_path,300);a!=null&&a.signedUrl&&window.open(a.signedUrl,"_blank")};return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-3",children:"Documents"}),e.jsx("div",{className:"space-y-2",children:t.map(n=>e.jsxs("button",{onClick:()=>r(n),className:"w-full flex items-center gap-3 p-3 rounded-xl hover:bg-slate-50 transition-colors text-left group",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0 group-hover:bg-blue-50 transition-colors",children:e.jsx(Sn,{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(yi,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function IEt({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(vd,{className:"w-3.5 h-3.5 text-emerald-600"}):e.jsx(Lm,{className:"w-3.5 h-3.5 text-blue-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("h3",{className:"text-sm font-medium text-slate-800",children:r.title}),e.jsx("span",{className:"text-xs text-slate-400 flex-shrink-0",children:ms(new Date(r.created_at),"MMM d")})]}),r.content&&e.jsx("p",{className:"text-sm text-slate-500 mt-1 leading-relaxed",children:r.content}),r.video_url&&e.jsx("div",{className:"mt-3 rounded-xl overflow-hidden bg-slate-900 aspect-video",children:e.jsx("iframe",{src:s(r.video_url)||r.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:r.title})})]})]})},r.id))})]})}function LEt({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var _,j;const[l,i]=N.useState({first_name:((_=t.client_name)==null?void 0:_.split(" ")[0])||"",last_name:((j=t.client_name)==null?void 0:j.split(" ").slice(1).join(" "))||"",email:t.client_email||"",phone:t.client_phone||"",preferred_contact_method:"email",client_role:"buyer",notes:"",spouse_first_name:"",spouse_last_name:"",spouse_email:"",spouse_phone:""}),[c,u]=N.useState({}),[p,f]=N.useState(!1),g=Dt({mutationFn:async()=>{const{error:w}=await H.from("portal_onboarding_submissions").insert({portal_id:t.id,first_name:l.first_name,last_name:l.last_name||null,email:l.email||null,phone:l.phone||null,preferred_contact_method:l.preferred_contact_method,client_role:l.client_role,notes:l.notes||null,device_fingerprint:a,custom_answers:Object.keys(c).length>0?c:null,spouse_first_name:p&&l.spouse_first_name||null,spouse_last_name:p&&l.spouse_last_name||null,spouse_email:p&&l.spouse_email||null,spouse_phone:p&&l.spouse_phone||null});if(w)throw w},onSuccess:o,onError:w=>{console.error("[PortalOnboarding] Submit failed:",w),me.error("Something went wrong. Please try again.")}}),b=s!=null&&s.property_address?`${s.property_address}, ${s.city||""}, ${s.state||""}`:null;return e.jsxs("div",{className:"max-w-md mx-auto px-4 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[(r==null?void 0:r.avatar_url)&&e.jsx("img",{src:r.avatar_url,alt:r.name,className:"w-14 h-14 rounded-full border-2 border-slate-200 mx-auto mb-3 object-cover"}),e.jsx("h1",{className:"text-xl font-bold text-slate-800",children:"Welcome to Your Portal"}),b&&e.jsxs("div",{className:"flex items-center justify-center gap-1 text-slate-500 text-sm mt-1",children:[e.jsx(ma,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:b.replace(/,\s*,/g,",").replace(/,\s*$/,"")})]}),e.jsx("p",{className:"text-sm text-slate-500 mt-2",children:"Please fill in your details to access your transaction portal."})]}),e.jsxs("form",{onSubmit:w=>{w.preventDefault(),g.mutate()},className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"First Name *"}),e.jsx(ze,{required:!0,value:l.first_name,onChange:w=>i(k=>({...k,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(ze,{value:l.last_name,onChange:w=>i(k=>({...k,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(ze,{type:"email",value:l.email,onChange:w=>i(k=>({...k,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(ze,{type:"tel",value:l.phone,onChange:w=>i(k=>({...k,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(k=>({...k,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(k=>({...k,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(ze,{required:w.is_required,value:c[w.id]||"",onChange:k=>u(S=>({...S,[w.id]:k.target.value})),className:"mt-1 rounded-xl"}),w.field_type==="textarea"&&e.jsx("textarea",{required:w.is_required,value:c[w.id]||"",onChange:k=>u(S=>({...S,[w.id]:k.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),w.field_type==="dropdown"&&e.jsxs("select",{required:w.is_required,value:c[w.id]||"",onChange:k=>u(S=>({...S,[w.id]:k.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm h-10",children:[e.jsx("option",{value:"",children:"Select..."}),(w.options||[]).map(k=>e.jsx("option",{value:k,children:k},k))]}),w.field_type==="toggle"&&e.jsx("div",{className:"mt-1.5 flex gap-2",children:["Yes","No"].map(k=>e.jsx("button",{type:"button",onClick:()=>u(S=>({...S,[w.id]:k})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${c[w.id]===k?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:k},k))})]},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(k=>({...k,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(ze,{value:l.spouse_first_name,onChange:w=>i(k=>({...k,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(ze,{value:l.spouse_last_name,onChange:w=>i(k=>({...k,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(ze,{type:"email",value:l.spouse_email,onChange:w=>i(k=>({...k,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(ze,{type:"tel",value:l.spouse_phone,onChange:w=>i(k=>({...k,spouse_phone:w.target.value})),className:"mt-1 rounded-xl"})]})]})]}),e.jsx(K,{type:"submit",disabled:g.isPending||!l.first_name,className:"w-full h-12 rounded-full text-sm font-semibold bg-slate-900 hover:bg-slate-800",children:g.isPending?"Submitting...":"Access My Portal"})]})]})}function DEt(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function OEt(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 REt={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. 🎉"}},DZe=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function tNe(t){return DZe.map(s=>{if(s==="Active")return{key:"Active",label:DEt(t),description:OEt(t)};const r=REt[s];return{key:s,label:r.label,description:r.description}})}function WPe(t){if(!t)return 0;const s=DZe.indexOf(t);return s>=0?s:0}function FEt(t,s){return mt({queryKey:["client-portal-public",t],queryFn:async()=>{if(!t)return null;const{data:r,error:n}=await H.from("client_portals").select(` *, deal_pipeline ( id, deal_name, property_address, city, state, deal_type, target_close_date, contract_date, expected_price, actual_close_date, stage_id, owner_user_id, deal_pipeline_stages (id, name, color, icon, sort_order, is_won_stage, is_lost_stage) ) `).eq("slug",t).eq("is_enabled",!0).maybeSingle();if(n)throw n;return r},enabled:s})}function zEt(t){return mt({queryKey:["client-portal-by-id",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("client_portals").select(` *, deal_pipeline ( id, deal_name, property_address, city, state, deal_type, target_close_date, contract_date, expected_price, actual_close_date, stage_id, owner_user_id, deal_pipeline_stages (id, name, color, icon, sort_order, is_won_stage, is_lost_stage) ) `).eq("id",t).eq("is_enabled",!0).maybeSingle();if(r)throw r;return s},enabled:!!t})}function OZe({slug:t}){var ee,Q,ie,re,oe,ce;const[s,r]=N.useState(!1),[n,a]=N.useState("primary"),[o]=N.useState(()=>{const xe=`portal_fp_${t}`;let ge=localStorage.getItem(xe);return ge||(ge=localStorage.getItem("portal_fp"),ge?localStorage.setItem(xe,ge):(ge=crypto.randomUUID(),localStorage.setItem(xe,ge),localStorage.setItem("portal_fp",ge))),ge});N.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:l,isLoading:i,error:c}=FEt(t,!0),u=l==null?void 0:l.linked_portal_id,{data:p}=zEt(u),f=(ee=l==null?void 0:l.deal_pipeline)==null?void 0:ee.owner_user_id,{data:g}=mt({queryKey:["portal-stages",f],queryFn:async()=>{const{data:xe,error:ge}=await H.from("deal_pipeline_stages").select("*").eq("owner_user_id",f).order("sort_order",{ascending:!0});if(ge)throw ge;return xe},enabled:!!f}),{data:b}=mt({queryKey:["portal-agent",f],queryFn:async()=>{const{data:xe,error:ge}=await H.from("profiles").select("id, name, avatar_url, phone, email").eq("id",f).single();if(ge)throw ge;return xe},enabled:!!f}),_=n==="linked"&&p?p:l,j=_==null?void 0:_.id,{data:w}=mt({queryKey:["portal-updates-public",j],queryFn:async()=>{const{data:xe,error:ge}=await H.from("portal_updates").select("*").eq("portal_id",j).order("created_at",{ascending:!1});if(ge)throw ge;return xe},enabled:!!j}),k=(Q=_==null?void 0:_.deal_pipeline)==null?void 0:Q.id,{data:S}=mt({queryKey:["portal-documents",k],queryFn:async()=>{const{data:xe,error:ge}=await H.from("deal_files").select("*").eq("deal_id",k).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(ge)throw ge;return xe},enabled:!!k}),M=l==null?void 0:l.id,{data:L,isLoading:I}=mt({queryKey:["portal-onboarding-check",M,o],queryFn:async()=>{const{data:xe,error:ge}=await H.from("portal_onboarding_submissions").select("id").eq("portal_id",M).eq("device_fingerprint",o).maybeSingle();if(ge)throw ge;return xe},enabled:!!M&&!!(l!=null&&l.require_onboarding)}),{data:O}=mt({queryKey:["portal-custom-questions-public",f],queryFn:async()=>{const{data:xe,error:ge}=await H.from("portal_custom_questions").select("*").eq("owner_user_id",f).eq("is_active",!0).order("sort_order",{ascending:!0});if(ge)throw ge;return xe},enabled:!!f&&!!(l!=null&&l.require_onboarding)}),q=!!L||s||!(l!=null&&l.require_onboarding);if(i||l!=null&&l.require_onboarding&&I)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(ys,{className:"h-48 w-full rounded-2xl"}),e.jsx(ys,{className:"h-10 w-48 mx-auto"}),e.jsx(ys,{className:"h-32 w-full rounded-2xl"}),e.jsx(ys,{className:"h-24 w-full rounded-2xl"})]})});if(c||!l)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("span",{className:"text-2xl",children:"🔒"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Portal Not Available"}),e.jsx("p",{className:"text-slate-500",children:"This portal is no longer active or doesn't exist."})]})});if(!q){const xe=l==null?void 0:l.deal_pipeline;return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:e.jsx(LEt,{portal:l,dealData:xe,agentProfile:b,customQuestions:O||[],deviceFingerprint:o,onComplete:()=>r(!0)})})}const U=(ie=l==null?void 0:l.deal_pipeline)==null?void 0:ie.deal_type,B=(re=p==null?void 0:p.deal_pipeline)==null?void 0:re.deal_type,V=!!p,Z=xe=>xe==="listing"?"Your Sale":xe==="buy-side"?"Your Purchase":"Transaction",X=xe=>xe==="listing"?e.jsx(bn,{className:"w-3.5 h-3.5"}):e.jsx(Sp,{className:"w-3.5 h-3.5"});return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white pb-12",children:[e.jsx(kEt,{dealData:_==null?void 0:_.deal_pipeline,agentProfile:b,welcomeMessage:_==null?void 0:_.welcome_message,isWon:(ce=(oe=_==null?void 0:_.deal_pipeline)==null?void 0:oe.deal_pipeline_stages)==null?void 0:ce.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:[X(U),Z(U)]}),e.jsxs("button",{onClick:()=>a("linked"),className:`flex-1 flex items-center justify-center gap-1.5 rounded-lg py-2.5 text-sm font-medium transition-all ${n==="linked"?"bg-white text-slate-800 shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:[X(B),Z(B)]})]}),e.jsx(BEt,{portal:_,updates:w,documents:S}),e.jsxs("div",{className:"text-center pt-6 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-slate-400",children:[e.jsx(th,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-xs",children:"Secure Client Portal"})]}),b&&e.jsxs("p",{className:"text-xs text-slate-400",children:["Managed by ",e.jsx("span",{className:"font-medium text-slate-500",children:b.name})]}),e.jsx("p",{className:"text-[10px] text-slate-300",children:"Powered by ReLevelUp"})]})]})]})}function BEt({portal:t,updates:s,documents:r}){const n=t,a=n==null?void 0:n.deal_pipeline,o=a==null?void 0:a.deal_pipeline_stages,l=o==null?void 0:o.is_won_stage,i=a==null?void 0:a.deal_type,c=t.stage_mapping;let u=tNe(i);c&&c.length>0&&(u=c.map((b,_)=>{var j,w;return{key:`custom-${_}`,label:b.label||((j=u[_])==null?void 0:j.label)||`Stage ${_+1}`,description:b.description||((w=u[_])==null?void 0:w.description)||"",video_url:b.video_url||void 0}}));const p=c&&c.length>0?Math.min(WPe(o==null?void 0:o.name),u.length-1):WPe(o==null?void 0:o.name),f=u[p],g=f==null?void 0:f.video_url;return e.jsxs(e.Fragment,{children:[e.jsx(CEt,{targetCloseDate:a==null?void 0:a.target_close_date,actualCloseDate:a==null?void 0:a.actual_close_date,clientName:t.client_name}),e.jsx(SEt,{journeyStages:u,currentIndex:p}),f&&e.jsx(MEt,{currentStage:f,nextStepText:t.next_step_text,nextStepVideoUrl:g||t.next_step_video_url}),e.jsx(EEt,{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(PEt,{documents:r}),s&&s.length>0&&e.jsx(IEt,{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 $Et(){const s=zd().pathname.slice(1);return N.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>{document.body.classList.remove("client-portal-page")}),[]),!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Client Portal"}),e.jsx("p",{className:"text-slate-500",children:"Visit your personalized portal link to view your transaction details."})]})}):e.jsx(OZe,{slug:s})}const h1e="levelup_affiliate_ref",qEt=30,UEt=()=>{const[t]=Cc();N.useEffect(()=>{const s=t.get("ref");if(s){const r={code:s.toUpperCase(),timestamp:Date.now()};localStorage.setItem(h1e,JSON.stringify(r)),console.log("[Affiliate] Stored referral code:",s)}},[t])},VEt=()=>{try{const t=localStorage.getItem(h1e);if(!t)return null;const s=JSON.parse(t),r=qEt*24*60*60*1e3;return Date.now()-s.timestamp>r?(localStorage.removeItem(h1e),console.log("[Affiliate] Referral code expired"),null):s.code}catch{return null}},$oe="/assets/levelup-logo-header-_ZX7DvlA.png",HEt="/assets/scale-your-team-ku4MPatU.png";function WEt({open:t,onOpenChange:s}){return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(_s,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-[#4a6b6d]/10 rounded-lg",children:e.jsx(ka,{className:"h-5 w-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(vs,{children:"Schedule a Brokerage Interest Meeting"}),e.jsx(Gr,{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 qu={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"]}},GEt=[{icon:pp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:ac,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:hn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:$c,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:Sn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:ko,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],KEt=[{icon:pr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:pn,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Un,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Ch,title:"Birthday & Anniversary Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:ma,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:No,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:ni,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Zh,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],ZEt=[{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."}],YEt=()=>{const{user:t,loading:s}=Ds(),r=fr(),[n]=Cc();N.useEffect(()=>{const q=window.location.host==="listings.relevelup.com",U=window.location.pathname==="/";if(q&&U){r("/public/listings",{replace:!0});return}},[r]);const[a,o]=N.useState(null),[l,i]=N.useState(null),[c,u]=N.useState(!1),[p,f]=N.useState(""),[g,b]=N.useState(""),[_,j]=N.useState(""),[w,k]=N.useState(!1),[S,M]=N.useState(!1),L=(q,U=!1)=>{i({tier:q,skipTrial:U}),u(!0)};UEt(),N.useEffect(()=>{const q=window.location.host==="listings.relevelup.com",U=location.pathname.startsWith("/public/");!s&&t&&!q&&!U&&r("/dashboard")},[t,s,r,location.pathname]),N.useEffect(()=>{n.get("canceled")==="true"&&me.error("Checkout was canceled. Feel free to try again when you're ready!")},[n]);const I=async(q,U=!1)=>{if(!p){me.error("Please enter your email address");return}if(!g.trim()){me.error("Please enter your full name");return}k(!0),o(q+(U?"_direct":""));const B=VEt();try{const{data:V,error:Z}=await H.functions.invoke("create-checkout",{body:{tier:q,email:p,name:g.trim(),couponCode:_.trim()||void 0,skipTrial:U,referralCode:B}});if(Z)throw Z;if(V!=null&&V.url)window.open(V.url,"_blank","noopener,noreferrer"),me.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(V){console.error("Checkout error:",V),me.error(V.message||"Failed to start checkout. Please try again.")}finally{k(!1),o(null),u(!1),i(null)}},O=()=>{l&&I(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:$oe,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var q;return(q=document.getElementById("features"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var q;return(q=document.getElementById("pricing"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},children:"Pricing"}),e.jsx(K,{onClick:()=>r("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),e.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-8",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx("img",{alt:"LevelUp Consulting Group",className:"h-[136px] md:h-[164px] drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),e.jsxs("p",{className:"text-lg text-white/80 max-w-3xl mx-auto leading-relaxed font-sans font-bold md:text-4xl",children:["The tools you need to get it done.",e.jsx("br",{}),e.jsx("em",{children:"The platform you need to keep it going."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center items-center pt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var q;return(q=document.getElementById("free-trial"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"px-8 py-7 text-lg font-semibold bg-white text-[#1e3a4c] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",children:["Start Your Free Trial",e.jsx(Qa,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),e.jsx(K,{size:"lg",variant:"outline",onClick:()=>{var q;return(q=document.getElementById("features"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"px-8 py-7 text-lg font-semibold border-2 border-white text-white bg-transparent hover:bg-white hover:text-[#1e3a4c] rounded-full",children:"See What's Included"})]})]})})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl md:text-5xl leading-tight font-sans font-semibold text-secondary",children:"We help brokerages and agents grow with training, tools, and built-in execution."}),e.jsxs("div",{className:"space-y-2 text-lg text-muted-foreground",children:[e.jsx("p",{children:"Agents get weekly coaching + plug-and-play marketing."}),e.jsx("p",{children:"Brokerages get higher adoption, consistency, and real engagement."})]}),e.jsx("p",{className:"text-2xl md:text-4xl text-[#4a6b6d] pt-4 font-sans font-bold",children:"LEVELUP EQUIPS BOTH TO THRIVE."}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Learn how we support agents and empower brokerages to grow—together."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center pt-4",children:[e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>{var q;return(q=document.getElementById("brokerage"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/5",children:[e.jsx(ka,{className:"mr-2 h-5 w-5"}),"Brokerage Partnership"]}),e.jsxs(K,{size:"lg",onClick:()=>{var q;return(q=document.getElementById("pricing"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:[e.jsx(to,{className:"mr-2 h-5 w-5"}),"Individual Membership"]})]})]})})}),e.jsx("section",{id:"features",className:"py-20 bg-muted/30",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl mb-6 font-sans font-bold",children:"What's inside our members only portal?"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Everything you need to grow your business, all in one place."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:GEt.map((q,U)=>e.jsxs(Ee,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Pt,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx(q.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(Rt,{className:"text-xl font-sans",children:q.title})]}),e.jsx(De,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:q.description})})]},U))})]})}),e.jsxs("section",{id:"agent-os",className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs("div",{className:"container mx-auto px-4 relative",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium mb-6",children:[e.jsx(pn,{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:KEt.map((q,U)=>e.jsxs(Ee,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:e.jsx(q.icon,{className:"w-6 h-6 text-white"})}),e.jsx(Rt,{className:"text-lg font-semibold text-white",children:q.title})]}),e.jsx(De,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:q.description})})]},U))}),e.jsx("div",{className:"text-center mt-12",children:e.jsxs(K,{size:"lg",onClick:()=>{var q;return(q=document.getElementById("pricing"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"bg-white text-[#4a6b6d] hover:bg-white/90 shadow-xl transition-all hover:scale-105",children:["Get Agent OS with Your Membership",e.jsx(Qa,{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(ka,{className:"w-4 h-4"}),"For Brokerages"]}),e.jsxs("h2",{className:"text-3xl font-sans font-bold md:text-6xl",children:["Empower Your"," ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"Entire Team"})]}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Give every agent on your team access to world-class training and resources. Track performance, streamline onboarding, and watch your brokerage thrive."}),e.jsx("ul",{className:"space-y-4",children:["Dedicated brokerage manager dashboard","Invite and manage agents with one click","Exclusive brokerage-only resources","Team analytics and performance tracking","Simplified agent onboarding","Share resources across your team"].map((q,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center flex-shrink-0",children:e.jsx(va,{className:"w-4 h-4 text-[#4a6b6d]"})}),e.jsx("span",{className:"text-foreground",children:q})]},U))}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var q;return(q=document.getElementById("pricing"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["See Brokerage Plans",e.jsx(da,{className:"ml-2 w-5 h-5"})]}),e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>M(!0),className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/10",children:[e.jsx(hn,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),e.jsx("div",{className:"relative hidden md:block",children:e.jsx("img",{src:HEt,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:ZEt.map((q,U)=>e.jsx(Ee,{className:"bg-muted/30 border-0",children:e.jsxs(De,{className:"pt-8",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(B=>e.jsx(Jn,{className:"w-5 h-5 fill-yellow-400 text-yellow-400"},B))}),e.jsxs("p",{className:"text-lg mb-6 italic text-muted-foreground",children:['"',q.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:q.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q.role})]})]})},U))})]})}),e.jsxs("section",{id:"free-trial",className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-8",children:[e.jsxs("h2",{className:"text-3xl md:text-5xl font-bold text-white",children:["Start Your Free Trial ",e.jsx("span",{className:"italic",children:"Today"})]}),e.jsx("p",{className:"text-lg md:text-xl text-white/80 leading-relaxed",children:"Get instant access to 7 days of trainings, templates, and tools — designed to give you quick wins now and resources you'll keep forever."}),e.jsx("div",{className:"pt-4",children:e.jsxs(K,{size:"lg",className:"px-12 py-7 text-lg font-semibold bg-white text-[#4a6b6d] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",onClick:()=>L("individual_agent"),children:["Start Free Trial",e.jsx(Qa,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]})})]})})]}),e.jsx("section",{id:"pricing",className:"py-20 bg-muted/30",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("h2",{className:"text-3xl mb-6 font-sans md:text-5xl font-bold",children:["Simple, Transparent ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"Pricing"})]}),e.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:"Choose the plan that fits your needs. All plans include everything you need to succeed."})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:[e.jsxs(Ee,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Pt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(to,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsx(Rt,{className:"text-xl font-sans",children:qu.individual_agent.name})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:qu.individual_agent.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:qu.individual_agent.period})]}),e.jsx(gr,{className:"text-base mt-2",children:qu.individual_agent.description}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-green-500/10 text-green-600 text-sm font-medium mt-4",children:[e.jsx(un,{className:"w-4 h-4"}),qu.individual_agent.trial]})]}),e.jsx(De,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:qu.individual_agent.features.map((q,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(va,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:q})]},U))})}),e.jsxs($L,{className:"flex flex-col gap-3 pt-4",children:[e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>L("individual_agent"),children:"Start Free Trial"}),e.jsx(K,{variant:"outline",className:"w-full rounded-full border-2 border-[#4a6b6d] text-[#4a6b6d] bg-white hover:bg-[#4a6b6d]/5 uppercase text-sm font-medium tracking-wide",onClick:()=>L("individual_agent",!0),children:"Skip Trial, Subscribe Now"})]})]}),e.jsxs(Ee,{className:"relative flex flex-col border-2 border-[#4a6b6d] shadow-2xl scale-105 bg-background",children:[e.jsx("div",{className:"absolute -top-4 left-1/2 -translate-x-1/2 px-6 py-2 bg-[#4a6b6d] text-white text-sm font-semibold rounded-full shadow-lg",children:"Most Popular"}),e.jsxs(Pt,{className:"pb-4 pt-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/20 flex items-center justify-center",children:e.jsx(ka,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-xl font-sans",children:qu.brokerage_under_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:qu.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:qu.brokerage_under_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:qu.brokerage_under_25.period})]}),e.jsx(gr,{className:"text-base mt-2",children:qu.brokerage_under_25.description})]}),e.jsx(De,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:qu.brokerage_under_25.features.map((q,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(va,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:q})]},U))})}),e.jsx($L,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg shadow-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>L("brokerage_under_25"),children:"Get Started"})})]}),e.jsxs(Ee,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Pt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(ka,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-xl font-sans",children:qu.brokerage_over_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:qu.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:qu.brokerage_over_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:qu.brokerage_over_25.period})]}),e.jsx(gr,{className:"text-base mt-2",children:qu.brokerage_over_25.description})]}),e.jsx(De,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:qu.brokerage_over_25.features.map((q,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(va,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:q})]},U))})}),e.jsx($L,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>L("brokerage_over_25"),children:"Get Started"})})]})]})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl text-white font-sans md:text-5xl",children:"Ready to Level Up?"}),e.jsx("p",{className:"text-lg text-white/80 max-w-2xl mx-auto",children:"Join thousands of agents who are closing more deals, saving time, and growing their business with LevelUp."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs(K,{size:"lg",onClick:()=>{var q;return(q=document.getElementById("pricing"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"px-10 py-7 text-lg font-semibold bg-white text-[#4a6b6d] hover:bg-white/90 shadow-2xl transition-all hover:scale-105",children:["Start Your Free Trial",e.jsx(Qa,{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:$oe,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(WEt,{open:S,onOpenChange:M}),e.jsx(fs,{open:c,onOpenChange:u,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsx(vs,{className:"text-xl font-sans font-semibold",children:"Enter your details to get started"}),e.jsx(Gr,{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(ze,{id:"dialog-name",type:"text",placeholder:"John Smith",value:g,onChange:q=>b(q.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(ve,{htmlFor:"dialog-email",children:["Email Address ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ze,{id:"dialog-email",type:"email",placeholder:"you@example.com",value:p,onChange:q=>f(q.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(ve,{htmlFor:"dialog-coupon",children:["Discount Code ",e.jsx("span",{className:"text-muted-foreground",children:"(Optional)"})]}),e.jsx(ze,{id:"dialog-coupon",type:"text",placeholder:"Enter discount code",value:_,onChange:q=>j(q.target.value),className:"mt-1"})]})]}),e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:O,disabled:w,children:w?"Loading...":"Continue to Checkout"})]})})]})},XEt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{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"})]})]})]})]})})]}),QEt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{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"})]})]})]})]})})]}),JEt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{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"})]})]})]})]})})]}),e6t=gC({email:gc().email("Invalid email address"),password:gc().min(6,"Password must be at least 6 characters")}),t6t=()=>{const{signIn:t,user:s}=Ds(),r=fr(),[n,a]=N.useState(!1),[o,l]=N.useState({}),[i,c]=N.useState(""),[u,p]=N.useState(!1),[f,g]=N.useState(!1);N.useEffect(()=>{s&&r("/dashboard")},[s,r]);const b=async j=>{j.preventDefault(),l({}),a(!0);const w=new FormData(j.currentTarget),k=w.get("email"),S=w.get("password");try{e6t.parse({email:k,password:S}),await t(k,S)}catch(M){if(M instanceof C0){const L={};M.errors.forEach(I=>{I.path[0]&&(L[I.path[0]]=I.message)}),l(L)}}finally{a(!1)}},_=async()=>{if(!i){me.error("Please enter your email address");return}p(!0);try{const{error:j}=await H.functions.invoke("send-password-reset",{body:{email:i,redirectTo:"https://dashboard.relevelup.com/profile?reset=true"}});if(j)throw j;me.success("Password reset email sent! Check your inbox."),g(!1),c("")}catch(j){me.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(Pi,{to:"/",className:"inline-flex items-center gap-2 text-sm text-white/80 hover:text-white transition-colors",children:[e.jsx(Ja,{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:mWe,alt:"LevelUp",className:"h-12 w-auto"})})}),e.jsxs(Ee,{className:"border-0 shadow-2xl bg-white/95 backdrop-blur-sm",children:[e.jsxs(Pt,{className:"space-y-1 text-center pb-4",children:[e.jsx(Rt,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(gr,{className:"text-gray-600",children:"Sign in to access your dashboard"})]}),e.jsx(De,{children:e.jsxs("form",{onSubmit:b,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(ze,{id:"signin-email",name:"email",type:"email",placeholder:"your@email.com",required:!0,className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"}),o.email&&e.jsx("p",{className:"text-sm text-red-600",children:o.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"signin-password",className:"text-gray-700",children:"Password"}),e.jsx(ze,{id:"signin-password",name:"password",type:"password",required:!0,className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"}),o.password&&e.jsx("p",{className:"text-sm text-red-600",children:o.password})]}),e.jsx(K,{type:"submit",className:"w-full bg-[#4a6b6d] hover:bg-[#3d5a5c] text-white font-semibold py-6 text-lg transition-all duration-200 shadow-lg hover:shadow-xl",disabled:n,children:n?"Signing in...":"Sign In"}),e.jsxs(fs,{open:f,onOpenChange:g,children:[e.jsx(qi,{asChild:!0,children:e.jsx(K,{variant:"link",className:"w-full text-sm text-[#4a6b6d] hover:text-[#3d5a5c]",children:"Forgot password?"})}),e.jsxs(ps,{className:"bg-white",children:[e.jsxs(_s,{children:[e.jsx(vs,{className:"text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Reset Password"}),e.jsx(Gr,{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(ze,{id:"reset-email",type:"email",placeholder:"your@email.com",value:i,onChange:j=>c(j.target.value),className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"})]}),e.jsx(K,{onClick:_,className:"w-full bg-[#4a6b6d] hover:bg-[#3d5a5c] text-white",disabled:u,children:u?"Sending...":"Send Reset Link"})]})]})]})]})})]}),e.jsxs("p",{className:"text-center text-white/70 text-sm mt-6",children:["Don't have an account?"," ",e.jsx(Pi,{to:"/",className:"text-white hover:underline font-medium",children:"View Plans"})]})]})})]})]})},s6t=()=>{const[t]=Cc(),s=t.get("tier"),r=s==null?void 0:s.includes("brokerage");return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ee,{className:"max-w-lg w-full",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-green-500/10 flex items-center justify-center mb-4",children:e.jsx(xi,{className:"w-10 h-10 text-green-500"})}),e.jsx(Rt,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(gr,{className:"text-lg",children:"Your subscription has been activated successfully."})]}),e.jsxs(De,{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(cr,{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."})})]})]})})},RZe=t=>{const[s,r]=N.useState(null),[n,a]=N.useState(!0);return N.useEffect(()=>{if(!t){a(!1);return}(async()=>{try{const{data:i}=await H.storage.from("avatars").list(`${t}`);if(i&&i.length>0){const{data:c}=H.storage.from("avatars").getPublicUrl(`${t}/${i[0].name}`);r(`${c.publicUrl}?t=${Date.now()}`)}else r(null)}catch(i){console.error("Error fetching avatar:",i),r(null)}finally{a(!1)}})()},[t]),{avatarUrl:s,loading:n,refreshAvatar:async()=>{if(t)try{const{data:l}=await H.storage.from("avatars").list(`${t}`);if(l&&l.length>0){const{data:i}=H.storage.from("avatars").getPublicUrl(`${t}/${l[0].name}`);r(`${i.publicUrl}?t=${Date.now()}`)}}catch(l){console.error("Error refreshing avatar:",l)}}}},FZe=async t=>{const s=new Map;return await Promise.all(t.map(async r=>{try{const{data:n}=await H.storage.from("avatars").list(`${r}`);if(n&&n.length>0){const{data:a}=H.storage.from("avatars").getPublicUrl(`${r}/${n[0].name}`);s.set(r,a.publicUrl)}}catch{}})),s},r6t=t=>{const[s,r]=N.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return N.useEffect(()=>{if(!t){r(a=>({...a,loading:!1}));return}(async()=>{try{const{data:a,error:o}=await H.from("profiles").select("is_trial, trial_expires_at, subscription_status, subscription_end_date").eq("id",t).single();if(o){console.error("Error fetching trial status:",o),r(c=>({...c,loading:!1}));return}const l=(a==null?void 0:a.subscription_status)==="trialing"&&(a==null?void 0:a.subscription_end_date),i=(a==null?void 0:a.is_trial)&&(a==null?void 0:a.trial_expires_at);if(l){const c=new Date().getTime(),u=new Date(a.subscription_end_date).getTime(),p=Math.ceil((u-c)/(1e3*60*60*24)),f=p<=0;r({isTrial:!0,isExpired:f,expiresAt:a.subscription_end_date,daysLeft:f?0:p,loading:!1})}else if(i){const c=new Date().getTime(),u=new Date(a.trial_expires_at).getTime(),p=Math.ceil((u-c)/(1e3*60*60*24)),f=p<=0;r({isTrial:!0,isExpired:f,expiresAt:a.trial_expires_at,daysLeft:f?0:p,loading:!1})}else r({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!1})}catch(a){console.error("Error in useTrialStatus:",a),r(o=>({...o,loading:!1}))}})()},[t]),s},zZe=()=>{const{data:t,isLoading:s}=mt({queryKey:["feature-flags"],queryFn:async()=>{const{data:n,error:a}=await H.from("feature_flags").select("*");if(a)throw a;return n}}),r=n=>{if(!t)return!1;const a=t.find(o=>o.key===n);return(a==null?void 0:a.enabled)??!1};return{flags:t,isLoading:s,isFeatureEnabled:r,isAgentOSEnabled:r("agent_os_enabled"),isInnerCircleEnabled:r("innercircle_enabled"),isMarketplaceEnabled:r("marketplace")}},GPe="community_last_seen_post_at";function n6t(){const{user:t}=Ds(),s=zd(),[r,n]=N.useState(0),[a,o]=N.useState(null);N.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${GPe}_${t.id}`);o(i)},[t]),N.useEffect(()=>{if(!t)return;(async()=>{let c=H.from("community_posts").select("id",{count:"exact",head:!0});a&&(c=c.gt("created_at",a));const{data:u}=await H.from("profiles").select("brokerage_id").eq("id",t.id).single(),{count:p,error:f}=await c;!f&&p!==null&&n(p)})()},[t,a]),N.useEffect(()=>{if(!t)return;const i=H.channel("community-new-posts").on("postgres_changes",{event:"INSERT",schema:"public",table:"community_posts"},async c=>{const u=c.new;if(u.user_id===t.id)return;const p=s.pathname==="/community";p||n(j=>j+1);const{data:f}=await H.from("profiles").select("name").eq("id",u.user_id).single(),g=(f==null?void 0:f.name)||"Someone",b=u.content.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),_=b.length>50?b.substring(0,50)+"...":b;p||me("New Community Post",{description:`${g}: ${_}`,action:{label:"View",onClick:()=>{window.location.href="/community"}}})}).subscribe();return()=>{H.removeChannel(i)}},[t,s.pathname]);const l=N.useCallback(()=>{if(!t)return;const i=new Date().toISOString();localStorage.setItem(`${GPe}_${t.id}`,i),o(i),n(0)},[t]);return N.useEffect(()=>{s.pathname==="/community"&&r>0&&l()},[s.pathname,r,l]),{unreadCount:r,markAsRead:l}}function a6t(){const{isAdmin:t}=Ds(),{data:s=0}=mt({queryKey:["wishlist-open-count"],queryFn:async()=>{const{count:r,error:n}=await H.from("wishlist_items").select("*",{count:"exact",head:!0}).eq("status","open");if(n)throw n;return r||0},enabled:t,staleTime:6e4});return{openCount:t?s:0}}const JA=qde,sNe=oje,i6t=Ude,BZe=N.forwardRef(({className:t,...s},r)=>e.jsx(GA,{className:It("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));BZe.displayName=GA.displayName;const o6t=mC("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"}}),yC=N.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(i6t,{children:[e.jsx(BZe,{}),e.jsxs(KA,{ref:a,className:It(o6t({side:t}),s),...n,children:[r,e.jsxs(AO,{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(Rr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));yC.displayName=KA.displayName;const eE=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col space-y-2 text-center sm:text-left",t),...s});eE.displayName="SheetHeader";const tE=N.forwardRef(({className:t,...s},r)=>e.jsx(MO,{ref:r,className:It("text-lg font-semibold text-foreground",t),...s}));tE.displayName=MO.displayName;const $Ze=N.forwardRef(({className:t,...s},r)=>e.jsx(TO,{ref:r,className:It("text-sm text-muted-foreground",t),...s}));$Ze.displayName=TO.displayName;var due="Collapsible",[l6t]=ad(due),[c6t,rNe]=l6t(due),qZe=N.forwardRef((t,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=t,[c,u]=ah({prop:n,defaultProp:a??!1,onChange:l,caller:due});return e.jsx(c6t,{scope:r,disabled:o,contentId:Tu(),open:c,onOpenToggle:N.useCallback(()=>u(p=>!p),[u]),children:e.jsx(nn.div,{"data-state":aNe(c),"data-disabled":o?"":void 0,...i,ref:s})})});qZe.displayName=due;var UZe="CollapsibleTrigger",VZe=N.forwardRef((t,s)=>{const{__scopeCollapsible:r,...n}=t,a=rNe(UZe,r);return e.jsx(nn.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":aNe(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Ir(t.onClick,a.onOpenToggle)})});VZe.displayName=UZe;var nNe="CollapsibleContent",HZe=N.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=rNe(nNe,t.__scopeCollapsible);return e.jsx(Fd,{present:r||a.open,children:({present:o})=>e.jsx(d6t,{...n,ref:s,present:o})})});HZe.displayName=nNe;var d6t=N.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=rNe(nNe,r),[i,c]=N.useState(n),u=N.useRef(null),p=qa(s,u),f=N.useRef(0),g=f.current,b=N.useRef(0),_=b.current,j=l.open||i,w=N.useRef(j),k=N.useRef(void 0);return N.useEffect(()=>{const S=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(S)},[]),wd(()=>{const S=u.current;if(S){k.current=k.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const M=S.getBoundingClientRect();f.current=M.height,b.current=M.width,w.current||(S.style.transitionDuration=k.current.transitionDuration,S.style.animationName=k.current.animationName),c(n)}},[l.open,n]),e.jsx(nn.div,{"data-state":aNe(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!j,...o,ref:p,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":_?`${_}px`:void 0,...t.style},children:j&&a})});function aNe(t){return t?"open":"closed"}var u6t=qZe;const gf=u6t,yf=VZe,vf=HZe,h6t="/assets/levelup-logo-Eif24dqY.png",m6t="/assets/levelup-logo-icon-C-7iromj.png",p6t="/assets/levelup-logo-mobile-B9skSjUG.png";var RO=t=>t.type==="checkbox",_4=t=>t instanceof Date,wm=t=>t==null;const WZe=t=>typeof t=="object";var Rd=t=>!wm(t)&&!Array.isArray(t)&&WZe(t)&&!_4(t),GZe=t=>Rd(t)&&t.target?RO(t.target)?t.target.checked:t.target.value:t,f6t=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,KZe=(t,s)=>t.has(f6t(s)),x6t=t=>{const s=t.constructor&&t.constructor.prototype;return Rd(s)&&s.hasOwnProperty("isPrototypeOf")},iNe=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function pu(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(!(iNe&&(t instanceof Blob||n))&&(r||Rd(t)))if(s=r?[]:{},!r&&!x6t(t))s=t;else for(const a in t)t.hasOwnProperty(a)&&(s[a]=pu(t[a]));else return t;return s}var uue=t=>/^\w*$/.test(t),Ad=t=>t===void 0,oNe=t=>Array.isArray(t)?t.filter(Boolean):[],lNe=t=>oNe(t.replace(/["|']|\]/g,"").split(/\.|\[/)),Tn=(t,s,r)=>{if(!s||!Rd(t))return r;const n=(uue(s)?[s]:lNe(s)).reduce((a,o)=>wm(a)?a:a[o],t);return Ad(n)||n===t?Ad(t[s])?r:t[s]:n},sf=t=>typeof t=="boolean",pl=(t,s,r)=>{let n=-1;const a=uue(s)?[s]:lNe(s),o=a.length,l=o-1;for(;++nht.useContext(cNe),g6t=t=>{const{children:s,...r}=t;return ht.createElement(cNe.Provider,{value:r},s)};var ZZe=(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]!==$g.all&&(s._proxyFormState[l]=!n||$g.all),r&&(r[l]=!0),t[l]}});return a};const dNe=typeof window<"u"?ht.useLayoutEffect:ht.useEffect;function y6t(t){const s=hue(),{control:r=s.control,disabled:n,name:a,exact:o}=t||{},[l,i]=ht.useState(r._formState),c=ht.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return dNe(()=>r._subscribe({name:a,formState:c.current,exact:o,callback:u=>{!n&&i({...r._formState,...u})}}),[a,n,o]),ht.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),ht.useMemo(()=>ZZe(l,r,c.current,!1),[l,r])}var i0=t=>typeof t=="string",YZe=(t,s,r,n,a)=>i0(t)?(n&&s.watch.add(t),Tn(r,t,a)):Array.isArray(t)?t.map(o=>(n&&s.watch.add(o),Tn(r,o))):(n&&(s.watchAll=!0),r),m1e=t=>wm(t)||!WZe(t);function Uv(t,s,r=new WeakSet){if(m1e(t)||m1e(s))return t===s;if(_4(t)&&_4(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(_4(l)&&_4(i)||Rd(l)&&Rd(i)||Array.isArray(l)&&Array.isArray(i)?!Uv(l,i,r):l!==i)return!1}}return!0}function v6t(t){const s=hue(),{control:r=s.control,name:n,defaultValue:a,disabled:o,exact:l,compute:i}=t||{},c=ht.useRef(a),u=ht.useRef(i),p=ht.useRef(void 0);u.current=i;const f=ht.useMemo(()=>r._getWatch(n,c.current),[r,n]),[g,b]=ht.useState(u.current?u.current(f):f);return dNe(()=>r._subscribe({name:n,formState:{values:!0},exact:l,callback:_=>{if(!o){const j=YZe(n,r._names,_.values||r._formValues,!1,c.current);if(u.current){const w=u.current(j);Uv(w,p.current)||(b(w),p.current=w)}else b(j)}}}),[r,o,n,l]),ht.useEffect(()=>r._removeUnmounted()),g}function b6t(t){const s=hue(),{name:r,disabled:n,control:a=s.control,shouldUnregister:o,defaultValue:l}=t,i=KZe(a._names.array,r),c=ht.useMemo(()=>Tn(a._formValues,r,Tn(a._defaultValues,r,l)),[a,r,l]),u=v6t({control:a,name:r,defaultValue:c,exact:!0}),p=y6t({control:a,name:r,exact:!0}),f=ht.useRef(t),g=ht.useRef(a.register(r,{...t.rules,value:u,...sf(t.disabled)?{disabled:t.disabled}:{}}));f.current=t;const b=ht.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!Tn(p.errors,r)},isDirty:{enumerable:!0,get:()=>!!Tn(p.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!Tn(p.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!Tn(p.validatingFields,r)},error:{enumerable:!0,get:()=>Tn(p.errors,r)}}),[p,r]),_=ht.useCallback(S=>g.current.onChange({target:{value:GZe(S),name:r},type:qoe.CHANGE}),[r]),j=ht.useCallback(()=>g.current.onBlur({target:{value:Tn(a._formValues,r),name:r},type:qoe.BLUR}),[r,a._formValues]),w=ht.useCallback(S=>{const M=Tn(a._fields,r);M&&S&&(M._f.ref={focus:()=>S.focus&&S.focus(),select:()=>S.select&&S.select(),setCustomValidity:L=>S.setCustomValidity(L),reportValidity:()=>S.reportValidity()})},[a._fields,r]),k=ht.useMemo(()=>({name:r,value:u,...sf(n)||p.disabled?{disabled:p.disabled||n}:{},onChange:_,onBlur:j,ref:w}),[r,n,p.disabled,_,j,w,u]);return ht.useEffect(()=>{const S=a._options.shouldUnregister||o;a.register(r,{...f.current.rules,...sf(f.current.disabled)?{disabled:f.current.disabled}:{}});const M=(L,I)=>{const O=Tn(a._fields,L);O&&O._f&&(O._f.mount=I)};if(M(r,!0),S){const L=pu(Tn(a._options.defaultValues,r));pl(a._defaultValues,r,L),Ad(Tn(a._formValues,r))&&pl(a._formValues,r,L)}return!i&&a.register(r),()=>{(i?S&&!a._state.action:S)?a.unregister(r):M(r,!1)}},[r,a,i,o]),ht.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),ht.useMemo(()=>({field:k,formState:p,fieldState:b}),[k,p,b])}const _6t=t=>t.render(b6t(t));var XZe=(t,s,r,n,a)=>s?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:a||!0}}:{},ZL=t=>Array.isArray(t)?t:[t],KPe=()=>{let t=[];return{get observers(){return t},next:a=>{for(const o of t)o.next&&o.next(a)},subscribe:a=>(t.push(a),{unsubscribe:()=>{t=t.filter(o=>o!==a)}}),unsubscribe:()=>{t=[]}}},dp=t=>Rd(t)&&!Object.keys(t).length,uNe=t=>t.type==="file",qg=t=>typeof t=="function",Uoe=t=>{if(!iNe)return!1;const s=t?t.ownerDocument:0;return t instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},QZe=t=>t.type==="select-multiple",hNe=t=>t.type==="radio",w6t=t=>hNe(t)||RO(t),Hxe=t=>Uoe(t)&&t.isConnected;function j6t(t,s){const r=s.slice(0,-1).length;let n=0;for(;n{for(const s in t)if(qg(t[s]))return!0;return!1};function Voe(t,s={}){const r=Array.isArray(t);if(Rd(t)||r)for(const n in t)Array.isArray(t[n])||Rd(t[n])&&!JZe(t[n])?(s[n]=Array.isArray(t[n])?[]:{},Voe(t[n],s[n])):wm(t[n])||(s[n]=!0);return s}function eYe(t,s,r){const n=Array.isArray(t);if(Rd(t)||n)for(const a in t)Array.isArray(t[a])||Rd(t[a])&&!JZe(t[a])?Ad(s)||m1e(r[a])?r[a]=Array.isArray(t[a])?Voe(t[a],[]):{...Voe(t[a])}:eYe(t[a],wm(s)?{}:s[a],r[a]):r[a]=!Uv(t[a],s[a]);return r}var VP=(t,s)=>eYe(t,s,Voe(s));const ZPe={value:!1,isValid:!1},YPe={value:!0,isValid:!0};var tYe=t=>{if(Array.isArray(t)){if(t.length>1){const s=t.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:s,isValid:!!s.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!Ad(t[0].attributes.value)?Ad(t[0].value)||t[0].value===""?YPe:{value:t[0].value,isValid:!0}:YPe:ZPe}return ZPe},sYe=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>Ad(t)?t:s?t===""?NaN:t&&+t:r&&i0(t)?new Date(t):n?n(t):t;const XPe={isValid:!1,value:null};var rYe=t=>Array.isArray(t)?t.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,XPe):XPe;function QPe(t){const s=t.ref;return uNe(s)?s.files:hNe(s)?rYe(t.refs).value:QZe(s)?[...s.selectedOptions].map(({value:r})=>r):RO(s)?tYe(t.refs).value:sYe(Ad(s.value)?t.ref.value:s.value,t)}var k6t=(t,s,r,n)=>{const a={};for(const o of t){const l=Tn(s,o);l&&pl(a,o,l._f)}return{criteriaMode:r,names:[...t],fields:a,shouldUseNativeValidation:n}},Hoe=t=>t instanceof RegExp,HP=t=>Ad(t)?t:Hoe(t)?t.source:Rd(t)?Hoe(t.value)?t.value.source:t.value:t,JPe=t=>({isOnSubmit:!t||t===$g.onSubmit,isOnBlur:t===$g.onBlur,isOnChange:t===$g.onChange,isOnAll:t===$g.all,isOnTouch:t===$g.onTouched});const eIe="AsyncFunction";var S6t=t=>!!t&&!!t.validate&&!!(qg(t.validate)&&t.validate.constructor.name===eIe||Rd(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===eIe)),C6t=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),tIe=(t,s,r)=>!r&&(s.watchAll||s.watch.has(t)||[...s.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const YL=(t,s,r,n)=>{for(const a of r||Object.keys(t)){const o=Tn(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(YL(i,s))break}else if(Rd(i)&&YL(i,s))break}}};function sIe(t,s,r){const n=Tn(t,r);if(n||uue(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const o=a.join("."),l=Tn(s,o),i=Tn(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 M6t=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return dp(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||$g.all))},T6t=(t,s,r)=>!t||!s||t===s||ZL(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),A6t=(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,E6t=(t,s)=>!oNe(Tn(t,s)).length&&Gd(t,s),P6t=(t,s,r)=>{const n=ZL(Tn(t,r));return pl(n,"root",s[r]),pl(t,r,n),t},_ie=t=>i0(t);function rIe(t,s,r="validate"){if(_ie(t)||Array.isArray(t)&&t.every(_ie)||sf(t)&&!t)return{type:r,message:_ie(t)?t:"",ref:s}}var _5=t=>Rd(t)&&!Hoe(t)?t:{value:t,message:""},nIe=async(t,s,r,n,a,o)=>{const{ref:l,refs:i,required:c,maxLength:u,minLength:p,min:f,max:g,pattern:b,validate:_,name:j,valueAsNumber:w,mount:k}=t._f,S=Tn(r,j);if(!k||s.has(j))return{};const M=i?i[0]:l,L=X=>{a&&M.reportValidity&&(M.setCustomValidity(sf(X)?"":X||""),M.reportValidity())},I={},O=hNe(l),q=RO(l),U=O||q,B=(w||uNe(l))&&Ad(l.value)&&Ad(S)||Uoe(l)&&l.value===""||S===""||Array.isArray(S)&&!S.length,V=XZe.bind(null,j,n,I),Z=(X,ee,Q,ie=bv.maxLength,re=bv.minLength)=>{const oe=X?ee:Q;I[j]={type:X?ie:re,message:oe,ref:l,...V(X?ie:re,oe)}};if(o?!Array.isArray(S)||!S.length:c&&(!U&&(B||wm(S))||sf(S)&&!S||q&&!tYe(i).isValid||O&&!rYe(i).isValid)){const{value:X,message:ee}=_ie(c)?{value:!!c,message:c}:_5(c);if(X&&(I[j]={type:bv.required,message:ee,ref:M,...V(bv.required,ee)},!n))return L(ee),I}if(!B&&(!wm(f)||!wm(g))){let X,ee;const Q=_5(g),ie=_5(f);if(!wm(S)&&!isNaN(S)){const re=l.valueAsNumber||S&&+S;wm(Q.value)||(X=re>Q.value),wm(ie.value)||(ee=renew Date(new Date().toDateString()+" "+ge),ce=l.type=="time",xe=l.type=="week";i0(Q.value)&&S&&(X=ce?oe(S)>oe(Q.value):xe?S>Q.value:re>new Date(Q.value)),i0(ie.value)&&S&&(ee=ce?oe(S)+X.value,ie=!wm(ee.value)&&S.length<+ee.value;if((Q||ie)&&(Z(Q,X.message,ee.message),!n))return L(I[j].message),I}if(b&&!B&&i0(S)){const{value:X,message:ee}=_5(b);if(Hoe(X)&&!S.match(X)&&(I[j]={type:bv.pattern,message:ee,ref:l,...V(bv.pattern,ee)},!n))return L(ee),I}if(_){if(qg(_)){const X=await _(S,r),ee=rIe(X,M);if(ee&&(I[j]={...ee,...V(bv.validate,ee.message)},!n))return L(ee.message),I}else if(Rd(_)){let X={};for(const ee in _){if(!dp(X)&&!n)break;const Q=rIe(await _[ee](S,r),M,ee);Q&&(X={...Q,...V(ee,Q.message)},L(Q.message),n&&(I[j]=X))}if(!dp(X)&&(I[j]={ref:M,...X},!n))return I}}return L(!0),I};const I6t={mode:$g.onSubmit,reValidateMode:$g.onChange,shouldFocusError:!0};function L6t(t={}){let s={...I6t,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:qg(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},a=Rd(s.defaultValues)||Rd(s.values)?pu(s.defaultValues||s.values)||{}:{},o=s.shouldUnregister?{}:pu(a),l={action:!1,mount:!1,watch:!1},i={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,u=0;const p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let f={...p};const g={array:KPe(),state:KPe()},b=s.criteriaMode===$g.all,_=Ge=>ct=>{clearTimeout(u),u=setTimeout(Ge,ct)},j=async Ge=>{if(!s.disabled&&(p.isValid||f.isValid||Ge)){const ct=s.resolver?dp((await q()).errors):await B(n,!0);ct!==r.isValid&&g.state.next({isValid:ct})}},w=(Ge,ct)=>{!s.disabled&&(p.isValidating||p.validatingFields||f.isValidating||f.validatingFields)&&((Ge||Array.from(i.mount)).forEach(qe=>{qe&&(ct?pl(r.validatingFields,qe,ct):Gd(r.validatingFields,qe))}),g.state.next({validatingFields:r.validatingFields,isValidating:!dp(r.validatingFields)}))},k=(Ge,ct=[],qe,Ze,Qe=!0,He=!0)=>{if(Ze&&qe&&!s.disabled){if(l.action=!0,He&&Array.isArray(Tn(n,Ge))){const Je=qe(Tn(n,Ge),Ze.argA,Ze.argB);Qe&&pl(n,Ge,Je)}if(He&&Array.isArray(Tn(r.errors,Ge))){const Je=qe(Tn(r.errors,Ge),Ze.argA,Ze.argB);Qe&&pl(r.errors,Ge,Je),E6t(r.errors,Ge)}if((p.touchedFields||f.touchedFields)&&He&&Array.isArray(Tn(r.touchedFields,Ge))){const Je=qe(Tn(r.touchedFields,Ge),Ze.argA,Ze.argB);Qe&&pl(r.touchedFields,Ge,Je)}(p.dirtyFields||f.dirtyFields)&&(r.dirtyFields=VP(a,o)),g.state.next({name:Ge,isDirty:Z(Ge,ct),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else pl(o,Ge,ct)},S=(Ge,ct)=>{pl(r.errors,Ge,ct),g.state.next({errors:r.errors})},M=Ge=>{r.errors=Ge,g.state.next({errors:r.errors,isValid:!1})},L=(Ge,ct,qe,Ze)=>{const Qe=Tn(n,Ge);if(Qe){const He=Tn(o,Ge,Ad(qe)?Tn(a,Ge):qe);Ad(He)||Ze&&Ze.defaultChecked||ct?pl(o,Ge,ct?He:QPe(Qe._f)):Q(Ge,He),l.mount&&j()}},I=(Ge,ct,qe,Ze,Qe)=>{let He=!1,Je=!1;const it={name:Ge};if(!s.disabled){if(!qe||Ze){(p.isDirty||f.isDirty)&&(Je=r.isDirty,r.isDirty=it.isDirty=Z(),He=Je!==it.isDirty);const Lt=Uv(Tn(a,Ge),ct);Je=!!Tn(r.dirtyFields,Ge),Lt?Gd(r.dirtyFields,Ge):pl(r.dirtyFields,Ge,!0),it.dirtyFields=r.dirtyFields,He=He||(p.dirtyFields||f.dirtyFields)&&Je!==!Lt}if(qe){const Lt=Tn(r.touchedFields,Ge);Lt||(pl(r.touchedFields,Ge,qe),it.touchedFields=r.touchedFields,He=He||(p.touchedFields||f.touchedFields)&&Lt!==qe)}He&&Qe&&g.state.next(it)}return He?it:{}},O=(Ge,ct,qe,Ze)=>{const Qe=Tn(r.errors,Ge),He=(p.isValid||f.isValid)&&sf(ct)&&r.isValid!==ct;if(s.delayError&&qe?(c=_(()=>S(Ge,qe)),c(s.delayError)):(clearTimeout(u),c=null,qe?pl(r.errors,Ge,qe):Gd(r.errors,Ge)),(qe?!Uv(Qe,qe):Qe)||!dp(Ze)||He){const Je={...Ze,...He&&sf(ct)?{isValid:ct}:{},errors:r.errors,name:Ge};r={...r,...Je},g.state.next(Je)}},q=async Ge=>{w(Ge,!0);const ct=await s.resolver(o,s.context,k6t(Ge||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return w(Ge),ct},U=async Ge=>{const{errors:ct}=await q(Ge);if(Ge)for(const qe of Ge){const Ze=Tn(ct,qe);Ze?pl(r.errors,qe,Ze):Gd(r.errors,qe)}else r.errors=ct;return ct},B=async(Ge,ct,qe={valid:!0})=>{for(const Ze in Ge){const Qe=Ge[Ze];if(Qe){const{_f:He,...Je}=Qe;if(He){const it=i.array.has(He.name),Lt=Qe._f&&S6t(Qe._f);Lt&&p.validatingFields&&w([Ze],!0);const Vt=await nIe(Qe,i.disabled,o,b,s.shouldUseNativeValidation&&!ct,it);if(Lt&&p.validatingFields&&w([Ze]),Vt[He.name]&&(qe.valid=!1,ct))break;!ct&&(Tn(Vt,He.name)?it?P6t(r.errors,Vt,He.name):pl(r.errors,He.name,Vt[He.name]):Gd(r.errors,He.name))}!dp(Je)&&await B(Je,ct,qe)}}return qe.valid},V=()=>{for(const Ge of i.unMount){const ct=Tn(n,Ge);ct&&(ct._f.refs?ct._f.refs.every(qe=>!Hxe(qe)):!Hxe(ct._f.ref))&&Oe(Ge)}i.unMount=new Set},Z=(Ge,ct)=>!s.disabled&&(Ge&&ct&&pl(o,Ge,ct),!Uv(ge(),a)),X=(Ge,ct,qe)=>YZe(Ge,i,{...l.mount?o:Ad(ct)?a:i0(Ge)?{[Ge]:ct}:ct},qe,ct),ee=Ge=>oNe(Tn(l.mount?o:a,Ge,s.shouldUnregister?Tn(a,Ge,[]):[])),Q=(Ge,ct,qe={})=>{const Ze=Tn(n,Ge);let Qe=ct;if(Ze){const He=Ze._f;He&&(!He.disabled&&pl(o,Ge,sYe(ct,He)),Qe=Uoe(He.ref)&&wm(ct)?"":ct,QZe(He.ref)?[...He.ref.options].forEach(Je=>Je.selected=Qe.includes(Je.value)):He.refs?RO(He.ref)?He.refs.forEach(Je=>{(!Je.defaultChecked||!Je.disabled)&&(Array.isArray(Qe)?Je.checked=!!Qe.find(it=>it===Je.value):Je.checked=Qe===Je.value||!!Qe)}):He.refs.forEach(Je=>Je.checked=Je.value===Qe):uNe(He.ref)?He.ref.value="":(He.ref.value=Qe,He.ref.type||g.state.next({name:Ge,values:pu(o)})))}(qe.shouldDirty||qe.shouldTouch)&&I(Ge,Qe,qe.shouldTouch,qe.shouldDirty,!0),qe.shouldValidate&&xe(Ge)},ie=(Ge,ct,qe)=>{for(const Ze in ct){if(!ct.hasOwnProperty(Ze))return;const Qe=ct[Ze],He=Ge+"."+Ze,Je=Tn(n,He);(i.array.has(Ge)||Rd(Qe)||Je&&!Je._f)&&!_4(Qe)?ie(He,Qe,qe):Q(He,Qe,qe)}},re=(Ge,ct,qe={})=>{const Ze=Tn(n,Ge),Qe=i.array.has(Ge),He=pu(ct);pl(o,Ge,He),Qe?(g.array.next({name:Ge,values:pu(o)}),(p.isDirty||p.dirtyFields||f.isDirty||f.dirtyFields)&&qe.shouldDirty&&g.state.next({name:Ge,dirtyFields:VP(a,o),isDirty:Z(Ge,He)})):Ze&&!Ze._f&&!wm(He)?ie(Ge,He,qe):Q(Ge,He,qe),tIe(Ge,i)&&g.state.next({...r,name:Ge}),g.state.next({name:l.mount?Ge:void 0,values:pu(o)})},oe=async Ge=>{l.mount=!0;const ct=Ge.target;let qe=ct.name,Ze=!0;const Qe=Tn(n,qe),He=Lt=>{Ze=Number.isNaN(Lt)||_4(Lt)&&isNaN(Lt.getTime())||Uv(Lt,Tn(o,qe,Lt))},Je=JPe(s.mode),it=JPe(s.reValidateMode);if(Qe){let Lt,Vt;const hs=ct.type?QPe(Qe._f):GZe(Ge),Ts=Ge.type===qoe.BLUR||Ge.type===qoe.FOCUS_OUT,Cs=!C6t(Qe._f)&&!s.resolver&&!Tn(r.errors,qe)&&!Qe._f.deps||A6t(Ts,Tn(r.touchedFields,qe),r.isSubmitted,it,Je),cs=tIe(qe,i,Ts);pl(o,qe,hs),Ts?(Qe._f.onBlur&&Qe._f.onBlur(Ge),c&&c(0)):Qe._f.onChange&&Qe._f.onChange(Ge);const er=I(qe,hs,Ts),xt=!dp(er)||cs;if(!Ts&&g.state.next({name:qe,type:Ge.type,values:pu(o)}),Cs)return(p.isValid||f.isValid)&&(s.mode==="onBlur"?Ts&&j():Ts||j()),xt&&g.state.next({name:qe,...cs?{}:er});if(!Ts&&cs&&g.state.next({...r}),s.resolver){const{errors:Es}=await q([qe]);if(He(hs),Ze){const ur=sIe(r.errors,n,qe),Mr=sIe(Es,n,ur.name||qe);Lt=Mr.error,qe=Mr.name,Vt=dp(Es)}}else w([qe],!0),Lt=(await nIe(Qe,i.disabled,o,b,s.shouldUseNativeValidation))[qe],w([qe]),He(hs),Ze&&(Lt?Vt=!1:(p.isValid||f.isValid)&&(Vt=await B(n,!0)));Ze&&(Qe._f.deps&&xe(Qe._f.deps),O(qe,Vt,Lt,er))}},ce=(Ge,ct)=>{if(Tn(r.errors,ct)&&Ge.focus)return Ge.focus(),1},xe=async(Ge,ct={})=>{let qe,Ze;const Qe=ZL(Ge);if(s.resolver){const He=await U(Ad(Ge)?Ge:Qe);qe=dp(He),Ze=Ge?!Qe.some(Je=>Tn(He,Je)):qe}else Ge?(Ze=(await Promise.all(Qe.map(async He=>{const Je=Tn(n,He);return await B(Je&&Je._f?{[He]:Je}:Je)}))).every(Boolean),!(!Ze&&!r.isValid)&&j()):Ze=qe=await B(n);return g.state.next({...!i0(Ge)||(p.isValid||f.isValid)&&qe!==r.isValid?{}:{name:Ge},...s.resolver||!Ge?{isValid:qe}:{},errors:r.errors}),ct.shouldFocus&&!Ze&&YL(n,ce,Ge?Qe:i.mount),Ze},ge=Ge=>{const ct={...l.mount?o:a};return Ad(Ge)?ct:i0(Ge)?Tn(ct,Ge):Ge.map(qe=>Tn(ct,qe))},ue=(Ge,ct)=>({invalid:!!Tn((ct||r).errors,Ge),isDirty:!!Tn((ct||r).dirtyFields,Ge),error:Tn((ct||r).errors,Ge),isValidating:!!Tn(r.validatingFields,Ge),isTouched:!!Tn((ct||r).touchedFields,Ge)}),pe=Ge=>{Ge&&ZL(Ge).forEach(ct=>Gd(r.errors,ct)),g.state.next({errors:Ge?r.errors:{}})},be=(Ge,ct,qe)=>{const Ze=(Tn(n,Ge,{_f:{}})._f||{}).ref,Qe=Tn(r.errors,Ge)||{},{ref:He,message:Je,type:it,...Lt}=Qe;pl(r.errors,Ge,{...Lt,...ct,ref:Ze}),g.state.next({name:Ge,errors:r.errors,isValid:!1}),qe&&qe.shouldFocus&&Ze&&Ze.focus&&Ze.focus()},Me=(Ge,ct)=>qg(Ge)?g.state.subscribe({next:qe=>"values"in qe&&Ge(X(void 0,ct),qe)}):X(Ge,ct,!0),Ne=Ge=>g.state.subscribe({next:ct=>{T6t(Ge.name,ct.name,Ge.exact)&&M6t(ct,Ge.formState||p,et,Ge.reRenderRoot)&&Ge.callback({values:{...o},...r,...ct,defaultValues:a})}}).unsubscribe,Pe=Ge=>(l.mount=!0,f={...f,...Ge.formState},Ne({...Ge,formState:f})),Oe=(Ge,ct={})=>{for(const qe of Ge?ZL(Ge):i.mount)i.mount.delete(qe),i.array.delete(qe),ct.keepValue||(Gd(n,qe),Gd(o,qe)),!ct.keepError&&Gd(r.errors,qe),!ct.keepDirty&&Gd(r.dirtyFields,qe),!ct.keepTouched&&Gd(r.touchedFields,qe),!ct.keepIsValidating&&Gd(r.validatingFields,qe),!s.shouldUnregister&&!ct.keepDefaultValue&&Gd(a,qe);g.state.next({values:pu(o)}),g.state.next({...r,...ct.keepDirty?{isDirty:Z()}:{}}),!ct.keepIsValid&&j()},Te=({disabled:Ge,name:ct})=>{(sf(Ge)&&l.mount||Ge||i.disabled.has(ct))&&(Ge?i.disabled.add(ct):i.disabled.delete(ct))},ke=(Ge,ct={})=>{let qe=Tn(n,Ge);const Ze=sf(ct.disabled)||sf(s.disabled);return pl(n,Ge,{...qe||{},_f:{...qe&&qe._f?qe._f:{ref:{name:Ge}},name:Ge,mount:!0,...ct}}),i.mount.add(Ge),qe?Te({disabled:sf(ct.disabled)?ct.disabled:s.disabled,name:Ge}):L(Ge,!0,ct.value),{...Ze?{disabled:ct.disabled||s.disabled}:{},...s.progressive?{required:!!ct.required,min:HP(ct.min),max:HP(ct.max),minLength:HP(ct.minLength),maxLength:HP(ct.maxLength),pattern:HP(ct.pattern)}:{},name:Ge,onChange:oe,onBlur:oe,ref:Qe=>{if(Qe){ke(Ge,ct),qe=Tn(n,Ge);const He=Ad(Qe.value)&&Qe.querySelectorAll&&Qe.querySelectorAll("input,select,textarea")[0]||Qe,Je=w6t(He),it=qe._f.refs||[];if(Je?it.find(Lt=>Lt===He):He===qe._f.ref)return;pl(n,Ge,{_f:{...qe._f,...Je?{refs:[...it.filter(Hxe),He,...Array.isArray(Tn(a,Ge))?[{}]:[]],ref:{type:He.type,name:Ge}}:{ref:He}}}),L(Ge,!1,void 0,He)}else qe=Tn(n,Ge,{}),qe._f&&(qe._f.mount=!1),(s.shouldUnregister||ct.shouldUnregister)&&!(KZe(i.array,Ge)&&l.action)&&i.unMount.add(Ge)}}},Be=()=>s.shouldFocusError&&YL(n,ce,i.mount),nt=Ge=>{sf(Ge)&&(g.state.next({disabled:Ge}),YL(n,(ct,qe)=>{const Ze=Tn(n,qe);Ze&&(ct.disabled=Ze._f.disabled||Ge,Array.isArray(Ze._f.refs)&&Ze._f.refs.forEach(Qe=>{Qe.disabled=Ze._f.disabled||Ge}))},0,!1))},Ae=(Ge,ct)=>async qe=>{let Ze;qe&&(qe.preventDefault&&qe.preventDefault(),qe.persist&&qe.persist());let Qe=pu(o);if(g.state.next({isSubmitting:!0}),s.resolver){const{errors:He,values:Je}=await q();r.errors=He,Qe=pu(Je)}else await B(n);if(i.disabled.size)for(const He of i.disabled)Gd(Qe,He);if(Gd(r.errors,"root"),dp(r.errors)){g.state.next({errors:{}});try{await Ge(Qe,qe)}catch(He){Ze=He}}else ct&&await ct({...r.errors},qe),Be(),setTimeout(Be);if(g.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:dp(r.errors)&&!Ze,submitCount:r.submitCount+1,errors:r.errors}),Ze)throw Ze},ft=(Ge,ct={})=>{Tn(n,Ge)&&(Ad(ct.defaultValue)?re(Ge,pu(Tn(a,Ge))):(re(Ge,ct.defaultValue),pl(a,Ge,pu(ct.defaultValue))),ct.keepTouched||Gd(r.touchedFields,Ge),ct.keepDirty||(Gd(r.dirtyFields,Ge),r.isDirty=ct.defaultValue?Z(Ge,pu(Tn(a,Ge))):Z()),ct.keepError||(Gd(r.errors,Ge),p.isValid&&j()),g.state.next({...r}))},fe=(Ge,ct={})=>{const qe=Ge?pu(Ge):a,Ze=pu(qe),Qe=dp(Ge),He=Qe?a:Ze;if(ct.keepDefaultValues||(a=qe),!ct.keepValues){if(ct.keepDirtyValues){const Je=new Set([...i.mount,...Object.keys(VP(a,o))]);for(const it of Array.from(Je))Tn(r.dirtyFields,it)?pl(He,it,Tn(o,it)):re(it,Tn(He,it))}else{if(iNe&&Ad(Ge))for(const Je of i.mount){const it=Tn(n,Je);if(it&&it._f){const Lt=Array.isArray(it._f.refs)?it._f.refs[0]:it._f.ref;if(Uoe(Lt)){const Vt=Lt.closest("form");if(Vt){Vt.reset();break}}}}if(ct.keepFieldsRef)for(const Je of i.mount)re(Je,Tn(He,Je));else n={}}o=s.shouldUnregister?ct.keepDefaultValues?pu(a):{}:pu(He),g.array.next({values:{...He}}),g.state.next({values:{...He}})}i={mount:ct.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!p.isValid||!!ct.keepIsValid||!!ct.keepDirtyValues,l.watch=!!s.shouldUnregister,g.state.next({submitCount:ct.keepSubmitCount?r.submitCount:0,isDirty:Qe?!1:ct.keepDirty?r.isDirty:!!(ct.keepDefaultValues&&!Uv(Ge,a)),isSubmitted:ct.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:Qe?{}:ct.keepDirtyValues?ct.keepDefaultValues&&o?VP(a,o):r.dirtyFields:ct.keepDefaultValues&&Ge?VP(a,Ge):ct.keepDirty?r.dirtyFields:{},touchedFields:ct.keepTouched?r.touchedFields:{},errors:ct.keepErrors?r.errors:{},isSubmitSuccessful:ct.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Ve=(Ge,ct)=>fe(qg(Ge)?Ge(o):Ge,ct),at=(Ge,ct={})=>{const qe=Tn(n,Ge),Ze=qe&&qe._f;if(Ze){const Qe=Ze.refs?Ze.refs[0]:Ze.ref;Qe.focus&&(Qe.focus(),ct.shouldSelect&&qg(Qe.select)&&Qe.select())}},et=Ge=>{r={...r,...Ge}},rt={control:{register:ke,unregister:Oe,getFieldState:ue,handleSubmit:Ae,setError:be,_subscribe:Ne,_runSchema:q,_focusError:Be,_getWatch:X,_getDirty:Z,_setValid:j,_setFieldArray:k,_setDisabledField:Te,_setErrors:M,_getFieldArray:ee,_reset:fe,_resetDefaultValues:()=>qg(s.defaultValues)&&s.defaultValues().then(Ge=>{Ve(Ge,s.resetOptions),g.state.next({isLoading:!1})}),_removeUnmounted:V,_disableForm:nt,_subjects:g,_proxyFormState:p,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state(Ge){l=Ge},get _defaultValues(){return a},get _names(){return i},set _names(Ge){i=Ge},get _formState(){return r},get _options(){return s},set _options(Ge){s={...s,...Ge}}},subscribe:Pe,trigger:xe,register:ke,handleSubmit:Ae,watch:Me,setValue:re,getValues:ge,reset:Ve,resetField:ft,clearErrors:pe,unregister:Oe,setError:be,setFocus:at,getFieldState:ue};return{...rt,formControl:rt}}function mue(t={}){const s=ht.useRef(void 0),r=ht.useRef(void 0),[n,a]=ht.useState({isDirty:!1,isValidating:!1,isLoading:qg(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:qg(t.defaultValues)?void 0:t.defaultValues});if(!s.current)if(t.formControl)s.current={...t.formControl,formState:n},t.defaultValues&&!qg(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...i}=L6t(t);s.current={...i,formState:n}}const o=s.current.control;return o._options=t,dNe(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>a({...o._formState}),reRenderRoot:!0});return a(i=>({...i,isReady:!0})),o._formState.isReady=!0,l},[o]),ht.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),ht.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),ht.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),ht.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),ht.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==n.isDirty&&o._subjects.state.next({isDirty:l})}},[o,n.isDirty]),ht.useEffect(()=>{t.values&&!Uv(t.values,r.current)?(o._reset(t.values,{keepFieldsRef:!0,...o._options.resetOptions}),r.current=t.values,a(l=>({...l}))):o._resetDefaultValues()},[o,t.values]),ht.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),s.current.formState=ZZe(n,o),s.current}const aIe=(t,s,r)=>{if(t&&"reportValidity"in t){const n=Tn(r,s);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},nYe=(t,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?aIe(n.ref,r,t):n.refs&&n.refs.forEach(a=>aIe(a,r,t))}},D6t=(t,s)=>{s.shouldUseNativeValidation&&nYe(t,s);const r={};for(const n in t){const a=Tn(s.fields,n),o=Object.assign(t[n]||{},{ref:a&&a.ref});if(O6t(s.names||Object.keys(t),n)){const l=Object.assign({},Tn(r,n));pl(l,"root",o),pl(r,n,l)}else pl(r,n,o)}return r},O6t=(t,s)=>t.some(r=>r.startsWith(s+"."));var R6t=function(t,s){for(var r={};t.length;){var n=t[0],a=n.code,o=n.message,l=n.path.join(".");if(!r[l])if("unionErrors"in n){var i=n.unionErrors[0].errors[0];r[l]={message:i.message,type:i.code}}else r[l]={message:o,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(p){return p.errors.forEach(function(f){return t.push(f)})}),s){var c=r[l].types,u=c&&c[n.code];r[l]=XZe(l,s,r,a,u?[].concat(u,n.message):n.message)}t.shift()}return r},pue=function(t,s,r){return r===void 0&&(r={}),function(n,a,o){try{return Promise.resolve(function(l,i){try{var c=Promise.resolve(t[r.mode==="sync"?"parse":"parseAsync"](n,s)).then(function(u){return o.shouldUseNativeValidation&&nYe({},o),{errors:{},values:r.raw?n:u}})}catch(u){return i(u)}return c&&c.then?c.then(void 0,i):c}(0,function(l){if(function(i){return Array.isArray(i==null?void 0:i.errors)}(l))return{values:{},errors:D6t(R6t(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const fue=g6t,aYe=N.createContext({}),Zc=({...t})=>e.jsx(aYe.Provider,{value:{name:t.name},children:e.jsx(_6t,{...t})}),xue=()=>{const t=N.useContext(aYe),s=N.useContext(iYe),{getFieldState:r,formState:n}=hue(),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}},iYe=N.createContext({}),Lc=N.forwardRef(({className:t,...s},r)=>{const n=N.useId();return e.jsx(iYe.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:It("space-y-2",t),...s})})});Lc.displayName="FormItem";const Dc=N.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=xue();return e.jsx(ve,{ref:r,className:It(n&&"text-destructive",t),htmlFor:a,...s})});Dc.displayName="FormLabel";const Oc=N.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=xue();return e.jsx(u2e,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});Oc.displayName="FormControl";const wie=N.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=xue();return e.jsx("p",{ref:r,id:n,className:It("text-sm text-muted-foreground",t),...s})});wie.displayName="FormDescription";const Sm=N.forwardRef(({className:t,children:s,...r},n)=>{const{error:a,formMessageId:o}=xue(),l=a?String(a==null?void 0:a.message):s;return l?e.jsx("p",{ref:n,id:o,className:It("text-sm font-medium text-destructive",t),...r,children:l}):null});Sm.displayName="FormMessage";const F6t=gC({category:LGe(["general","technology","crm","marketing"]),subject:gc().min(5,"Subject must be at least 5 characters").max(200),description:gc().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),z6t={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function p1e({trigger:t}){const[s,r]=N.useState(!1),[n,a]=N.useState(!1),{user:o}=Ds(),l=mue({resolver:pue(F6t),defaultValues:{category:"general",subject:"",description:""}}),i=async c=>{if(!o){me.error("You must be logged in to submit a ticket");return}a(!0);try{const{error:u}=await H.from("support_tickets").insert({user_id:o.id,category:c.category,subject:c.subject,description:c.description});if(u)throw u;try{await H.functions.invoke("support-ticket-notify",{body:{category:z6t[c.category],subject:c.subject}})}catch(p){console.log("Notification send attempted:",p)}me.success("Support ticket submitted successfully!"),l.reset(),r(!1)}catch(u){console.error("Error submitting ticket:",u),me.error("Failed to submit ticket. Please try again.")}finally{a(!1)}};return e.jsxs(fs,{open:s,onOpenChange:r,children:[e.jsx(qi,{asChild:!0,children:t||e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(hL,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:"Support"})]})}),e.jsxs(ps,{className:"sm:max-w-[500px]",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Need Help?"}),e.jsx(Gr,{children:"Submit a support ticket and we'll get back to you as soon as possible."})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg mb-4",children:[e.jsx(Un,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["You can also text us at: ",e.jsx("span",{className:"font-medium text-foreground",children:"1-866-527-8668"})]})]}),e.jsx(fue,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(Zc,{control:l.control,name:"category",render:({field:c})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Category"}),e.jsxs(Zs,{onValueChange:c.onChange,defaultValue:c.value,children:[e.jsx(Oc,{children:e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select a category"})})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"general",children:"General Support"}),e.jsx(Mt,{value:"technology",children:"Technology Support"}),e.jsx(Mt,{value:"crm",children:"CRM Support"}),e.jsx(Mt,{value:"marketing",children:"Marketing Support"})]})]}),e.jsx(Sm,{})]})}),e.jsx(Zc,{control:l.control,name:"subject",render:({field:c})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Subject"}),e.jsx(Oc,{children:e.jsx(ze,{placeholder:"Brief description of your issue",...c})}),e.jsx(Sm,{})]})}),e.jsx(Zc,{control:l.control,name:"description",render:({field:c})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Description"}),e.jsx(Oc,{children:e.jsx(Er,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...c})}),e.jsx(Sm,{})]})}),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 B6t=()=>{const{user:t}=Ds(),s=fr(),[r,n]=N.useState([]),[a,o]=N.useState(0),[l,i]=N.useState(!1),[c,u]=N.useState(null);N.useEffect(()=>{if(!t)return;const _=`notification_last_read_${t.id}`;let j=c;if(!j){const S=localStorage.getItem(_);S&&(j=S,u(S))}(async()=>{const{data:S,error:M}=await H.from("push_notifications").select("*").order("created_at",{ascending:!1}).limit(20);if(!M&&S){n(S);const L=j?new Date(j):null,I=S.filter(O=>L?new Date(O.created_at)>L:!0);o(I.length)}})();const k=H.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},S=>{const M=S.new;n(I=>[M,...I].slice(0,20));const L=j?new Date(j):null;(!L||new Date(M.created_at)>L)&&o(I=>I+1),Notification.permission==="granted"&&new Notification(M.title,{body:M.body,icon:"/favicon.ico"})}).subscribe();return()=>{H.removeChannel(k)}},[t,c]);const p=_=>{const j=_.toLowerCase();return j.includes("community")||j.includes("post")?so:j.includes("academy")||j.includes("video")?An:j.includes("template")?ac:j.includes("event")?hn:j.includes("newsletter")?l1:j.includes("brokerage")?Gh:j.includes("swag")||j.includes("social")?ko:j.includes("toolbox")||j.includes("tool")?ey:j.includes("brief")?pn:so},f=_=>{i(!1),_.url&&_.url!=="/"&&s(_.url)},g=()=>{if(!t)return;const _=new Date().toISOString(),j=`notification_last_read_${t.id}`;localStorage.setItem(j,_),u(_),o(0)},b=_=>{i(_),_&&a>0&&g()};return e.jsxs(iu,{open:l,onOpenChange:b,children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(Lm,{className:"h-5 w-5"}),a>0&&e.jsx(tt,{variant:"destructive",className:"absolute -top-1 -right-1 h-5 w-5 flex items-center justify-center p-0 text-xs",children:a>9?"9+":a})]})}),e.jsxs(Bd,{align:"end",className:"w-80",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b",children:[e.jsx("span",{className:"font-semibold",children:"Notifications"}),r.length>0&&e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:g,children:"Mark all read"})]}),e.jsx(Gi,{className:"h-[300px]",children:r.length===0?e.jsx("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No notifications yet"}):r.map(_=>{const j=p(_.title);return e.jsxs(Ma,{className:"group flex items-start gap-3 p-3 cursor-pointer data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",onClick:()=>f(_),children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx(j,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-sm",children:_.title}),e.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2 group-data-[highlighted]:text-accent-foreground/80",children:_.body}),e.jsx("span",{className:"text-xs text-muted-foreground group-data-[highlighted]:text-accent-foreground/80",children:Uc(new Date(_.created_at),{addSuffix:!0})})]})]},_.id)})})]})]})};var iIe=1,$6t=.9,q6t=.8,U6t=.17,Wxe=.1,Gxe=.999,V6t=.9999,H6t=.99,W6t=/[\\\/_+.#"@\[\(\{&]/,G6t=/[\\\/_+.#"@\[\(\{&]/g,K6t=/[\s-]/,oYe=/[\s-]/g;function f1e(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?iIe:H6t;var i=`${a},${o}`;if(l[i]!==void 0)return l[i];for(var c=n.charAt(o),u=r.indexOf(c,a),p=0,f,g,b,_;u>=0;)f=f1e(t,s,r,n,u+1,o+1,l),f>p&&(u===a?f*=iIe:W6t.test(t.charAt(u-1))?(f*=q6t,b=t.slice(a,u-1).match(G6t),b&&a>0&&(f*=Math.pow(Gxe,b.length))):K6t.test(t.charAt(u-1))?(f*=$6t,_=t.slice(a,u-1).match(oYe),_&&a>0&&(f*=Math.pow(Gxe,_.length))):(f*=U6t,a>0&&(f*=Math.pow(Gxe,u-a))),t.charAt(u)!==s.charAt(o)&&(f*=V6t)),(ff&&(f=g*Wxe)),f>p&&(p=f),u=r.indexOf(c,u+1);return l[i]=p,p}function oIe(t){return t.toLowerCase().replace(oYe," ")}function Z6t(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,f1e(t,s,oIe(t),oIe(s),0,0,{})}var WP='[cmdk-group=""]',Kxe='[cmdk-group-items=""]',Y6t='[cmdk-group-heading=""]',lYe='[cmdk-item=""]',lIe=`${lYe}:not([aria-disabled="true"])`,x1e="cmdk-item-select",B5="data-value",X6t=(t,s,r)=>Z6t(t,s,r),cYe=N.createContext(void 0),FO=()=>N.useContext(cYe),dYe=N.createContext(void 0),mNe=()=>N.useContext(dYe),uYe=N.createContext(void 0),hYe=N.forwardRef((t,s)=>{let r=$5(()=>{var pe,be;return{search:"",value:(be=(pe=t.value)!=null?pe:t.defaultValue)!=null?be:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=$5(()=>new Set),a=$5(()=>new Map),o=$5(()=>new Map),l=$5(()=>new Set),i=mYe(t),{label:c,children:u,value:p,onValueChange:f,filter:g,shouldFilter:b,loop:_,disablePointerSelection:j=!1,vimBindings:w=!0,...k}=t,S=Tu(),M=Tu(),L=Tu(),I=N.useRef(null),O=lPt();HS(()=>{if(p!==void 0){let pe=p.trim();r.current.value=pe,q.emit()}},[p]),HS(()=>{O(6,ee)},[]);let q=N.useMemo(()=>({subscribe:pe=>(l.current.add(pe),()=>l.current.delete(pe)),snapshot:()=>r.current,setState:(pe,be,Me)=>{var Ne,Pe,Oe,Te;if(!Object.is(r.current[pe],be)){if(r.current[pe]=be,pe==="search")X(),V(),O(1,Z);else if(pe==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ke=document.getElementById(L);ke?ke.focus():(Ne=document.getElementById(S))==null||Ne.focus()}if(O(7,()=>{var ke;r.current.selectedItemId=(ke=Q())==null?void 0:ke.id,q.emit()}),Me||O(5,ee),((Pe=i.current)==null?void 0:Pe.value)!==void 0){let ke=be??"";(Te=(Oe=i.current).onValueChange)==null||Te.call(Oe,ke);return}}q.emit()}},emit:()=>{l.current.forEach(pe=>pe())}}),[]),U=N.useMemo(()=>({value:(pe,be,Me)=>{var Ne;be!==((Ne=o.current.get(pe))==null?void 0:Ne.value)&&(o.current.set(pe,{value:be,keywords:Me}),r.current.filtered.items.set(pe,B(be,Me)),O(2,()=>{V(),q.emit()}))},item:(pe,be)=>(n.current.add(pe),be&&(a.current.has(be)?a.current.get(be).add(pe):a.current.set(be,new Set([pe]))),O(3,()=>{X(),V(),r.current.value||Z(),q.emit()}),()=>{o.current.delete(pe),n.current.delete(pe),r.current.filtered.items.delete(pe);let Me=Q();O(4,()=>{X(),(Me==null?void 0:Me.getAttribute("id"))===pe&&Z(),q.emit()})}),group:pe=>(a.current.has(pe)||a.current.set(pe,new Set),()=>{o.current.delete(pe),a.current.delete(pe)}),filter:()=>i.current.shouldFilter,label:c||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:S,inputId:L,labelId:M,listInnerRef:I}),[]);function B(pe,be){var Me,Ne;let Pe=(Ne=(Me=i.current)==null?void 0:Me.filter)!=null?Ne:X6t;return pe?Pe(pe,r.current.search,be):0}function V(){if(!r.current.search||i.current.shouldFilter===!1)return;let pe=r.current.filtered.items,be=[];r.current.filtered.groups.forEach(Ne=>{let Pe=a.current.get(Ne),Oe=0;Pe.forEach(Te=>{let ke=pe.get(Te);Oe=Math.max(ke,Oe)}),be.push([Ne,Oe])});let Me=I.current;ie().sort((Ne,Pe)=>{var Oe,Te;let ke=Ne.getAttribute("id"),Be=Pe.getAttribute("id");return((Oe=pe.get(Be))!=null?Oe:0)-((Te=pe.get(ke))!=null?Te:0)}).forEach(Ne=>{let Pe=Ne.closest(Kxe);Pe?Pe.appendChild(Ne.parentElement===Pe?Ne:Ne.closest(`${Kxe} > *`)):Me.appendChild(Ne.parentElement===Me?Ne:Ne.closest(`${Kxe} > *`))}),be.sort((Ne,Pe)=>Pe[1]-Ne[1]).forEach(Ne=>{var Pe;let Oe=(Pe=I.current)==null?void 0:Pe.querySelector(`${WP}[${B5}="${encodeURIComponent(Ne[0])}"]`);Oe==null||Oe.parentElement.appendChild(Oe)})}function Z(){let pe=ie().find(Me=>Me.getAttribute("aria-disabled")!=="true"),be=pe==null?void 0:pe.getAttribute(B5);q.setState("value",be||void 0)}function X(){var pe,be,Me,Ne;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let Pe=0;for(let Oe of n.current){let Te=(be=(pe=o.current.get(Oe))==null?void 0:pe.value)!=null?be:"",ke=(Ne=(Me=o.current.get(Oe))==null?void 0:Me.keywords)!=null?Ne:[],Be=B(Te,ke);r.current.filtered.items.set(Oe,Be),Be>0&&Pe++}for(let[Oe,Te]of a.current)for(let ke of Te)if(r.current.filtered.items.get(ke)>0){r.current.filtered.groups.add(Oe);break}r.current.filtered.count=Pe}function ee(){var pe,be,Me;let Ne=Q();Ne&&(((pe=Ne.parentElement)==null?void 0:pe.firstChild)===Ne&&((Me=(be=Ne.closest(WP))==null?void 0:be.querySelector(Y6t))==null||Me.scrollIntoView({block:"nearest"})),Ne.scrollIntoView({block:"nearest"}))}function Q(){var pe;return(pe=I.current)==null?void 0:pe.querySelector(`${lYe}[aria-selected="true"]`)}function ie(){var pe;return Array.from(((pe=I.current)==null?void 0:pe.querySelectorAll(lIe))||[])}function re(pe){let be=ie()[pe];be&&q.setState("value",be.getAttribute(B5))}function oe(pe){var be;let Me=Q(),Ne=ie(),Pe=Ne.findIndex(Te=>Te===Me),Oe=Ne[Pe+pe];(be=i.current)!=null&&be.loop&&(Oe=Pe+pe<0?Ne[Ne.length-1]:Pe+pe===Ne.length?Ne[0]:Ne[Pe+pe]),Oe&&q.setState("value",Oe.getAttribute(B5))}function ce(pe){let be=Q(),Me=be==null?void 0:be.closest(WP),Ne;for(;Me&&!Ne;)Me=pe>0?iPt(Me,WP):oPt(Me,WP),Ne=Me==null?void 0:Me.querySelector(lIe);Ne?q.setState("value",Ne.getAttribute(B5)):oe(pe)}let xe=()=>re(ie().length-1),ge=pe=>{pe.preventDefault(),pe.metaKey?xe():pe.altKey?ce(1):oe(1)},ue=pe=>{pe.preventDefault(),pe.metaKey?re(0):pe.altKey?ce(-1):oe(-1)};return N.createElement(nn.div,{ref:s,tabIndex:-1,...k,"cmdk-root":"",onKeyDown:pe=>{var be;(be=k.onKeyDown)==null||be.call(k,pe);let Me=pe.nativeEvent.isComposing||pe.keyCode===229;if(!(pe.defaultPrevented||Me))switch(pe.key){case"n":case"j":{w&&pe.ctrlKey&&ge(pe);break}case"ArrowDown":{ge(pe);break}case"p":case"k":{w&&pe.ctrlKey&&ue(pe);break}case"ArrowUp":{ue(pe);break}case"Home":{pe.preventDefault(),re(0);break}case"End":{pe.preventDefault(),xe();break}case"Enter":{pe.preventDefault();let Ne=Q();if(Ne){let Pe=new Event(x1e);Ne.dispatchEvent(Pe)}}}}},N.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:dPt},c),gue(t,pe=>N.createElement(dYe.Provider,{value:q},N.createElement(cYe.Provider,{value:U},pe))))}),Q6t=N.forwardRef((t,s)=>{var r,n;let a=Tu(),o=N.useRef(null),l=N.useContext(uYe),i=FO(),c=mYe(t),u=(n=(r=c.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;HS(()=>{if(!u)return i.item(a,l==null?void 0:l.id)},[u]);let p=pYe(a,o,[t.value,t.children,o],t.keywords),f=mNe(),g=xw(O=>O.value&&O.value===p.current),b=xw(O=>u||i.filter()===!1?!0:O.search?O.filtered.items.get(a)>0:!0);N.useEffect(()=>{let O=o.current;if(!(!O||t.disabled))return O.addEventListener(x1e,_),()=>O.removeEventListener(x1e,_)},[b,t.onSelect,t.disabled]);function _(){var O,q;j(),(q=(O=c.current).onSelect)==null||q.call(O,p.current)}function j(){f.setState("value",p.current,!0)}if(!b)return null;let{disabled:w,value:k,onSelect:S,forceMount:M,keywords:L,...I}=t;return N.createElement(nn.div,{ref:S1(o,s),...I,id:a,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!g,"data-disabled":!!w,"data-selected":!!g,onPointerMove:w||i.getDisablePointerSelection()?void 0:j,onClick:w?void 0:_},t.children)}),J6t=N.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=Tu(),i=N.useRef(null),c=N.useRef(null),u=Tu(),p=FO(),f=xw(b=>a||p.filter()===!1?!0:b.search?b.filtered.groups.has(l):!0);HS(()=>p.group(l),[]),pYe(l,i,[t.value,t.heading,c]);let g=N.useMemo(()=>({id:l,forceMount:a}),[a]);return N.createElement(nn.div,{ref:S1(i,s),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},r&&N.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),gue(t,b=>N.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},N.createElement(uYe.Provider,{value:g},b))))}),ePt=N.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=N.useRef(null),o=xw(l=>!l.search);return!r&&!o?null:N.createElement(nn.div,{ref:S1(a,s),...n,"cmdk-separator":"",role:"separator"})}),tPt=N.forwardRef((t,s)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=mNe(),l=xw(u=>u.search),i=xw(u=>u.selectedItemId),c=FO();return N.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),N.createElement(nn.input,{ref:s,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":i,id:c.inputId,type:"text",value:a?t.value:l,onChange:u=>{a||o.setState("search",u.target.value),r==null||r(u.target.value)}})}),sPt=N.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=N.useRef(null),l=N.useRef(null),i=xw(u=>u.selectedItemId),c=FO();return N.useEffect(()=>{if(l.current&&o.current){let u=l.current,p=o.current,f,g=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let b=u.offsetHeight;p.style.setProperty("--cmdk-list-height",b.toFixed(1)+"px")})});return g.observe(u),()=>{cancelAnimationFrame(f),g.unobserve(u)}}},[]),N.createElement(nn.div,{ref:S1(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:c.listId},gue(t,u=>N.createElement("div",{ref:S1(l,c.listInnerRef),"cmdk-list-sizer":""},u)))}),rPt=N.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return N.createElement(qde,{open:r,onOpenChange:n},N.createElement(Ude,{container:l},N.createElement(GA,{"cmdk-overlay":"",className:a}),N.createElement(KA,{"aria-label":t.label,"cmdk-dialog":"",className:o},N.createElement(hYe,{ref:s,...i}))))}),nPt=N.forwardRef((t,s)=>xw(r=>r.filtered.count===0)?N.createElement(nn.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),aPt=N.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return N.createElement(nn.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},gue(t,l=>N.createElement("div",{"aria-hidden":!0},l)))}),Ep=Object.assign(hYe,{List:sPt,Item:Q6t,Input:tPt,Group:J6t,Separator:ePt,Dialog:rPt,Empty:nPt,Loading:aPt});function iPt(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function oPt(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function mYe(t){let s=N.useRef(t);return HS(()=>{s.current=t}),s}var HS=typeof window>"u"?N.useEffect:N.useLayoutEffect;function $5(t){let s=N.useRef();return s.current===void 0&&(s.current=t()),s}function xw(t){let s=mNe(),r=()=>t(s.snapshot());return N.useSyncExternalStore(s.subscribe,r,r)}function pYe(t,s,r,n=[]){let a=N.useRef(),o=FO();return HS(()=>{var l;let i=(()=>{var u;for(let p of r){if(typeof p=="string")return p.trim();if(typeof p=="object"&&"current"in p)return p.current?(u=p.current.textContent)==null?void 0:u.trim():a.current}})(),c=n.map(u=>u.trim());o.value(t,i,c),(l=s.current)==null||l.setAttribute(B5,i),a.current=i}),a}var lPt=()=>{let[t,s]=N.useState(),r=$5(()=>new Map);return HS(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),s({})}};function cPt(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function gue({asChild:t,children:s},r){return t&&N.isValidElement(s)?N.cloneElement(cPt(s),{ref:s.ref},r(s.props.children)):r(s)}var dPt={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Lx=N.forwardRef(({className:t,...s},r)=>e.jsx(Ep,{ref:r,className:It("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));Lx.displayName=Ep.displayName;const uPt=({children:t,...s})=>e.jsx(fs,{...s,children:e.jsx(ps,{className:"overflow-hidden p-0 shadow-lg",children:e.jsx(Lx,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:t})})}),Dx=N.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(cn,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Ep.Input,{ref:r,className:It("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));Dx.displayName=Ep.Input.displayName;const Ox=N.forwardRef(({className:t,...s},r)=>e.jsx(Ep.List,{ref:r,className:It("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));Ox.displayName=Ep.List.displayName;const Rx=N.forwardRef((t,s)=>e.jsx(Ep.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Rx.displayName=Ep.Empty.displayName;const Fx=N.forwardRef(({className:t,...s},r)=>e.jsx(Ep.Group,{ref:r,className:It("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));Fx.displayName=Ep.Group.displayName;const hPt=N.forwardRef(({className:t,...s},r)=>e.jsx(Ep.Separator,{ref:r,className:It("-mx-1 h-px bg-border",t),...s}));hPt.displayName=Ep.Separator.displayName;const bp=N.forwardRef(({className:t,...s},r)=>e.jsx(Ep.Item,{ref:r,className:It("group relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-primary/80 data-[selected=true]:text-primary-foreground data-[disabled=true]:opacity-50",t),...s}));bp.displayName=Ep.Item.displayName;const mPt={event:{label:"Events",icon:Dd,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:ac,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:Kh,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:ey,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:pn,color:"bg-fuchsia-500/10 text-fuchsia-600"}},cIe=()=>{const[t,s]=N.useState(!1),[r,n]=N.useState(""),[a,o]=N.useState([]),[l,i]=N.useState(!1),c=fr();N.useEffect(()=>{const g=b=>{b.key==="k"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),s(_=>!_))};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[]);const u=N.useCallback(async g=>{if(!g.trim()){o([]);return}i(!0);const b=`%${g}%`;try{const[_,j,w,k,S]=await Promise.all([H.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${b},description.ilike.${b}`).limit(5),H.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${b},description.ilike.${b}`).limit(5),H.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${b},description.ilike.${b}`).limit(5),H.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${b},description.ilike.${b}`).limit(5),H.from("social_swag").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${b},description.ilike.${b}`).limit(5)]),M=[];_.data&&_.data.forEach(L=>{M.push({id:L.id,title:L.title,description:L.description,type:"event",date:L.event_date,path:`/event/${L.id}`})}),j.data&&j.data.forEach(L=>{M.push({id:L.id,title:L.name,description:L.description,type:"template",date:L.publish_date,path:`/templates/${L.id}`})}),w.data&&w.data.forEach(L=>{M.push({id:L.id,title:L.title,description:L.description,type:"academy",date:L.publish_date,path:`/academy/${L.id}`})}),k.data&&k.data.forEach(L=>{M.push({id:L.id,title:L.name,description:L.description,type:"toolbox",date:L.publish_date,path:`/toolbox/${L.id}`})}),S.data&&S.data.forEach(L=>{M.push({id:L.id,title:L.title,description:L.description,type:"social-swag",date:L.publish_date,path:`/social-swag/${L.id}`})}),o(M)}catch(_){console.error("Search error:",_)}finally{i(!1)}},[]);N.useEffect(()=>{const g=setTimeout(()=>{u(r)},300);return()=>clearTimeout(g)},[r,u]);const p=g=>{s(!1),n(""),c(g)},f=a.reduce((g,b)=>(g[b.type]||(g[b.type]=[]),g[b.type].push(b),g),{});return e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-9 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>s(!0),children:[e.jsx(cn,{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(uPt,{open:t,onOpenChange:s,children:[e.jsx(Dx,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:r,onValueChange:n}),e.jsxs(Ox,{children:[l&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&r&&a.length===0&&e.jsxs(Rx,{children:['No results found for "',r,'"']}),!l&&!r&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Start typing to search across all content..."}),Object.entries(f).map(([g,b])=>{const _=mPt[g],j=_.icon;return e.jsx(Fx,{heading:_.label,children:b.map(w=>e.jsxs(bp,{value:`${w.type}-${w.id}-${w.title}`,onSelect:()=>p(w.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[e.jsx("div",{className:`p-2 rounded-md ${_.color}`,children:e.jsx(j,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:w.title}),w.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:w.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(tt,{variant:"secondary",className:"text-xs",children:_.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Uc(new Date(w.date),{addSuffix:!0})})]})]},`${w.type}-${w.id}`))},g)})]})]})]})},pPt=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=N.useState(null),o=fr();if(N.useEffect(()=>{const u=()=>{const f=new Date().getTime(),b=new Date(t).getTime()-f;if(b<=0){a({days:0,hours:0,minutes:0});return}const _=Math.floor(b/(1e3*60*60*24)),j=Math.floor(b%(1e3*60*60*24)/(1e3*60*60)),w=Math.floor(b%(1e3*60*60)/(1e3*60));a({days:_,hours:j,minutes:w})};u();const p=setInterval(u,6e4);return()=>clearInterval(p)},[t]),!n)return null;const l=n.days===0&&n.hours===0&&n.minutes===0,i=n.days<=1,c=n.days<=3&&!i;return l?e.jsxs("div",{className:It("flex items-center justify-between gap-3 px-4 py-2 rounded-lg bg-destructive/10 border border-destructive/20",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ku,{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(pn,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):e.jsxs("div",{className:It("flex items-center justify-between gap-3 px-4 py-2 rounded-lg border transition-colors",i?"bg-destructive/10 border-destructive/20":c?"bg-amber-500/10 border-amber-500/20":"bg-primary/10 border-primary/20",s),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(un,{className:It("h-4 w-4",i?"text-destructive":c?"text-amber-500":"text-primary")}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:It("text-sm font-medium",i?"text-destructive":c?"text-amber-600":"text-primary"),children:"Free Trial:"}),e.jsxs("div",{className:"flex items-center gap-1",children:[n.days>0&&e.jsxs("span",{className:It("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.days,"d"]}),e.jsxs("span",{className:It("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),e.jsxs("span",{className:It("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),e.jsx("span",{className:It("text-xs",i?"text-destructive/70":c?"text-amber-600/70":"text-primary/70"),children:"remaining"})]})]})]}),r&&e.jsxs(K,{size:"sm",onClick:()=>o("/subscription"),variant:i?"destructive":c?"default":"outline",className:It("text-xs h-7 px-3",c&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[e.jsx(pn,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},fPt=()=>{const t=fr();return e.jsx("div",{className:"fixed inset-0 bg-background/95 backdrop-blur-sm z-50 flex items-center justify-center p-4 overflow-y-auto",children:e.jsxs(Ee,{className:"w-full max-w-2xl shadow-2xl border-destructive/20 my-8",children:[e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-4 h-16 w-16 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(Ku,{className:"h-8 w-8 text-destructive"})}),e.jsx(Rt,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(gr,{className:"text-base",children:"Your 7-day free trial has expired. Upgrade now to continue accessing all the powerful tools and resources LevelUp has to offer!"})]}),e.jsxs(De,{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(De,{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(pr,{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(pn,{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(De,{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(ka,{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(ka,{className:"h-4 w-4 mr-2"}),"Choose Brokerage"]})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"With a full membership, you'll get:"}),e.jsxs("ul",{className:"text-sm space-y-1 text-muted-foreground grid sm:grid-cols-2 gap-x-4",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Unlimited access to all marketing templates"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Complete Academy training library"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," AI-powered tools and resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Community forums and support"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Exclusive member events and workshops"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Deal pipeline & scorecard tracking"]})]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"text-sm font-medium text-center",children:"Questions? Contact us:"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[e.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{children:"1-866-527-8668"})]}),e.jsxs("a",{href:"mailto:support@relevelup.com",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(cr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},xPt=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",onClick:s,className:It("relative transition-colors",t&&"text-primary hover:text-primary",r),children:[e.jsx(Ah,{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(Yl,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var yue="Checkbox",[gPt]=ad(yue),[yPt,pNe]=gPt(yue);function vPt(t){const{__scopeCheckbox:s,checked:r,children:n,defaultChecked:a,disabled:o,form:l,name:i,onCheckedChange:c,required:u,value:p="on",internal_do_not_use_render:f}=t,[g,b]=ah({prop:r,defaultProp:a??!1,onChange:c,caller:yue}),[_,j]=N.useState(null),[w,k]=N.useState(null),S=N.useRef(!1),M=_?!!l||!!_.closest("form"):!0,L={checked:g,disabled:o,setChecked:b,control:_,setControl:j,name:i,form:l,value:p,hasConsumerStoppedPropagationRef:S,required:u,defaultChecked:X_(a)?!1:a,isFormControl:M,bubbleInput:w,setBubbleInput:k};return e.jsx(yPt,{scope:s,...L,children:bPt(f)?f(L):n})}var fYe="CheckboxTrigger",xYe=N.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...n},a)=>{const{control:o,value:l,disabled:i,checked:c,required:u,setControl:p,setChecked:f,hasConsumerStoppedPropagationRef:g,isFormControl:b,bubbleInput:_}=pNe(fYe,t),j=qa(a,p),w=N.useRef(c);return N.useEffect(()=>{const k=o==null?void 0:o.form;if(k){const S=()=>f(w.current);return k.addEventListener("reset",S),()=>k.removeEventListener("reset",S)}},[o,f]),e.jsx(nn.button,{type:"button",role:"checkbox","aria-checked":X_(c)?"mixed":c,"aria-required":u,"data-state":_Ye(c),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:j,onKeyDown:Ir(s,k=>{k.key==="Enter"&&k.preventDefault()}),onClick:Ir(r,k=>{f(S=>X_(S)?!0:!S),_&&b&&(g.current=k.isPropagationStopped(),g.current||k.stopPropagation())})})});xYe.displayName=fYe;var fNe=N.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:c,onCheckedChange:u,form:p,...f}=t;return e.jsx(vPt,{__scopeCheckbox:r,checked:a,defaultChecked:o,disabled:i,required:l,onCheckedChange:u,name:n,form:p,value:c,internal_do_not_use_render:({isFormControl:g})=>e.jsxs(e.Fragment,{children:[e.jsx(xYe,{...f,ref:s,__scopeCheckbox:r}),g&&e.jsx(bYe,{__scopeCheckbox:r})]})})});fNe.displayName=yue;var gYe="CheckboxIndicator",yYe=N.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=pNe(gYe,r);return e.jsx(Fd,{present:n||X_(o.checked)||o.checked===!0,children:e.jsx(nn.span,{"data-state":_Ye(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});yYe.displayName=gYe;var vYe="CheckboxBubbleInput",bYe=N.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:i,disabled:c,name:u,value:p,form:f,bubbleInput:g,setBubbleInput:b}=pNe(vYe,t),_=qa(r,b),j=EO(o),w=yO(n);N.useEffect(()=>{const S=g;if(!S)return;const M=window.HTMLInputElement.prototype,I=Object.getOwnPropertyDescriptor(M,"checked").set,O=!a.current;if(j!==o&&I){const q=new Event("click",{bubbles:O});S.indeterminate=X_(o),I.call(S,X_(o)?!1:o),S.dispatchEvent(q)}},[g,j,o,a]);const k=N.useRef(X_(o)?!1:o);return e.jsx(nn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??k.current,required:i,disabled:c,name:u,value:p,form:f,...s,tabIndex:-1,ref:_,style:{...s.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});bYe.displayName=vYe;function bPt(t){return typeof t=="function"}function X_(t){return t==="indeterminate"}function _Ye(t){return X_(t)?"indeterminate":t?"checked":"unchecked"}const Oo=N.forwardRef(({className:t,...s},r)=>e.jsx(fNe,{ref:r,className:It("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(yYe,{className:It("flex items-center justify-center text-current"),children:e.jsx(va,{className:"h-4 w-4"})})}));Oo.displayName=fNe.displayName;var xNe="Radio",[_Pt,wYe]=ad(xNe),[wPt,jPt]=_Pt(xNe),jYe=N.forwardRef((t,s)=>{const{__scopeRadio:r,name:n,checked:a=!1,required:o,disabled:l,value:i="on",onCheck:c,form:u,...p}=t,[f,g]=N.useState(null),b=qa(s,w=>g(w)),_=N.useRef(!1),j=f?u||!!f.closest("form"):!0;return e.jsxs(wPt,{scope:r,checked:a,disabled:l,children:[e.jsx(nn.button,{type:"button",role:"radio","aria-checked":a,"data-state":CYe(a),"data-disabled":l?"":void 0,disabled:l,value:i,...p,ref:b,onClick:Ir(t.onClick,w=>{a||c==null||c(),j&&(_.current=w.isPropagationStopped(),_.current||w.stopPropagation())})}),j&&e.jsx(SYe,{control:f,bubbles:!_.current,name:n,value:i,checked:a,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});jYe.displayName=xNe;var NYe="RadioIndicator",kYe=N.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=jPt(NYe,r);return e.jsx(Fd,{present:n||o.checked,children:e.jsx(nn.span,{"data-state":CYe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})})});kYe.displayName=NYe;var NPt="RadioBubbleInput",SYe=N.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=N.useRef(null),i=qa(l,o),c=EO(r),u=yO(s);return N.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==r&&b){const _=new Event("click",{bubbles:n});b.call(p,r),p.dispatchEvent(_)}},[c,r,n]),e.jsx(nn.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}})});SYe.displayName=NPt;function CYe(t){return t?"checked":"unchecked"}var kPt=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],vue="RadioGroup",[SPt]=ad(vue,[Tw,wYe]),MYe=Tw(),TYe=wYe(),[CPt,MPt]=SPt(vue),AYe=N.forwardRef((t,s)=>{const{__scopeRadioGroup:r,name:n,defaultValue:a,value:o,required:l=!1,disabled:i=!1,orientation:c,dir:u,loop:p=!0,onValueChange:f,...g}=t,b=MYe(r),_=Mw(u),[j,w]=ah({prop:o,defaultProp:a??null,onChange:f,caller:vue});return e.jsx(CPt,{scope:r,name:n,required:l,disabled:i,value:j,onValueChange:w,children:e.jsx(Lde,{asChild:!0,...b,orientation:c,dir:_,loop:p,children:e.jsx(nn.div,{role:"radiogroup","aria-required":l,"aria-orientation":c,"data-disabled":i?"":void 0,dir:_,...g,ref:s})})})});AYe.displayName=vue;var EYe="RadioGroupItem",PYe=N.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=MPt(EYe,r),l=o.disabled||n,i=MYe(r),c=TYe(r),u=N.useRef(null),p=qa(s,u),f=o.value===a.value,g=N.useRef(!1);return N.useEffect(()=>{const b=j=>{kPt.includes(j.key)&&(g.current=!0)},_=()=>g.current=!1;return document.addEventListener("keydown",b),document.addEventListener("keyup",_),()=>{document.removeEventListener("keydown",b),document.removeEventListener("keyup",_)}},[]),e.jsx(Dde,{asChild:!0,...i,focusable:!l,active:f,children:e.jsx(jYe,{disabled:l,required:o.required,checked:f,...c,...a,name:o.name,ref:p,onCheck:()=>o.onValueChange(a.value),onKeyDown:Ir(b=>{b.key==="Enter"&&b.preventDefault()}),onFocus:Ir(a.onFocus,()=>{var b;g.current&&((b=u.current)==null||b.click())})})})});PYe.displayName=EYe;var TPt="RadioGroupIndicator",IYe=N.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=TYe(r);return e.jsx(kYe,{...a,...n,ref:s})});IYe.displayName=TPt;var LYe=AYe,DYe=PYe,APt=IYe;const gNe=N.forwardRef(({className:t,...s},r)=>e.jsx(LYe,{className:It("grid gap-2",t),...s,ref:r}));gNe.displayName=LYe.displayName;const Woe=N.forwardRef(({className:t,...s},r)=>e.jsx(DYe,{ref:r,className:It("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(APt,{className:"flex items-center justify-center",children:e.jsx(bd,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Woe.displayName=DYe.displayName;const EPt=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=Ds(),[o,l]=N.useState({}),[i,c]=N.useState({}),[u,p]=N.useState([]);N.useEffect(()=>{s&&a&&t.polls.length>0&&f()},[s,a,t.polls]);const f=async()=>{if(!a)return;const w=t.polls.map(S=>S.id),{data:k}=await H.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",w);if(k){const S={};k.forEach(M=>{S[M.poll_id]||(S[M.poll_id]=[]),S[M.poll_id].push(M.option_id)}),c(S)}},g=(w,k)=>{l(S=>({...S,[w]:k}))},b=(w,k,S)=>{l(M=>{const L=M[w]||[];return S?{...M,[w]:[...L,k]}:{...M,[w]:L.filter(I=>I!==k)}})},_=async w=>{if(!a)return;const k=o[w];if(!k||Array.isArray(k)&&k.length===0){me.error("Please select an option");return}p(S=>[...S,w]);try{await H.from("levelup_brief_poll_responses").delete().eq("poll_id",w).eq("user_id",a.id);const S=Array.isArray(k)?k:[k],M=S.map(I=>({poll_id:w,option_id:I,user_id:a.id})),{error:L}=await H.from("levelup_brief_poll_responses").insert(M);if(L)throw L;c(I=>({...I,[w]:S})),me.success("Response submitted!")}catch(S){console.error("Error submitting poll response:",S),me.error("Failed to submit response")}finally{p(S=>S.filter(M=>M!==w))}},j=w=>(w.includes("mediadelivery.net")||w.includes("bunny"),w);return e.jsx(fs,{open:s,onOpenChange:w=>!w&&r(),children:e.jsxs(ps,{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(Rr,{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(Ah,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx(tt,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),e.jsx(vs,{className:"text-xl font-bold text-white",children:t.brief.title})]})]})]}),e.jsx(Gi,{className:"max-h-[calc(90vh-240px)]",children:e.jsxs("div",{className:"p-6 space-y-6",children:[t.brief.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.brief.description}}),t.brief.video_url&&e.jsx("div",{className:"relative w-full aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:j(t.brief.video_url),className:"absolute inset-0 w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})}),t.brief.graphic_url&&!t.brief.video_url&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted",children:t.brief.graphic_link_url?e.jsx("a",{href:t.brief.graphic_link_url,target:"_blank",rel:"noopener noreferrer",className:"block",children:e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain cursor-pointer hover:opacity-90 transition-opacity"})}):e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain"})}),t.links.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:"Quick Links"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.links.map(w=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>window.open(w.url,"_blank"),className:"gap-2",children:[e.jsx(tn,{className:"h-4 w-4"}),w.title]},w.id))})]}),t.polls.map(w=>{var M,L;const k=((M=i[w.id])==null?void 0:M.length)>0,S=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}),k&&e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[e.jsx(sa,{className:"h-3 w-3"}),"Responded"]})]}),w.poll_type==="single"?e.jsx(gNe,{value:o[w.id]||((L=i[w.id])==null?void 0:L[0])||"",onValueChange:I=>g(w.id,I),className:"space-y-2",children:w.options.map(I=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Woe,{value:I.id,id:I.id}),e.jsx(ve,{htmlFor:I.id,className:"cursor-pointer",children:I.option_text})]},I.id))}):e.jsx("div",{className:"space-y-2",children:w.options.map(I=>{const q=(o[w.id]||i[w.id]||[]).includes(I.id);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Oo,{id:I.id,checked:q,onCheckedChange:U=>b(w.id,I.id,U)}),e.jsx(ve,{htmlFor:I.id,className:"cursor-pointer",children:I.option_text})]},I.id)})}),e.jsx(K,{size:"sm",onClick:()=>_(w.id),disabled:S,children:S?"Submitting...":k?"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"})]})]})})},PPt=()=>{const{user:t}=Ds(),[s,r]=N.useState(null),[n,a]=N.useState(!1),[o,l]=N.useState(!0),[i,c]=N.useState(!1),u=N.useCallback(async()=>{if(!t){l(!1);return}try{const{data:_,error:j}=await H.from("levelup_briefs").select("*").eq("is_published",!0).lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(1).single();if(j||!_){l(!1);return}const{data:w}=await H.from("levelup_brief_views").select("*").eq("brief_id",_.id).eq("user_id",t.id).maybeSingle(),[k,S]=await Promise.all([H.from("levelup_brief_links").select("*").eq("brief_id",_.id).order("sort_order"),H.from("levelup_brief_polls").select("*").eq("brief_id",_.id).order("sort_order")]),M=[];if(S.data)for(const U of S.data){const{data:B}=await H.from("levelup_brief_poll_options").select("*").eq("poll_id",U.id).order("sort_order");M.push({...U,options:B||[]})}const L={brief:_,links:k.data||[],polls:M};r(L);const I=!!w,O=(w==null?void 0:w.dismissed_at)!=null,q=localStorage.getItem(`brief-dismissed-${_.id}`)==="true";if(O||q)c(!1),a(!1);else if(!I)a(!0),c(!0);else if(_.show_frequency==="every_login")a(!0),c(!0);else if(_.show_frequency==="daily"){const U=new Date(w.viewed_at);(new Date().getTime()-U.getTime())/(1e3*60*60)>=24&&(a(!0),c(!0))}else c(!1)}catch(_){console.error("Error fetching brief:",_)}finally{l(!1)}},[t]);N.useEffect(()=>{u()},[u]);const p=async()=>{if(!(!t||!s))try{const{data:_}=await H.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();_?await H.from("levelup_brief_views").update({viewed_at:new Date().toISOString()}).eq("id",_.id):await H.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id})}catch(_){console.error("Error marking brief as viewed:",_)}};return{currentBrief:s,shouldShowPopup:n,hasUnseenBrief:i,loading:o,openBrief:()=>{a(!0)},closeBrief:()=>{a(!1),p()},dismissBrief:async()=>{if(!(!t||!s)){a(!1),c(!1);try{const{data:_,error:j}=await H.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();if(j&&console.error("Error checking existing brief view:",j),_){const{error:w}=await H.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",_.id).eq("user_id",t.id);w&&console.error("Error updating brief dismiss:",w)}else{const{error:w}=await H.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});w&&console.error("Error inserting brief dismiss:",w)}localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}catch(_){console.error("Error dismissing brief:",_),s&&localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}}},refetch:u}};function IPt(){const[t,s]=N.useState(!1),[r,n]=N.useState(!1),[a,o]=N.useState(null);N.useEffect(()=>{if(localStorage.getItem("install-banner-dismissed")||window.matchMedia("(display-mode: standalone)").matches||!/iPhone|iPad|iPod|Android/i.test(navigator.userAgent))return;const f=/iPhone|iPad|iPod/i.test(navigator.userAgent);n(f),s(!0);const g=b=>{b.preventDefault(),o(b)};return window.addEventListener("beforeinstallprompt",g),()=>{window.removeEventListener("beforeinstallprompt",g)}},[]);const l=()=>{localStorage.setItem("install-banner-dismissed","true"),s(!1)},i=async()=>{if(a){await a.prompt();const{outcome:c}=await a.userChoice;c==="accepted"&&l(),o(null)}};return t?e.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-50 p-4 bg-primary text-primary-foreground shadow-lg animate-in slide-in-from-bottom duration-300",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"flex-shrink-0 p-2 bg-primary-foreground/10 rounded-full",children:e.jsx(yi,{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(SL,{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(Rr,{className:"h-4 w-4"})})]})]})}):null}const LPt=({children:t,onRefresh:s})=>{const[r,n]=N.useState(!1),[a,o]=N.useState(0),[l,i]=N.useState(!1),c=N.useRef(null),u=N.useRef(0),p=Qt(),f=80,g=120,b=N.useCallback(S=>{const M=c.current;M&&M.scrollTop<=0&&(u.current=S.touches[0].clientY,n(!0))},[]),_=N.useCallback(S=>{if(!r||l)return;const M=c.current;if(!M||M.scrollTop>0){n(!1),o(0);return}const I=S.touches[0].clientY-u.current;if(I>0){const q=Math.min(I*.5,g);o(q),q>10&&S.preventDefault()}},[r,l]),j=N.useCallback(async()=>{if(r)if(n(!1),a>=f&&!l){i(!0),o(f);try{s?await s():await p.invalidateQueries()}catch(S){console.error("Refresh failed:",S)}finally{i(!1),o(0)}}else o(0)},[r,a,l,s,p]),w=Math.min(a/f,1),k=w*180;return e.jsxs("div",{ref:c,className:"h-full overflow-auto",onTouchStart:b,onTouchMove:_,onTouchEnd:j,children:[e.jsx("div",{className:"flex justify-center items-center overflow-hidden transition-all duration-200 ease-out",style:{height:a>0?a:0,opacity:w},children:e.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${l?"animate-spin":""}`,style:{transform:l?void 0:`rotate(${k}deg)`,transition:l?void 0:"transform 0.1s ease-out"},children:e.jsx(Go,{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})]})},OYe=()=>{const{user:t}=Ds(),[s,r]=N.useState(!1),[n,a]=N.useState(!1),[o,l]=N.useState(0),[i,c]=N.useState(!0);N.useEffect(()=>{(async()=>{if(!t){c(!1);return}try{const{data:b}=await H.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(b){a(!0),r(!1),c(!1);return}const{data:_}=await H.from("profiles").select("login_count").eq("id",t.id).single(),j=(_==null?void 0:_.login_count)||0;l(j);const w=sessionStorage.getItem("review-prompt-dismissed");r(j>=4&&!w)}catch(b){console.error("Error checking review eligibility:",b)}finally{c(!1)}})()},[t]);const u=N.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),p=N.useCallback(async(g,b)=>{if(!t)return{success:!1,error:"Not authenticated"};try{const{error:_}=await H.from("membership_reviews").insert({user_id:t.id,rating:g,review_text:b});if(_)throw _;return a(!0),r(!1),{success:!0,pointsAwarded:25}}catch(_){return console.error("Error submitting review:",_),{success:!1,error:_.message}}},[t]),f=N.useCallback(async()=>{if(t)try{await H.from("membership_reviews").update({posted_to_google:!0}).eq("user_id",t.id)}catch(g){console.error("Error updating Google review status:",g)}},[t]);return{shouldShowPrompt:s,hasSubmittedReview:n,loginCount:o,isLoading:i,dismissPrompt:u,submitReview:p,markPostedToGoogle:f}},DPt="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",OPt=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=OYe(),[o,l]=N.useState(!1),[i,c]=N.useState("review"),[u,p]=N.useState(0),[f,g]=N.useState(0),[b,_]=N.useState(""),[j,w]=N.useState(!1),[k,S]=N.useState(!1);if(s||!t&&!k)return null;const M=async()=>{if(u===0){wn({title:"Please select a rating",variant:"destructive"});return}w(!0);const O=await n(u,b);w(!1),O.success?(S(!0),wn({title:"Thank you for your feedback!",description:"Your review helps us improve."}),c("google")):wn({title:"Error submitting review",description:O.error,variant:"destructive"})},L=async O=>{O&&(await navigator.clipboard.writeText(b||`${u} star rating for LevelUp!`),wn({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(DPt,"_blank")),l(!1),r()},I=()=>{l(!1),r()};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>l(!0),className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-40 flex items-center gap-2 rounded-full bg-primary/90 px-3 py-2 text-xs text-primary-foreground shadow-lg backdrop-blur-sm transition-all hover:bg-primary hover:scale-105 md:bottom-6",children:[e.jsx(Jn,{className:"h-3.5 w-3.5 fill-current"}),e.jsx("span",{className:"hidden sm:inline",children:"Leave a Review"})]}),e.jsx(fs,{open:o,onOpenChange:I,children:e.jsx(ps,{className:"sm:max-w-md",children:i==="review"?e.jsxs(e.Fragment,{children:[e.jsxs(_s,{children:[e.jsx(vs,{className:"text-center",children:"How are you enjoying LevelUp?"}),e.jsx(Gr,{className:"text-center",children:"Your feedback helps us improve the experience for all members."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsx("div",{className:"flex justify-center gap-1",children:[1,2,3,4,5].map(O=>e.jsx("button",{type:"button",onClick:()=>p(O),onMouseEnter:()=>g(O),onMouseLeave:()=>g(0),className:"p-1 transition-transform hover:scale-110",children:e.jsx(Jn,{className:It("h-8 w-8 transition-colors",(f||u)>=O?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},O))}),e.jsx(Er,{placeholder:"Tell us about your experience (optional)",value:b,onChange:O=>_(O.target.value),rows:4,className:"resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:I,className:"flex-1",children:"Maybe Later"}),e.jsx(K,{onClick:M,disabled:j||u===0,className:"flex-1",children:j?"Submitting...":"Submit Review"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(_s,{children:[e.jsx(vs,{className:"text-center",children:"🎉 Thank you!"}),e.jsx(Gr,{className:"text-center",children:"Would you mind sharing your review on Google? It really helps other agents discover LevelUp!"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"We'll copy your review so you can easily paste it."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),className:"flex-1",children:"No Thanks"}),e.jsx(K,{onClick:()=>L(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function RPt(t){const s="=".repeat((4-t.length%4)%4),r=(t+s).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),a=new Uint8Array(n.length);for(let o=0;o{if(!f){l(!1);return}(async()=>{try{const j="vapid_public_key";let w=localStorage.getItem(j);if(!w){const{data:M,error:L}=await H.functions.invoke("get-vapid-public-key",{body:{}});if(L)throw L;if(w=(M==null?void 0:M.vapidPublicKey)??null,!w)throw new Error("Missing VAPID public key");localStorage.setItem(j,w)}p(w);const k=await navigator.serviceWorker.register("/push-sw.js");c(k),r(Notification.permission);const S=await k.pushManager.getSubscription();a(!!S)}catch(j){console.error("Error initializing push notifications:",j)}finally{l(!1)}})()},[f]);const g=N.useCallback(async()=>{if(!f||!i||!t)return console.error("Push notifications not supported or user not logged in"),!1;if(!u)return me.error("Push notifications are not ready yet. Please try again in a moment."),!1;try{l(!0);const _=await i.pushManager.getSubscription();if(_){try{await _.unsubscribe()}catch(L){console.warn("Failed to unsubscribe existing push subscription:",L)}const{error:M}=await H.from("push_subscriptions").delete().eq("user_id",t.id);M&&console.warn("Failed to cleanup push_subscriptions rows:",M)}if(Notification.permission!=="granted"){const M=await Notification.requestPermission();if(r(M),M!=="granted")return M==="denied"?me.error("Notifications blocked. Please enable them in your browser settings (click the lock icon in the address bar)."):me.error("Notification permission was dismissed. Please try again."),!1}const j=RPt(u);let w;try{w=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:j})}catch(M){console.error("PushManager.subscribe() failed:",M);const L=(M==null?void 0:M.message)||String(M);return L.includes("permission")?me.error("Push permission denied. Check your browser notification settings."):L.includes("key")||L.includes("VAPID")?me.error("Push configuration error. Please contact support."):L.includes("AbortError")?me.error("Push subscription was cancelled. Please try again."):me.error(`Failed to subscribe: ${L}`),!1}const k=w.toJSON(),{error:S}=await H.from("push_subscriptions").upsert({user_id:t.id,endpoint:k.endpoint,p256dh_key:k.keys.p256dh,auth_key:k.keys.auth},{onConflict:"user_id,endpoint"});if(S)throw console.error("Error saving subscription:",S),me.error("Failed to save notification preferences. Please try again."),S;return a(!0),me.success("Push notifications enabled!"),!0}catch(_){if(console.error("Error subscribing to push notifications:",_),!(_ instanceof Error&&_.message.includes("toast"))){const j=_ instanceof Error?_.message:"Unknown error";me.error("Failed to enable push notifications: "+j)}return!1}finally{l(!1)}},[f,i,t,u]),b=N.useCallback(async()=>{if(!i||!t)return!1;try{l(!0);const _=await i.pushManager.getSubscription();return _&&await _.unsubscribe(),await H.from("push_subscriptions").delete().eq("user_id",t.id),a(!1),me.success("Push notifications disabled"),!0}catch(_){console.error("Error unsubscribing:",_);const j=_ instanceof Error?_.message:"Unknown error";return me.error("Failed to disable push notifications: "+j),!1}finally{l(!1)}},[i,t]);return{isSupported:f,permission:s,isSubscribed:n,isLoading:o,vapidPublicKey:u,subscribe:g,unsubscribe:b}}const Zxe="push_notification_prompt_dismissed",FPt=()=>{const{user:t}=Ds(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=RYe(),[o,l]=N.useState(!1),[i,c]=N.useState(!1);N.useEffect(()=>{if(!t||!s||r||n||localStorage.getItem(`${Zxe}_${t.id}`))return;const g=setTimeout(()=>{l(!0)},2e3);return()=>clearTimeout(g)},[t,s,r,n]);const u=async()=>{c(!0);const f=await a();c(!1),f&&(t&&localStorage.setItem(`${Zxe}_${t.id}`,"true"),l(!1))},p=()=>{t&&localStorage.setItem(`${Zxe}_${t.id}`,"true"),l(!1)};return!s||r?null:e.jsx(fs,{open:o,onOpenChange:f=>!f&&p(),children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:e.jsx(Lm,{className:"h-6 w-6 text-primary"})}),e.jsx(vs,{className:"text-center",children:"Stay in the Loop!"}),e.jsx(Gr,{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."})]})})},dIe=t=>{let s;const r=new Set,n=(u,p)=>{const f=typeof u=="function"?u(s):u;if(!Object.is(f,s)){const g=s;s=p??(typeof f!="object"||f===null)?f:Object.assign({},s,f),r.forEach(b=>b(s,g))}},a=()=>s,i={setState:n,getState:a,getInitialState:()=>c,subscribe:u=>(r.add(u),()=>r.delete(u))},c=s=t(n,a,i);return i},zPt=t=>t?dIe(t):dIe,BPt=t=>t;function $Pt(t,s=BPt){const r=ht.useSyncExternalStore(t.subscribe,ht.useCallback(()=>s(t.getState()),[t,s]),ht.useCallback(()=>s(t.getInitialState()),[t,s]));return ht.useDebugValue(r),r}const uIe=t=>{const s=zPt(t),r=n=>$Pt(s,n);return Object.assign(r,s),r},qPt=t=>t?uIe(t):uIe;function UPt(t,s){let r;try{r=t()}catch{return}return{getItem:a=>{var o;const l=c=>c===null?null:JSON.parse(c,void 0),i=(o=r.getItem(a))!=null?o:null;return i instanceof Promise?i.then(l):l(i)},setItem:(a,o)=>r.setItem(a,JSON.stringify(o,void 0)),removeItem:a=>r.removeItem(a)}}const g1e=t=>s=>{try{const r=t(s);return r instanceof Promise?r:{then(n){return g1e(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return g1e(n)(r)}}}},VPt=(t,s)=>(r,n,a)=>{let o={storage:UPt(()=>localStorage),partialize:j=>j,version:0,merge:(j,w)=>({...w,...j}),...s},l=!1;const i=new Set,c=new Set;let u=o.storage;if(!u)return t((...j)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...j)},n,a);const p=()=>{const j=o.partialize({...n()});return u.setItem(o.name,{state:j,version:o.version})},f=a.setState;a.setState=(j,w)=>(f(j,w),p());const g=t((...j)=>(r(...j),p()),n,a);a.getInitialState=()=>g;let b;const _=()=>{var j,w;if(!u)return;l=!1,i.forEach(S=>{var M;return S((M=n())!=null?M:g)});const k=((w=o.onRehydrateStorage)==null?void 0:w.call(o,(j=n())!=null?j:g))||void 0;return g1e(u.getItem.bind(u))(o.name).then(S=>{if(S)if(typeof S.version=="number"&&S.version!==o.version){if(o.migrate){const M=o.migrate(S.state,S.version);return M instanceof Promise?M.then(L=>[!0,L]):[!0,M]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,S.state];return[!1,void 0]}).then(S=>{var M;const[L,I]=S;if(b=o.merge(I,(M=n())!=null?M:g),r(b,!0),L)return p()}).then(()=>{k==null||k(b,void 0),b=n(),l=!0,c.forEach(S=>S(b))}).catch(S=>{k==null||k(void 0,S)})};return a.persist={setOptions:j=>{o={...o,...j},j.storage&&(u=j.storage)},clearStorage:()=>{u==null||u.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>_(),hasHydrated:()=>l,onHydrate:j=>(i.add(j),()=>{i.delete(j)}),onFinishHydration:j=>(c.add(j),()=>{c.delete(j)})},o.skipHydration||_(),b||g},HPt=VPt,bue=qPt()(HPt((t,s)=>({cartItems:[],addToCart:(r,n,a=1,o)=>{t(l=>{const i=l.cartItems.findIndex(c=>{var u;return c.product.id===r.id&&((u=c.variant)==null?void 0:u.id)===(n==null?void 0:n.id)});if(i>=0){const c=[...l.cartItems];return c[i].quantity+=a,o&&(c[i].artworkUrl=o),{cartItems:c}}return{cartItems:[...l.cartItems,{product:r,variant:n,quantity:a,artworkUrl:o}]}})},removeFromCart:(r,n)=>{t(a=>({cartItems:a.cartItems.filter(o=>{var l;return!(o.product.id===r&&((l=o.variant)==null?void 0:l.id)===n)})}))},updateQuantity:(r,n,a)=>{t(o=>({cartItems:o.cartItems.map(l=>{var i;return l.product.id===r&&((i=l.variant)==null?void 0:i.id)===n?{...l,quantity:Math.max(1,a)}:l})}))},updateArtwork:(r,n,a)=>{t(o=>({cartItems:o.cartItems.map(l=>{var i;return l.product.id===r&&((i=l.variant)==null?void 0:i.id)===n?{...l,artworkUrl:a}:l})}))},clearCart:()=>t({cartItems:[]}),getItemPrice:r=>{const n=Number(r.product.base_price),a=r.variant?Number(r.variant.price_adjustment):0;return n+a},getSubtotal:()=>{const{cartItems:r,getItemPrice:n}=s();return r.reduce((a,o)=>a+n(o)*o.quantity,0)},getShippingTotal:()=>{const{cartItems:r}=s();return r.reduce((n,a)=>n+Number(a.product.shipping_fee)*a.quantity,0)},getTotal:()=>{const{getSubtotal:r,getShippingTotal:n}=s();return r()+n()}}),{name:"marketplace-cart",partialize:t=>({cartItems:t.cartItems})}));function zO(){const{user:t}=Ds(),{data:s,isLoading:r}=mt({queryKey:["agent-lead-site",t==null?void 0:t.id],queryFn:async()=>{const{data:n,error:a}=await H.from("lead_sites").select("id, subdomain_slug, site_title, is_active").eq("agent_id",t.id).eq("is_active",!0).maybeSingle();if(a)throw a;return n},enabled:!!t,staleTime:5*60*1e3});return{leadSite:s??null,hasLeadSite:!!s,isLoading:r,siteUrl:s?`https://${s.subdomain_slug}.thelocalmove.com`:null}}const FYe=N.createContext({onlineUsers:[],totalOnline:0}),WPt=async t=>{try{const{data:s}=await H.storage.from("avatars").list(`${t}`);if(s&&s.length>0){const{data:r}=H.storage.from("avatars").getPublicUrl(`${t}/${s[0].name}`);return r.publicUrl}}catch{}},GPt=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=Ds(),[a,o]=N.useState([]),[l,i]=N.useState(null);N.useEffect(()=>{if(!s)return;const u=H.channel("app-presence",{config:{presence:{key:s.id}}});return u.on("presence",{event:"sync"},()=>{const p=u.presenceState(),f=[];Object.entries(p).forEach(([g,b])=>{if(b&&b.length>0){const _=b[0];f.push({id:g,name:_.name||"Unknown",avatarUrl:_.avatarUrl,brokerageId:_.brokerageId,onlineSince:_.onlineSince})}}),o(f)}).on("presence",{event:"join"},()=>{}).on("presence",{event:"leave"},()=>{}).subscribe(async p=>{var f;if(p==="SUBSCRIBED"){const{data:g}=await H.from("profiles").select("name, brokerage_id").eq("id",s.id).single(),b=await WPt(s.id);await u.track({name:(g==null?void 0:g.name)||((f=s.email)==null?void 0:f.split("@")[0])||"User",avatarUrl:b,brokerageId:g==null?void 0:g.brokerage_id,onlineSince:new Date().toISOString()})}}),i(u),()=>{u.unsubscribe()}},[s]);const c=a.filter(u=>u.id===(s==null?void 0:s.id)?!1:!!(n||r&&u.brokerageId===r||!r&&!u.brokerageId));return e.jsx(FYe.Provider,{value:{onlineUsers:c,totalOnline:a.length},children:t})},zYe=()=>N.useContext(FYe),hIe="dashboard-sidebar-collapsed",Ms=({children:t,title:s})=>{var ft;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=Ds(),{isAssistant:i,actingAsAgent:c,hasPermission:u}=K2e(),{isImpersonating:p}=Pde(),g=(i&&!!c?40:0)+(p?40:0),{avatarUrl:b}=RZe(r==null?void 0:r.id),{isTrial:_,isExpired:j,expiresAt:w}=r6t(r==null?void 0:r.id),{isMarketplaceEnabled:k}=zZe(),{currentBrief:S,shouldShowPopup:M,hasUnseenBrief:L,openBrief:I,closeBrief:O,dismissBrief:q}=PPt(),{unreadCount:U}=n6t(),{openCount:B}=a6t(),{data:V}=Bx(),Z=!!V,ee=bue(fe=>fe.cartItems).reduce((fe,Ve)=>fe+Ve.quantity,0),{leadSite:Q,hasLeadSite:ie,siteUrl:re}=zO(),oe=fr(),ce=zd(),[xe,ge]=N.useState(null);N.useEffect(()=>{r!=null&&r.id&&H.from("profiles").select("name").eq("id",r.id).single().then(({data:fe})=>{fe!=null&&fe.name&&ge(fe.name)})},[r==null?void 0:r.id]);const ue=xe||((ft=r==null?void 0:r.user_metadata)==null?void 0:ft.name)||(r==null?void 0:r.email)||"User",[pe,be]=N.useState(()=>typeof window<"u"?localStorage.getItem(hIe)==="true":!1);N.useEffect(()=>{localStorage.setItem(hIe,String(pe))},[pe]);const[Me,Ne]=N.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,contacts:!0,website:!0,help:!1}),Pe=fe=>{Ne(Ve=>({...Ve,[fe]:!Ve[fe]}))},Oe=fe=>fe.split(" ").map(Ve=>Ve[0]).join("").toUpperCase().slice(0,2),Te=fe=>ce.pathname===fe,ke=fe=>fe.some(Ve=>ce.pathname===Ve),Be=({path:fe,icon:Ve,label:at,badgeCount:et})=>{const Ce=e.jsxs(K,{variant:"ghost",size:"sm",className:It("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Te(fe)&&"bg-sidebar-accent text-sidebar-accent-foreground",pe?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>oe(fe),children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ve,{className:"h-4 w-4 shrink-0"}),pe&&et!=null&&et>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!pe&&at,!pe&&et!=null&&et>0&&e.jsx("span",{className:"ml-auto flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:et>9?"9+":et})]});return pe?e.jsxs(bc,{delayDuration:0,children:[e.jsx(_c,{asChild:!0,children:Ce}),e.jsxs(Yl,{side:"right",className:"flex items-center gap-2",children:[at,et!=null&&et>0&&e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:et>9?"9+":et})]})]}):Ce},nt=({id:fe,label:Ve,icon:at,children:et,activePaths:Ce,showBetaBadge:rt,defaultPath:Ge,badgeCount:ct})=>{if(pe){const qe=Ge||Ce[0];return e.jsxs(bc,{delayDuration:0,children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:It("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",ke(Ce)&&"text-primary"),onClick:()=>oe(qe),children:e.jsxs("div",{className:"relative",children:[e.jsx(at,{className:"h-4 w-4"}),ct!=null&&ct>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]})})}),e.jsxs(Yl,{side:"right",className:"flex items-center gap-2",children:[Ve,rt&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600",children:"Beta"}),ct!=null&&ct>0&&e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:ct>9?"9+":ct})]})]})}return e.jsxs(gf,{open:Me[fe],onOpenChange:()=>Pe(fe),children:[e.jsx(yf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke(Ce)&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[e.jsx(at,{className:"h-4 w-4"}),Ve,rt&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("span",{className:"flex items-center gap-1",children:[ct!=null&&ct>0&&e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:ct>9?"9+":ct}),e.jsx(Eo,{className:It("h-4 w-4 transition-transform duration-200",Me[fe]&&"rotate-180")})]})]})}),e.jsx(vf,{className:"pl-4 space-y-1 mt-1",children:et})]})},Ae=({isMobile:fe=!1})=>{const Ve=fe?!1:pe;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:It("p-3 border-b border-sidebar-border",Ve?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[Ve?e.jsx("img",{src:m6t,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:h6t,alt:"LevelUp",className:"h-8 w-auto"}),!fe&&e.jsxs(bc,{delayDuration:0,children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>be(!Ve),children:e.jsx(cl,{className:It("h-4 w-4 transition-transform duration-300",Ve&&"rotate-180")})})}),e.jsx(Yl,{side:"right",children:Ve?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(Gi,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:e.jsxs("nav",{className:It("p-3 space-y-1",Ve&&"flex flex-col items-center"),children:[e.jsx(Be,{path:"/dashboard",icon:rS,label:"Dashboard"}),e.jsx(Be,{path:"/apps",icon:nx,label:"Apps & Tools"}),pe?e.jsxs(bc,{delayDuration:0,children:[e.jsx(_c,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-10 h-10 p-0 justify-center relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Te("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/levelup-u"),children:[e.jsx(Kh,{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(Yl,{side:"right",className:"flex items-center gap-2",children:["LevelUp U",e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-primary-foreground bg-primary rounded px-1 py-0.5",children:"New"})]})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Te("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/levelup-u"),children:[e.jsx(Kh,{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(Be,{path:"/events",icon:Dd,label:"Events"}),e.jsxs(nt,{id:"agentos",label:"Agent OS",icon:kM,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(Be,{path:"/mission-control",icon:ni,label:"Mission Control"}),u("contacts")&&!Ve&&e.jsxs(gf,{open:Me.contacts,onOpenChange:()=>Pe("contacts"),children:[e.jsx(yf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke(["/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(pr,{className:"h-4 w-4"}),"Contacts"]}),e.jsx(Eo,{className:It("h-3.5 w-3.5 transition-transform duration-200",Me.contacts&&"rotate-180")})]})}),e.jsxs(vf,{className:"pl-4 pr-1 space-y-0.5 mt-0.5",children:[e.jsx(Be,{path:"/mission-control/contacts",icon:pr,label:"All Contacts"}),e.jsx(Be,{path:"/mission-control/relationship-scorecard",icon:kh,label:"Relationship Report"}),e.jsx(Be,{path:"/mission-control/sphere-gaps",icon:NL,label:"Sphere Gaps"}),e.jsx(Be,{path:"/mission-control/connect-page",icon:dl,label:"Connect Page"})]})]}),u("contacts")&&Ve&&e.jsx(Be,{path:"/mission-control/contacts",icon:pr,label:"Contacts"}),u("contacts")&&e.jsx(Be,{path:"/mission-control/plans",icon:Dd,label:"TouchPlans"}),u("pipeline")&&e.jsx(Be,{path:"/mission-control/pipeline",icon:h0,label:"Deal Pipeline"}),u("pipeline")&&e.jsx(Be,{path:"/mission-control/tasks",icon:zv,label:"Tasks"}),u("popbys")&&e.jsx(Be,{path:"/mission-control/popbys",icon:ko,label:"Popbys"}),u("videos")&&e.jsx(Be,{path:"/mission-control/video-library",icon:An,label:"Video Library"}),u("scorecard")&&e.jsx(Be,{path:"/mission-control/scorecard",icon:No,label:"Scorecard"}),u("listings")&&e.jsx(Be,{path:"/mission-control/listings",icon:ka,label:"Listing Exchange"}),!Ve&&e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Te("/mission-control/smart-drips")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/mission-control/smart-drips"),children:[e.jsx(Zh,{className:"h-4 w-4"}),"Smart Drips",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),Ve&&e.jsx(Be,{path:"/mission-control/smart-drips",icon:Zh,label:"Smart Drips"})]}),ie&&Q&&e.jsxs(nt,{id:"website",label:"My Website",icon:su,activePaths:[`/admin/lead-sites/${Q.id}/edit`],defaultPath:`/admin/lead-sites/${Q.id}/edit`,children:[Ve?e.jsxs(bc,{delayDuration:0,children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open(re||"#","_blank"),children:e.jsx(On,{className:"h-4 w-4"})})}),e.jsx(Yl,{side:"right",children:"View Site"})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open(re||"#","_blank"),children:[e.jsx(On,{className:"h-4 w-4"}),"View Site",e.jsx(tn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsx(Be,{path:`/my-website/${Q.id}/edit`,icon:Ra,label:"Edit Website"}),e.jsx(Be,{path:"/my-website/mls-listings",icon:bn,label:"MLS Listings"}),e.jsx(Be,{path:"/my-website/market-report",icon:No,label:"Market Reports"}),e.jsx(Be,{path:"/mission-control/website-activity",icon:kh,label:"Website Activity"})]}),e.jsxs(nt,{id:"marketing",label:"Marketing",icon:Ah,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx(Be,{path:"/templates",icon:ac,label:"Templates"}),e.jsx(Be,{path:"/social-swag-2",icon:h1,label:"Social Swag"}),e.jsx(Be,{path:"/newsletters",icon:l1,label:"Newsletters"})]}),e.jsxs(nt,{id:"learning",label:"Learning",icon:Sh,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx(Be,{path:"/academy",icon:Kh,label:"Academy"}),e.jsx(Be,{path:"/toolbox",icon:ey,label:"Toolbox"})]}),e.jsxs(nt,{id:"community",label:"Community",icon:so,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:U,children:[e.jsx(Be,{path:"/community",icon:pr,label:"Community",badgeCount:U}),e.jsx(Be,{path:"/wishlist",icon:$_,label:"Wishlist",badgeCount:B}),!Ve&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open("https://www.facebook.com/share/g/1CC6thti2V/","_blank"),children:[e.jsx(tn,{className:"h-4 w-4"}),"Facebook Group"]})]}),e.jsxs(nt,{id:"goods",label:"The Goods",icon:vp,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[k&&!Ve&&e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ce.pathname.startsWith("/marketplace")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/marketplace"),children:[e.jsx(vp,{className:"h-4 w-4"}),"Marketplace",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1.5 py-0.5 rounded-full bg-primary text-primary-foreground",children:"New"})]}),k&&Ve&&e.jsx(Be,{path:"/marketplace",icon:vp,label:"Marketplace"}),e.jsx(Be,{path:"/reward-store",icon:xo,label:"Reward Store"})]}),e.jsxs(nt,{id:"help",label:"Help & Services",icon:Dv,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx(Be,{path:"/support",icon:DM,label:"Support"}),e.jsx(Be,{path:"/additional-services",icon:pn,label:"Additional Services"})]}),a&&e.jsxs(e.Fragment,{children:[!Ve&&e.jsx("div",{className:"pt-3 pb-1",children:e.jsx("p",{className:"px-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Admin"})}),Ve?e.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:e.jsx(Be,{path:"/admin",icon:Th,label:"Admin Dashboard"})}):e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ce.pathname==="/admin"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/admin"),children:[e.jsx(Th,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&e.jsxs(e.Fragment,{children:[!Ve&&e.jsx("div",{className:"pt-3 pb-1",children:e.jsx("p",{className:"px-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"My Brokerage"})}),Ve?e.jsxs("div",{className:"border-t border-sidebar-border mt-3 pt-3 space-y-1",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(Be,{path:"/my-brokerage",icon:ka,label:"My Brokerage"}),e.jsx(Be,{path:"/brokerage-content",icon:Sh,label:"Brokerage Content"})]}),Z&&!o&&e.jsx(Be,{path:"/my-team",icon:pr,label:"My Team"}),o&&e.jsxs(e.Fragment,{children:[e.jsx(Be,{path:"/brokerage/dashboard",icon:Xo,label:"Manage Brokerages"}),e.jsx(Be,{path:"/brokerage/teams",icon:pr,label:"Teams"}),e.jsx(Be,{path:"/brokerage/recruiting",icon:Ah,label:"Recruiting"}),e.jsx(Be,{path:"/brokerage-resources",icon:Gh,label:"Brokerage Resources"})]})]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Te("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/my-brokerage"),children:[e.jsx(ka,{className:"h-4 w-4"}),"My Brokerage"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Te("/brokerage-content")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage-content"),children:[e.jsx(Sh,{className:"h-4 w-4"}),"Brokerage Content"]})]}),Z&&!o&&e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Te("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/my-team"),children:[e.jsx(pr,{className:"h-4 w-4"}),"My Team"]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Te("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage/dashboard"),children:[e.jsx(Xo,{className:"h-4 w-4"}),"Manage Brokerages"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Te("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage/teams"),children:[e.jsx(pr,{className:"h-4 w-4"}),"Teams",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"New"})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Te("/brokerage/recruiting")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage/recruiting"),children:[e.jsx(Ah,{className:"h-4 w-4"}),"Recruiting"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Te("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage-resources"),children:[e.jsx(Gh,{className:"h-4 w-4"}),"Brokerage Resources"]})]})]})]})]})}),e.jsxs("div",{className:"p-3 border-t border-sidebar-border md:hidden",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Te("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/profile"),children:[e.jsx(to,{className:"h-4 w-4"}),"Profile"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:n,children:[e.jsx(iS,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(GPt,{children:e.jsx(z1,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[_&&j&&e.jsx(fPt,{}),typeof document<"u"&&yp.createPortal(e.jsx("aside",{className:It("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-30 !pointer-events-auto transition-[width] duration-300",pe?"w-16":"w-56"),style:{top:`${g}px`,height:`calc(100vh - ${g}px)`},children:e.jsx(Ae,{})}),document.body),e.jsxs("div",{className:It("flex-1 flex flex-col overflow-hidden transition-all duration-300",pe?"md:ml-16":"md:ml-56"),style:{height:`calc(100vh - ${g}px)`,marginTop:`${g}px`},children:[e.jsx("header",{className:"sticky top-0 z-40 bg-card border-b border-border flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between px-6 py-3",children:[e.jsxs(JA,{children:[e.jsx(sNe,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(OM,{className:"h-5 w-5"})})}),e.jsx(yC,{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:p6t,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(cIe,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[_&&!j&&w&&e.jsx(pPt,{expiresAt:w,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(cIe,{})}),S&&e.jsx(xPt,{hasUnseenBrief:L,onClick:I}),k&&e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",onClick:()=>oe("/marketplace/cart"),children:[e.jsx(vp,{className:"h-5 w-5"}),ee>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-5 w-5 rounded-full bg-primary text-primary-foreground text-xs font-medium flex items-center justify-center",children:ee>99?"99+":ee})]}),e.jsx(B6t,{}),e.jsx(p1e,{}),e.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",ue.split(" ")[0],"!"]}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx("button",{className:"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded-full",children:e.jsxs(Nn,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[e.jsx($a,{src:b||void 0}),e.jsx(kn,{className:"bg-primary text-primary-foreground font-medium text-sm",children:Oe(ue)})]})})}),e.jsxs(Bd,{align:"end",className:"w-48",children:[e.jsxs(Ma,{onClick:()=>oe("/profile"),className:"cursor-pointer",children:[e.jsx(to,{className:"h-4 w-4 mr-2"}),"Profile"]}),e.jsxs(Ma,{onClick:()=>oe("/mission-control/integrations"),className:"cursor-pointer",children:[e.jsx(gL,{className:"h-4 w-4 mr-2"}),"Integrations"]}),e.jsx(dw,{}),e.jsxs(Ma,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(iS,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),e.jsx(LPt,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),S&&e.jsx(EPt,{brief:S,open:M,onClose:O,onDismiss:q}),e.jsx(IPt,{}),e.jsx(OPt,{}),e.jsx(FPt,{})]})]})})})},KPt=()=>{const{user:t}=Ds(),[s,r]=N.useState(!1),[n,a]=N.useState(null),[o,l]=N.useState(""),i=async f=>{var g;if(!(t!=null&&t.email)){me.error("Please sign in to upgrade");return}r(!0),a(f);try{const{data:b,error:_}=await H.functions.invoke("create-checkout",{body:{tier:f,email:t.email,name:((g=t.user_metadata)==null?void 0:g.full_name)||t.email,couponCode:o.trim()||void 0,skipTrial:!0}});if(_)throw _;if(b!=null&&b.url)window.open(b.url,"_blank","noopener,noreferrer"),me.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(b){console.error("Checkout error:",b),me.error(b.message||"Failed to start checkout. Please try again.")}finally{r(!1),a(null)}},c=["Unlimited access to all marketing templates","Complete Academy training library","AI-powered tools and resources","Community forums and support","Exclusive member events and workshops","Deal pipeline & scorecard tracking","Listing exchange access","Social media content library"],u=["Everything in Individual plan","Up to 25 agent seats","Brokerage admin dashboard","Team performance analytics","Custom branding options","Priority support","Agent onboarding tools","Brokerage-wide announcements"],p=["Everything in Brokerage plan","Unlimited agent seats","Dedicated account manager","Advanced analytics & reporting","White-label options","API access","Custom integrations","Enterprise-level support"];return e.jsx(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(ze,{id:"coupon",placeholder:"Enter discount code",value:o,onChange:f=>l(f.target.value),className:"mt-1"})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6 mb-8",children:[e.jsxs(Ee,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 bg-primary text-primary-foreground text-xs px-3 py-1 rounded-bl-lg font-medium",children:"Popular"}),e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(pr,{className:"h-7 w-7 text-primary"})}),e.jsx(Rt,{className:"text-xl",children:"Individual Agent"}),e.jsx(gr,{children:"Perfect for solo agents ready to level up"})]}),e.jsxs(De,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-primary",children:"$39"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:c.map((f,g)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(va,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},g))}),e.jsxs(K,{className:"w-full",size:"lg",onClick:()=>i("individual_agent"),disabled:s,children:[s&&n==="individual_agent"?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(pn,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Ee,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors",children:[e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(ka,{className:"h-7 w-7 text-amber-600"})}),e.jsx(Rt,{className:"text-xl",children:"Brokerage"}),e.jsx(gr,{children:"For teams and brokerages up to 25 agents"})]}),e.jsxs(De,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-amber-600",children:"$299"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:u.map((f,g)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(va,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},g))}),e.jsxs(K,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",size:"lg",onClick:()=>i("brokerage_under_25"),disabled:s,children:[s&&n==="brokerage_under_25"?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ka,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Ee,{className:"border-2 border-purple-500/20 hover:border-purple-500/50 transition-colors",children:[e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-purple-500/10 flex items-center justify-center",children:e.jsx(ka,{className:"h-7 w-7 text-purple-600"})}),e.jsx(Rt,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(gr,{children:"For larger brokerages with 25+ agents"})]}),e.jsxs(De,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-purple-600",children:"$499"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:p.map((f,g)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(va,{className:"h-4 w-4 text-purple-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},g))}),e.jsxs(K,{variant:"outline",className:"w-full border-purple-500 text-purple-600 hover:bg-purple-50",size:"lg",onClick:()=>i("brokerage_over_25"),disabled:s,children:[s&&n==="brokerage_over_25"?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ka,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]})]}),e.jsx(Ee,{className:"bg-muted/50",children:e.jsxs(De,{className:"py-6",children:[e.jsx("p",{className:"text-center font-medium mb-4",children:"Questions? We're here to help!"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{children:"1-866-527-8668"})]}),e.jsxs("a",{href:"mailto:support@relevelup.com",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(cr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})})]})})},ZPt=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=Ds(),a=fr(),[o,l]=N.useState(""),[i,c]=N.useState(!1),[u,p]=N.useState(!1);N.useEffect(()=>{!s&&!t&&a("/auth")},[t,s,a]),N.useEffect(()=>{!s&&t&&n&&a("/profile?setup=true")},[t,s,n,a]);const f=async()=>{if(!o.trim()){me.error("Please enter a brokerage name");return}const{data:g}=await H.auth.getSession(),b=g.session;if(!t||!b){me.error("Please sign in again to create your brokerage."),a("/auth");return}c(!0);try{console.log("[SetupBrokerage] Creating brokerage…",{hasUser:!!t,hasSession:!!b,userId:t==null?void 0:t.id});const{data:_,error:j}=await H.functions.invoke("create-brokerage",{body:{name:o.trim()}});if(console.log("[SetupBrokerage] create-brokerage response",{data:_,error:j}),j)throw j;if(!(_!=null&&_.ok))throw new Error((_==null?void 0:_.error)||"Failed to create brokerage");c(!1),p(!0),me.success("Brokerage created! Setting up your account..."),setTimeout(()=>{a("/profile?setup=true")},2e3)}catch(_){console.error("Error creating brokerage:",_),me.error(_.message||"Failed to create brokerage"),c(!1)}};return s?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):u?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ee,{className:"max-w-lg w-full",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(ws,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx(Rt,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(gr,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(xi,{className:"w-5 h-5 text-green-500"}),e.jsx("span",{children:"Brokerage created"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(ws,{className:"w-5 h-5 animate-spin text-primary"}),e.jsx("span",{children:"Assigning you as manager..."})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground mt-4",children:"You'll be redirected to complete your profile setup in a moment."})]})]})}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ee,{className:"max-w-lg w-full",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(ka,{className:"w-10 h-10 text-primary"})}),e.jsx(Rt,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(gr,{className:"text-lg",children:"Create your brokerage to start managing your team"})]}),e.jsxs(De,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(ze,{id:"brokerage-name",placeholder:"Enter your brokerage name",value:o,onChange:g=>l(g.target.value),onKeyDown:g=>g.key==="Enter"&&f()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This is how your brokerage will appear to your agents"})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-muted/50 space-y-3",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(pr,{className:"w-4 h-4 text-primary"}),"What you can do as a Brokerage Manager:"]}),e.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(xi,{className:"w-4 h-4 text-green-500"}),"Invite agents to join your brokerage"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(xi,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(xi,{className:"w-4 h-4 text-green-500"}),"Track your team's activity and engagement"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(xi,{className:"w-4 h-4 text-green-500"}),"Share resources with your agents"]})]})]}),e.jsxs(K,{onClick:f,className:"w-full",disabled:i||!o.trim(),children:[i?"Creating...":"Create Brokerage",e.jsx(Qa,{className:"w-4 h-4 ml-2"})]})]})]})})},mIe=()=>{const t=fr(),[s,r]=N.useState("verifying"),[n,a]=N.useState("");N.useEffect(()=>{(async()=>{try{const{data:{session:i},error:c}=await H.auth.getSession();if(c)throw c;if(i!=null&&i.user){const{data:u}=await H.from("profiles").select("login_count").eq("id",i.user.id).single();if(((u==null?void 0:u.login_count)||0)>1){console.log("Account already claimed, redirecting to dashboard"),r("already_claimed");return}console.log("User logged in successfully:",i.user.email),r("success");try{await H.functions.invoke("trial-claim-hook",{body:{userId:i.user.id}})}catch(p){console.log("Trial claim hook (non-critical):",p)}setTimeout(()=>{t("/profile?setup=true")},1500)}else setTimeout(()=>{r("already_claimed")},2e3)}catch(i){console.error("Claim error:",i),r("already_claimed")}})()},[t]);const o=()=>{window.location.href="https://dashboard.relevelup.com/auth"};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"space-y-1 text-center",children:[e.jsxs("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary/10",children:[s==="verifying"&&e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),s==="success"&&e.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),s==="already_claimed"&&e.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),s==="error"&&e.jsx("svg",{className:"h-8 w-8 text-destructive",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]}),e.jsxs(Rt,{className:"text-2xl",children:[s==="verifying"&&"Claiming Your Account...",s==="success"&&"Account Claimed!",s==="already_claimed"&&"Account Already Claimed",s==="error"&&"Claim Failed"]}),e.jsxs(gr,{children:[s==="verifying"&&"Please wait while we verify your account...",s==="success"&&"Redirecting you to complete your profile...",s==="already_claimed"&&"This account has already been set up. Please log in to access your dashboard.",s==="error"&&n]})]}),(s==="already_claimed"||s==="error")&&e.jsx(De,{children:e.jsx(K,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},YPt=()=>{const t=fr(),[s]=Cc(),[r,n]=N.useState(s.get("code")||""),[a,o]=N.useState(""),[l,i]=N.useState(""),[c,u]=N.useState(""),[p,f]=N.useState(!1),[g,b]=N.useState(!1),[_,j]=N.useState(!1),[w,k]=N.useState(!1),[S,M]=N.useState(null),[L,I]=N.useState(null),[O,q]=N.useState(null),[U,B]=N.useState(null);N.useEffect(()=>{const ee=s.get("code");ee&&(n(ee),V(ee))},[s]);const V=async ee=>{j(!0);const{data:Q,error:ie}=await H.from("invite_codes").select("id, code, max_uses, uses_count, expires_at, is_active, brokerage_id, trial_days").eq("code",ee.toUpperCase().trim()).single();if(ie||!Q){me.error("Invalid invite code"),j(!1);return}if(!Q.is_active){me.error("This invite code is no longer active"),j(!1);return}if(Q.max_uses&&Q.uses_count>=Q.max_uses){me.error("This invite code has reached its maximum uses"),j(!1);return}if(Q.expires_at&&new Date(Q.expires_at){ee.preventDefault(),V(r)},X=async ee=>{var Q;if(ee.preventDefault(),!c.trim()){me.error("Please enter your name");return}if(l.length<6){me.error("Password must be at least 6 characters");return}b(!0);try{const ie=`${window.location.origin}/`,{data:re,error:oe}=await H.auth.signUp({email:a.trim(),password:l,options:{emailRedirectTo:ie,data:{name:c.trim()}}});if(oe){oe.message.includes("already registered")?me.error("This email is already registered. Please sign in instead."):me.error(oe.message);return}re.user&&(await H.rpc("add_default_signup_tag",{user_id:re.user.id}),L?await H.functions.invoke("assign-brokerage",{body:{userId:re.user.id,brokerageId:L}}):U?await H.functions.invoke("assign-brokerage",{body:{userId:re.user.id,trialDays:U}}):await H.functions.invoke("assign-brokerage",{body:{userId:re.user.id,grandfathered:!0}}),S&&await H.from("invite_codes").update({uses_count:((Q=(await H.from("invite_codes").select("uses_count").eq("id",S).single()).data)==null?void 0:Q.uses_count)+1}).eq("id",S),me.success("Account created! You can now access the dashboard."),t("/dashboard"))}catch(ie){console.error("Signup error:",ie),me.error("An unexpected error occurred")}finally{b(!1)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsx(Rt,{className:"text-2xl font-bold text-primary",children:O?`Join ${O}`:"Join LevelUp"}),e.jsx(gr,{children:w?O?`Create your account to join ${O}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx(De,{children:w?e.jsxs("form",{onSubmit:X,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Full Name"}),e.jsx(ze,{id:"name",type:"text",placeholder:"John Doe",value:c,onChange:ee=>u(ee.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",placeholder:"you@example.com",value:a,onChange:ee=>o(ee.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{id:"password",type:p?"text":"password",placeholder:"••••••••",value:l,onChange:ee=>i(ee.target.value),required:!0,minLength:6}),e.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>f(!p),children:p?e.jsx(kp,{className:"h-4 w-4"}):e.jsx(On,{className:"h-4 w-4"})})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:g,children:g?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):e.jsxs("form",{onSubmit:Z,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"inviteCode",children:"Invite Code"}),e.jsx(ze,{id:"inviteCode",type:"text",placeholder:"Enter your invite code",value:r,onChange:ee=>n(ee.target.value),required:!0,autoFocus:!0})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:_,children:_?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},XPt="/assets/testimonial-avatar-1-BsCQFauB.jpg",QPt="/assets/testimonial-avatar-2-B6VPVc2t.jpg",JPt="/assets/testimonial-avatar-3-GuEFwYUE.jpg",eIt="/assets/testimonial-avatar-4-98iKMtkB.jpg",tIt="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",sIt=[XPt,QPt,JPt,eIt,tIt],rIt=gC({name:gc().trim().min(2,"Name must be at least 2 characters").max(100),email:gc().trim().email("Please enter a valid email address").max(255),phone:gc().trim().min(10,"Please enter a valid phone number").max(20).optional().or(Toe("")),brokerage:gc().trim().max(200).optional().or(Toe(""))}),nIt=[{icon:pp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:ac,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:hn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:$c,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:Sn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:ko,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],aIt=[{icon:pr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:pn,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Un,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Ch,title:"Birthday Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:ma,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:No,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:ni,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Zh,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],iIt=[{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."}],oIt=()=>{const t=fr(),[s,r]=N.useState(!1),[n,a]=N.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=N.useState({}),i=async c=>{var p,f;c.preventDefault(),l({});const u=rIt.safeParse(n);if(!u.success){const g={};u.error.errors.forEach(b=>{b.path[0]&&(g[b.path[0]]=b.message)}),l(g);return}r(!0);try{const{data:g,error:b}=await H.functions.invoke("create-trial-signup",{body:{name:n.name.trim(),email:n.email.trim().toLowerCase(),phone:((p=n.phone)==null?void 0:p.trim())||void 0,brokerage:((f=n.brokerage)==null?void 0:f.trim())||void 0}});if(b){console.error("Trial signup error:",b),me.error(b.message||"Something went wrong. Please try again.");return}if(g!=null&&g.error){me.error(g.error);return}me.success("🎉 Welcome aboard! Check your email to claim your account."),t("/trial/success")}catch(g){console.error("Trial signup error:",g),me.error("Something went wrong. Please try again.")}finally{r(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{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:$oe,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var c;return(c=document.getElementById("features"))==null?void 0:c.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(K,{onClick:()=>t("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),e.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"grid lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{className:"space-y-8 text-center lg:text-left",children:[e.jsx("div",{className:"flex justify-center lg:justify-start",children:e.jsx("img",{alt:"LevelUp Consulting Group",className:"h-24 md:h-32 drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium",children:[e.jsx(pn,{className:"h-4 w-4 text-yellow-400"}),e.jsx("span",{children:"7-Day Free Trial • No Credit Card Required"})]}),e.jsxs("h1",{className:"text-3xl md:text-4xl lg:text-5xl font-bold text-white leading-tight font-sans",children:["Take LevelUp for a"," ",e.jsx("span",{className:"italic",children:"Free Test Drive"})]}),e.jsxs("p",{className:"text-lg md:text-xl text-white/80 max-w-xl mx-auto lg:mx-0 font-sans",children:["The tools you need to get it done.",e.jsx("br",{}),e.jsx("em",{children:"The platform you need to keep it going."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center lg:justify-start",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/80",children:[e.jsx(sa,{className:"h-5 w-5 text-green-400"}),e.jsx("span",{children:"No credit card required"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-white/80",children:[e.jsx(sa,{className:"h-5 w-5 text-green-400"}),e.jsx("span",{children:"Full access to all features"})]})]}),e.jsxs("div",{className:"flex items-center gap-4 justify-center lg:justify-start pt-4",children:[e.jsx("div",{className:"flex -space-x-3",children:sIt.map((c,u)=>e.jsx("img",{src:c,alt:`Agent ${u+1}`,className:"w-10 h-10 rounded-full border-2 border-white/20 object-cover"},u))}),e.jsxs("div",{children:[e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(c=>e.jsx(Jn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},c))}),e.jsx("p",{className:"text-sm text-white/60",children:"Trusted by 3,000+ agents"})]})]})]}),e.jsx("div",{className:"lg:pl-8",children:e.jsx(Ee,{className:"bg-white shadow-2xl border-0",children:e.jsxs(De,{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(f0,{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(ze,{id:"name",type:"text",placeholder:"John Smith",value:n.name,onChange:c=>a({...n,name:c.target.value}),required:!0}),o.name&&e.jsx("p",{className:"text-sm text-destructive",children:o.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"email",children:"Email Address *"}),e.jsx(ze,{id:"email",type:"email",placeholder:"john@example.com",value:n.email,onChange:c=>a({...n,email:c.target.value}),required:!0}),o.email&&e.jsx("p",{className:"text-sm text-destructive",children:o.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"phone",children:"Phone Number"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:c=>a({...n,phone:c.target.value})}),o.phone&&e.jsx("p",{className:"text-sm text-destructive",children:o.phone})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"brokerage",children:"Brokerage Name"}),e.jsx(ze,{id:"brokerage",type:"text",placeholder:"Your brokerage or team name",value:n.brokerage,onChange:c=>a({...n,brokerage:c.target.value})}),o.brokerage&&e.jsx("p",{className:"text-sm text-destructive",children:o.brokerage})]}),e.jsx(K,{type:"submit",className:"w-full h-12 text-lg font-semibold bg-[#4a6b6d] hover:bg-[#3d5a5c]",disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx(Qa,{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:nIt.map((c,u)=>e.jsxs(Ee,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Pt,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx(c.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(Rt,{className:"text-xl font-sans",children:c.title})]}),e.jsx(De,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:c.description})})]},u))})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs("div",{className:"container mx-auto px-4 relative",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium mb-6",children:[e.jsx(pn,{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:aIt.map((c,u)=>e.jsxs(Ee,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:e.jsx(c.icon,{className:"w-6 h-6 text-white"})}),e.jsx(Rt,{className:"text-lg font-semibold text-white",children:c.title})]}),e.jsx(De,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:c.description})})]},u))})]})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4 font-sans",children:"Loved by Top Producers"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"See what agents are saying about LevelUp"})]}),e.jsx("div",{className:"grid md:grid-cols-3 gap-8 max-w-5xl mx-auto",children:iIt.map((c,u)=>e.jsx(Ee,{className:"border hover:shadow-lg transition-shadow",children:e.jsxs(De,{className:"p-6",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(p=>e.jsx(Jn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},p))}),e.jsxs("p",{className:"text-muted-foreground mb-4 italic",children:['"',c.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:c.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.role})]})]})},u))})]})}),e.jsx("section",{className:"py-16 bg-muted/30",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-wrap justify-center gap-8 md:gap-16",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(th,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Secure & Private"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Bank-level encryption"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(Zh,{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(pr,{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(De,{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(Qa,{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:lje,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."})]})})})]})]})},lIt=()=>{const t=fr();return e.jsxs(e.Fragment,{children:[e.jsx(Sc,{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:$oe,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(De,{className:"p-8 md:p-12 text-center",children:[e.jsxs("div",{className:"relative inline-block mb-8",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] flex items-center justify-center",children:e.jsx(sa,{className:"h-12 w-12 text-white"})}),e.jsx("div",{className:"absolute -top-2 -right-2 w-10 h-10 rounded-full bg-yellow-500 flex items-center justify-center animate-bounce",children:e.jsx(ru,{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(cr,{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(Qa,{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:lje,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},cIt=gC({viewerName:gc().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:gc().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:gc().max(20,"Phone must be less than 20 characters").optional(),message:gc().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function dIt({shareToken:t,agentName:s,hasContact:r}){const[n,a]=N.useState(!1),[o,l]=N.useState(!1),[i,c]=N.useState(null),u=mue({resolver:pue(cIt),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),p=async f=>{a(!0),c(null);try{const{data:g,error:b}=await H.functions.invoke("video-reply-notify",{body:{shareToken:t,viewerName:f.viewerName,viewerEmail:f.viewerEmail,viewerPhone:f.viewerPhone||void 0,message:f.message}});if(b)throw new Error(b.message);if(!(g!=null&&g.success))throw new Error((g==null?void 0:g.error)||"Failed to send reply");l(!0)}catch(g){console.error("Failed to submit reply:",g),c(g.message||"Something went wrong. Please try again.")}finally{a(!1)}};return o?e.jsx(Ee,{className:"border-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",children:e.jsxs(De,{className:"py-8 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/20 mb-4",children:e.jsx(sa,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:"Message Sent!"}),e.jsxs("p",{className:"text-muted-foreground",children:[s?`${s} will`:"They'll"," get back to you soon."]})]})}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx($c,{className:"h-5 w-5 text-primary"}),e.jsx(Rt,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(gr,{children:r?`Have a question or want to connect? Send ${s||"them"} a message.`:`Interested? Share your info and ${s||"your agent"} will be in touch.`})]}),e.jsx(De,{children:e.jsx(fue,{...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(Zc,{control:u.control,name:"viewerName",render:({field:f})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Your Name *"}),e.jsx(Oc,{children:e.jsx(ze,{placeholder:"John Smith",...f})}),e.jsx(Sm,{})]})}),e.jsx(Zc,{control:u.control,name:"viewerEmail",render:({field:f})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Email *"}),e.jsx(Oc,{children:e.jsx(ze,{type:"email",placeholder:"john@example.com",...f})}),e.jsx(Sm,{})]})})]}),!r&&e.jsx(Zc,{control:u.control,name:"viewerPhone",render:({field:f})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Phone (optional)"}),e.jsx(Oc,{children:e.jsx(ze,{type:"tel",placeholder:"(555) 123-4567",...f})}),e.jsx(Sm,{})]})}),e.jsx(Zc,{control:u.control,name:"message",render:({field:f})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Message *"}),e.jsx(Oc,{children:e.jsx(Er,{placeholder:r?"Thanks for the video! I had a question about...":"I'm interested in learning more about...",className:"min-h-[100px] resize-none",...f})}),e.jsx(Sm,{})]})}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i}),e.jsx(K,{type:"submit",className:"w-full gap-2",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Bn,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const uIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsxs("div",{className:"absolute inset-0 opacity-[0.08]",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[16%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[32%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[48%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[64%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[80%] left-0 right-0 h-[8%] bg-red-600"})]}),e.jsx("div",{className:"absolute top-0 left-0 w-[35%] h-[45%] bg-blue-900/10 rounded-br-3xl"}),e.jsx(Jn,{className:"absolute top-[5%] left-[8%] w-6 h-6 text-blue-600/30 fill-blue-600/20"}),e.jsx(Jn,{className:"absolute top-[15%] left-[20%] w-4 h-4 text-blue-600/25 fill-blue-600/15"}),e.jsx(Jn,{className:"absolute top-[8%] left-[28%] w-5 h-5 text-blue-600/30 fill-blue-600/20"}),e.jsx(Jn,{className:"absolute top-[25%] left-[12%] w-4 h-4 text-blue-600/20 fill-blue-600/10"}),e.jsx(Jn,{className:"absolute top-[20%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse"}),e.jsx(n1,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 rotate-12"})]}),hIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-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(pn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-8 text-red-400/40"})]}),e.jsxs("div",{className:"absolute top-[5%] right-[20%] w-24 h-24",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-blue-400/20 animate-ping",style:{animationDuration:"4s",animationDelay:"1s"}}),e.jsx(Jn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-6 h-6 text-blue-400/40 fill-blue-400/20"})]}),e.jsxs("div",{className:"absolute top-[20%] left-[50%] w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border border-white/10 animate-ping",style:{animationDuration:"3.5s",animationDelay:"0.5s"}}),e.jsx(pn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-5 h-5 text-amber-400/40"})]}),e.jsx(Jn,{className:"absolute bottom-[25%] left-[10%] w-6 h-6 text-blue-500/25 fill-blue-500/15 animate-pulse"}),e.jsx(Jn,{className:"absolute bottom-[15%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse",style:{animationDelay:"0.5s"}}),e.jsx(n1,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),mIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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(Hg,{className:"w-20 h-20 text-pink-400 rotate-12"})}),e.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:e.jsx(Hg,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),e.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:e.jsx(Hg,{className:"w-14 h-14 text-purple-400 rotate-45"})}),e.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:e.jsx(Hg,{className:"w-16 h-16 text-pink-300 -rotate-6"})}),e.jsx(ni,{className:"absolute top-[15%] left-[30%] w-5 h-5 text-rose-300/40 fill-rose-300/20 animate-pulse"}),e.jsx(ni,{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(ni,{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"})]}),pIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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(Nc,{className:"absolute top-[8%] left-[12%] w-12 h-12 text-blue-600/15"}),e.jsx(Jn,{className:"absolute top-[15%] left-[22%] w-5 h-5 text-amber-500/25 fill-amber-500/15"}),e.jsx(Nc,{className:"absolute bottom-[20%] right-[8%] w-14 h-14 text-indigo-500/12"}),e.jsx("div",{className:"absolute top-[3%] left-[40%] opacity-12",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tr-none rotate-6"}),e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tl-none -rotate-6"})]})}),e.jsx(Jn,{className:"absolute bottom-[25%] left-[15%] w-6 h-6 text-blue-500/20 fill-blue-500/10 animate-pulse"}),e.jsx(Jn,{className:"absolute top-[20%] right-[22%] w-5 h-5 text-indigo-400/20 fill-indigo-400/10 animate-pulse",style:{animationDelay:"0.5s"}})]}),fIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-pink-100/20 via-purple-100/15 to-sky-100/20"}),e.jsx("div",{className:"absolute top-[5%] left-[8%] w-12 h-16 rounded-full bg-gradient-to-b from-pink-300/25 to-pink-400/18 rotate-12"}),e.jsx("div",{className:"absolute top-[8%] right-[12%] w-10 h-14 rounded-full bg-gradient-to-b from-purple-300/25 to-purple-400/18 -rotate-6"}),e.jsx("div",{className:"absolute bottom-[18%] left-[15%] w-11 h-15 rounded-full bg-gradient-to-b from-sky-300/20 to-sky-400/12 rotate-6"}),e.jsx("div",{className:"absolute bottom-[22%] right-[10%] w-12 h-16 rounded-full bg-gradient-to-b from-yellow-300/20 to-yellow-400/12 -rotate-12"}),e.jsx("div",{className:"absolute top-[10%] left-[10%] w-6 h-1 bg-white/30 rounded-full rotate-12"}),e.jsx("div",{className:"absolute top-[12%] right-[15%] w-5 h-1 bg-white/25 rounded-full -rotate-6"}),e.jsx(Hg,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),e.jsx(Hg,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),e.jsx(MM,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),xIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-900/12 via-purple-900/8 to-slate-900/12"}),e.jsx(eS,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),e.jsx(eS,{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(pn,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),e.jsx(pn,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),gIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-900/8 via-green-900/5 to-emerald-900/8"}),e.jsx(p1,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),e.jsx(p1,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),e.jsx(p1,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),e.jsx(n0,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),e.jsx(n0,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(n0,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(n0,{className:"absolute top-[8%] left-[70%] w-8 h-8 text-blue-200/20 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[12%] left-[10%] w-5 h-5 rounded-full bg-red-500/25"}),e.jsx("div",{className:"absolute top-[15%] right-[15%] w-4 h-4 rounded-full bg-amber-400/25"}),e.jsx("div",{className:"absolute top-[20%] left-[55%] w-4 h-4 rounded-full bg-green-500/20"}),e.jsx(Jn,{className:"absolute top-[3%] left-[50%] -translate-x-1/2 w-10 h-10 text-amber-400/35 fill-amber-400/25"})]}),yIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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(ni,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-red-400/22 fill-red-400/12"}),e.jsx(ni,{className:"absolute top-[20%] right-[25%] w-5 h-5 text-orange-400/22 fill-orange-400/12"})]}),vIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-yellow-900/8 via-amber-900/4 to-purple-900/8"}),e.jsx(Jn,{className:"absolute top-[5%] left-[15%] w-12 h-12 text-yellow-400/35 fill-yellow-400/25 animate-pulse"}),e.jsx(Jn,{className:"absolute top-[8%] right-[12%] w-10 h-10 text-amber-400/30 fill-amber-400/20 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(Jn,{className:"absolute top-[15%] left-[40%] w-7 h-7 text-yellow-300/25 fill-yellow-300/15 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(Jn,{className:"absolute top-[12%] right-[35%] w-8 h-8 text-amber-300/28 fill-amber-300/18 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[20%] left-[25%] w-4 h-4 rounded-full bg-pink-400/30"}),e.jsx("div",{className:"absolute top-[18%] right-[30%] w-3 h-3 rounded-full bg-sky-400/30"}),e.jsx("div",{className:"absolute top-[25%] left-[60%] w-2.5 h-2.5 rounded-full bg-emerald-400/30"}),e.jsx("div",{className:"absolute top-[22%] right-[42%] w-3 h-3 rounded-full bg-purple-400/30"}),e.jsx(pn,{className:"absolute top-[3%] left-[50%] w-10 h-10 text-yellow-400/40"}),e.jsx(ru,{className:"absolute bottom-[18%] left-[10%] w-12 h-12 text-purple-400/18 rotate-12"}),e.jsx(ru,{className:"absolute bottom-[20%] right-[12%] w-10 h-10 text-amber-400/15 -rotate-12"})]}),bIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/10 via-indigo-900/6 to-sky-900/10"}),e.jsxs("div",{className:"absolute bottom-[12%] left-1/2 -translate-x-1/2 flex items-end gap-3",children:[e.jsx("div",{className:"w-2 h-14 bg-blue-400/18 rounded-full"}),e.jsx("div",{className:"w-2 h-12 bg-blue-300/15 rounded-full"}),e.jsx("div",{className:"w-2 h-16 bg-blue-400/20 rounded-full"}),e.jsx("div",{className:"w-2.5 h-20 bg-blue-500/22 rounded-full"})," ",e.jsx("div",{className:"w-2 h-16 bg-blue-400/20 rounded-full"}),e.jsx("div",{className:"w-2 h-12 bg-blue-300/15 rounded-full"}),e.jsx("div",{className:"w-2 h-14 bg-blue-400/18 rounded-full"})]}),e.jsx("div",{className:"absolute bottom-[38%] left-[calc(50%-42px)] w-3 h-4 bg-yellow-400/30 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[35%] left-[calc(50%-28px)] w-2.5 h-3 bg-yellow-300/25 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[40%] left-[calc(50%-14px)] w-3 h-4 bg-amber-400/30 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[45%] left-1/2 -translate-x-1/2 w-4 h-5 bg-yellow-400/35 rounded-full blur-sm"}),e.jsx(Jn,{className:"absolute top-[8%] left-[50%] -translate-x-1/2 w-14 h-14 text-yellow-400/28 fill-yellow-400/18"}),e.jsx(pn,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),e.jsx(pn,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),_It=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-green-900/12 via-emerald-900/6 to-teal-900/10"}),e.jsx(Kv,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),e.jsx(Kv,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),e.jsx(Kv,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),e.jsx(Kv,{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"})]})]})]}),wIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/10 via-indigo-900/6 to-sky-900/10"}),e.jsx("div",{className:"absolute top-[8%] left-[12%] w-16 h-16 rounded-full border-4 border-blue-500/18"}),e.jsx("div",{className:"absolute top-[10%] right-[10%] w-14 h-14 rounded-full border-4 border-indigo-500/15"}),e.jsx("div",{className:"absolute bottom-[18%] left-[18%] w-12 h-12 rounded-full border-3 border-sky-500/12"}),e.jsx(Jn,{className:"absolute top-[5%] left-[42%] w-10 h-10 text-amber-400/30 fill-amber-400/20"}),e.jsx(Jn,{className:"absolute top-[15%] right-[25%] w-7 h-7 text-yellow-400/25 fill-yellow-400/15"}),e.jsx(Nc,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(Nc,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(n1,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),jIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/6 via-rose-900/6 to-purple-900/6"}),e.jsx(Ch,{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(ru,{className:"absolute top-[8%] left-[45%] w-10 h-10 text-purple-400/22 rotate-12"}),e.jsx(ko,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),NIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-rose-900/12 via-pink-900/8 to-red-900/12"}),e.jsx(ni,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-rose-400/28 fill-rose-400/18"}),e.jsx(ni,{className:"absolute top-[8%] right-[12%] w-14 h-14 text-pink-400/25 fill-pink-400/15"}),e.jsx(ni,{className:"absolute bottom-[15%] left-[12%] w-12 h-12 text-red-400/22 fill-red-400/12"}),e.jsx(ni,{className:"absolute bottom-[18%] right-[10%] w-13 h-13 text-rose-300/25 fill-rose-300/15"}),e.jsx(ni,{className:"absolute top-[15%] left-[30%] w-6 h-6 text-pink-300/35 fill-pink-300/20 animate-pulse"}),e.jsx(ni,{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(ni,{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(ni,{className:"absolute top-[25%] right-[25%] w-4 h-4 text-pink-400/30 fill-pink-400/15 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[18%] left-[45%] w-8 h-8 rounded-full bg-rose-300/18 blur-sm"}),e.jsx("div",{className:"absolute bottom-[25%] right-[40%] w-6 h-6 rounded-full bg-pink-300/15 blur-sm"})]}),kIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/10 via-yellow-900/6 to-orange-900/10"}),e.jsxs("div",{className:"absolute top-[5%] right-[12%]",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-yellow-400/25 blur-sm"}),e.jsx(m1,{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(m1,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),e.jsx(pn,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),e.jsx(m1,{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"})]}),SIt=()=>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(bn,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),e.jsx(bn,{className:"absolute bottom-[15%] right-[8%] w-16 h-16 text-emerald-500/18"}),e.jsx(Sp,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),e.jsx(Sp,{className:"absolute bottom-[22%] left-[22%] w-8 h-8 text-yellow-400/22"}),e.jsx(ni,{className:"absolute top-[18%] left-[40%] w-6 h-6 text-rose-400/22 fill-rose-400/12"}),e.jsx(ni,{className:"absolute top-[22%] right-[35%] w-5 h-5 text-teal-400/20 fill-teal-400/10"}),e.jsx(pn,{className:"absolute top-[5%] left-[55%] w-8 h-8 text-teal-400/30"}),e.jsx(ru,{className:"absolute bottom-[20%] left-[48%] w-10 h-10 text-cyan-400/18 rotate-12"})]}),CIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-emerald-900/10 via-teal-900/6 to-cyan-900/10"}),e.jsx(ru,{className:"absolute top-[5%] left-[12%] w-14 h-14 text-emerald-400/25 rotate-12"}),e.jsx(ru,{className:"absolute top-[8%] right-[10%] w-12 h-12 text-teal-400/22 -rotate-12"}),e.jsx(Sp,{className:"absolute bottom-[18%] left-[18%] w-12 h-12 text-amber-400/25"}),e.jsx(bn,{className:"absolute bottom-[15%] right-[12%] w-14 h-14 text-teal-500/18"}),e.jsx(pn,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),e.jsx(pn,{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"})]}),MIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/10 via-yellow-900/6 to-orange-900/10"}),e.jsx(Sp,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),e.jsx(Sp,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),e.jsx(Sp,{className:"absolute top-[12%] right-[15%] w-9 h-9 text-amber-300/25"}),e.jsx(bn,{className:"absolute top-[8%] left-[42%] w-12 h-12 text-teal-500/18"}),e.jsx(ru,{className:"absolute bottom-[22%] right-[18%] w-12 h-12 text-orange-400/18 rotate-12"}),e.jsx(pn,{className:"absolute top-[5%] right-[35%] w-8 h-8 text-yellow-400/35"}),e.jsx(Jn,{className:"absolute top-[18%] left-[28%] w-6 h-6 text-amber-400/25 fill-amber-400/15"})]}),TIt=()=>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(bn,{className:"absolute bottom-[10%] left-[50%] -translate-x-1/2 w-20 h-20 text-teal-500/22"}),e.jsx("div",{className:"absolute bottom-[18%] left-[12%] w-12 h-10 bg-amber-400/18 rounded-sm"}),e.jsx("div",{className:"absolute bottom-[20%] left-[20%] w-10 h-8 bg-orange-400/15 rounded-sm"}),e.jsx("div",{className:"absolute bottom-[16%] right-[15%] w-11 h-9 bg-amber-300/18 rounded-sm"}),e.jsx(Sp,{className:"absolute top-[10%] right-[12%] w-10 h-10 text-amber-400/28"}),e.jsx(ni,{className:"absolute top-[8%] left-[18%] w-8 h-8 text-rose-400/25 fill-rose-400/15"}),e.jsx(pn,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),e.jsx(s1,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),pIe=()=>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"})]}),AIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(ni,{className:"absolute top-6 left-[12%] w-4 h-4 text-rose-300/50 fill-rose-300/30 animate-pulse"}),e.jsx(ni,{className:"absolute top-10 right-[18%] w-3 h-3 text-pink-300/50 fill-pink-300/30 animate-pulse delay-150"}),e.jsx(ni,{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(ni,{className:"absolute top-14 right-[35%] w-3.5 h-3.5 text-pink-300/40 fill-pink-300/20 animate-pulse delay-200"})]}),EIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(s1,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),e.jsx(pn,{className:"absolute top-10 right-[15%] w-3 h-3 text-amber-400/50 animate-pulse delay-100"}),e.jsx(bn,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),PIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Q4,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),e.jsx(RM,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),e.jsx(Q4,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),GP=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(pn,{className:"absolute top-5 left-[10%] w-4 h-4 text-emerald-400/50 animate-pulse"}),e.jsx(ru,{className:"absolute top-10 right-[12%] w-5 h-5 text-amber-400/50 animate-pulse delay-150"}),e.jsx(pn,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),fIe=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(bn,{className:"absolute top-6 left-[12%] w-4 h-4 text-teal-400/40 animate-pulse"}),e.jsx(pn,{className:"absolute top-10 right-[15%] w-3 h-3 text-emerald-400/50 animate-pulse delay-100"}),e.jsx(bn,{className:"absolute top-4 right-[40%] w-3 h-3 text-cyan-400/30 animate-pulse delay-200"})]}),y1e=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:e.jsx(pn,{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(ni,{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(AIt,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:e.jsx(ZI,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Thinking of You, ${t}`:"Thinking of You",subText:"Just wanted to reach out and say hello",gradientClasses:"from-violet-50/70 via-purple-50/50 to-indigo-50/40 dark:from-violet-950/30 dark:via-purple-950/20 dark:to-indigo-950/20",accentColor:"violet",decorativeElement:e.jsx(GP,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:e.jsx(Q4,{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(PIt,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:e.jsx(No,{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(pr,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Thank You for the Referral, ${t}!`:"Thank You for the Referral!",subText:"Your trust in me means everything",gradientClasses:"from-emerald-50/70 via-green-50/50 to-teal-50/40 dark:from-emerald-950/30 dark:via-green-950/20 dark:to-teal-950/20",accentColor:"emerald",decorativeElement:e.jsx(GP,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:e.jsx(Nc,{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(pIe,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:e.jsx(ma,{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(fIe,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:e.jsx(RM,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Hey ${t}!`:"Hey There!",subText:"No reason needed – just wanted to connect",gradientClasses:"from-sky-50/70 via-blue-50/50 to-indigo-50/40 dark:from-sky-950/30 dark:via-blue-950/20 dark:to-indigo-950/20",accentColor:"sky",decorativeElement:e.jsx(GP,{})},{id:"birthday",name:"Birthday",description:"Celebrate their special day",icon:e.jsx(Ch,{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(jIt,{})},{id:"valentines_day",name:"Valentine's Day",description:"Show appreciation on this special day",icon:e.jsx(ni,{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(NIt,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:e.jsx(m1,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Groundhog Day, ${t}!`:"Happy Groundhog Day!",subText:"Wishing you an early spring!",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx(kIt,{})},{id:"new_years",name:"New Year's Day",description:"Ring in the new year",icon:e.jsx(Jn,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy New Year, ${t}!`:"Happy New Year!",subText:"Wishing you a year full of success and happiness",gradientClasses:"from-yellow-50/70 via-amber-50/50 to-orange-50/40 dark:from-yellow-950/30 dark:via-amber-950/20 dark:to-orange-950/20",accentColor:"yellow",decorativeElement:e.jsx(vIt,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:e.jsx(MM,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Easter, ${t}!`:"Happy Easter!",subText:"Wishing you a joyful celebration",gradientClasses:"from-pink-50/70 via-purple-50/50 to-sky-50/40 dark:from-pink-950/30 dark:via-purple-950/20 dark:to-sky-950/20",accentColor:"pink",decorativeElement:e.jsx(fIt,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:e.jsx(Hg,{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(mIt,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(Nc,{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(pIt,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:e.jsx(n1,{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(uIt,{})},{id:"independence_day",name:"4th of July",description:"Celebrate Independence Day",icon:e.jsx(eh,{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(hIt,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(Nc,{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(wIt,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:e.jsx(eS,{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(xIt,{})},{id:"thanksgiving",name:"Thanksgiving",description:"Express gratitude this season",icon:e.jsx(ni,{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(yIt,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:e.jsx(p1,{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(gIt,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:e.jsx(pn,{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(bIt,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:e.jsx(Kv,{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(_It,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:e.jsx(bn,{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(SIt,{})},{id:"under_contract",name:"Under Contract",description:"Celebrate this exciting milestone",icon:e.jsx(ru,{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(CIt,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:e.jsx(hn,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Exciting News, ${t}!`:"Just Listed!",subText:"A new property is now on the market",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-violet-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-violet-950/20",accentColor:"blue",decorativeElement:e.jsx(fIe,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:e.jsx(nc,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Just Sold!",subText:"Another successful transaction completed",gradientClasses:"from-emerald-50/70 via-green-50/50 to-teal-50/40 dark:from-emerald-950/30 dark:via-green-950/20 dark:to-teal-950/20",accentColor:"emerald",decorativeElement:e.jsx(GP,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:e.jsx(pS,{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(s1,{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(EIt,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:e.jsx(Sp,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"It's official – the keys are yours!",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx(MIt,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:e.jsx(bn,{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(TIt,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:e.jsx(sh,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Amazing News, ${t}!`:"Offer Accepted!",subText:"Your offer has been accepted – congratulations!",gradientClasses:"from-green-50/70 via-emerald-50/50 to-teal-50/40 dark:from-green-950/30 dark:via-emerald-950/20 dark:to-teal-950/20",accentColor:"green",decorativeElement:e.jsx(GP,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:e.jsx(Nc,{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(pIe,{})}],IIt=[{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 LIt(t){return y1e.filter(s=>s.category===t)}function XM(t){return y1e.find(s=>s.id===t)||y1e[0]}function xIe(){const{shareToken:t,recipientToken:s}=yo(),[r,n]=N.useState(null),[a,o]=N.useState(null),[l,i]=N.useState(null),[c,u]=N.useState(!0),[p,f]=N.useState(null),[g,b]=N.useState(!0),_=N.useRef(null),j=N.useRef(0),w=N.useRef(0),k=(()=>{const X=new URLSearchParams(window.location.search);return s||X.get("rt")||null})(),S=N.useCallback((X,ee=!1)=>{if(!k||X<=0)return;const Q=Math.max(1,Math.round(X));if(Q<=w.current)return;const re=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${encodeURIComponent(k)}&e=watch&ws=${Q}`;ee&&navigator.sendBeacon?navigator.sendBeacon(re):fetch(re,{method:"GET",keepalive:ee}).catch(()=>{}),w.current=Math.max(w.current,Q)},[k]);N.useEffect(()=>{var ce;if(!g||!(r!=null&&r.playback_url)||!k)return;let X=!1;const ee=()=>{j.current>0&&S(j.current,!0)},Q=()=>{document.visibilityState==="hidden"&&ee()},ie=()=>{ee()},re=()=>{var ge;if(X||!_.current||!((ge=window.playerjs)!=null&&ge.Player))return;const xe=new window.playerjs.Player(_.current);xe.on("timeupdate",ue=>{const pe=Math.floor(Number((ue==null?void 0:ue.seconds)??0));!Number.isFinite(pe)||pe<=0||(j.current=Math.max(j.current,pe))}),xe.on("pause",()=>{j.current>0&&S(j.current)}),xe.on("ended",()=>{j.current>0&&S(j.current,!0)})},oe=document.querySelector('script[data-bunny-playerjs="true"]');if((ce=window.playerjs)!=null&&ce.Player)re();else if(oe)oe.addEventListener("load",re,{once:!0});else{const xe=document.createElement("script");xe.src="https://assets.mediadelivery.net/playerjs/playerjs-latest.min.js",xe.async=!0,xe.defer=!0,xe.dataset.bunnyPlayerjs="true",xe.onload=re,document.body.appendChild(xe)}return document.addEventListener("visibilitychange",Q),window.addEventListener("beforeunload",ie),()=>{X=!0,document.removeEventListener("visibilitychange",Q),window.removeEventListener("beforeunload",ie),ee()}},[g,r==null?void 0:r.playback_url,k,S]),N.useEffect(()=>{j.current=0,w.current=0},[k,t]),N.useEffect(()=>{const X=()=>{['[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(re=>{document.querySelectorAll(re).forEach(oe=>{oe.style.display="none"})})};X();const ee=[setTimeout(X,500),setTimeout(X,1500),setTimeout(X,3e3)],Q=new MutationObserver(X);return Q.observe(document.body,{childList:!0,subtree:!0}),()=>{ee.forEach(clearTimeout),Q.disconnect()}},[]),N.useEffect(()=>{(async()=>{if(!t){f("Invalid share link"),u(!1);return}const{data:ee,error:Q}=await H.from("agent_videos").select("id, title, playback_url, thumbnail_url, preview_url, duration_seconds, share_token, owner_user_id, contact_id, page_template, recipient_name").eq("share_token",t).eq("is_deleted",!1).single();if(Q||!ee){f("Video not found or has been removed"),u(!1);return}n(ee);try{await H.rpc("log_video_view",{p_video_id:ee.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch(ie){console.warn("Failed to log video view:",ie)}if(ee.owner_user_id){const{data:ie}=await H.from("profiles").select("id, name, email, phone").eq("id",ee.owner_user_id).single();if(ie){o(ie);try{const{data:re}=await H.storage.from("avatars").list(`${ee.owner_user_id}`);if(re&&re.length>0){const{data:oe}=H.storage.from("avatars").getPublicUrl(`${ee.owner_user_id}/${re[0].name}`);i(oe.publicUrl)}}catch{}}}u(!1)})()},[t]);const M=X=>{if(!X)return"0:00";const ee=Math.floor(X/60),Q=X%60;return`${ee}:${Q.toString().padStart(2,"0")}`},L=X=>X.includes("iframe.mediadelivery.net/play/")?X.replace("/play/","/embed/")+"?autoplay=true&responsive=true":X,I=X=>{if(!X)return"?";const ee=X.split(" ");return ee.length>=2?`${ee[0][0]}${ee[1][0]}`.toUpperCase():X.substring(0,2).toUpperCase()},O=XM((r==null?void 0:r.page_template)||"default"),q=(r==null?void 0:r.recipient_name)||null,U=O.headerText(q),V=`https://dashboard.relevelup.com/share/video/${t}`;if(c)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-primary"})});if(p||!r)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx(Ee,{className:"max-w-md w-full",children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(An,{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 Z=O.id!=="default";return e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsx("title",{children:U}),e.jsx("meta",{name:"description",content:O.subText}),e.jsx("meta",{property:"og:title",content:U}),e.jsx("meta",{property:"og:description",content:O.subText}),e.jsx("meta",{property:"og:type",content:"video.other"}),e.jsx("meta",{property:"og:url",content:V}),r.preview_url&&e.jsx("meta",{property:"og:image",content:r.preview_url}),!r.preview_url&&r.thumbnail_url&&e.jsx("meta",{property:"og:image",content:r.thumbnail_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{property:"og:video",content:r.playback_url}),e.jsx("meta",{property:"og:video:type",content:"text/html"}),e.jsx("meta",{property:"og:video:width",content:"1280"}),e.jsx("meta",{property:"og:video:height",content:"720"})]}),e.jsx("meta",{name:"twitter:card",content:"player"}),e.jsx("meta",{name:"twitter:title",content:U}),e.jsx("meta",{name:"twitter:description",content:O.subText}),r.preview_url&&e.jsx("meta",{name:"twitter:image",content:r.preview_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{name:"twitter:player",content:r.playback_url}),e.jsx("meta",{name:"twitter:player:width",content:"1280"}),e.jsx("meta",{name:"twitter:player:height",content:"720"})]})]}),e.jsxs("div",{className:It("min-h-screen flex items-center justify-center p-4 bg-gradient-to-b relative",O.gradientClasses),children:[Z&&O.decorativeElement,e.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[Z&&e.jsxs("div",{className:"text-center py-4 animate-fade-in",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:It("w-14 h-14 rounded-full flex items-center justify-center shadow-sm",O.accentColor==="primary"&&"bg-primary/10 text-primary",O.accentColor==="amber"&&"bg-amber-100 text-amber-600 dark:bg-amber-900/50 dark:text-amber-400",O.accentColor==="teal"&&"bg-teal-100 text-teal-600 dark:bg-teal-900/50 dark:text-teal-400",O.accentColor==="rose"&&"bg-rose-100 text-rose-600 dark:bg-rose-900/50 dark:text-rose-400",O.accentColor==="emerald"&&"bg-emerald-100 text-emerald-600 dark:bg-emerald-900/50 dark:text-emerald-400",O.accentColor==="yellow"&&"bg-yellow-100 text-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400",O.accentColor==="pink"&&"bg-pink-100 text-pink-600 dark:bg-pink-900/50 dark:text-pink-400",O.accentColor==="blue"&&"bg-blue-100 text-blue-600 dark:bg-blue-900/50 dark:text-blue-400",O.accentColor==="red"&&"bg-red-100 text-red-600 dark:bg-red-900/50 dark:text-red-400",O.accentColor==="orange"&&"bg-orange-100 text-orange-600 dark:bg-orange-900/50 dark:text-orange-400",O.accentColor==="green"&&"bg-green-100 text-green-600 dark:bg-green-900/50 dark:text-green-400",O.accentColor==="violet"&&"bg-violet-100 text-violet-600 dark:bg-violet-900/50 dark:text-violet-400",O.accentColor==="sky"&&"bg-sky-100 text-sky-600 dark:bg-sky-900/50 dark:text-sky-400"),children:e.jsx("div",{className:"scale-150",children:O.icon})})}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold mb-2",children:U}),e.jsx("p",{className:"text-muted-foreground",children:O.subText})]}),a&&e.jsxs("div",{className:"flex items-center gap-4 p-4 bg-card/90 backdrop-blur-sm rounded-lg border shadow-sm",children:[e.jsxs(Nn,{className:"h-14 w-14 border-2 border-primary/20",children:[e.jsx($a,{src:l||void 0,alt:a.name||"Agent"}),e.jsx(kn,{className:"bg-primary/10 text-primary font-semibold",children:I(a.name)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:Z?"A special video from":"A personal video from"}),e.jsx("h2",{className:"text-lg font-semibold truncate",children:a.name||"Your Agent"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Real Estate Professional"})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[a.phone&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`tel:${a.phone}`,"aria-label":"Call agent",children:e.jsx(Un,{className:"h-4 w-4"})})}),a.email&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`mailto:${a.email}`,"aria-label":"Email agent",children:e.jsx(cr,{className:"h-4 w-4"})})})]})]}),e.jsx(Ee,{className:"overflow-hidden shadow-lg",children:g&&r.playback_url?e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:e.jsx("iframe",{ref:_,src:L(r.playback_url),title:r.title||"Video message",className:"absolute top-0 left-0 w-full h-full",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})}):e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>b(!0),children:[r.preview_url||r.thumbnail_url?e.jsx("img",{src:r.preview_url||r.thumbnail_url||"",alt:r.title?`${r.title} video preview`:"Video message preview",className:"w-full h-full object-cover",onError:X=>{var Q;X.currentTarget.style.display="none";const ee=(Q=X.currentTarget.parentElement)==null?void 0:Q.querySelector(".video-fallback");ee&&(ee.style.display="flex")}}):null,e.jsx("div",{className:"video-fallback w-full h-full items-center justify-center bg-gradient-to-br from-primary/20 to-primary/5",style:{display:r.preview_url||r.thumbnail_url?"none":"flex"},children:e.jsx(An,{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(nl,{className:"h-10 w-10 text-primary ml-1"})})}),r.duration_seconds&&e.jsx("div",{className:"absolute bottom-3 right-3 bg-black/70 text-white text-sm px-2 py-1 rounded",children:M(r.duration_seconds)})]})}),!Z&&e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.title||"Video Message"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:g?"Enjoy the video!":"Click to play the video"})]}),!g&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(K,{size:"lg",onClick:()=>b(!0),className:"gap-2",children:[e.jsx(nl,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(dIt,{shareToken:t,agentName:(a==null?void 0:a.name)||null,hasContact:!!r.contact_id})]})]})]})}function DIt(){return N.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(o1t,{})}function OIt(){const{token:t}=yo();return N.useEffect(()=>{if(!t)return;const s=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/video-og-image?token=${t}`;window.location.replace(s)},[t]),e.jsx("main",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(ws,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading video preview…"})]})})}const RIt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},FIt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},w5={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function zIt(){var Q,ie,re,oe;const{slugOrId:t}=yo(),[s]=Cc(),{data:r,isLoading:n}=JWe(t||""),a=eGe(),o=QNt(),l=s.get("ref"),[i,c]=N.useState(""),[u,p]=N.useState(""),[f,g]=N.useState(""),[b,_]=N.useState(""),[j,w]=N.useState(!1),[k,S]=N.useState(!1),[M,L]=N.useState(null),[I,O]=N.useState(!1);N.useEffect(()=>{l&&o.mutate(l)},[l]);const q=ce=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ce),U=async ce=>{if(ce.preventDefault(),!(!i.trim()||!f.trim()||!r)){w(!0);try{await a.mutateAsync({listingId:r.id,agentId:r.agent_id,firstName:i.trim(),lastName:u.trim(),email:f.trim(),phone:b.trim(),shareToken:l}),S(!0),me.success("Thanks! The agent will be in touch soon.")}catch(xe){console.error("Lead submission error:",xe),me.error(`Failed to submit: ${xe.message||"Please try again"}`)}finally{w(!1)}}},B=(r==null?void 0:r.photos)||[],V=B.find(ce=>ce.is_primary)||B[0],Z=()=>{M!==null&&L(M===0?B.length-1:M-1)},X=()=>{M!==null&&L(M===B.length-1?0:M+1)};if(n)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(ys,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(ys,{className:"h-10 w-48 mb-6"}),e.jsx(ys,{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(ys,{className:"h-12 w-48"}),e.jsx(ys,{className:"h-6 w-full"}),e.jsx(ys,{className:"h-6 w-3/4"})]}),e.jsx(ys,{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(Pi,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:woe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(bn,{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(Pi,{to:"/public/listings",children:"Browse All Listings"})})]})]});const ee=r.property_address?`${r.property_address} - ${r.city}, ${r.state}`:`${r.city}, ${r.state} Home for Sale`;return e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsxs("title",{children:[ee," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${q(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${r.square_footage?r.square_footage.toLocaleString()+" sqft":""} ${w5[r.property_type]} in ${r.city}, ${r.state}. ${((Q=r.description)==null?void 0:Q.slice(0,150))||""}`}),e.jsx("link",{rel:"canonical",href:`https://listings.relevelup.com/${r.slug||r.id}`}),e.jsx("meta",{property:"og:title",content:ee}),e.jsx("meta",{property:"og:description",content:`${q(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${w5[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} - ${w5[r.property_type]} for sale`}),e.jsx("meta",{property:"og:site_name",content:"LevelUp Listings"}),e.jsx("meta",{property:"og:locale",content:"en_US"}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:ee}),e.jsx("meta",{name:"twitter:description",content:`${q(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA in ${r.city}, ${r.state}`}),V&&e.jsx("meta",{name:"twitter:image",content:V.photo_url}),e.jsx("meta",{name:"robots",content:"index, follow"}),e.jsx("meta",{name:"geo.region",content:`US-${r.state}`}),e.jsx("meta",{name:"geo.placename",content:r.city}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"RealEstateListing",name:r.property_address||`${r.city}, ${r.state} Home`,description:r.description||`${w5[r.property_type]} for sale in ${r.city}, ${r.state}`,url:`https://listings.relevelup.com/${r.slug||r.id}`,datePosted:r.created_at,image:B.map(ce=>ce.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:(ie=r.agent.brokerage)!=null&&ie.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(Pi,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:woe,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs(Pi,{to:"/public/listings",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),B.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>L(0),children:e.jsx("img",{src:V==null?void 0:V.photo_url,alt:`${r.property_address||r.city+", "+r.state} - ${w5[r.property_type]} main photo`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:B.slice(1,5).map((ce,xe)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>L(xe+1),children:[e.jsx("img",{src:ce.photo_url,alt:`${r.property_address||r.city} - Photo ${xe+2} of ${B.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),xe===3&&B.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",B.length-5," more"]})]},ce.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx(tt,{className:`${RIt[r.status]} text-white border-0`,children:FIt[r.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:q(r.price)}),r.property_address&&e.jsx("p",{className:"text-xl font-medium",children:r.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ma,{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(Im,{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(Ju,{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(y0,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.square_footage.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),r.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.year_built}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(tt,{variant:"secondary",children:[e.jsx(ka,{className:"h-3 w-3 mr-1"}),w5[r.property_type]]}),r.lot_size&&e.jsxs(tt,{variant:"secondary",children:["Lot: ",r.lot_size]}),r.has_hoa&&e.jsx(tt,{variant:"secondary",children:"HOA"})]}),r.description&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"About This Property"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})]}),r.agent_notes&&r.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.agent_notes})]}),r.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:r.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{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(De,{className:"p-0",children:[e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>O(!0),children:[r.video.thumbnail_url?e.jsx("img",{src:r.video.thumbnail_url,alt:"Video thumbnail",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gradient-to-br from-primary/20 to-primary/30",children:e.jsx(An,{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(nl,{className:"h-8 w-8 text-primary fill-primary ml-1"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs(K,{onClick:()=>O(!0),className:"w-full gap-2",size:"lg",children:[e.jsx(nl,{className:"h-4 w-4"}),"Watch Video Tour"]}),r.video.title&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2 text-center truncate",children:r.video.title})]})]})}),r.agent&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(to,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(De,{children:[e.jsx("p",{className:"font-semibold text-lg",children:r.agent.name}),((re=r.agent.brokerage)==null?void 0:re.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.agent.brokerage.name})]})]}),e.jsxs(Ee,{className:"border-primary",children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(De,{children:k?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:e.jsx(cr,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The listing agent will contact you soon."})]}):e.jsxs("form",{onSubmit:U,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"firstName",children:"First Name *"}),e.jsx(ze,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:ce=>c(ce.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lastName",children:"Last Name"}),e.jsx(ze,{id:"lastName",type:"text",placeholder:"Doe",value:u,onChange:ce=>p(ce.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email *"}),e.jsx(ze,{id:"email",type:"email",placeholder:"you@example.com",value:f,onChange:ce=>g(ce.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:b,onChange:ce=>_(ce.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(fs,{open:M!==null,onOpenChange:()=>L(null),children:e.jsxs(ps,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(_s,{className:"sr-only",children:e.jsx(vs,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>L(null),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Rr,{className:"h-5 w-5"})}),M!==null&&B[M]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:B[M].photo_url,alt:`Photo ${M+1}`,className:"w-full max-h-[80vh] object-contain"}),B.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:Z,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(cl,{className:"h-6 w-6"})}),e.jsx("button",{onClick:X,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(da,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm",children:[M+1," / ",B.length]})]})]})]})}),e.jsx(fs,{open:I,onOpenChange:O,children:e.jsxs(ps,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[e.jsx(_s,{className:"sr-only",children:e.jsx(vs,{children:"Video Tour"})}),e.jsx("button",{onClick:()=>O(!1),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Rr,{className:"h-5 w-5"})}),((oe=r==null?void 0:r.video)==null?void 0:oe.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 BIt(){var o;const{slug:t}=yo(),{data:s,isLoading:r,error:n}=nGe(t);if(N.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),N.useEffect(()=>{s!=null&&s.id&&fo(s.id,"card_view")},[s==null?void 0:s.id]),r)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md mx-auto p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(ys,{className:"h-28 w-28 rounded-full"}),e.jsx(ys,{className:"h-6 w-48"}),e.jsx(ys,{className:"h-4 w-36"})]}),e.jsx(ys,{className:"h-12 w-full"}),e.jsx(ys,{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(Sc,{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(dje,{card:s})]})}function BYe({slugOverride:t}={}){var Ce;const{slug:s}=yo(),r=t||s,[n]=Cc(),a=n.get("t"),[o,l]=N.useState(!0),[i,c]=N.useState(null),[u,p]=N.useState(null),f=N.useRef(null),g=N.useRef(null),[b,_]=N.useState(null),[j,w]=N.useState(null),[k,S]=N.useState(!1),[M,L]=N.useState(!1),[I,O]=N.useState(0),[q,U]=N.useState(!1),[B,V]=N.useState(""),[Z,X]=N.useState(""),[ee,Q]=N.useState(""),[ie,re]=N.useState(""),[oe,ce]=N.useState(""),[xe,ge]=N.useState(""),[ue,pe]=N.useState(""),[be,Me]=N.useState(""),[Ne,Pe]=N.useState(""),[Oe,Te]=N.useState(""),[ke,Be]=N.useState(""),[nt,Ae]=N.useState("");N.useEffect(()=>{ft()},[r,a]);const ft=async()=>{if(!r)return;l(!0);const{data:rt,error:Ge}=await H.from("contact_intake_pages").select("*").eq("slug",r).eq("is_active",!0).maybeSingle();if(Ge||!rt){U(!0),l(!1);return}p(rt),g.current=rt;const{data:ct}=await H.from("profiles").select("name, avatar_url, title, phone, email, brokerage_id").eq("id",rt.user_id).single();if(ct){let qe;if(ct.brokerage_id){const{data:He}=await H.from("brokerages").select("name").eq("id",ct.brokerage_id).single();qe=(He==null?void 0:He.name)||void 0}let Ze=ct.avatar_url||null;if(!Ze){const{data:He}=H.storage.from("avatars").getPublicUrl(`${rt.user_id}/avatar.jpg`);He!=null&&He.publicUrl&&(Ze=`${He.publicUrl}?t=${Date.now()}`)}const Qe={...ct,avatar_url:Ze,brokerage_name:qe};c(Qe),f.current=Qe}if(a)try{console.log("[ConnectPage] Resolving token:",a,"for page:",rt.id);const{data:qe,error:Ze}=await H.functions.invoke("process-intake-submissions",{body:{action:"resolve_token",token:a,page_id:rt.id}});if(console.log("[ConnectPage] Resolve result:",{resolved:qe,resolveErr:Ze}),!Ze&&(qe!=null&&qe.contact_id)){w(qe.contact_id);const Qe=qe.contact;Qe&&(_(Qe),V(Qe.first_name||""),X(Qe.last_name||""),Q(Qe.email||""),re(Qe.phone||""),ce(Qe.address||""),ge(Qe.city||""),pe(Qe.state||""),Me(Qe.zip||""),Pe(Qe.birthday||""),Te(Qe.home_anniversary||""))}}catch(qe){console.error("Failed to resolve token:",qe)}l(!1)},fe=async()=>{var rt,Ge;if(!B.trim()){me.error("Please enter your first name");return}if(!r){me.error("Invalid page. Please refresh.");return}L(!0);try{let ct=(rt=g.current)==null?void 0:rt.id,qe=(Ge=g.current)==null?void 0:Ge.user_id;if(!ct||!qe){const{data:Qe}=await H.from("contact_intake_pages").select("id, user_id").eq("slug",r).eq("is_active",!0).maybeSingle();if(!Qe){me.error("This page is no longer active. Please contact the agent directly."),L(!1);return}ct=Qe.id,qe=Qe.user_id}const{error:Ze}=await H.from("contact_intake_submissions").insert({intake_page_id:ct,agent_user_id:qe,existing_contact_id:j,first_name:B.trim(),last_name:Z.trim()||null,email:ee.trim()||null,phone:ie.trim()||null,address:oe.trim()||null,city:xe.trim()||null,state:ue.trim()||null,zip:be.trim()||null,birthday:Ne||null,home_anniversary:Oe||null,real_estate_interest:ke||null,message:nt.trim()||null});if(console.log("[ConnectPage] Insert result:",{error:Ze}),Ze)throw Ze;a&&await H.from("contact_intake_tokens").update({used_at:new Date().toISOString()}).eq("token",a);try{const Qe=[B.trim(),Z.trim()].filter(Boolean).join(" ");await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/connect-page-notify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentUserId:qe,contactName:Qe,contactEmail:ee.trim()||null,contactPhone:ie.trim()||null,slug:r})})}catch(Qe){console.warn("Connect page notification failed (non-blocking):",Qe)}S(!0)}catch(ct){console.error(ct),me.error("Something went wrong. Please try again.")}finally{L(!1)}};if(o)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-slate-400"})});if(q)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("h1",{className:"text-2xl font-semibold text-slate-700",children:"Page Not Found"}),e.jsx("p",{className:"text-slate-500",children:"This connect page doesn't exist or is no longer active."})]})});if(k)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50 p-4",children:[e.jsx(Sc,{children:e.jsxs("title",{children:["Thank You | ",i==null?void 0:i.name]})}),e.jsxs(Hs.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(Hs.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",delay:.2},className:"mx-auto w-20 h-20 rounded-full bg-emerald-100 flex items-center justify-center",children:e.jsx(sa,{className:"h-10 w-10 text-emerald-600"})}),e.jsx("h1",{className:"text-3xl font-bold text-slate-800",children:"Thank You!"}),e.jsxs("p",{className:"text-lg text-slate-600",children:[i==null?void 0:i.name," has received your info and will be in touch soon."]}),e.jsxs("div",{className:"flex items-center justify-center gap-1 text-sm text-slate-400 pt-4",children:[e.jsx(ni,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})]})]});const Ve=!!a&&!!b,at=3,et=[{title:Ve?"Confirm Your Info":"Let's Get Connected",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"First Name *"}),e.jsx("input",{type:"text",value:B,onChange:rt=>V(rt.target.value),placeholder:"Jane",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Last Name"}),e.jsx("input",{type:"text",value:Z,onChange:rt=>X(rt.target.value),placeholder:"Smith",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Email"}),e.jsx("input",{type:"email",value:ee,onChange:rt=>Q(rt.target.value),placeholder:"jane@email.com",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Phone"}),e.jsx("input",{type:"tel",value:ie,onChange:rt=>re(rt.target.value),placeholder:"(555) 123-4567",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]})},{title:"A Little More About You",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Street Address"}),e.jsx("input",{type:"text",value:oe,onChange:rt=>ce(rt.target.value),placeholder:"123 Main St",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"City"}),e.jsx("input",{type:"text",value:xe,onChange:rt=>ge(rt.target.value),placeholder:"Austin",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"col-span-1",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"State"}),e.jsx("input",{type:"text",value:ue,onChange:rt=>pe(rt.target.value),placeholder:"TX",maxLength:2,className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Zip"}),e.jsx("input",{type:"text",value:be,onChange:rt=>Me(rt.target.value),placeholder:"78701",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Birthday"}),e.jsx("input",{type:"date",value:Ne,onChange:rt=>Pe(rt.target.value),className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),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:Oe,onChange:rt=>Te(rt.target.value),className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]})]})},{title:"One Last Thing",fields:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-600 mb-3",children:["Are you thinking about making a move anytime soon? ",e.jsx("span",{className:"text-slate-400 font-normal",children:"(totally optional)"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{value:"buying",label:"🏠 Buying",desc:"Looking for a home"},{value:"selling",label:"📋 Selling",desc:"Thinking of selling"},{value:"both",label:"🔄 Both",desc:"Buy & sell"},{value:"not_now",label:"😊 Not right now",desc:"Just staying connected"}].map(rt=>e.jsxs("button",{type:"button",onClick:()=>Be(ke===rt.value?"":rt.value),className:`p-3.5 rounded-xl border-2 text-left transition-all ${ke===rt.value?"border-blue-500 bg-blue-50 shadow-sm":"border-slate-200 bg-white hover:border-slate-300"}`,children:[e.jsx("span",{className:"block text-sm font-medium text-slate-800",children:rt.label}),e.jsx("span",{className:"block text-xs text-slate-500 mt-0.5",children:rt.desc})]},rt.value))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:["Anything else you'd like to share? ",e.jsx("span",{className:"text-slate-400 font-normal",children:"(optional)"})]}),e.jsx("textarea",{value:nt,onChange:rt=>Ae(rt.target.value),placeholder:"Feel free to drop a note...",rows:3,className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all resize-none"})]})]})}];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-blue-50",children:[e.jsxs(Sc,{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(Hs.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:((Ce=i==null?void 0:i.name)==null?void 0:Ce.charAt(0))||"?"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800",children:i==null?void 0:i.name}),(i==null?void 0:i.title)&&e.jsx("p",{className:"text-slate-500 mt-0.5",children:i.title}),(i==null?void 0:i.brokerage_name)&&e.jsx("p",{className:"text-sm text-slate-400",children:i.brokerage_name}),((i==null?void 0:i.phone)||(i==null?void 0:i.email))&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[(i==null?void 0:i.phone)&&e.jsx("a",{href:`tel:${i.phone}`,className:"flex items-center justify-center w-10 h-10 rounded-full bg-blue-50 hover:bg-blue-100 text-blue-600 transition-colors","aria-label":"Call agent",children:e.jsx(Un,{className:"h-4.5 w-4.5"})}),(i==null?void 0:i.email)&&e.jsx("a",{href:`mailto:${i.email}`,className:"flex items-center justify-center w-10 h-10 rounded-full bg-blue-50 hover:bg-blue-100 text-blue-600 transition-colors","aria-label":"Email agent",children:e.jsx(cr,{className:"h-4.5 w-4.5"})})]})]}),e.jsx(Hs.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},className:"text-center text-slate-600 mb-8 px-4 leading-relaxed",children:(u==null?void 0:u.welcome_message)||"I'd love to stay connected! Fill in your info below."}),e.jsx("div",{className:"flex gap-2 mb-8 px-2",children:Array.from({length:at}).map((rt,Ge)=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-all duration-500 ${Ge<=I?"bg-blue-500":"bg-slate-200"}`},Ge))}),e.jsxs(Hs.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(wZe,{mode:"wait",children:e.jsxs(Hs.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(pn,{className:"h-5 w-5 text-blue-500"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-800",children:et[I].title})]}),et[I].fields]},I)}),e.jsxs("div",{className:"flex justify-between mt-8",children:[I>0?e.jsx("button",{type:"button",onClick:()=>O(rt=>rt-1),className:"px-5 py-2.5 text-sm font-medium text-slate-600 hover:text-slate-800 transition-colors",children:"Back"}):e.jsx("div",{}),I{if(I===0&&!B.trim()){me.error("Please enter your first name");return}O(rt=>rt+1)},className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm",children:"Continue"}):e.jsx("button",{type:"button",onClick:()=>fe(),disabled:M,className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm disabled:opacity-50 flex items-center gap-2",children:M?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):"Submit"})]}),I>0&&IO(rt=>rt+1),className:"text-xs text-slate-400 hover:text-slate-500 transition-colors",children:"Skip this step"})})]}),e.jsx("div",{className:"text-center mt-8",children:e.jsxs("div",{className:"flex items-center justify-center gap-1 text-xs text-slate-400",children:[e.jsx(ni,{className:"h-3 w-3"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})})]})]})}function KP({banners:t,autoPlayInterval:s=5e3,className:r}){const[n,a]=N.useState(0),[o,l]=N.useState(!1),i=N.useCallback(()=>{a(f=>(f+1)%t.length)},[t.length]),c=N.useCallback(()=>{a(f=>(f-1+t.length)%t.length)},[t.length]),u=N.useCallback(f=>{a(f)},[]);if(N.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:It("relative w-full overflow-hidden rounded-xl",r),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[e.jsxs("div",{className:"relative aspect-[21/9] md:aspect-[3/1] w-full",children:[e.jsx("img",{src: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:It("absolute left-2 top-1/2 -translate-y-1/2 bg-black/30 hover:bg-black/50 text-white rounded-full","opacity-0 transition-opacity",o&&"opacity-100"),onClick:c,children:e.jsx(cl,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:It("absolute right-2 top-1/2 -translate-y-1/2 bg-black/30 hover:bg-black/50 text-white rounded-full","opacity-0 transition-opacity",o&&"opacity-100"),onClick:i,children:e.jsx(da,{className:"h-6 w-6"})})]}),t.length>1&&e.jsx("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex gap-2",children:t.map((f,g)=>e.jsx("button",{onClick:()=>u(g),className:It("w-2 h-2 rounded-full transition-all duration-300",g===n?"bg-white w-6":"bg-white/50 hover:bg-white/70"),"aria-label":`Go to slide ${g+1}`},g))})]}),e.jsxs("div",{className:"bg-foreground rounded-b-xl px-5 py-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm md:text-base font-semibold text-background truncate",children:p.title}),p.description&&e.jsx("p",{className:"text-xs text-background/70 truncate",children:p.description})]}),p.link_url&&e.jsx("a",{href:p.link_url,target:"_blank",rel:"noopener noreferrer",className:"shrink-0",children:e.jsx(K,{size:"sm",className:"bg-primary text-primary-foreground font-semibold transition-colors hover:bg-background hover:text-foreground",children:p.link_text||"Learn More"})})]})]})}function $It(t){return"EST"}function nD(t){const r=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(t),n=$It();return`${r} ${n}`}function QM(t){const s=new Date,r=new Date(t),n=aM(r,-15),a=aM(r,30);return s>a?"ended":Rg(s,{start:r,end:a})?"live":Rg(s,{start:n,end:r})?"starting_soon":"upcoming"}function yNe(t){const s=QM(t);return s==="starting_soon"||s==="live"}const gIe=yNe,qIt=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=N.useState(new Date);N.useEffect(()=>{const b=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(b)},[]);const o=t.filter(b=>yNe(b.event_date));if(o.length===0)return null;const l=o[0],i=QM(l.event_date),c=s.find(b=>b.event_id===l.id),u=(c==null?void 0:c.zoom_join_url)||l.zoom_link,p=!!c,f=i==="live",g=f?{container:"from-red-500/10 via-red-500/5 to-primary/10 border-red-500/30",pulse:"from-red-500/5",indicator:"bg-red-500",text:"text-red-500",button:"bg-red-500 hover:bg-red-600",outlineButton:"border-red-500/50 text-red-500 hover:bg-red-500/10"}:{container:"from-amber-500/10 via-amber-500/5 to-primary/10 border-amber-500/30",pulse:"from-amber-500/5",indicator:"bg-amber-500",text:"text-amber-500",button:"bg-amber-500 hover:bg-amber-600",outlineButton:"border-amber-500/50 text-amber-500 hover:bg-amber-500/10"};return e.jsxs("div",{className:`relative mb-8 overflow-hidden rounded-xl bg-gradient-to-r ${g.container} border`,children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-r ${g.pulse} to-transparent animate-pulse`}),e.jsx("div",{className:"relative p-4 sm:p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex items-center justify-center",children:[e.jsx("span",{className:`absolute inline-flex h-full w-full animate-ping rounded-full ${g.indicator} opacity-75`}),e.jsx("span",{className:`relative flex h-3 w-3 rounded-full ${g.indicator}`})]}),e.jsx("div",{className:`flex items-center gap-2 ${g.text} font-bold text-sm uppercase tracking-wider`,children:f?e.jsxs(e.Fragment,{children:[e.jsx(d1,{className:"h-4 w-4"}),"Live Now"]}):e.jsxs(e.Fragment,{children:[e.jsx(un,{className:"h-4 w-4"}),"Starting Soon"]})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-lg text-foreground line-clamp-1",children:l.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?`Started at ${nD(new Date(l.event_date))}`:`Starts at ${nD(new Date(l.event_date))}`})]}),e.jsx("div",{className:"flex items-center gap-2",children:p?e.jsxs(K,{onClick:()=>window.open(u,"_blank"),className:`${g.button} text-white gap-2`,children:[e.jsx(tn,{className:"h-4 w-4"}),f?"Join Now":"Join When Live"]}):e.jsxs(K,{variant:"outline",onClick:r,className:`${g.outlineButton} gap-2`,children:[e.jsx(pr,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var vNe="Progress",bNe=100,[UIt]=ad(vNe),[VIt,HIt]=UIt(vNe),$Ye=N.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=WIt,...l}=t;(a||a===0)&&!yIe(a)&&console.error(GIt(`${a}`,"Progress"));const i=yIe(a)?a:bNe;n!==null&&!vIe(n,i)&&console.error(KIt(`${n}`,"Progress"));const c=vIe(n,i)?n:null,u=Goe(c)?o(c,i):void 0;return e.jsx(VIt,{scope:r,value:c,max:i,children:e.jsx(nn.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":Goe(c)?c:void 0,"aria-valuetext":u,role:"progressbar","data-state":VYe(c,i),"data-value":c??void 0,"data-max":i,...l,ref:s})})});$Ye.displayName=vNe;var qYe="ProgressIndicator",UYe=N.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=HIt(qYe,r);return e.jsx(nn.div,{"data-state":VYe(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});UYe.displayName=qYe;function WIt(t,s){return`${Math.round(t/s*100)}%`}function VYe(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function Goe(t){return typeof t=="number"}function yIe(t){return Goe(t)&&!isNaN(t)&&t>0}function vIe(t,s){return Goe(t)&&!isNaN(t)&&t<=s&&t>=0}function GIt(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${bNe}\`.`}function KIt(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 ${bNe} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var HYe=$Ye,ZIt=UYe;const Bi=N.forwardRef(({className:t,value:s,...r},n)=>e.jsx(HYe,{ref:n,className:It("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(ZIt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));Bi.displayName=HYe.displayName;function YIt(){const{user:t,isBrokerageManager:s}=Ds(),[r,n]=N.useState([]),[a,o]=N.useState([]),[l,i]=N.useState(!1),[c,u]=N.useState(!0),p=s?"brokerage_manager":"agent";N.useEffect(()=>{if(!(t!=null&&t.id)){u(!1);return}f()},[t==null?void 0:t.id,p]);const f=async()=>{if(t!=null&&t.id)try{const{data:L,error:I}=await H.from("onboarding_checklist_items").select("*").eq("target_role",p).eq("is_active",!0).order("sort_order");if(I)throw I;const{data:O,error:q}=await H.from("onboarding_checklist_progress").select("item_id, completed_at").eq("user_id",t.id);if(q)throw q;const{data:U,error:B}=await H.from("onboarding_checklist_dismissed").select("id").eq("user_id",t.id).maybeSingle();if(B)throw B;n(L||[]),o(O||[]),i(!!U),L&&L.length>0&&await g(L,O||[])}catch(L){console.error("Error fetching checklist data:",L)}finally{u(!1)}},g=async(L,I)=>{var Te,ke;if(!(t!=null&&t.id))return;const O=I.map(Be=>Be.item_id),q=L.filter(Be=>!O.includes(Be.id));if(q.length===0)return;const[U,B,V,Z,X,ee,Q,ie,re,oe,ce,xe,ge,ue,pe]=await Promise.all([H.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle(),H.from("resource_shares").select("id",{count:"exact",head:!0}).eq("sender_id",t.id),H.from("community_posts").select("id",{count:"exact",head:!0}).eq("user_id",t.id),H.from("event_registrations").select("id",{count:"exact",head:!0}).eq("user_id",t.id),H.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","template"),H.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","academy_video"),H.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","toolbox"),H.from("activity_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id),H.from("innercircle_contacts").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),H.from("agent_videos").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),H.from("contact_touch_logs").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),H.from("scorecard_transactions").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),H.from("listings").select("id",{count:"exact",head:!0}).eq("agent_id",t.id),H.from("innercircle_contacts").select("id").eq("owner_user_id",t.id),H.from("deal_pipeline").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id)]),be={},Me=(Te=U.data)==null?void 0:Te.brokerage_id;be.share_resource=(B.count||0)>0,be.post_community=(V.count||0)>0,be.register_event=(Z.count||0)>0,be.view_template=(X.count||0)>0,be.watch_academy=(ee.count||0)>0,be.use_toolbox=(Q.count||0)>0,be.launch_app=(ie.count||0)>0,be.add_contact=(re.count||0)>0,be.create_video=(oe.count||0)>0,be.complete_touch=(ce.count||0)>0,be.add_transaction=(xe.count||0)>0,be.add_listing=(ge.count||0)>0,be.add_deal=(pe.count||0)>0;const Ne=((ke=ue.data)==null?void 0:ke.map(Be=>Be.id))||[],Pe=[];Me?Pe.push(H.from("profiles").select("id").eq("brokerage_id",Me).neq("id",t.id).then(Be=>{var nt;be.add_agent=(((nt=Be.data)==null?void 0:nt.length)||0)>0})):be.add_agent=!1,Ne.length>0?(Pe.push(H.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",Ne).then(Be=>{be.add_plan=(Be.count||0)>0})),Pe.push(H.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",Ne).then(Be=>{be.schedule_popby=(Be.count||0)>0}))):(be.add_plan=!1,be.schedule_popby=!1),await Promise.all(Pe);const Oe=q.filter(Be=>be[Be.action_type]);if(Oe.length>0){const Be=Oe.map(Ae=>({user_id:t.id,item_id:Ae.id})),{error:nt}=await H.from("onboarding_checklist_progress").upsert(Be,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!nt){const Ae=Oe.map(ft=>({item_id:ft.id,completed_at:new Date().toISOString()}));o(ft=>[...ft,...Ae])}}},b=async L=>{if(t!=null&&t.id)try{const{error:I}=await H.from("onboarding_checklist_progress").insert({user_id:t.id,item_id:L});if(I)throw I;o(O=>[...O,{item_id:L,completed_at:new Date().toISOString()}])}catch(I){console.error("Error marking item complete:",I)}},_=async()=>{if(t!=null&&t.id)try{const{error:L}=await H.from("onboarding_checklist_dismissed").insert({user_id:t.id});if(L)throw L;i(!0)}catch(L){console.error("Error dismissing checklist:",L)}},j=a.length,w=r.length,k=w>0&&j>=w,S=w>0?j/w*100:0;return{items:r,progress:a,isDismissed:l,loading:c,completedCount:j,totalCount:w,isComplete:k,progressPercentage:S,isItemComplete:L=>a.some(I=>I.item_id===L),markComplete:b,dismiss:_,refetch:f}}const XIt={add_agent:e.jsx(pr,{className:"h-4 w-4"}),share_resource:e.jsx(_d,{className:"h-4 w-4"}),post_community:e.jsx(so,{className:"h-4 w-4"}),register_event:e.jsx(hn,{className:"h-4 w-4"}),view_template:e.jsx(Rv,{className:"h-4 w-4"}),watch_academy:e.jsx(Kh,{className:"h-4 w-4"}),use_toolbox:e.jsx(ey,{className:"h-4 w-4"}),launch_app:e.jsx(UI,{className:"h-4 w-4"}),add_deal:e.jsx(h0,{className:"h-4 w-4"}),add_listing:e.jsx(bn,{className:"h-4 w-4"})},QIt={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function JIt(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:c,dismiss:u}=YIt(),p=fr(),[f,g]=N.useState(!0);return r||s||a===0||o?null:e.jsxs(Ee,{className:"mb-6 border-primary/20 bg-gradient-to-r from-primary/5 to-transparent",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(f0,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Get Started with LevelUp"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Complete these steps to make the most of your membership"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>g(!f),className:"h-8 w-8 p-0",children:f?e.jsx(pf,{className:"h-4 w-4"}):e.jsx(Eo,{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(Rr,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm mb-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Progress"}),e.jsxs("span",{className:"font-medium",children:[n," of ",a," complete"]})]}),e.jsx(Bi,{value:l,className:"h-2"})]})]}),f&&e.jsx(De,{className:"pt-0",children:e.jsx("div",{className:"space-y-3",children:t.map(b=>{const _=i(b.id);return e.jsxs("div",{className:It("flex items-start gap-3 p-3 rounded-lg transition-colors",_?"bg-muted/50":"bg-background hover:bg-muted/30 cursor-pointer"),onClick:()=>{if(_)return;const j=QIt[b.action_type];j?p(j):c(b.id)},children:[e.jsx("div",{className:"mt-0.5",children:_?e.jsx(sa,{className:"h-5 w-5 text-primary"}):e.jsx(bd,{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:XIt[b.action_type]||e.jsx(bd,{className:"h-4 w-4"})}),e.jsx("span",{className:It("font-medium",_&&"line-through text-muted-foreground"),children:b.title})]}),b.description&&e.jsx("p",{className:It("text-sm text-muted-foreground mt-1",_&&"line-through"),children:b.description})]})]},b.id)})})})]})}const Ux=()=>mt({queryKey:["relationship-types"],queryFn:async()=>{const{data:t,error:s}=await H.from("relationship_types").select("*").order("sort_order");if(s)throw s;return t}}),Gm=t=>{const s=ci(),r=1e3,n=async a=>{const o=[];let l=0;for(;;){const{data:i,error:c}=await a.range(l,l+r-1);if(c)throw c;const u=i??[];if(o.push(...u),u.length{let a=H.from("innercircle_contacts").select(` *, lead_source_ref:lead_sources(id, name), tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).eq("owner_user_id",s).order("created_at",{ascending:!1}).order("first_name");return await n(a)},enabled:!!s})},eLt=t=>mt({queryKey:["innercircle-contact",t],queryFn:async()=>{const{data:s,error:r}=await H.from("innercircle_contacts").select(` *, lead_source_ref:lead_sources(id, name), tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).eq("id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),WYe=()=>{const t=ci();return mt({queryKey:["innercircle-contact-counts",t],queryFn:async()=>{const{data:s,error:r}=await H.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(r)throw r;const n={};return s==null||s.forEach(a=>{var o;(o=a.tags)==null||o.forEach(l=>{n[l.relationship_type_id]=(n[l.relationship_type_id]||0)+1})}),n},enabled:!!t})},_ue=()=>{const t=Qt(),s=ci();return Dt({mutationFn:async r=>{const{tagIds:n,...a}=r,o={...a,birthday:a.birthday||null,home_anniversary:a.home_anniversary||null,owner_user_id:s},{data:l,error:i}=await H.from("innercircle_contacts").insert(o).select().single();if(i)throw i;if(n&&n.length>0){const{error:c}=await H.from("innercircle_contact_tags").insert(n.map(u=>({contact_id:l.id,relationship_type_id:u})));if(c)throw c}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),wn({title:"Contact created successfully"})},onError:r=>{wn({title:"Error creating contact",description:r.message,variant:"destructive"})}})},_Ne=()=>{const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{tagIds:n,tags:a,...o}=r,l={...o,birthday:o.birthday||null,home_anniversary:o.home_anniversary||null},{data:i,error:c}=await H.from("innercircle_contacts").update(l).eq("id",s).select().single();if(c)throw c;if(n!==void 0&&(await H.from("innercircle_contact_tags").delete().eq("contact_id",s),n.length>0)){const{error:u}=await H.from("innercircle_contact_tags").insert(n.map(p=>({contact_id:s,relationship_type_id:p})));if(u)throw u}return i},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),wn({title:"Contact updated successfully"})},onError:s=>{wn({title:"Error updating contact",description:s.message,variant:"destructive"})}})},GYe=()=>{const t=Qt();return Dt({mutationFn:async({contactId:s,spouseContactId:r})=>{if(r){const{error:n}=await H.from("innercircle_contacts").update({spouse_contact_id:r}).eq("id",s);if(n)throw n;const{error:a}=await H.from("innercircle_contacts").update({spouse_contact_id:s}).eq("id",r);if(a)throw a}else{const{data:n}=await H.from("innercircle_contacts").select("spouse_contact_id").eq("id",s).single(),a=n==null?void 0:n.spouse_contact_id,{error:o}=await H.from("innercircle_contacts").update({spouse_contact_id:null}).eq("id",s);if(o)throw o;if(a){const{error:l}=await H.from("innercircle_contacts").update({spouse_contact_id:null}).eq("id",a);if(l)throw l}}},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-spouse"]}),wn({title:"Spouse link updated"})},onError:s=>{wn({title:"Error linking spouse",description:s.message,variant:"destructive"})}})},wNe=()=>{const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("innercircle_contacts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),wn({title:"Contact deleted successfully"})},onError:s=>{wn({title:"Error deleting contact",description:s.message,variant:"destructive"})}})},BO=()=>mt({queryKey:["action-types"],queryFn:async()=>{const{data:t,error:s}=await H.from("action_types").select("*").order("sort_order");if(s)throw s;return t}}),tLt=t=>mt({queryKey:["action-scripts",t],queryFn:async()=>{let s=H.from("action_scripts").select("*, action_type:action_types(*)");const{data:r,error:n}=await s;if(n)throw n;return r}}),sLt=()=>mt({queryKey:["touchpoint-plans"],queryFn:async()=>{const{data:t,error:s}=await H.from("touchpoint_plans").select(` *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) `).order("name");if(s)throw s;return t}}),rLt=()=>{const t=Qt(),s=ci();return Dt({mutationFn:async({name:r,description:n})=>{const{data:a,error:o}=await H.from("touchpoint_plans").insert({name:r,description:n,owner_user_id:s,active:!0,is_template:!1}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),wn({title:"Plan created successfully"})},onError:r=>{wn({title:"Error creating plan",description:r.message,variant:"destructive"})}})},nLt=()=>{const t=Qt(),s=ci();return Dt({mutationFn:async({sourcePlanId:r,newName:n})=>{const{data:a,error:o}=await H.from("touchpoint_plans").select(` *, items:touchpoint_plan_items(*) `).eq("id",r).single();if(o)throw o;if(!a)throw new Error("Source plan not found");const{data:l,error:i}=await H.from("touchpoint_plans").insert({name:n,description:a.description,owner_user_id:s,active:!0,is_template:!1}).select().single();if(i)throw i;if(a.items&&a.items.length>0){const c=a.items.map(p=>({plan_id:l.id,month_number:p.month_number,action_type_id:p.action_type_id,default_script_id:p.default_script_id,notes:p.notes})),{error:u}=await H.from("touchpoint_plan_items").insert(c);if(u)throw u}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),wn({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{wn({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},aLt=()=>{const t=Qt();return Dt({mutationFn:async({id:s,name:r,description:n})=>{const{data:a,error:o}=await H.from("touchpoint_plans").update({name:r,description:n}).eq("id",s).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),wn({title:"Plan updated successfully"})}})},iLt=()=>{const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("touchpoint_plans").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),wn({title:"Plan deleted successfully"})}})},oLt=()=>{const t=Qt();return Dt({mutationFn:async({planId:s,items:r})=>{if(await H.from("touchpoint_plan_items").delete().eq("plan_id",s),r.length>0){const{error:n}=await H.from("touchpoint_plan_items").insert(r.map(a=>({plan_id:s,month_number:a.month_number,action_type_id:a.action_type_id,default_script_id:a.default_script_id||null,notes:a.notes})));if(n)throw n}},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),wn({title:"Plan schedule updated"})}})},lLt=()=>{const t=Qt();return Dt({mutationFn:async({actionTypeId:s,title:r,scriptBody:n,emailSubject:a,tone:o})=>{const{data:{user:l}}=await H.auth.getUser(),{data:i,error:c}=await H.from("action_scripts").insert({action_type_id:s,title:r,script_body:n,email_subject:a||null,tone:o||null,active:!0,user_id:l==null?void 0:l.id}).select().single();if(c)throw c;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["action-scripts"]}),wn({title:"Script created successfully"})},onError:s=>{wn({title:"Error creating script",description:s.message,variant:"destructive"})}})},cLt=()=>{const t=ci();return mt({queryKey:["user-plan-enrollments",t],queryFn:async()=>{const{data:s,error:r}=await H.from("user_plan_enrollments").select(` *, plan:touchpoint_plans(*), relationship_type:relationship_types(*) `);if(r)throw r;return s},enabled:!!t})},dLt=()=>{const t=Qt(),s=ci();return Dt({mutationFn:async({planId:r,relationshipTypeId:n,active:a})=>{const{data:o}=await H.from("user_plan_enrollments").select("id").eq("plan_id",r).eq("relationship_type_id",n).maybeSingle();if(o){const{error:l}=await H.from("user_plan_enrollments").update({active:a}).eq("id",o.id);if(l)throw l}else if(a){const{error:l}=await H.from("user_plan_enrollments").insert({owner_user_id:s,plan_id:r,relationship_type_id:n,active:!0,start_date:new Date().toISOString().split("T")[0]});if(l)throw l}},onSuccess:()=>{t.invalidateQueries({queryKey:["user-plan-enrollments"]}),wn({title:"Plan enrollment updated"})}})},$O=(t=7)=>{const s=ci();return mt({queryKey:["contact-touch-logs",s,t],queryFn:async()=>{const r=new Date;r.setDate(r.getDate()-t);const{data:n,error:a}=await H.from("contact_touch_logs").select(` *, contact:innercircle_contacts(*), action_type:action_types(*) `).eq("owner_user_id",s).gte("completed_at",r.toISOString()).order("completed_at",{ascending:!1});if(a)throw a;return n},enabled:!!s})},KYe=()=>{const t=ci();return mt({queryKey:["contacts-last-touch",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_touch_logs").select("contact_id, completed_at").eq("owner_user_id",t).order("completed_at",{ascending:!1});if(r)throw r;const n={};return s==null||s.forEach(a=>{n[a.contact_id]||(n[a.contact_id]=a.completed_at)}),n},enabled:!!t})},uLt=(t=90)=>{const{data:s}=Gm(),{data:r}=KYe();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=Qt(),s=ci();return Dt({mutationFn:async({contactId:r,actionTypeId:n,scriptUsedId:a,notes:o,completedAt:l})=>{const{data:i,error:c}=await H.from("contact_touch_logs").insert({owner_user_id:s,contact_id:r,action_type_id:n,script_used_id:a,notes:o,completed_at:l||new Date().toISOString()}).select().single();if(c)throw c;return i},onSuccess:async(r,n)=>{var a,o;t.invalidateQueries({queryKey:["contact-touch-logs"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),t.invalidateQueries({queryKey:["today-actions"]}),wn({title:"Action completed!"});try{const[l,i]=await Promise.all([H.from("innercircle_contacts").select("email").eq("id",n.contactId).single(),H.from("action_types").select("name").eq("id",n.actionTypeId).single()]),c=(a=l.data)==null?void 0:a.email,u=((o=i.data)==null?void 0:o.name)||"Touch";c&&H.functions.invoke("boldtrail-sync",{body:{action:"push_touch",contact_email:c,touch_type:u,touch_notes:n.notes||null,touch_date:n.completedAt||r.completed_at}}).catch(()=>{})}catch{}}})},ZYe="agentos_weekly_touch_goal",bIe=20,Koe=()=>{if(typeof window>"u")return bIe;const t=localStorage.getItem(ZYe);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return bIe},YYe=t=>{localStorage.setItem(ZYe,t.toString())},NNe=()=>{const{data:t}=$O(7),s=new Date;s.setHours(0,0,0,0);const r=new Date(s);r.setDate(s.getDate()-s.getDay());const n=(t==null?void 0:t.filter(l=>new Date(l.completed_at)>=r).length)||0;let a=0;if(t&&t.length>0){const l=new Set(t.map(c=>new Date(c.completed_at).toDateString()));let i=new Date(s);for(;l.has(i.toDateString());)a++,i.setDate(i.getDate()-1)}const o=Koe();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},hLt=()=>{const t=ci();return mt({queryKey:["contact-plan-cycles",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_plan_cycles").select(` *, contact:innercircle_contacts(*), plan:touchpoint_plans( *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) ) `);if(r)throw r;return s},enabled:!!t})},mLt=()=>{const t=Qt();return ci(),Dt({mutationFn:async()=>{const{data:s}=await H.from("user_plan_enrollments").select("*").eq("active",!0);if(!s||s.length===0)return;const{data:r}=await H.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(!r)return;const{data:n}=await H.from("contact_plan_cycles").select("contact_id, plan_id"),a=new Set((n==null?void 0:n.map(l=>`${l.contact_id}-${l.plan_id}`))||[]),o=[];for(const l of r)for(const i of l.tags||[]){const c=s.find(u=>u.relationship_type_id===i.relationship_type_id);c&&!a.has(`${l.id}-${c.plan_id}`)&&o.push({contact_id:l.id,plan_id:c.plan_id,relationship_type_id:i.relationship_type_id})}if(o.length>0){const{error:l}=await H.from("contact_plan_cycles").insert(o);if(l)throw l}return o.length},onSuccess:s=>{t.invalidateQueries({queryKey:["contact-plan-cycles"]}),s&&s>0&&wn({title:`${s} contact(s) enrolled in plans`})}})},XYe=()=>{const t=ci(),{data:s}=hLt(),{data:r}=$O(30);return mt({queryKey:["today-actions",t,s==null?void 0:s.length,r==null?void 0:r.length],queryFn:async()=>{var _;if(!s||s.length===0)return[];const{data:n}=await H.from("contact_snoozes").select("contact_id").gte("snoozed_until",new Date().toISOString()),a=new Set((n==null?void 0:n.map(j=>j.contact_id))||[]),o=new Date,l=[],i=new Date(o.getFullYear(),o.getMonth(),1),c=new Set((r==null?void 0:r.filter(j=>new Date(j.completed_at)>=i).map(j=>`${j.contact_id}-${j.action_type_id}`))||[]);for(const j of s){if(!((_=j.plan)!=null&&_.items)||j.plan.items.length===0||!j.contact||a.has(j.contact_id))continue;const w=new Date(j.cycle_start_date),S=Math.floor((o.getTime()-w.getTime())/(30.44*24*60*60*1e3))%12+1,M=j.plan.items.find(L=>L.month_number===S);if(M&&M.action_type){const L=`${j.contact_id}-${M.action_type_id}`;if(!c.has(L)){const{data:I}=await H.from("relationship_types").select("name").eq("id",j.relationship_type_id).single();l.push({contact:j.contact,actionType:M.action_type,script:M.default_script||void 0,planName:j.plan.name,relationshipTypeName:(I==null?void 0:I.name)||"",monthNumber:S})}}}const u=5,p=o.getDate(),f=l.sort((j,w)=>j.contact.first_name.localeCompare(w.contact.first_name)),g=(p-1)%Math.max(1,f.length);return[...f.slice(g),...f.slice(0,g)].slice(0,u)},enabled:!!t&&!!s})};function pLt(){const t=fr(),{data:s,isLoading:r}=XYe(),{data:n}=Gm(),a=NNe(),[o,l]=N.useState(Koe()),[i,c]=N.useState(""),[u,p]=N.useState(!1);N.useEffect(()=>{l(Koe())},[]);const f=()=>{const O=parseInt(i,10);if(isNaN(O)||O<1){wn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(O),YYe(O),p(!1),wn({title:"Goal updated",description:`Weekly touch goal set to ${O}`})},g=()=>{c(o.toString()),p(!0)},b=$m(new Date),_=El(b,7),j=O=>{if(!O)return null;const q=O.split(/[-/T]/);if(q.length<3)return null;const U=parseInt(q[1],10)-1,B=parseInt(q[2],10);return isNaN(U)||isNaN(B)?null:new Date(b.getFullYear(),U,B)},w=(n==null?void 0:n.map(O=>{const q=j(O.birthday),U=j(O.home_anniversary),B=[];return q&&q>=b&&q<=_&&B.push({contact:O,type:"birthday",date:q,isToday:Cl(q,b)}),U&&U>=b&&U<=_&&B.push({contact:O,type:"anniversary",date:U,isToday:Cl(U,b)}),B}).flat().sort((O,q)=>O.date.getTime()-q.date.getTime()).slice(0,3))||[],k=(n==null?void 0:n.filter(O=>{const q=j(O.birthday),U=j(O.home_anniversary);return q&&Cl(q,b)||U&&Cl(U,b)}).length)||0,S=(s==null?void 0:s.length)||0,M=k+S,L=(a==null?void 0:a.actionsThisWeek)||0,I=(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(De,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-primary/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-primary/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-primary/10 rounded w-1/2"})]})]})})}):e.jsxs(Ee,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:[e.jsxs(Pt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5 text-primary"}),"Agent OS"]}),e.jsx("div",{className:"flex items-center gap-2",children:I>0&&e.jsxs(tt,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[e.jsx(eh,{className:"h-3 w-3"}),I," day streak"]})})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[M>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-primary font-medium",children:[M," tasks"]})," for today"]}):"No tasks for today",L>0&&e.jsxs("span",{className:"ml-2",children:["• ",e.jsx("span",{className:"text-emerald-600 font-medium",children:L})," touches this week"]})]})]}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control/contacts?new=true")},children:[e.jsx(Tl,{className:"h-3.5 w-3.5"}),"Add Contact"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control")},children:[e.jsx(Un,{className:"h-3.5 w-3.5"}),"Log Touch"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-emerald-200 text-emerald-700 hover:bg-emerald-50 hover:text-emerald-800",onClick:O=>{O.stopPropagation(),t("/mission-control/video/record")},children:[e.jsx(An,{className:"h-3.5 w-3.5"}),"Quick Video"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control/popbys")},children:[e.jsx(ma,{className:"h-3.5 w-3.5"}),"Pop-by Map"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-purple-200 text-purple-700 hover:bg-purple-50 hover:text-purple-800",onClick:O=>{O.stopPropagation(),t("/mission-control/pipeline")},children:[e.jsx(h0,{className:"h-3.5 w-3.5"}),"Pipeline"]})]}),e.jsxs("div",{className:"pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zm,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Weekly Goal"}),e.jsxs(fs,{open:u,onOpenChange:p,children:[e.jsx(qi,{asChild:!0,children:e.jsx("button",{onClick:g,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(Xo,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})}),e.jsxs(ps,{className:"sm:max-w-[360px]",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Set Weekly Goal"}),e.jsx(Gr,{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(ze,{id:"weekly-goal",type:"number",min:"1",value:i,onChange:O=>c(O.target.value),placeholder:"20",onKeyDown:O=>{O.key==="Enter"&&f()}})]}),e.jsx(K,{onClick:f,className:"w-full",children:"Save Goal"})]})]})]})]}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium text-primary",children:L}),e.jsxs("span",{className:"text-muted-foreground",children:[" / ",o," touches"]})]})]}),e.jsx(Bi,{value:Math.min(L/o*100,100),className:"h-2 bg-muted [&>div]:bg-primary"}),L>=o&&e.jsxs("p",{className:"text-xs text-emerald-600 mt-1.5 flex items-center gap-1",children:[e.jsx("span",{children:"🎉"})," Goal achieved! Keep the momentum going."]}),L0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5",children:[o-L," more to hit your weekly goal"]})]}),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(Ch,{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((O,q)=>e.jsxs("div",{className:`flex items-center justify-between p-2 rounded-lg cursor-pointer transition-colors ${O.isToday?"bg-pink-500/10 hover:bg-pink-500/15":"bg-muted/50 hover:bg-muted"}`,onClick:U=>{U.stopPropagation(),t(`/mission-control/contacts/${O.contact.id}`)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[O.type==="birthday"?e.jsx(Ch,{className:"h-3.5 w-3.5 text-pink-500"}):e.jsx(bn,{className:"h-3.5 w-3.5 text-blue-500"}),e.jsxs("span",{className:"text-sm",children:[O.contact.first_name," ",O.contact.last_name]}),O.isToday&&e.jsx(tt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-pink-500/20 text-pink-600",children:"Today!"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:O.isToday?O.type==="birthday"?"🎂":"🏠":ms(O.date,"EEE, MMM d")}),e.jsx(da,{className:"h-3 w-3"})]})]},`${O.contact.id}-${O.type}-${q}`))})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full gap-1 text-muted-foreground hover:text-primary",onClick:()=>t("/mission-control"),children:["Open Agent OS",e.jsx(Qa,{className:"h-4 w-4"})]})]})]})}function fLt(t){return mt({queryKey:["brokerage-content-categories",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("brokerage_content_categories").select("*").eq("brokerage_id",t).order("sort_order");if(r)throw r;return s},enabled:!!t})}function xLt(t,s){return mt({queryKey:["brokerage-content",t,s],queryFn:async()=>{if(!t)return[];let r=H.from("brokerage_content").select("*, category:brokerage_content_categories(*)").eq("brokerage_id",t).order("created_at",{ascending:!1});s&&(r=r.eq("category_id",s));const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!t})}function gLt(t,s=4){return mt({queryKey:["brokerage-content-recent",t,s],queryFn:async()=>{if(!t)return[];const{data:r,error:n}=await H.from("brokerage_content").select("*, category:brokerage_content_categories(*)").eq("brokerage_id",t).order("created_at",{ascending:!1}).limit(s);if(n)throw n;return r},enabled:!!t})}function yLt(t){const s=Qt();return Dt({mutationFn:async r=>{const{data:n,error:a}=await H.from("brokerage_content").insert(r).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content"]}),s.invalidateQueries({queryKey:["brokerage-content-recent"]})}})}function vLt(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("brokerage_content").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content"]}),t.invalidateQueries({queryKey:["brokerage-content-recent"]})}})}function bLt(t){const s=Qt();return Dt({mutationFn:async r=>{const{data:n,error:a}=await H.from("brokerage_content_categories").insert({...r,brokerage_id:t}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}function _Lt(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("brokerage_content_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}function wLt(t){const s=Qt();return Dt({mutationFn:async()=>{const r=[{name:"Events",icon:"📅",sort_order:0,is_default:!0,brokerage_id:t},{name:"Videos",icon:"🎥",sort_order:1,is_default:!0,brokerage_id:t},{name:"Documents",icon:"📄",sort_order:2,is_default:!0,brokerage_id:t},{name:"Resources",icon:"🔗",sort_order:3,is_default:!0,brokerage_id:t},{name:"Graphics",icon:"🎨",sort_order:4,is_default:!0,brokerage_id:t}],{error:n}=await H.from("brokerage_content_categories").upsert(r,{onConflict:"brokerage_id,name"});if(n)throw n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}const jLt={video:nl,pdf:Sn,link:dl,event:hn,graphic:ac},NLt={video:"bg-red-500/10 text-red-600 dark:text-red-400",pdf:"bg-blue-500/10 text-blue-600 dark:text-blue-400",link:"bg-green-500/10 text-green-600 dark:text-green-400",event:"bg-purple-500/10 text-purple-600 dark:text-purple-400",graphic:"bg-amber-500/10 text-amber-600 dark:text-amber-400"};function kLt(t){if(!t)return null;try{const s=new URL(t),r=s.hostname.replace("www.","");let n=null;if(r==="youtube.com"||r==="m.youtube.com"?n=s.searchParams.get("v"):r==="youtu.be"&&(n=s.pathname.slice(1)),n)return`https://img.youtube.com/vi/${n}/hqdefault.jpg`}catch{}return null}function SLt(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 CLt({item:t}){const s=fr(),r=jLt[t.content_type]||dl,n=NLt[t.content_type]||"",[a,o]=N.useState(null),l=t.thumbnail_url||(t.content_type==="graphic"&&t.file_url?t.file_url:null)||(t.content_type==="video"?kLt(t.url):null);N.useEffect(()=>{l||!t.url||t.content_type!=="video"||!SLt(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(c=>c.ok?c.json():null).then(c=>{c!=null&&c.thumbnail_url&&o(c.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,l]);const i=l||a;return e.jsxs(Ee,{className:"group cursor-pointer overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",onClick:()=>s(`/brokerage-content/${t.id}`),children:[i?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:i,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/20 flex items-center justify-center",children:e.jsx(r,{className:"h-8 w-8 text-muted-foreground/30"})}),e.jsxs(De,{className:"p-3",children:[e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsxs(tt,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${n}`,children:[e.jsx(r,{className:"h-3 w-3 mr-0.5"}),t.content_type]})}),e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:t.title}),t.content_type==="event"&&t.event_date&&e.jsx("p",{className:"text-xs text-primary mt-1 font-medium",children:ms(new Date(t.event_date),"MMM d · h:mm a")})]})]})}function MLt(){const{brokerageId:t}=Ds(),s=fr(),{data:r=[],isLoading:n}=gLt(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(ka,{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(Qa,{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(CLt,{item:a},a.id))})]})}const QYe=()=>mt({queryKey:["listing-exchange-enabled"],queryFn:async()=>{const{data:t,error:s}=await H.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").maybeSingle();if(s)throw s;return(t==null?void 0:t.enabled)??!1}}),JYe=t=>{const{user:s,brokerageId:r}=Ds();return mt({queryKey:["listings",t,r],queryFn:async()=>{let n=H.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("is_public",!0);t!=null&&t.status&&(n=n.eq("status",t.status)),t!=null&&t.propertyType&&(n=n.eq("property_type",t.propertyType)),t!=null&&t.city&&(n=n.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(n=n.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(n=n.lte("price",t.maxPrice)),t!=null&&t.openToReferrals&&(n=n.eq("open_to_referrals",!0));const{data:a,error:o}=await n;if(o)throw o;let l=a||[];if(r){const{data:i}=await H.from("profiles").select("id").eq("brokerage_id",r);if(i&&i.length>0){const c=i.map(f=>f.id);let u=H.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("share_with_brokerage",!0).eq("is_public",!1).in("agent_id",c);t!=null&&t.status&&(u=u.eq("status",t.status)),t!=null&&t.propertyType&&(u=u.eq("property_type",t.propertyType)),t!=null&&t.city&&(u=u.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(u=u.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(u=u.lte("price",t.maxPrice)),t!=null&&t.openToReferrals&&(u=u.eq("open_to_referrals",!0));const{data:p}=await u;if(p){const f=new Set(l.map(b=>b.id)),g=p.filter(b=>!f.has(b.id));l=[...l,...g]}}}switch(t==null?void 0:t.sortBy){case"updated":l.sort((i,c)=>new Date(c.updated_at).getTime()-new Date(i.updated_at).getTime());break;case"price_asc":l.sort((i,c)=>i.price-c.price);break;case"price_desc":l.sort((i,c)=>c.price-i.price);break;default:l.sort((i,c)=>new Date(c.created_at).getTime()-new Date(i.created_at).getTime())}return l}})},eXe=()=>{const{user:t}=Ds();return mt({queryKey:["my-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("listings").select(` *, photos:listing_photos(*) `).eq("agent_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})},tXe=t=>{const{user:s}=Ds();return mt({queryKey:["listing",t],queryFn:async()=>{const{data:r,error:n}=await H.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)), video:agent_videos!listings_video_id_fkey(id, playback_url, thumbnail_url, title, duration_seconds) `).eq("id",t).single();if(n)throw n;return s&&await H.from("listing_views").insert({listing_id:t,viewer_id:s.id}),r},enabled:!!t})},TLt=()=>{const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("listings").insert({...r,agent_id:s.id}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},ALt=()=>{const t=Qt();return Dt({mutationFn:async({agentId:s,...r})=>{const{data:n,error:a}=await H.from("listings").insert({...r,agent_id:s}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]}),t.invalidateQueries({queryKey:["brokerage-listings"]})}})},ELt=()=>{const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("listings").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]}),t.invalidateQueries({queryKey:["listing",s.id]})}})},sXe=()=>{const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("listings").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},PLt=()=>{const t=Qt();return Dt({mutationFn:async({listingId:s,photoUrl:r,isPrimary:n=!1})=>{const{data:a,error:o}=await H.from("listing_photos").insert({listing_id:s,photo_url:r,is_primary:n}).select().single();if(o)throw o;return a},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s.listing_id]}),t.invalidateQueries({queryKey:["my-listings"]})}})},ILt=()=>{const t=Qt();return Dt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await H.from("listing_photos").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s]}),t.invalidateQueries({queryKey:["my-listings"]})}})},LLt=()=>{const t=Qt();return Dt({mutationFn:async({photos:s})=>{var o;const r=s.map(l=>H.from("listing_photos").update({sort_order:l.sort_order,is_primary:l.is_primary}).eq("id",l.id)),a=(o=(await Promise.all(r)).find(l=>l.error))==null?void 0:o.error;if(a)throw a;return s},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["listing"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},DLt=()=>{const t=Qt();return Dt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await H.from("listing_photos").update({is_primary:!1}).eq("listing_id",r);if(n)throw n;const{error:a}=await H.from("listing_photos").update({is_primary:!0}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s]}),t.invalidateQueries({queryKey:["my-listings"]})}})},OLt=()=>{const{user:t}=Ds();return mt({queryKey:["saved-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("listing_saves").select(` *, listing:listings( *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id) ) `).eq("agent_id",t.id);if(r)throw r;return s},enabled:!!t})},rXe=()=>{const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await H.from("listing_saves").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await H.from("listing_saves").delete().eq("id",n.id),{saved:!1}):(await H.from("listing_saves").insert({listing_id:r,agent_id:s.id}),{saved:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["saved-listings"]}),t.invalidateQueries({queryKey:["listings"]})}})},nXe=t=>{const{user:s}=Ds();return mt({queryKey:["listing-saved",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await H.from("listing_saves").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},RLt=()=>{const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await H.from("listing_follows").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await H.from("listing_follows").delete().eq("id",n.id),{following:!1}):(await H.from("listing_follows").insert({listing_id:r,agent_id:s.id}),{following:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["listing-following"]})}})},FLt=t=>{const{user:s}=Ds();return mt({queryKey:["listing-following",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await H.from("listing_follows").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},zLt=()=>{const{user:t}=Ds();return Dt({mutationFn:async({listingId:s,shareType:r})=>{if(!t)throw new Error("Not authenticated");const{error:n}=await H.from("listing_shares").insert({listing_id:s,sharing_agent_id:t.id,share_type:r});if(n)throw n}})},BLt=()=>{const{user:t}=Ds();return mt({queryKey:["my-referrals",t==null?void 0:t.id],queryFn:async()=>{if(!t)return{sent:[],received:[]};const[s,r]=await Promise.all([H.from("listing_referrals").select(` *, listing:listings(*,photos:listing_photos(*)) `).eq("sender_agent_id",t.id).order("created_at",{ascending:!1}),H.from("listing_referrals").select(` *, sender:profiles!listing_referrals_sender_agent_id_fkey(id, name, email), listing:listings(*,photos:listing_photos(*)) `).eq("listing_agent_id",t.id).order("created_at",{ascending:!1})]);return{sent:s.data||[],received:r.data||[]}},enabled:!!t})},$Lt=()=>{const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async({listingId:r,listingAgentId:n,buyerName:a,buyerType:o,notes:l})=>{if(!s)throw new Error("Not authenticated");const{data:i,error:c}=await H.from("listing_referrals").insert({listing_id:r,sender_agent_id:s.id,listing_agent_id:n,buyer_name:a,buyer_type:o,notes:l}).select().single();if(c)throw c;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["my-referrals"]})}})},qLt=()=>mt({queryKey:["listing-leaderboard"],queryFn:async()=>{const{data:t}=await H.from("listing_shares").select("sharing_agent_id, profiles!listing_shares_agent_id_fkey(name)").order("created_at",{ascending:!1}),s=new Map;t==null||t.forEach(l=>{var u;const i=l.sharing_agent_id;if(!i)return;const c=s.get(i);c?c.count++:s.set(i,{name:((u=l.profiles)==null?void 0:u.name)||"Unknown",count:1})});const r=Array.from(s.entries()).map(([l,i])=>({agentId:l,...i})).sort((l,i)=>i.count-l.count).slice(0,10),{data:n}=await H.from("listings").select("agent_id, agent:profiles!listings_agent_id_fkey(name)").eq("is_approved",!0),a=new Map;n==null||n.forEach(l=>{var c;const i=a.get(l.agent_id);i?i.count++:a.set(l.agent_id,{name:((c=l.agent)==null?void 0:c.name)||"Unknown",count:1})});const o=Array.from(a.entries()).map(([l,i])=>({agentId:l,...i})).sort((l,i)=>i.count-l.count).slice(0,10);return{topSharers:r,topListers:o}}}),ULt=()=>{const{user:t,brokerageId:s}=Ds();return mt({queryKey:["brokerage-listings",s],queryFn:async()=>{if(!t||!s)return[];const{data:r}=await H.from("profiles").select("id").eq("brokerage_id",s);if(!r||r.length===0)return[];const n=r.map(l=>l.id),{data:a,error:o}=await H.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).in("agent_id",n).eq("is_approved",!0).order("created_at",{ascending:!1});if(o)throw o;return a},enabled:!!t&&!!s})},aXe=({className:t,variant:s="default"})=>e.jsx(tt,{variant:"outline",className:It("text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0 h-4",s==="default"?"border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10":"border-muted-foreground/30 text-muted-foreground",t),children:"Beta"}),VLt={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"},HLt={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function WLt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function GLt(){const t=fr(),{data:s,isLoading:r}=QYe(),{data:n,isLoading:a}=JYe({status:void 0,propertyType:void 0,sortBy:"newest"}),o=(n==null?void 0:n.filter(p=>p.is_approved&&p.is_public))||[],l=o.filter(p=>p.is_featured),i=o.filter(p=>!p.is_featured),c=[...l,...i].slice(0,6),u=r||a;return!u&&!s?null:u?e.jsx(Ee,{className:"bg-gradient-to-br from-emerald-500/5 via-emerald-500/10 to-emerald-500/5 border-emerald-500/20",children:e.jsx(De,{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(aXe,{})]}),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(Qa,{className:"h-4 w-4"})]})]}),c.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(bn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No listings available yet"}),e.jsx(K,{variant:"link",size:"sm",onClick:()=>t("/mission-control/listings/new"),className:"mt-2",children:"Add the first listing"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:c.map(p=>{var g,b;const f=((g=p.photos)==null?void 0:g.find(_=>_.is_primary))||((b=p.photos)==null?void 0:b[0]);return e.jsxs("div",{onClick:()=>t(`/mission-control/listings/${p.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"aspect-[4/3] bg-muted/50 overflow-hidden relative",children:[f!=null&&f.photo_url?e.jsx("img",{src:f.photo_url,alt:`${p.city}, ${p.state}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(bn,{className:"h-8 w-8 text-muted-foreground/50"})}),p.is_featured&&e.jsx("div",{className:"absolute top-1.5 left-1.5",children:e.jsxs(tt,{className:"gap-1 bg-amber-500 text-white border-0 text-[10px] px-1.5 py-0.5",children:[e.jsx(Jn,{className:"h-2.5 w-2.5 fill-current"}),"Featured"]})}),e.jsx("div",{className:"absolute top-1.5 right-1.5",children:e.jsx(tt,{className:`text-[10px] px-1.5 py-0.5 ${VLt[p.status]}`,children:HLt[p.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:WLt(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 iXe(t=10,s){return mt({queryKey:["event-leaderboard",t,s],queryFn:async()=>{const{data:r}=await H.from("user_roles").select("user_id").eq("role","admin"),n=new Set((r==null?void 0:r.map(g=>g.user_id))||[]);let a=null;if(s){const{data:g}=await H.from("profiles").select("id").eq("brokerage_id",s);a=new Set((g==null?void 0:g.map(b=>b.id))||[])}const{data:o,error:l}=await H.from("agent_attendance_stats").select("user_id, total_points, total_events_attended, current_streak").order("total_points",{ascending:!1}).limit(t+n.size+50);if(l)throw l;if(!o||o.length===0)return[];let i=o.filter(g=>!n.has(g.user_id));a&&(i=i.filter(g=>a.has(g.user_id)));const c=i.slice(0,t),u=c.map(g=>g.user_id),{data:p}=await H.from("profiles").select("id, name").in("id",u),f=new Map((p==null?void 0:p.map(g=>[g.id,{name:g.name}]))||[]);return c.map(g=>({user_id:g.user_id,total_points:g.total_points,total_events_attended:g.total_events_attended,current_streak:g.current_streak,profile:f.get(g.user_id)||null}))}})}function oXe(t){return mt({queryKey:["user-attendance-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("agent_attendance_stats").select("*").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return s},enabled:!!t})}function lXe(t){return mt({queryKey:["user-badges",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("agent_badges").select("*").eq("user_id",t).order("earned_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function cXe(t,s){return mt({queryKey:["user-rank",t,s],queryFn:async()=>{if(!t)return null;const{data:r}=await H.from("agent_attendance_stats").select("total_points").eq("user_id",t).single();if(!r)return null;const{data:n}=await H.from("user_roles").select("user_id").eq("role","admin"),a=new Set((n==null?void 0:n.map(c=>c.user_id))||[]),{data:o,error:l}=await H.from("agent_attendance_stats").select("user_id, total_points").gt("total_points",r.total_points);if(l)throw l;let i=(o==null?void 0:o.filter(c=>!a.has(c.user_id)))||[];if(s){const{data:c}=await H.from("profiles").select("id").eq("brokerage_id",s),u=new Set((c==null?void 0:c.map(p=>p.id))||[]);i=i.filter(p=>u.has(p.user_id))}return i.length+1},enabled:!!t})}function KLt(){const{user:t,brokerageId:s,isAdmin:r}=Ds();fr();const n=!!s,[a,o]=N.useState("brokerage"),l=()=>{if(r)return null;if(n)return a==="global"?null:s},{data:i,isLoading:c}=iXe(5,l()),{data:u}=oXe(t==null?void 0:t.id),{data:p}=cXe(t==null?void 0:t.id,l()),{data:f}=lXe(t==null?void 0:t.id),g=r||n,b=()=>r?"Agent Leaderboard":n?a==="global"?"All LevelUp":"My Brokerage":"My Points";if(c)return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(xo,{className:"h-4 w-4 text-yellow-500"}),b()]})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-2",children:[...Array(g?5:3)].map((j,w)=>e.jsx(ys,{className:"h-10 w-full"},w))})})]});const _=j=>j===0?e.jsx(xo,{className:"h-4 w-4 text-yellow-500 mx-auto"}):j===1?e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"2"}):j===2?e.jsx("span",{className:"text-sm font-medium text-amber-600",children:"3"}):e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:j+1});if(g){const j=(i==null?void 0:i.slice(0,5))||[];return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"pb-2",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(xo,{className:"h-4 w-4 text-yellow-500"}),b()]}),!r&&n&&e.jsxs("div",{className:"flex gap-1 mt-2",children:[e.jsx(K,{variant:a==="brokerage"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("brokerage"),children:"My Brokerage"}),e.jsx(K,{variant:a==="global"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("global"),children:"All LevelUp"})]})]}),e.jsxs(De,{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,k)=>{var S,M,L;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":k===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:_(k)}),e.jsx(Nn,{className:"h-6 w-6",children:e.jsx(kn,{className:"text-xs",children:((M=(S=w.profile)==null?void 0:S.name)==null?void 0:M.charAt(0))||"?"})}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((L=w.profile)==null?void 0:L.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(Pi,{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(ko,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(da,{className:"h-4 w-4"})]})]})]})}return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(xo,{className:"h-4 w-4 text-yellow-500"}),"My Points"]})}),e.jsx(De,{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(eh,{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(Nc,{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(Pi,{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(ko,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(da,{className:"h-4 w-4"})]})]}):e.jsxs("div",{className:"text-center text-muted-foreground py-4 text-sm",children:[e.jsx(Jn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{children:"Attend events to earn points!"}),e.jsxs(Pi,{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(ko,{className:"h-4 w-4"}),"Visit Reward Store",e.jsx(da,{className:"h-4 w-4"})]})]})})]})}const sE=()=>mt({queryKey:["lead-sources"],queryFn:async()=>{const{data:t,error:s}=await H.from("lead_sources").select("*").eq("is_active",!0).order("sort_order");if(s)throw s;return t}}),kNe=()=>{const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async r=>{const{data:n}=await H.from("lead_sources").select("id, name").eq("is_active",!0).ilike("name",r.trim()),a=(n||[]).find(i=>i.name.toLowerCase()===r.trim().toLowerCase()&&!0);if(a)throw new Error(`Lead source "${a.name}" already exists`);const{data:o,error:l}=await H.from("lead_sources").insert({name:r,owner_user_id:s==null?void 0:s.id,sort_order:100}).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),me.success("Lead source added")},onError:r=>{me.error("Failed to add lead source"),console.error(r)}})},ZLt=()=>{const t=Qt();return Dt({mutationFn:async({id:s,name:r})=>{const{error:n}=await H.from("lead_sources").update({name:r}).eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),me.success("Lead source updated")},onError:s=>{me.error(s.message||"Failed to update lead source")}})},YLt=()=>{const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("lead_sources").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),me.success("Lead source removed")},onError:s=>{me.error(s.message||"Failed to remove lead source")}})},SNe=(t,s)=>{const{user:r,isAdmin:n}=Ds(),a=n&&s?s:r==null?void 0:r.id;return mt({queryKey:["scorecard-transactions",t,a],queryFn:async()=>{let o=H.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).eq("owner_user_id",a).order("close_date",{ascending:!1});t&&(o=o.gte("close_date",`${t}-01-01`).lte("close_date",`${t}-12-31`));const{data:l,error:i}=await o;if(i)throw i;return l},enabled:!!a})},CNe=t=>{const{user:s,isAdmin:r}=Ds(),n=r&&t?t:s==null?void 0:s.id;return mt({queryKey:["scorecard-transactions-all",n],queryFn:async()=>{const{data:a,error:o}=await H.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).eq("owner_user_id",n).order("close_date",{ascending:!1});if(o)throw o;return a},enabled:!!n})},wue=()=>{const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async r=>{const{data:n,error:a}=await H.from("scorecard_transactions").insert({...r,owner_user_id:s.id}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),me.success("Transaction added")},onError:r=>{me.error("Failed to add transaction"),console.error(r)}})},XLt=()=>{const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("scorecard_transactions").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),me.success("Transaction updated")},onError:s=>{me.error("Failed to update transaction"),console.error(s)}})},QLt=()=>{const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("scorecard_transactions").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),me.success("Transaction deleted")},onError:s=>{me.error("Failed to delete transaction"),console.error(s)}})},dXe=(t,s)=>{const{user:r,isAdmin:n}=Ds(),a=n&&s?s:r==null?void 0:r.id;return mt({queryKey:["scorecard-goals",t,a],queryFn:async()=>{const{data:o,error:l}=await H.from("scorecard_goals").select("*").eq("owner_user_id",a).eq("year",t).maybeSingle();if(l)throw l;return o},enabled:!!a})},JLt=()=>{const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async r=>{const{data:n,error:a}=await H.from("scorecard_goals").upsert({...r,owner_user_id:s.id},{onConflict:"owner_user_id,year"}).select().single();if(a)throw a;return n},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["scorecard-goals",n.year]}),me.success("Goals saved")},onError:r=>{me.error("Failed to save goals"),console.error(r)}})},jue=()=>{const{user:t}=Ds();return mt({queryKey:["scorecard-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("scorecard_settings").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s},enabled:!!(t!=null&&t.id)})},e8t=()=>{const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async r=>{const{data:n,error:a}=await H.from("scorecard_settings").upsert({...r,user_id:s.id},{onConflict:"user_id"}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-settings"]}),me.success("Settings saved")},onError:r=>{me.error("Failed to save settings"),console.error(r)}})},uXe=(t,s)=>{const{data:r,isLoading:n}=SNe(t,s),{data:a,isLoading:o}=CNe(s),{data:l}=jue(),i=(l==null?void 0:l.show_commission)??!0,c=u=>{if(!u||u.length===0)return{totalTransactions:0,buyerCount:0,sellerCount:0,totalVolume:0,averagePrice:0,totalCommission:0,totalNetToAgent:0,topLeadSource:null,transactionsByMonth:[],leadSourceBreakdown:[]};const p=u.filter(I=>I.transaction_type==="buyer").length,f=u.filter(I=>I.transaction_type==="seller").length,g=u.reduce((I,O)=>I+Number(O.sale_price),0),b=u.reduce((I,O)=>I+(Number(O.commission_amount)||0),0),_=u.reduce((I,O)=>{const q=Number(O.commission_amount)||0;if(!q)return I;let U=q;return O.brokerage_split_pct&&(U-=q*(O.brokerage_split_pct/100)),O.team_split_pct&&(U-=q*(O.team_split_pct/100)),O.franchise_fee_pct&&(U-=q*(O.franchise_fee_pct/100)),O.referral_fee_pct&&(U-=q*(O.referral_fee_pct/100)),O.transaction_fee&&(U-=O.transaction_fee),I+Math.max(0,U)},0),j={};u.forEach(I=>{var q;const O=((q=I.lead_source)==null?void 0:q.name)||"Unknown";j[O]=(j[O]||0)+1});const w=Object.entries(j).map(([I,O])=>({name:I,count:O})).sort((I,O)=>O.count-I.count),k=w[0]||null,S={};u.forEach(I=>{const O=Dl(I.close_date).toLocaleString("default",{month:"short"});S[O]=(S[O]||0)+1});const L=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(I=>({month:I,count:S[I]||0}));return{totalTransactions:u.length,buyerCount:p,sellerCount:f,totalVolume:g,averagePrice:u.length>0?g/u.length:0,totalCommission:i?b:0,totalNetToAgent:i?_:0,topLeadSource:k,transactionsByMonth:L,leadSourceBreakdown:w}};return{yearStats:c(r),lifetimeStats:c(a),isLoading:n||o,showCommission:i}},t8t=()=>{const{isAdmin:t}=Ds();return mt({queryKey:["agents-with-transactions"],queryFn:async()=>{const{data:s,error:r}=await H.from("scorecard_transactions").select("owner_user_id").order("owner_user_id");if(r)throw r;const n=[...new Set(s.map(l=>l.owner_user_id))],{data:a,error:o}=await H.from("profiles").select("id, name, email").in("id",n);if(o)throw o;return a},enabled:t})},Gb={recency:40,touchpoints:30,transactions:20},_Ie={warm:70,cooling:40};function s8t(t){return t===null?0:t<=14?Gb.recency:t<=30?Gb.recency*.85:t<=60?Gb.recency*.65:t<=90?Gb.recency*.4:t<=180?Gb.recency*.2:Gb.recency*.05}function r8t(t){const s=Math.min(t/12,1);return Math.round(Gb.touchpoints*s)}function n8t(t){return t?Gb.transactions:0}function a8t(){return 0}function i8t(t){return t>=_Ie.warm?"warm":t>=_Ie.cooling?"cooling":"at-risk"}function Nue(){const{data:t,isLoading:s}=Gm(),{data:r}=KYe(),{data:n}=$O(365),{data:a}=CNe(),o=N.useMemo(()=>{if(!t)return[];const i=new Date,c=y4(i,12),u={};n==null||n.forEach(f=>{new Date(f.completed_at)>=c&&(u[f.contact_id]=(u[f.contact_id]||0)+1)});const p=new Set((a==null?void 0:a.filter(f=>f.contact_id).map(f=>f.contact_id))||[]);return t.map(f=>{const g=(r==null?void 0:r[f.id])||null,b=g?oy(i,new Date(g)):null,_=u[f.id]||0,j=p.has(f.id),w=s8t(b),k=r8t(_),S=n8t(j),M=a8t(),L=Math.round(w+k+S+M),I={score:L,status:i8t(L),breakdown:{recency:Math.round(w),touchpoints:Math.round(k),transactions:Math.round(S),referrals:Math.round(M)},lastTouchDate:g,daysSinceTouch:b,touchCountLast12Months:_,hasTransaction:j};return{...f,relationshipScore:I}})},[t,r,n,a]),l=N.useMemo(()=>{const i=o.filter(g=>g.relationshipScore.status==="warm").length,c=o.filter(g=>g.relationshipScore.status==="cooling").length,u=o.filter(g=>g.relationshipScore.status==="at-risk").length,p=o.length,f=p>0?Math.round(o.reduce((g,b)=>g+b.relationshipScore.score,0)/p):0;return{warm:i,cooling:c,atRisk:u,total:p,averageScore:f}},[o]);return{contactsWithScores:o,stats:l,isLoading:s}}function hXe(){const t=fr(),{stats:s,contactsWithScores:r,isLoading:n}=Nue();if(n)return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(ys,{className:"h-5 w-40"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsx(ys,{className:"h-20 w-full"}),e.jsx(ys,{className:"h-16 w-full"})]})]});if(s.total===0)return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"Relationship Health"]})}),e.jsxs(De,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add contacts to see your relationship health scores."}),e.jsx(K,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>t("/mission-control/contacts?new=true"),children:"Add Your First Contact"})]})]});const a=Math.round(s.warm/s.total*100),o=Math.round(s.cooling/s.total*100),l=Math.round(s.atRisk/s.total*100),i=r.filter(c=>c.relationshipScore.status==="at-risk").sort((c,u)=>c.relationshipScore.score-u.relationshipScore.score).slice(0,3);return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(ul,{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(De,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-emerald-500"}),e.jsx("span",{children:"Warm"})]}),e.jsxs("span",{className:"font-medium",children:[s.warm," (",a,"%)"]})]}),e.jsx(Bi,{value:a,className:"h-2 bg-muted [&>div]:bg-emerald-500"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-amber-500"}),e.jsx("span",{children:"Cooling Off"})]}),e.jsxs("span",{className:"font-medium",children:[s.cooling," (",o,"%)"]})]}),e.jsx(Bi,{value:o,className:"h-2 bg-muted [&>div]:bg-amber-500"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-red-500"}),e.jsx("span",{children:"At Risk"})]}),e.jsxs("span",{className:"font-medium",children:[s.atRisk," (",l,"%)"]})]}),e.jsx(Bi,{value:l,className:"h-2 bg-muted [&>div]:bg-red-500"})]})]}),i.length>0&&e.jsxs("div",{className:"pt-3 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(pS,{className:"h-4 w-4 text-red-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Needs Attention"})]}),e.jsx("div",{className:"space-y-2",children:i.map(c=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-red-500/5 hover:bg-red-500/10 cursor-pointer transition-colors",onClick:()=>t(`/mission-control/contacts/${c.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),e.jsxs("span",{className:"text-sm",children:[c.first_name," ",c.last_name]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:c.relationshipScore.daysSinceTouch===null?"Never":`${c.relationshipScore.daysSinceTouch}d`}),e.jsx(da,{className:"h-3 w-3"})]})]},c.id))})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t("/mission-control/contacts?filter=at-risk"),children:["View All At-Risk Contacts",e.jsx(da,{className:"h-4 w-4 ml-1"})]})]})]})}const o8t=()=>{var re;const{user:t,isAdmin:s}=Ds(),r=fr(),[n,a]=N.useState([]),[o,l]=N.useState([]),[i,c]=N.useState([]),[u,p]=N.useState([]),[f,g]=N.useState([]),[b,_]=N.useState([]),[j,w]=N.useState(new Set),[k,S]=N.useState([]),[M,L]=N.useState([]),[I,O]=N.useState([]),[q,U]=N.useState(null),[B,V]=N.useState(!0);N.useEffect(()=>{Z()},[t]);const Z=async()=>{var oe,ce,xe,ge,ue;try{const[pe,be,Me,Ne,Pe,Oe,Te,ke,Be,nt,Ae]=await Promise.all([H.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),H.from("app_tiles").select("*").order("name"),H.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),H.from("events").select("*").order("event_date",{ascending:!0}),H.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",t==null?void 0:t.id),H.from("canva_templates").select("id, name, preview_image_url, publish_date").order("publish_date",{ascending:!1}).limit(4),H.from("resource_kits").select("id, name, description, featured_image_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),H.from("academy_videos").select("id, title, description, thumbnail_url, duration, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),H.from("additional_services").select("id, name, description, preview_image_url, signup_link_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),H.from("dashboard_banners").select("id, title, description, image_url, link_url, link_text, placement, section_after").eq("is_active",!0).order("sort_order"),H.from("profiles").select("name").eq("id",t==null?void 0:t.id).single()]);(oe=Ae.data)!=null&&oe.name&&U(Ae.data.name);const ft=((ce=pe.data)==null?void 0:ce.map(rt=>rt.tag))||[],fe=new Set(((xe=Me.data)==null?void 0:xe.map(rt=>rt.app_id))||[]);w(fe);const at=(((ge=be.data)==null?void 0:ge.filter(rt=>!rt.required_tags||rt.required_tags.length===0?!0:rt.required_tags.some(Ge=>ft.includes(Ge))))||[]).sort((rt,Ge)=>rt.name==="LevelUp Members Portal"?-1:Ge.name==="LevelUp Members Portal"?1:0);a(at.slice(0,6));const et=((ue=Ne.data)==null?void 0:ue.filter(rt=>QM(rt.event_date)!=="ended"))||[];l(et.slice(0,4)),S(Pe.data||[]),c(Oe.data||[]),p(Te.data||[]),g(ke.data||[]),_(Be.data||[]);const Ce=nt.data||[];L(Ce.filter(rt=>rt.placement==="top")),O(Ce.filter(rt=>rt.placement==="between"))}catch(pe){console.error("Error loading dashboard:",pe),me.error("Failed to load dashboard data")}finally{V(!1)}},X=async oe=>{var xe;const ce=window.open("about:blank","_blank");try{await H.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:oe.app_id,app_name:oe.name,user_agent:navigator.userAgent});const{data:ge,error:ue}=await H.functions.invoke("sso-launch",{body:{app_id:oe.app_id}});if(ue)throw ue;ge!=null&&ge.redirect_url?ce&&!ce.closed?(ce.location.href=ge.redirect_url,(xe=ce.focus)==null||xe.call(ce)):window.location.assign(ge.redirect_url):(ce==null||ce.close(),me.error("Launch link unavailable"))}catch(ge){ce==null||ce.close(),console.error("Error launching app:",ge),me.error("Failed to launch app")}},ee=oe=>k==null?void 0:k.some(ce=>ce.event_id===oe),Q=oe=>{const ce=k==null?void 0:k.find(xe=>xe.event_id===oe);return ce==null?void 0:ce.zoom_join_url};if(B)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 ie=oe=>I.filter(ce=>ce.section_after===oe);return e.jsxs(Ms,{title:"Dashboard",children:[e.jsx(qIt,{events:o,registrations:k,onNavigateToEvents:()=>r("/events")}),M.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(KP,{banners:M})}),e.jsx(JIt,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",(q||((re=t==null?void 0:t.user_metadata)==null?void 0:re.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(pLt,{}),e.jsx(hXe,{}),e.jsx(KLt,{})]}),e.jsx(MLt,{}),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(Qa,{className:"h-4 w-4"})]})]}),o.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming events"})]})})}):e.jsx("div",{className:"bg-card rounded-xl border border-border overflow-hidden divide-y divide-border max-w-full",children:o.map(oe=>{const ce=ee(oe.id),xe=Q(oe.id)||oe.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 ${gIe(oe.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[gIe(oe.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(d1,{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(oe.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(oe.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:oe.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(oe.event_date))," at ",nD(new Date(oe.event_date))]})]}),e.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:ce?e.jsxs(K,{size:"sm",variant:"default",className:"gap-1",onClick:ge=>{ge.stopPropagation(),window.open(xe,"_blank")},children:[e.jsx(tn,{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(da,{className:"h-4 w-4"})]})})]},oe.id)})})]}),ie("events").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(KP,{banners:ie("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(Qa,{className:"h-4 w-4"})]})]}),f.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(pp,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No academy videos available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:f.map(oe=>e.jsxs("div",{onClick:()=>r(`/academy/${oe.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:[oe.thumbnail_url?e.jsx("img",{src:oe.thumbnail_url,alt:oe.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(pp,{className:"h-8 w-8 text-muted-foreground/50"})}),oe.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:oe.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:oe.title})})]},oe.id))})]}),ie("academy").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(KP,{banners:ie("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(Qa,{className:"h-4 w-4"})]})]}),u.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Om,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No resource kits available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:u.map(oe=>e.jsxs("div",{onClick:()=>r(`/toolbox/${oe.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:oe.featured_image_url?e.jsx("img",{src:oe.featured_image_url,alt:oe.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Om,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:oe.name})})]},oe.id))})]}),ie("toolbox").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(KP,{banners:ie("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(Qa,{className:"h-4 w-4"})]})]}),i.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(F_,{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(oe=>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:oe.preview_image_url?e.jsx("img",{src:oe.preview_image_url,alt:oe.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(F_,{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:oe.name})})]},oe.id))})]}),ie("templates").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(KP,{banners:ie("templates")})}),e.jsx("div",{className:"mb-10",children:e.jsx(GLt,{})}),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(Qa,{className:"h-4 w-4"})]})]}),n.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(De,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Nx,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No apps available"})]})})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:n.map(oe=>{const ce=j.has(oe.id);return e.jsxs("div",{onClick:()=>X(oe),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:oe.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:oe.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:oe.description})]}),ce&&e.jsx(Nx,{className:"h-5 w-5 text-primary fill-current flex-shrink-0"})]},oe.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(Qa,{className:"h-4 w-4"})]})]}),b.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(pn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional services available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:b.map(oe=>e.jsxs("div",{onClick:()=>window.open(oe.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:oe.preview_image_url?e.jsx("img",{src:oe.preview_image_url,alt:oe.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(pn,{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:oe.name}),oe.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:oe.description})]})]},oe.id))})]})]})};var mXe="AlertDialog",[l8t]=ad(mXe,[YHe]),B1=YHe(),pXe=t=>{const{__scopeAlertDialog:s,...r}=t,n=B1(s);return e.jsx(qde,{...n,...r,modal:!0})};pXe.displayName=mXe;var c8t="AlertDialogTrigger",fXe=N.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=B1(r);return e.jsx(oje,{...a,...n,ref:s})});fXe.displayName=c8t;var d8t="AlertDialogPortal",xXe=t=>{const{__scopeAlertDialog:s,...r}=t,n=B1(s);return e.jsx(Ude,{...n,...r})};xXe.displayName=d8t;var u8t="AlertDialogOverlay",gXe=N.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=B1(r);return e.jsx(GA,{...a,...n,ref:s})});gXe.displayName=u8t;var JM="AlertDialogContent",[h8t,m8t]=l8t(JM),p8t=I$e("AlertDialogContent"),yXe=N.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=B1(r),l=N.useRef(null),i=qa(s,l),c=N.useRef(null);return e.jsx(dNt,{contentName:JM,titleName:vXe,docsSlug:"alert-dialog",children:e.jsx(h8t,{scope:r,cancelRef:c,children:e.jsxs(KA,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:Ir(a.onOpenAutoFocus,u=>{var p;u.preventDefault(),(p=c.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[e.jsx(p8t,{children:n}),e.jsx(x8t,{contentRef:l})]})})})});yXe.displayName=JM;var vXe="AlertDialogTitle",bXe=N.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=B1(r);return e.jsx(MO,{...a,...n,ref:s})});bXe.displayName=vXe;var _Xe="AlertDialogDescription",wXe=N.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=B1(r);return e.jsx(TO,{...a,...n,ref:s})});wXe.displayName=_Xe;var f8t="AlertDialogAction",jXe=N.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=B1(r);return e.jsx(AO,{...a,...n,ref:s})});jXe.displayName=f8t;var NXe="AlertDialogCancel",kXe=N.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=m8t(NXe,r),o=B1(r),l=qa(s,a);return e.jsx(AO,{...o,...n,ref:l})});kXe.displayName=NXe;var x8t=({contentRef:t})=>{const s=`\`${JM}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${JM}\` by passing a \`${_Xe}\` 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 \`${JM}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return N.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},g8t=pXe,y8t=fXe,v8t=xXe,SXe=gXe,CXe=yXe,MXe=jXe,TXe=kXe,AXe=bXe,EXe=wXe;const kc=g8t,Cm=y8t,b8t=v8t,PXe=N.forwardRef(({className:t,...s},r)=>e.jsx(SXe,{className:It("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));PXe.displayName=SXe.displayName;const Xl=N.forwardRef(({className:t,...s},r)=>e.jsxs(b8t,{children:[e.jsx(PXe,{}),e.jsx(CXe,{ref:r,className:It("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s})]}));Xl.displayName=CXe.displayName;const Ql=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col space-y-2 text-center sm:text-left",t),...s});Ql.displayName="AlertDialogHeader";const Jl=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});Jl.displayName="AlertDialogFooter";const ec=N.forwardRef(({className:t,...s},r)=>e.jsx(AXe,{ref:r,className:It("text-lg font-semibold",t),...s}));ec.displayName=AXe.displayName;const tc=N.forwardRef(({className:t,...s},r)=>e.jsx(EXe,{ref:r,className:It("text-sm text-muted-foreground",t),...s}));tc.displayName=EXe.displayName;const Ol=N.forwardRef(({className:t,...s},r)=>e.jsx(MXe,{ref:r,className:It(K8(),t),...s}));Ol.displayName=MXe.displayName;const sc=N.forwardRef(({className:t,...s},r)=>e.jsx(TXe,{ref:r,className:It(K8({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));sc.displayName=TXe.displayName;const _8t=[{key:"contacts",label:"Contacts",icon:Un,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:rS,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:Om,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:An,description:"View and upload videos"},{key:"listings",label:"Listings",icon:bn,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:R_,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:ma,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:Cx,description:"Create and edit digital business card"},{key:"guest_book",label:"Guest Book",icon:Sh,description:"Manage open house guest books"},{key:"presentations",label:"Presentations",icon:Jg,description:"Create and manage smart presentations"}];function w8t(){var q;const{user:t}=Ds(),[s,r]=N.useState([]),[n,a]=N.useState(!0),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState(null),[f,g]=N.useState({email:"",name:"",password:""}),[b,_]=N.useState("create"),[j,w]=N.useState(!1),[k,S]=N.useState(null);N.useEffect(()=>{t&&M()},[t]);const M=async()=>{if(t){a(!0);try{const{data:U,error:B}=await H.from("agent_assistant_assignments").select("id, assistant_id, permissions, created_at").eq("agent_id",t.id);if(B)throw B;if(U&&U.length>0){const V=U.map(ee=>ee.assistant_id),{data:Z}=await H.from("profiles").select("id, name, email").in("id",V),X=U.map(ee=>{const Q=Z==null?void 0:Z.find(ie=>ie.id===ee.assistant_id);return{...ee,permissions:ee.permissions,assistant_profile:Q?{name:Q.name||"",email:Q.email||""}:void 0}});r(X)}else r([])}catch(U){console.error("Error loading assistants:",U)}finally{a(!1)}}},L=async()=>{if(t){if(b==="link"){if(!f.email.trim()){me.error("Please enter the assistant's email");return}w(!0);try{const{data:{session:U}}=await H.auth.getSession();if(!U)throw new Error("Not authenticated");const{data:B,error:V}=await H.from("profiles").select("id, name, email").eq("email",f.email.trim().toLowerCase()).single();if(V||!B){me.error("No account found with that email. Try creating a new assistant instead.");return}const{data:Z}=await H.from("agent_assistant_assignments").select("id").eq("agent_id",t.id).eq("assistant_id",B.id);if(Z&&Z.length>0){me.error("This assistant is already assigned to you");return}const X=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U.access_token}`},body:JSON.stringify({userId:B.id,role:"assistant",action:"add",agentId:t.id})}),ee=await X.json();if(!X.ok)throw new Error(ee.error||"Failed to assign assistant role");const{error:Q}=await H.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:B.id,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(Q)throw Q;me.success(`${B.name||B.email} linked as your assistant`),l(!1),g({email:"",name:"",password:""}),M()}catch(U){console.error("Error linking assistant:",U),me.error(U.message||"Failed to link assistant")}finally{w(!1)}return}if(!f.email.trim()||!f.name.trim()||!f.password.trim()){me.error("Please fill in all fields");return}if(f.password.length<6){me.error("Password must be at least 6 characters");return}w(!0);try{const{data:{session:U}}=await H.auth.getSession();if(!U)throw new Error("Not authenticated");const B=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U.access_token}`},body:JSON.stringify({email:f.email.trim(),password:f.password,name:f.name.trim(),purpose:"assistant"})}),V=await B.json();if(!B.ok)throw new Error(V.error||"Failed to create assistant account");const Z=V.userId||V.id;if(!Z)throw new Error("No user ID returned");const X=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U.access_token}`},body:JSON.stringify({userId:Z,role:"assistant",action:"add",agentId:t.id})}),ee=await X.json();if(!X.ok)throw new Error(ee.error||"Failed to assign assistant role");const{error:Q}=await H.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:Z,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(Q)throw Q;me.success(`Assistant account created for ${f.name.trim()}`),l(!1),g({email:"",name:"",password:""}),M()}catch(U){console.error("Error adding assistant:",U),me.error(U.message||"Failed to add assistant")}finally{w(!1)}}},I=async()=>{if(!(!u||!t))try{const{data:{session:U}}=await H.auth.getSession();if(!U)throw new Error("Not authenticated");const{error:B}=await H.from("agent_assistant_assignments").delete().eq("id",u.id);if(B)throw B;const{data:V}=await H.from("agent_assistant_assignments").select("id").eq("assistant_id",u.assistant_id);(!V||V.length===0)&&await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U.access_token}`},body:JSON.stringify({userId:u.assistant_id,role:"assistant",action:"remove"})}),me.success("Assistant removed"),c(!1),p(null),M()}catch(U){console.error("Error removing assistant:",U),me.error(U.message||"Failed to remove assistant")}},O=async(U,B,V)=>{S(U);try{const Z=s.find(Q=>Q.id===U);if(!Z)return;const X={...Z.permissions,[B]:V},{error:ee}=await H.from("agent_assistant_assignments").update({permissions:X}).eq("id",U);if(ee)throw ee;r(Q=>Q.map(ie=>ie.id===U?{...ie,permissions:X}:ie))}catch(Z){console.error("Error updating permissions:",Z),me.error("Failed to update permissions")}finally{S(null)}};return n?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"My Assistants"]})}),e.jsx(De,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(gr,{children:"Add assistants to help manage your Agent OS"})]}),e.jsxs(K,{size:"sm",onClick:()=>{_("create"),l(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Assistant"]})]})}),e.jsx(De,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No assistant assigned. Add one to help manage your contacts, deals, and more."}):e.jsx("div",{className:"space-y-4",children:s.map(U=>{var B,V,Z,X;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(Nn,{className:"h-10 w-10",children:e.jsx(kn,{children:((V=(B=U.assistant_profile)==null?void 0:B.name)==null?void 0:V.split(" ").map(ee=>ee[0]).join("").toUpperCase())||"A"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Z=U.assistant_profile)==null?void 0:Z.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((X=U.assistant_profile)==null?void 0:X.email)||""})]}),e.jsxs(tt,{variant:"secondary",className:"ml-2",children:[e.jsx(th,{className:"h-3 w-3 mr-1"}),"Assistant"]})]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{p(U),c(!0)},children:e.jsx(Nr,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-3",children:"Permissions"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:_8t.map(ee=>{const Q=ee.icon;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:ee.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ee.description})]})]}),e.jsx(qr,{checked:U.permissions[ee.key]||!1,onCheckedChange:ie=>O(U.id,ee.key,ie),disabled:k===U.id})]},ee.key)})})]})]},U.id)})})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Add Assistant"}),e.jsx(Gr,{children:b==="create"?"Create a new account for your assistant.":"Link an existing assistant account by their email."})]}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsxs(K,{variant:b==="create"?"default":"outline",size:"sm",onClick:()=>_("create"),children:[e.jsx($s,{className:"h-3 w-3 mr-1"}),"Create New"]}),e.jsxs(K,{variant:b==="link"?"default":"outline",size:"sm",onClick:()=>_("link"),children:[e.jsx(Bo,{className:"h-3 w-3 mr-1"}),"Link Existing"]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[b==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"assistant-name",children:"Name"}),e.jsx(ze,{id:"assistant-name",value:f.name,onChange:U=>g({...f,name:U.target.value}),placeholder:"Assistant's full name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"assistant-email",children:"Email"}),e.jsx(ze,{id:"assistant-email",type:"email",value:f.email,onChange:U=>g({...f,email:U.target.value}),placeholder:"assistant@email.com"})]}),b==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"assistant-password",children:"Temporary Password"}),e.jsx(ze,{id:"assistant-password",type:"password",value:f.password,onChange:U=>g({...f,password:U.target.value}),placeholder:"Min 6 characters"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your assistant can change this after their first login."})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:L,disabled:j,children:[j&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),b==="create"?"Create Assistant":"Link Assistant"]})]})]})}),e.jsx(kc,{open:i,onOpenChange:c,children:e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Remove Assistant?"}),e.jsxs(tc,{children:["This will remove ",(q=u==null?void 0:u.assistant_profile)==null?void 0:q.name,"'s access to your Agent OS. Their account will remain active but they won't be able to manage your data."]})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:I,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function yh(t){this.content=t}yh.prototype={constructor:yh,find:function(t){for(var s=0;s>1}};yh.from=function(t){if(t instanceof yh)return t;var s=[];if(t)for(var r in t)s.push(r,t[r]);return new yh(s)};function IXe(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=IXe(a.content,o.content,r+1);if(l!=null)return l}r+=a.nodeSize}}function LXe(t,s,r,n){for(let a=t.childCount,o=s.childCount;;){if(a==0||o==0)return a==o?null:{a:r,b:n};let l=t.child(--a),i=s.child(--o),c=l.nodeSize;if(l==i){r-=c,n-=c;continue}if(!l.sameMarkup(i))return{a:r,b:n};if(l.isText&&l.text!=i.text){let u=0,p=Math.min(l.text.length,i.text.length);for(;us&&n(c,a+i,o||null,l)!==!1&&c.content.size){let p=i+1;c.nodesBetween(Math.max(0,s-p),Math.min(c.content.size,r-p),n,a+p)}i=u}}descendants(s){this.nodesBetween(0,this.size,s)}textBetween(s,r,n,a){let o="",l=!0;return this.nodesBetween(s,r,(i,c)=>{let u=i.isText?i.text.slice(Math.max(s,c)-c,r-c):i.isLeaf?a?typeof a=="function"?a(i):a:i.type.spec.leafText?i.type.spec.leafText(i):"":"";i.isBlock&&(i.isLeaf&&u||i.isTextblock)&&n&&(l?l=!1:o+=n),o+=u},0),o}append(s){if(!s.size)return this;if(!this.size)return s;let r=this.lastChild,n=s.firstChild,a=this.content.slice(),o=0;for(r.isText&&r.sameMarkup(n)&&(a[a.length-1]=r.withText(r.text+n.text),o=1);os)for(let o=0,l=0;ls&&((lr)&&(i.isText?i=i.cut(Math.max(0,s-l),Math.min(i.text.length,r-l)):i=i.cut(Math.max(0,s-l-1),Math.min(i.content.size,r-l-1))),n.push(i),a+=i.nodeSize),l=c}return new Dr(n,a)}cutByIndex(s,r){return s==r?Dr.empty:s==0&&r==this.content.length?this:new Dr(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 Dr(a,o)}addToStart(s){return new Dr([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new Dr(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?oz(r+1,o):oz(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 Dr.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Dr(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return Dr.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}};Il.none=[];class Yoe extends Error{}class jn{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=OXe(this.content,s+this.openStart,r);return n&&new jn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new jn(DXe(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 jn.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 jn(Dr.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 jn(s,n,a)}}jn.empty=new jn(Dr.empty,0,0);function DXe(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(DXe(o.content,s-a-1,r-a-1)))}function OXe(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=OXe(l.content,s-o-1,r,l);return i&&t.replaceChild(a,l.copy(i))}function j8t(t,s,r){if(r.openStart>t.depth)throw new Yoe("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new Yoe("Inconsistent open depths");return RXe(t,s,r,0)}function RXe(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 XL(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&&(vS(t.nodeAfter,n),o++));for(let i=o;ia&&b1e(t,s,a+1),l=n.depth>a&&b1e(r,n,a+1),i=[];return XL(null,t,a,i),o&&l&&s.index(a)==r.index(a)?(FXe(o,l),vS(bS(o,zXe(t,s,r,n,a+1)),i)):(o&&vS(bS(o,Xoe(t,s,a+1)),i),XL(s,r,a,i),l&&vS(bS(l,Xoe(r,n,a+1)),i)),XL(n,null,a,i),new Dr(i)}function Xoe(t,s,r){let n=[];if(XL(null,t,r,n),t.depth>r){let a=b1e(t,s,r+1);vS(bS(a,Xoe(t,s,r+1)),n)}return XL(s,null,r,n),new Dr(n)}function N8t(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(Dr.from(a));return{start:a.resolveNoCache(t.openStart+r),end:a.resolveNoCache(a.content.size-t.openEnd-r)}}class aD{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 Qoe(this,s,n);return null}sameParent(s){return this.pos-this.parentOffset==s.pos-s.parentOffset}max(s){return s.pos>this.pos?s:this}min(s){return s.pos=0&&r<=s.content.size))throw new RangeError("Position "+r+" out of range");let n=[],a=0,o=r;for(let l=s;;){let{index:i,offset:c}=l.content.findIndex(o),u=o-c;if(n.push(l,i,a+c),!u||(l=l.child(i),l.isText))break;o=u-1,a+=c+1}return new aD(r,n,o)}static resolveCached(s,r){let n=wIe.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()+")"),BXe(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=Dr.empty,a=0,o=n.childCount){let l=this.contentMatchAt(s).matchFragment(n,a,o),i=l&&l.matchFragment(this.content,r);if(!i||!i.validEnd)return!1;for(let c=a;cr.type.name)}`);this.content.forEach(r=>r.check())}toJSON(){let s={type:this.type.name};for(let r in this.attrs){s.attrs=this.attrs;break}return this.content.size&&(s.content=this.content.toJSON()),this.marks.length&&(s.marks=this.marks.map(r=>r.toJSON())),s}static fromJSON(s,r){if(!r)throw new RangeError("Invalid input for Node.fromJSON");let n;if(r.marks){if(!Array.isArray(r.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=r.marks.map(s.markFromJSON)}if(r.type=="text"){if(typeof r.text!="string")throw new RangeError("Invalid text node in JSON");return s.text(r.text,n)}let a=Dr.fromJSON(s,r.content),o=s.nodeType(r.type).create(r.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};Q_.prototype.text=void 0;class Joe extends Q_{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):BXe(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 Joe(this.type,this.attrs,this.text,s)}withText(s){return s==this.text?this:new Joe(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 BXe(t,s){for(let r=t.length-1;r>=0;r--)s=t[r].type.name+"("+s+")";return s}class WS{constructor(s){this.validEnd=s,this.next=[],this.wrapCache=[]}static parse(s,r){let n=new M8t(s,r);if(n.next==null)return WS.empty;let a=$Xe(n);n.next&&n.err("Unexpected trailing text");let o=D8t(L8t(a));return O8t(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(` `)}}WS.empty=new WS(!0);class M8t{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 $Xe(t){let s=[];do s.push(T8t(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function T8t(t){let s=[];do s.push(A8t(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function A8t(t){let s=I8t(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=E8t(t,s);else break;return s}function jIe(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let s=Number(t.next);return t.pos++,s}function E8t(t,s){let r=jIe(t),n=r;return t.eat(",")&&(t.next!="}"?n=jIe(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function P8t(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 I8t(t){if(t.eat("(")){let s=$Xe(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=P8t(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 L8t(t){let s=[[]];return a(o(t,0),r()),s;function r(){return s.push([])-1}function n(l,i,c){let u={term:c,to:i};return s[l].push(u),u}function a(l,i){l.forEach(c=>c.to=i)}function o(l,i){if(l.type=="choice")return l.exprs.reduce((c,u)=>c.concat(o(u,i)),[]);if(l.type=="seq")for(let c=0;;c++){let u=o(l.exprs[c],i);if(c==l.exprs.length-1)return u;a(u,i=r())}else if(l.type=="star"){let c=r();return n(i,c),a(o(l.expr,c),c),[n(c)]}else if(l.type=="plus"){let c=r();return a(o(l.expr,i),c),a(o(l.expr,c),c),[n(c)]}else{if(l.type=="opt")return[n(i)].concat(o(l.expr,i));if(l.type=="range"){let c=i;for(let u=0;u{t[l].forEach(({term:i,to:c})=>{if(!i)return;let u;for(let p=0;p{u||a.push([i,u=[]]),u.indexOf(p)==-1&&u.push(p)})})});let o=s[n.join(",")]=new WS(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:VXe(this.attrs,s)}create(s=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Q_(this,this.computeAttrs(s),Dr.from(r),Il.setFrom(n))}createChecked(s=null,r,n){return r=Dr.from(r),this.checkContent(r),new Q_(this,this.computeAttrs(s),r,Il.setFrom(n))}createAndFill(s=null,r,n){if(s=this.computeAttrs(s),r=Dr.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(Dr.empty,!0);return o?new Q_(this,s,r.append(o),Il.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 GXe(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 R8t(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 F8t{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?R8t(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class kue{constructor(s,r,n,a){this.name=s,this.rank=r,this.schema=n,this.spec=a,this.attrs=WXe(s,a.attrs),this.excluded=null;let o=UXe(this.attrs);this.instance=o?new Il(this,o):null}create(s=null){return!s&&this.instance?this.instance:new Il(this,VXe(this.attrs,s))}static compile(s,r){let n=Object.create(null),a=0;return s.forEach((o,l)=>n[o]=new kue(o,a++,r,l)),n}removeFromSet(s){for(var r=0;r-1}}class KXe{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=yh.from(s.nodes),r.marks=yh.from(s.marks||{}),this.nodes=kIe.compile(this.spec.nodes,this),this.marks=kue.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]=WS.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?SIe(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==""?[]:SIe(this,l.split(" "))}this.nodeFromJSON=a=>Q_.fromJSON(this,a),this.markFromJSON=a=>Il.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 kIe){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 Joe(n,n.defaultAttrs,s,Il.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 SIe(t,s){let r=[];for(let n=0;n-1)&&r.push(l=c)}if(!l)throw new SyntaxError("Unknown mark type: '"+s[n]+"'")}return r}function z8t(t){return t.tag!=null}function B8t(t){return t.style!=null}let QL=class w1e{constructor(s,r){this.schema=s,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(a=>{if(z8t(a))this.tags.push(a);else if(B8t(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 MIe(this,r,!1);return n.addAll(s,Il.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new MIe(this,r,!0);return n.addAll(s,Il.none,r.from,r.to),jn.maxOpen(n.finish())}matchTag(s,r,n){for(let a=n?this.tags.indexOf(n)+1:0;as.length&&(i.charCodeAt(s.length)!=61||i.slice(s.length+1)!=r))){if(l.getAttrs){let c=l.getAttrs(r);if(c===!1)continue;l.attrs=c||void 0}return l}}}static schemaRules(s){let r=[];function n(a){let o=a.priority==null?50:a.priority,l=0;for(;l{n(l=TIe(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=TIe(l)),l.node||l.ignore||l.mark||(l.node=a)})}return r}static fromSchema(s){return s.cached.domParser||(s.cached.domParser=new w1e(s,w1e.schemaRules(s)))}};const ZXe={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},$8t={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},YXe={ol:!0,ul:!0},iD=1,j1e=2,JL=4;function CIe(t,s,r){return s!=null?(s?iD:0)|(s==="full"?j1e:0):t&&t.whitespace=="pre"?iD|j1e:r&~JL}class lz{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=Il.none,this.match=o||(l&JL?null:s.contentMatch)}findWrapping(s){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Dr.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&iD)){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=Dr.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(Dr.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&&!ZXe.hasOwnProperty(s.parentNode.nodeName.toLowerCase())}}class MIe{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=CIe(null,r.preserveWhitespace,0)|(n?JL:0);a?o=new lz(a.type,a.attrs,Il.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new lz(null,null,Il.none,!0,null,l):o=new lz(s.schema.topNodeType,null,Il.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&j1e?"full":this.localPreserveWS||(a.options&iD)>0,{schema:l}=this.parser;if(o==="full"||a.inlineContext(s)||/[^ \t\r\n\u000c]/.test(n)){if(o)if(o==="full")n=n.replace(/\r\n?/g,` `);else if(l.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(l.linebreakReplacement.create())){let i=n.split(/\r?\n|\r/);for(let c=0;c!c.clearMark(u)):r=r.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)i=c;else break}}return r}addElementByRule(s,r,n,a){let o,l;if(r.node)if(l=this.parser.schema.nodes[r.node],l.isLeaf)this.insertNode(l.create(r.attrs),n,s.nodeName=="BR")||this.leafFallback(s,n);else{let c=this.enter(l,r.attrs||null,n,r.preserveWhitespace);c&&(o=!0,n=c)}else{let c=this.parser.schema.marks[r.mark];n=n.concat(c.create(r.attrs))}let i=this.top;if(l&&l.isLeaf)this.findInside(s);else if(a)this.addElement(s,n,a);else if(r.getContent)this.findInside(s),r.getContent(s,this.parser.schema).forEach(c=>this.insertNode(c,n,!1));else{let c=s;typeof r.contentElement=="string"?c=s.querySelector(r.contentElement):typeof r.contentElement=="function"?c=r.contentElement(s):r.contentElement&&(c=r.contentElement),this.findAround(s,c,!0),this.addAll(c,n),this.findAround(s,c,!1)}o&&this.sync(i)&&this.open--}addAll(s,r,n,a){let o=n||0;for(let l=n?s.childNodes[n]:s.firstChild,i=a==null?null:s.childNodes[a];l!=i;l=l.nextSibling,++o)this.findAtPoint(s,o),this.addDOM(l,r);this.findAtPoint(s,o)}findPlace(s,r,n){let a,o;for(let l=this.open,i=0;l>=0;l--){let c=this.nodes[l],u=c.findWrapping(s);if(u&&(!a||a.length>u.length+i)&&(a=u,o=c,!u.length))break;if(c.solid){if(n)break;i+=2}}if(!a)return null;this.sync(o);for(let l=0;l(l.type?l.type.allowsMarkType(u.type):AIe(u.type,s))?(c=u.addToSet(c),!1):!0),this.nodes.push(new lz(s,r,c,a,null,i)),this.open++,n}closeExtra(s=!1){let r=this.nodes.length-1;if(r>this.open){for(;r>this.open;r--)this.nodes[r-1].content.push(this.nodes[r].finish(s));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(s){for(let r=this.open;r>=0;r--){if(this.nodes[r]==s)return this.open=r,!0;this.localPreserveWS&&(this.nodes[r].options|=iD)}return!1}get currentPos(){this.closeExtra();let s=0;for(let r=this.open;r>=0;r--){let n=this.nodes[r].content;for(let a=n.length-1;a>=0;a--)s+=n[a].nodeSize;r&&s++}return s}findAtPoint(s,r){if(this.find)for(let n=0;n-1)return s.split(/\s*\|\s*/).some(this.matchesContext,this);let r=s.split("/"),n=this.options.context,a=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(a?0:1),l=(i,c)=>{for(;i>=0;i--){let u=r[i];if(u==""){if(i==r.length-1||i==0)continue;for(;c>=o;c--)if(l(i-1,c))return!0;return!1}else{let p=c>0||c==0&&a?this.nodes[c].type:n&&c>=o?n.node(c-o).type:null;if(!p||p.name!=u&&!p.isInGroup(u))return!1;c--}}return!0};return l(r.length-1,this.open)}textblockFromContext(){let s=this.options.context;if(s)for(let r=s.depth;r>=0;r--){let n=s.node(r).contentMatchAt(s.indexAfter(r)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let r in this.parser.schema.nodes){let n=this.parser.schema.nodes[r];if(n.isTextblock&&n.defaultAttrs)return n}}}function q8t(t){for(let s=t.firstChild,r=null;s;s=s.nextSibling){let n=s.nodeType==1?s.nodeName.toLowerCase():null;n&&YXe.hasOwnProperty(n)&&r?(r.appendChild(s),s=r):n=="li"?r=s:n&&(r=null)}}function U8t(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function TIe(t){let s={};for(let r in t)s[r]=t[r];return s}function AIe(t,s){let r=s.schema.nodes;for(let n in r){let a=r[n];if(!a.allowsMarkType(t))continue;let o=[],l=i=>{o.push(i);for(let c=0;c{if(o.length||l.marks.length){let i=0,c=0;for(;i=0;a--){let o=this.serializeMark(s.marks[a],s.isInline,r);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(s,r,n={}){let a=this.marks[s.type.name];return a&&jie(Xxe(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return jie(s,r,n,a)}static fromSchema(s){return s.cached.domSerializer||(s.cached.domSerializer=new vC(this.nodesFromSchema(s),this.marksFromSchema(s)))}static nodesFromSchema(s){let r=EIe(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return EIe(s.marks)}}function EIe(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function Xxe(t){return t.document||window.document}const PIe=new WeakMap;function V8t(t){let s=PIe.get(t);return s===void 0&&PIe.set(t,s=H8t(t)),s}function H8t(t){let s=null;function r(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")s||(s=[]),s.push(n);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=a.indexOf(" ");l>0&&(r=a.slice(0,l),a=a.slice(l+1));let i,c=r?t.createElementNS(r,a):t.createElement(a),u=s[1],p=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){p=2;for(let f in u)if(u[f]!=null){let g=f.indexOf(" ");g>0?c.setAttributeNS(f.slice(0,g),f.slice(g+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=p;fp)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:b,contentDOM:_}=jie(t,g,r,n);if(c.appendChild(b),_){if(i)throw new RangeError("Multiple content holes");i=_}}}return{dom:c,contentDOM:i}}const XXe=65535,QXe=Math.pow(2,16);function W8t(t,s){return t+s*QXe}function IIe(t){return t&XXe}function G8t(t){return(t-(t&XXe))/QXe}const JXe=1,eQe=2,Nie=4,tQe=8;class N1e{constructor(s,r,n){this.pos=s,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&tQe)>0}get deletedBefore(){return(this.delInfo&(JXe|Nie))>0}get deletedAfter(){return(this.delInfo&(eQe|Nie))>0}get deletedAcross(){return(this.delInfo&Nie)>0}}class lf{constructor(s,r=!1){if(this.ranges=s,this.inverted=r,!s.length&&lf.empty)return lf.empty}recover(s){let r=0,n=IIe(s);if(!this.inverted)for(let a=0;as)break;let u=this.ranges[i+o],p=this.ranges[i+l],f=c+u;if(s<=f){let g=u?s==c?-1:s==f?1:r:r,b=c+a+(g<0?0:p);if(n)return b;let _=s==(r<0?c:f)?null:W8t(i/3,s-c),j=s==c?eQe:s==f?JXe:Nie;return(r<0?s!=c:s!=f)&&(j|=tQe),new N1e(b,j,_)}a+=p-u}return n?s+a:new N1e(s+a,0,null)}touches(s,r){let n=0,a=IIe(r),o=this.inverted?2:1,l=this.inverted?1:2;for(let i=0;is)break;let u=this.ranges[i+o],p=c+u;if(s<=p&&i==a*3)return!0;n+=this.ranges[i+l]-u}return!1}forEach(s){let r=this.inverted?2:1,n=this.inverted?1:2;for(let a=0,o=0;a=0;r--){let a=s.getMirror(r);this.appendMap(s._maps[r].invert(),a!=null&&a>r?n-a-1:void 0)}}invert(){let s=new oD;return s.appendMappingInverted(this),s}map(s,r=1){if(this.mirror)return this._map(s,r,!0);for(let n=this.from;no&&c!l.isAtom||!i.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),a),r.openStart,r.openEnd);return eu.fromReplace(s,this.from,this.to,o)}invert(){return new o0(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 N_(r.pos,n.pos,this.mark)}merge(s){return s instanceof N_&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new N_(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 N_(r.from,r.to,s.markFromJSON(r.mark))}}em.jsonID("addMark",N_);class o0 extends em{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 jn(MNe(r.content,a=>a.mark(this.mark.removeFromSet(a.marks)),s),r.openStart,r.openEnd);return eu.fromReplace(s,this.from,this.to,n)}invert(){return new N_(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 o0(r.pos,n.pos,this.mark)}merge(s){return s instanceof o0&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new o0(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 o0(r.from,r.to,s.markFromJSON(r.mark))}}em.jsonID("removeMark",o0);class k_ extends em{constructor(s,r){super(),this.pos=s,this.mark=r}apply(s){let r=s.nodeAt(this.pos);if(!r)return eu.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return eu.fromReplace(s,this.pos,this.pos+1,new jn(Dr.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 rh(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 rh(r.from,r.to,r.gapFrom,r.gapTo,jn.fromJSON(s,r.slice),r.insert,!!r.structure)}}em.jsonID("replaceAround",rh);function k1e(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 K8t(t,s,r,n){let a=[],o=[],l,i;t.doc.nodesBetween(s,r,(c,u,p)=>{if(!c.isInline)return;let f=c.marks;if(!n.isInSet(f)&&p.type.allowsMarkType(n.type)){let g=Math.max(u,s),b=Math.min(u+c.nodeSize,r),_=n.addToSet(f);for(let j=0;jt.step(c)),o.forEach(c=>t.step(c))}function Z8t(t,s,r,n){let a=[],o=0;t.doc.nodesBetween(s,r,(l,i)=>{if(!l.isInline)return;o++;let c=null;if(n instanceof kue){let u=l.marks,p;for(;p=n.isInSet(u);)(c||(c=[])).push(p),u=p.removeFromSet(u)}else n?n.isInSet(l.marks)&&(c=[n]):c=l.marks;if(c&&c.length){let u=Math.min(i+l.nodeSize,r);for(let p=0;pt.step(new o0(l.from,l.to,l.style)))}function TNe(t,s,r,n=r.contentMatch,a=!0){let o=t.doc.nodeAt(s),l=[],i=s+1;for(let c=0;c=0;c--)t.step(l[c])}function Y8t(t,s,r){return(s==0||t.canReplace(s,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function rE(t){let r=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth,a=0,o=0;;--n){let l=t.$from.node(n),i=t.$from.index(n)+a,c=t.$to.indexAfter(n)-o;if(nr;_--)j||n.index(_)>0?(j=!0,p=Dr.from(n.node(_).copy(p)),f++):c--;let g=Dr.empty,b=0;for(let _=o,j=!1;_>r;_--)j||a.after(_+1)=0;l--){if(n.size){let i=r[l].type.contentMatch.matchFragment(n);if(!i||!i.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=Dr.from(r[l].type.create(r[l].attrs,n))}let a=s.start,o=s.end;t.step(new rh(a,o,a,o,new jn(n,0,0),r.length,!0))}function tDt(t,s,r,n,a){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(s,r,(l,i)=>{let c=typeof a=="function"?a(l):a;if(l.isTextblock&&!l.hasMarkup(n,c)&&sDt(t.doc,t.mapping.slice(o).map(i),n)){let u=null;if(n.schema.linebreakReplacement){let b=n.whitespace=="pre",_=!!n.contentMatch.matchType(n.schema.linebreakReplacement);b&&!_?u=!1:!b&&_&&(u=!0)}u===!1&&rQe(t,l,i,o),TNe(t,t.mapping.slice(o).map(i,1),n,void 0,u===null);let p=t.mapping.slice(o),f=p.map(i,1),g=p.map(i+l.nodeSize,1);return t.step(new rh(f,g,f+1,g-1,new jn(Dr.from(n.create(c,null,l.marks)),0,0),1,!0)),u===!0&&sQe(t,l,i,o),!1}})}function sQe(t,s,r,n){s.forEach((a,o)=>{if(a.isText){let l,i=/\r?\n|\r/g;for(;l=i.exec(a.text);){let c=t.mapping.slice(n).map(r+1+o+l.index);t.replaceWith(c,c+1,s.type.schema.linebreakReplacement.create())}}})}function rQe(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 sDt(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function rDt(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 rh(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new jn(Dr.from(l),0,0),1,!0))}function f1(t,s,r=1,n){let a=t.resolve(s),o=a.depth-r,l=n&&n[n.length-1]||a.parent;if(o<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!l.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let u=a.depth-1,p=r-2;u>o;u--,p--){let f=a.node(u),g=a.index(u);if(f.type.spec.isolating)return!1;let b=f.content.cutByIndex(g,f.childCount),_=n&&n[p+1];_&&(b=b.replaceChild(0,_.type.create(_.attrs)));let j=n&&n[p]||f;if(!f.canReplace(g+1,f.childCount)||!j.type.validContent(b))return!1}let i=a.indexAfter(o),c=n&&n[0];return a.node(o).canReplaceWith(i,i,c?c.type:a.node(o+1).type)}function nDt(t,s,r=1,n){let a=t.doc.resolve(s),o=Dr.empty,l=Dr.empty;for(let i=a.depth,c=a.depth-r,u=r-1;i>c;i--,u--){o=Dr.from(a.node(i).copy(o));let p=n&&n[u];l=Dr.from(p?p.type.create(p.attrs,l):a.node(i).copy(l))}t.step(new Zu(s,s,new jn(o.append(l),r,r),!0))}function Lw(t,s){let r=t.resolve(s),n=r.index();return nQe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function aDt(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&&nQe(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 iDt(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);rQe(t,p.node(),p.before(),i)}l.inlineContent&&TNe(t,s+r-1,l,o.node().contentMatchAt(o.index()),n==null);let c=t.mapping.slice(i),u=c.map(s-r);if(t.step(new Zu(u,c.map(s+r,-1),jn.empty,!0)),n===!0){let p=t.doc.resolve(u);sQe(t,p.node(),p.before(),t.steps.length)}return t}function oDt(t,s,r){let n=t.resolve(s);if(n.parent.canReplaceWith(n.index(),n.index(),r))return s;if(n.parentOffset==0)for(let a=n.depth-1;a>=0;a--){let o=n.index(a);if(n.node(a).canReplaceWith(o,o,r))return n.before(a+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let a=n.depth-1;a>=0;a--){let o=n.indexAfter(a);if(n.node(a).canReplaceWith(o,o,r))return n.after(a+1);if(o=0;l--){let i=l==n.depth?0:n.pos<=(n.start(l+1)+n.end(l+1))/2?-1:1,c=n.index(l)+(i>0?1:0),u=n.node(l),p=!1;if(o==1)p=u.canReplace(c,c,a);else{let f=u.contentMatchAt(c).findWrapping(a.firstChild.type);p=f&&u.canReplaceWith(c,c,f[0])}if(p)return i==0?n.pos:i<0?n.before(l+1):n.after(l+1)}return null}function Cue(t,s,r=s,n=jn.empty){if(s==r&&!n.size)return null;let a=t.resolve(s),o=t.resolve(r);return iQe(a,o,n)?new Zu(s,r,n):new lDt(a,o,n).fit()}function iQe(t,s,r){return!r.openStart&&!r.openEnd&&t.start()==s.start()&&t.parent.canReplace(t.index(),s.index(),r.content)}class lDt{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Dr.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=Dr.from(s.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let s=this.mustMoveInline(),r=this.placed.size-this.depth-this.$from.depth,n=this.$from,a=this.close(s<0?this.$to:n.doc.resolve(s));if(!a)return null;let o=this.placed,l=n.depth,i=a.depth;for(;l&&i&&o.childCount==1;)o=o.firstChild.content,l--,i--;let c=new jn(o,l,i);return s>-1?new rh(n.pos,s,this.$to.pos,this.$to.end(),c,r):c.size||n.pos!=this.$to.pos?new Zu(n.pos,a.pos,c):null}findFittable(){let s=this.unplaced.openStart;for(let r=this.unplaced.content,n=0,a=this.unplaced.openEnd;n1&&(a=0),o.type.spec.isolating&&a<=n){s=n;break}r=o.content}for(let r=1;r<=2;r++)for(let n=r==1?s:this.unplaced.openStart;n>=0;n--){let a,o=null;n?(o=Jxe(this.unplaced.content,n-1).firstChild,a=o.content):a=this.unplaced.content;let l=a.firstChild;for(let i=this.depth;i>=0;i--){let{type:c,match:u}=this.frontier[i],p,f=null;if(r==1&&(l?u.matchType(l.type)||(f=u.fillBefore(Dr.from(l),!1)):o&&c.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:i,parent:o,inject:f};if(r==2&&l&&(p=u.findWrapping(l.type)))return{sliceDepth:n,frontierDepth:i,parent:o,wrap:p};if(o&&u.matchType(o.type))break}}}openMore(){let{content:s,openStart:r,openEnd:n}=this.unplaced,a=Jxe(s,r);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new jn(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=Jxe(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new jn(jI(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new jn(jI(s,r,1),r,n)}placeNodes({sliceDepth:s,frontierDepth:r,parent:n,inject:a,wrap:o}){for(;this.depth>r;)this.closeFrontierNode();if(o)for(let j=0;j1||c==0||j.content.size)&&(f=w,p.push(oQe(j.mark(g.allowedMarks(j.marks)),u==1?c:0,u==i.childCount?b:-1)))}let _=u==i.childCount;_||(b=-1),this.placed=NI(this.placed,r,Dr.from(p)),this.frontier[r].match=f,_&&b<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let j=0,w=i;j1&&a==this.$to.end(--n);)++a;return a}findCloseLevel(s){e:for(let r=Math.min(this.depth,s.depth);r>=0;r--){let{match:n,type:a}=this.frontier[r],o=r=0;i--){let{match:c,type:u}=this.frontier[i],p=ege(s,i,u,c,!0);if(!p||p.childCount)continue e}return{depth:r,fit:l,move:o?s.doc.resolve(s.after(r+1)):s}}}}close(s){let r=this.findCloseLevel(s);if(!r)return null;for(;this.depth>r.depth;)this.closeFrontierNode();r.fit.childCount&&(this.placed=NI(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=NI(this.placed,this.depth,Dr.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Dr.empty,!0);r.childCount&&(this.placed=NI(this.placed,this.frontier.length,r))}}function jI(t,s,r){return s==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(jI(t.firstChild.content,s-1,r)))}function NI(t,s,r){return s==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(NI(t.lastChild.content,s-1,r)))}function Jxe(t,s){for(let r=0;r1&&(n=n.replaceChild(0,oQe(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(Dr.empty,!0)))),t.copy(n)}function ege(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&&!cDt(r,o.content,l)?i:null}function cDt(t,s,r){for(let n=r;n0;g--,b--){let _=a.node(g).type.spec;if(_.defining||_.definingAsContext||_.isolating)break;l.indexOf(g)>-1?i=g:a.before(g)==b&&l.splice(1,0,-g)}let c=l.indexOf(i),u=[],p=n.openStart;for(let g=n.content,b=0;;b++){let _=g.firstChild;if(u.push(_),b==n.openStart)break;g=_.content}for(let g=p-1;g>=0;g--){let b=u[g],_=dDt(b.type);if(_&&!b.sameMarkup(a.node(Math.abs(i)-1)))p=g;else if(_||!b.type.isTextblock)break}for(let g=n.openStart;g>=0;g--){let b=(g+p+1)%(n.openStart+1),_=u[b];if(_)for(let j=0;j=0&&(t.replace(s,r,n),!(t.steps.length>f));g--){let b=l[g];b<0||(s=a.before(b),r=o.after(b))}}function lQe(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(Dr.empty,!0))}return t}function hDt(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=oDt(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new jn(Dr.from(n),0,0))}function mDt(t,s,r){let n=t.doc.resolve(s),a=t.doc.resolve(r),o=cQe(n,a);for(let l=0;l0&&(c||n.node(i-1).canReplace(n.index(i-1),a.indexAfter(i-1))))return t.delete(n.before(i),a.after(i))}for(let l=1;l<=n.depth&&l<=a.depth;l++)if(s-n.start(l)==n.depth-l&&r>n.end(l)&&a.end(l)-r!=a.depth-l&&n.start(l-1)==a.start(l-1)&&n.node(l-1).canReplace(n.index(l-1),a.index(l-1)))return t.delete(n.before(l),r);t.delete(s,r)}function cQe(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 eT extends em{constructor(s,r,n){super(),this.pos=s,this.attr=r,this.value=n}apply(s){let r=s.nodeAt(this.pos);if(!r)return eu.fail("No node at attribute step's position");let n=Object.create(null);for(let o in r.attrs)n[o]=r.attrs[o];n[this.attr]=this.value;let a=r.type.create(n,null,r.marks);return eu.fromReplace(s,this.pos,this.pos+1,new jn(Dr.from(a),0,r.isLeaf?0:1))}getMap(){return lf.empty}invert(s){return new eT(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 eT(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 eT(r.pos,r.attr,r.value)}}em.jsonID("attr",eT);class lD extends em{constructor(s,r){super(),this.attr=s,this.value=r}apply(s){let r=Object.create(null);for(let a in s.attrs)r[a]=s.attrs[a];r[this.attr]=this.value;let n=s.type.create(r,s.content,s.marks);return eu.ok(n)}getMap(){return lf.empty}invert(s){return new lD(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 lD(r.attr,r.value)}}em.jsonID("docAttr",lD);let VT=class extends Error{};VT=function t(s){let r=Error.call(this,s);return r.__proto__=t.prototype,r};VT.prototype=Object.create(Error.prototype);VT.prototype.constructor=VT;VT.prototype.name="TransformError";class ENe{constructor(s){this.doc=s,this.steps=[],this.docs=[],this.mapping=new oD}get before(){return this.docs.length?this.docs[0]:this.doc}step(s){let r=this.maybeStep(s);if(r.failed)throw new VT(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=jn.empty){let a=Cue(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new jn(Dr.from(n),0,0))}delete(s,r){return this.replace(s,r,jn.empty)}insert(s,r){return this.replaceWith(s,s,r)}replaceRange(s,r,n){return uDt(this,s,r,n),this}replaceRangeWith(s,r,n){return hDt(this,s,r,n),this}deleteRange(s,r){return mDt(this,s,r),this}lift(s,r){return X8t(this,s,r),this}join(s,r=1){return iDt(this,s,r),this}wrap(s,r){return eDt(this,s,r),this}setBlockType(s,r=s,n,a=null){return tDt(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return rDt(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new eT(s,r,n)),this}setDocAttribute(s,r){return this.step(new lD(s,r)),this}addNodeMark(s,r){return this.step(new k_(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 Il)r.isInSet(n.marks)&&this.step(new GS(s,r));else{let a=n.marks,o,l=[];for(;o=r.isInSet(a);)l.push(new GS(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 nDt(this,s,r,n),this}addMark(s,r,n){return K8t(this,s,r,n),this}removeMark(s,r,n){return Z8t(this,s,r,n),this}clearIncompatible(s,r,n){return TNe(this,s,r,n),this}}const tge=Object.create(null);class fi{constructor(s,r,n){this.$anchor=s,this.$head=r,this.ranges=n||[new dQe(s.min(r),s.max(r))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let s=this.ranges;for(let r=0;r=0;o--){let l=r<0?q5(s.node(0),s.node(o),s.before(o+1),s.index(o),r,n):q5(s.node(0),s.node(o),s.after(o+1),s.index(o)+1,r,n);if(l)return l}return null}static near(s,r=1){return this.findFrom(s,r)||this.findFrom(s,-r)||new bf(s.node(0))}static atStart(s){return q5(s,s,0,0,1)||new bf(s)}static atEnd(s){return q5(s,s,s.content.size,s.childCount,-1)||new bf(s)}static fromJSON(s,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=tge[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 tge)throw new RangeError("Duplicate use of selection JSON ID "+s);return tge[s]=r,r.prototype.jsonID=s,r}getBookmark(){return ei.between(this.$anchor,this.$head).getBookmark()}}fi.prototype.visible=!0;class dQe{constructor(s,r){this.$from=s,this.$to=r}}let DIe=!1;function OIe(t){!DIe&&!t.parent.inlineContent&&(DIe=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ei extends fi{constructor(s,r=s){OIe(s),OIe(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 fi.near(n);let a=s.resolve(r.map(this.anchor));return new ei(a.parent.inlineContent?a:n,n)}replace(s,r=jn.empty){if(super.replace(s,r),r==jn.empty){let n=this.$from.marksAcross(this.$to);n&&s.ensureMarks(n)}}eq(s){return s instanceof ei&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new Mue(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 ei(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=fi.findFrom(r,n,!0)||fi.findFrom(r,-n,!0);if(o)r=o.$head;else return fi.near(r,n)}return s.parent.inlineContent||(a==0?s=r:(s=(fi.findFrom(s,-n,!0)||fi.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&&Wa.isSelectable(i))return Wa.create(t,r-(a<0?i.nodeSize:0))}else{let c=q5(t,i,r+a,a<0?i.childCount:0,a,o);if(c)return c}r+=i.nodeSize*a}return null}function RIe(t,s,r){let n=t.steps.length-1;if(n{l==null&&(l=p)}),t.setSelection(fi.near(t.doc.resolve(l),r))}const FIe=1,cz=2,zIe=4;class fDt extends ENe{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|=cz,this}ensureMarks(s){return Il.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&cz)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~cz,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)||Il.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(fi.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|=zIe,this}get scrolledIntoView(){return(this.updated&zIe)>0}}function BIe(t,s){return!s||!t?t:t.bind(s)}class kI{constructor(s,r,n){this.name=s,this.init=BIe(r.init,n),this.apply=BIe(r.apply,n)}}const xDt=[new kI("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new kI("selection",{init(t,s){return t.selection||fi.atStart(s.doc)},apply(t){return t.selection}}),new kI("storedMarks",{init(t){return t.storedMarks||null},apply(t,s,r,n){return n.selection.$cursor?t.storedMarks:null}}),new kI("scrollToSelection",{init(){return 0},apply(t,s){return t.scrolledIntoView?s+1:s}})];class sge{constructor(s,r){this.schema=s,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=xDt.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 kI(n.key,n.spec.state,n))})}}class cM{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 sge(s.schema,s.plugins),o=new cM(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=Q_.fromJSON(s.schema,r.doc);else if(l.name=="selection")o.selection=fi.fromJSON(o.doc,r.selection);else if(l.name=="storedMarks")r.storedMarks&&(o.storedMarks=r.storedMarks.map(s.schema.markFromJSON));else{if(n)for(let i in n){let c=n[i],u=c.spec.state;if(c.key==l.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(r,i)){o[l.name]=u.fromJSON.call(c,s,r[i],o);return}}o[l.name]=l.init(s,o)}}),o}}function uQe(t,s,r){for(let n in t){let a=t[n];a instanceof Function?a=a.bind(s):n=="handleDOMEvents"&&(a=uQe(a,s,{})),r[n]=a}return r}class Iu{constructor(s){this.spec=s,this.props={},s.props&&uQe(s.props,this,this.props),this.key=s.key?s.key.key:hQe("plugin")}getState(s){return s[this.key]}}const rge=Object.create(null);function hQe(t){return t in rge?t+"$"+ ++rge[t]:(rge[t]=0,t+"$")}class tm{constructor(s="key"){this.key=hQe(s)}get(s){return s.config.pluginsByKey[this.key]}getState(s){return s[this.key]}}const bh=function(t){for(var s=0;;s++)if(t=t.previousSibling,!t)return s},HT=function(t){let s=t.assignedSlot||t.parentNode;return s&&s.nodeType==11?s.host:s};let S1e=null;const Pv=function(t,s,r){let n=S1e||(S1e=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,s||0),n},gDt=function(){S1e=null},KS=function(t,s,r,n){return r&&($Ie(t,s,r,n,-1)||$Ie(t,s,r,n,1))},yDt=/^(img|br|input|textarea|hr)$/i;function $Ie(t,s,r,n,a){for(var o;;){if(t==r&&s==n)return!0;if(s==(a<0?0:xx(t))){let l=t.parentNode;if(!l||l.nodeType!=1||qO(t)||yDt.test(t.nodeName)||t.contentEditable=="false")return!1;s=bh(t)+(a<0?0:1),t=l}else if(t.nodeType==1){let l=t.childNodes[s+(a<0?-1:0)];if(l.nodeType==1&&l.contentEditable=="false")if(!((o=l.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)s+=a;else return!1;else t=l,s=a<0?xx(t):0}else return!1}}function xx(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function vDt(t,s){for(;;){if(t.nodeType==3&&s)return t;if(t.nodeType==1&&s>0){if(t.contentEditable=="false")return null;t=t.childNodes[s-1],s=xx(t)}else if(t.parentNode&&!qO(t))s=bh(t),t=t.parentNode;else return null}}function bDt(t,s){for(;;){if(t.nodeType==3&&s2),cx=WT||(T0?/Mac/.test(T0.platform):!1),fQe=T0?/Win/.test(T0.platform):!1,Zv=/Android \d/.test(Dw),UO=!!qIe&&"webkitFontSmoothing"in qIe.documentElement.style,NDt=UO?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function kDt(t){let s=t.defaultView&&t.defaultView.visualViewport;return s?{left:0,right:s.width,top:0,bottom:s.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function _v(t,s){return typeof t=="number"?t:t[s]}function SDt(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 UIe(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=HT(l);continue}let i=l,c=i==o.body,u=c?kDt(o):SDt(i),p=0,f=0;if(s.topu.bottom-_v(n,"bottom")&&(f=s.bottom-s.top>u.bottom-u.top?s.top+_v(a,"top")-u.top:s.bottom-u.bottom+_v(a,"bottom")),s.leftu.right-_v(n,"right")&&(p=s.right-u.right+_v(a,"right")),p||f)if(c)o.defaultView.scrollBy(p,f);else{let b=i.scrollLeft,_=i.scrollTop;f&&(i.scrollTop+=f),p&&(i.scrollLeft+=p);let j=i.scrollLeft-b,w=i.scrollTop-_;s={left:s.left-j,top:s.top-w,right:s.right-j,bottom:s.bottom-w}}let g=c?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(g))break;l=g=="absolute"?l.offsetParent:HT(l)}}function CDt(t){let s=t.dom.getBoundingClientRect(),r=Math.max(0,s.top),n,a;for(let o=(s.left+s.right)/2,l=r+1;l=r-20){n=i,a=c.top;break}}return{refDOM:n,refTop:a,stack:xQe(t.dom)}}function xQe(t){let s=[],r=t.ownerDocument;for(let n=t;n&&(s.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=HT(n));return s}function MDt({refDOM:t,refTop:s,stack:r}){let n=t?t.getBoundingClientRect().top:0;gQe(r,n==0?0:n-s)}function gQe(t,s){for(let r=0;r=i){l=Math.max(_.bottom,l),i=Math.min(_.top,i);let j=_.left>s.left?_.left-s.left:_.right=(_.left+_.right)/2?1:0));continue}}else _.top>s.top&&!c&&_.left<=s.left&&_.right>=s.left&&(c=p,u={left:Math.max(_.left,Math.min(_.right,s.left)),top:_.top});!r&&(s.left>=_.right&&s.top>=_.top||s.left>=_.left&&s.top>=_.bottom)&&(o=f+1)}}return!r&&c&&(r=c,a=u,n=0),r&&r.nodeType==3?ADt(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:yQe(r,a)}function ADt(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 INe(t,s){return t.left>=s.left-1&&t.left<=s.right+1&&t.top>=s.top-1&&t.top<=s.bottom+1}function EDt(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 IDt(t,s,r,n){let a=-1;for(let o=s,l=!1;o!=t.dom;){let i=t.docView.nearestDesc(o,!0),c;if(!i)return null;if(i.dom.nodeType==1&&(i.node.isBlock&&i.parent||!i.contentDOM)&&((c=i.dom.getBoundingClientRect()).width||c.height)&&(i.node.isBlock&&i.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(i.dom.nodeName)&&(!l&&c.left>n.left||c.top>n.top?a=i.posBefore:(!l&&c.right-1?a:t.docView.posFromDOM(s,r,-1)}function vQe(t,s,r){let n=t.childNodes.length;if(n&&r.tops.top&&a++}let u;UO&&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=IDt(t,n,a,s))}i==null&&(i=PDt(t,l,s));let c=t.docView.nearestDesc(l,!0);return{pos:i,inside:c?c.posAtStart-c.border:-1}}function VIe(t){return t.top=0&&a==n.nodeValue.length?(c--,p=1):r<0?c--:u++,ZP(qb(Pv(n,c,u),p),p<0)}if(!t.state.doc.resolve(s-(o||0)).parent.inlineContent){if(o==null&&a&&(r<0||a==xx(n))){let c=n.childNodes[a-1];if(c.nodeType==1)return nge(c.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(r<0||a==xx(n))){let c=n.childNodes[a-1],u=c.nodeType==3?Pv(c,xx(c)-(l?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return ZP(qb(u,1),!1)}if(o==null&&a=0)}function ZP(t,s){if(t.width==0)return t;let r=s?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function nge(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 _Qe(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 ODt(t,s,r){let n=s.selection,a=r=="up"?n.$from:n.$to;return _Qe(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=bQe(t,a.pos,1);for(let i=o.firstChild;i;i=i.nextSibling){let c;if(i.nodeType==1)c=i.getClientRects();else if(i.nodeType==3)c=Pv(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 RDt=/[\u0590-\u08ac]/;function FDt(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?!RDt.test(n.parent.textContent)||!i.modify?r=="left"||r=="backward"?o:l:_Qe(t,s,()=>{let{focusNode:c,focusOffset:u,anchorNode:p,anchorOffset:f}=t.domSelectionRange(),g=i.caretBidiLevel;i.modify("move",r,"character");let b=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:_,focusOffset:j}=t.domSelectionRange(),w=_&&!b.contains(_.nodeType==1?_:_.parentNode)||c==_&&u==j;try{i.collapse(p,f),c&&(c!=p||u!=f)&&i.extend&&i.extend(c,u)}catch{}return g!=null&&(i.caretBidiLevel=g),w}):n.pos==n.start()||n.pos==n.end()}let HIe=null,WIe=null,GIe=!1;function zDt(t,s,r){return HIe==s&&WIe==r?GIe:(HIe=s,WIe=r,GIe=r=="up"||r=="down"?ODt(t,s,r):FDt(t,s,r))}const Ex=0,KIe=1,w4=2,A0=3;class VO{constructor(s,r,n,a){this.parent=s,this.children=r,this.dom=n,this.contentDOM=a,this.dirty=Ex,n.pmViewDesc=this}matchesWidget(s){return!1}matchesMark(s){return!1}matchesNode(s,r,n){return!1}matchesHack(s){return!1}parseRule(){return null}stopEvent(s){return!1}get size(){let s=0;for(let r=0;rbh(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 jQe){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 wQe&&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?bh(o.dom)+1:0}}else{let o,l=!0;for(;o=n=p&&r<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(s,r,p);s=l;for(let f=i;f>0;f--){let g=this.children[f-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){a=bh(g.dom)+1;break}s-=g.size}a==-1&&(a=0)}if(a>-1&&(u>r||i==this.children.length-1)){r=u;for(let p=i+1;p_&&lr){let _=i;i=c,c=_}let b=document.createRange();b.setEnd(c.node,c.offset),b.setStart(i.node,i.offset),u.removeAllRanges(),u.addRange(b)}}ignoreMutation(s){return!this.contentDOM&&s.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(s,r){for(let n=0,a=0;a=n:sn){let i=n+o.border,c=l-o.border;if(s>=i&&r<=c){this.dirty=s==n||r==l?w4:KIe,s==i&&r==c&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=A0:o.markDirty(s-i,r-i);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?w4:A0}n=l}this.dirty=w4}markParentsDirty(){let s=1;for(let r=this.parent;r;r=r.parent,s++){let n=s==1?w4:KIe;r.dirty{if(!o)return a;if(o.parent)return o.parent.posBeforeChild(o)})),!r.type.spec.raw){if(l.nodeType!=1){let i=document.createElement("span");i.appendChild(l),l=i}l.contentEditable="false",l.classList.add("ProseMirror-widget")}super(s,[],l,null),this.widget=r,this.widget=r,o=this}matchesWidget(s){return this.dirty==Ex&&s.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(s){let r=this.widget.spec.stopEvent;return r?r(s):!1}ignoreMutation(s){return s.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class BDt extends VO{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 ZS extends VO{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=vC.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new ZS(s,r,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&A0||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(s){return this.dirty!=A0&&this.mark.eq(s)}markDirty(s,r){if(super.markDirty(s,r),this.dirty!=Ex){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=E1e(o,0,s,n));for(let i=0;i{if(!c)return l;if(c.parent)return c.parent.posBeforeChild(c)},n,a),p=u&&u.dom,f=u&&u.contentDOM;if(r.isText){if(!p)p=document.createTextNode(r.text);else if(p.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else p||({dom:p,contentDOM:f}=vC.renderSpec(document,r.type.spec.toDOM(r),null,r.attrs));!f&&!r.isText&&p.nodeName!="BR"&&(p.hasAttribute("contenteditable")||(p.contentEditable="false"),r.type.spec.draggable&&(p.draggable=!0));let g=p;return p=SQe(p,n,r),u?c=new $Dt(s,r,n,a,p,f||null,g,u,o,l+1):r.isText?new Aue(s,r,n,a,p,g,o):new ew(s,r,n,a,p,f||null,g,o,l+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let s={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(s.preserveWhitespace="full"),!this.contentDOM)s.getContent=()=>this.node.content;else if(!this.contentLost)s.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let n=this.children[r];if(this.dom.contains(n.dom.parentNode)){s.contentElement=n.dom.parentNode;break}}s.contentElement||(s.getContent=()=>Dr.empty)}return s}matchesNode(s,r,n){return this.dirty==Ex&&s.eq(this.node)&&ele(r,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(s,r){let n=this.node.inlineContent,a=r,o=s.composing?this.localCompositionInfo(s,r):null,l=o&&o.pos>-1?o:null,i=o&&o.pos<0,c=new UDt(this,l&&l.node,s);WDt(this.node,this.innerDeco,(u,p,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,n,s):u.type.side>=0&&!f&&c.syncToMarks(p==this.node.childCount?Il.none:this.node.child(p).marks,n,s),c.placeWidget(u,s,a)},(u,p,f,g)=>{c.syncToMarks(u.marks,n,s);let b;c.findNodeMatch(u,p,f,g)||i&&s.state.selection.from>a&&s.state.selection.to-1&&c.updateNodeAt(u,p,f,b,s)||c.updateNextNode(u,p,f,s,g,a)||c.addNode(u,p,f,s,a),a+=u.nodeSize}),c.syncToMarks([],n,s),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==w4)&&(l&&this.protectLocalComposition(s,l),NQe(this.contentDOM,this.children,s),WT&&GDt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof ei)||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=KDt(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 BDt(this,o,r,a);s.input.compositionNodes.push(l),this.children=E1e(this.children,n,n+a.length,s,l)}update(s,r,n,a){return this.dirty==A0||!s.sameMarkup(this.node)?!1:(this.updateInner(s,r,n,a),!0)}updateInner(s,r,n,a){this.updateOuterDeco(r),this.node=s,this.innerDeco=n,this.contentDOM&&this.updateChildren(a,this.posAtStart),this.dirty=Ex}updateOuterDeco(s){if(ele(s,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=kQe(this.dom,this.nodeDOM,A1e(this.outerDeco,this.node,r),A1e(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 ZIe(t,s,r,n,a){SQe(n,s,t);let o=new ew(void 0,t,s,r,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class Aue extends ew{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==A0||this.dirty!=Ex&&!this.inParent()||!s.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=Ex||s.text!=this.node.text)&&s.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=s.text,a.trackWrites==this.nodeDOM&&(a.trackWrites=null)),this.node=s,this.dirty=Ex,!0)}inParent(){let s=this.parent.contentDOM;for(let r=this.nodeDOM;r;r=r.parentNode)if(r==s)return!0;return!1}domFromPos(s){return{node:this.nodeDOM,offset:s}}localPosFromDOM(s,r,n){return s==this.nodeDOM?this.posAtStart+Math.min(r,this.node.text.length):super.localPosFromDOM(s,r,n)}ignoreMutation(s){return s.type!="characterData"&&s.type!="selection"}slice(s,r,n){let a=this.node.cut(s,r),o=document.createTextNode(a.text);return new Aue(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=A0)}get domAtom(){return!1}isText(s){return this.node.text==s}}class jQe extends VO{parseRule(){return{ignore:!0}}matchesHack(s){return this.dirty==Ex&&this.dom.nodeName==s}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class $Dt extends ew{constructor(s,r,n,a,o,l,i,c,u,p){super(s,r,n,a,o,l,i,u,p),this.spec=c}update(s,r,n,a){if(this.dirty==A0)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 NQe(t,s,r){let n=t.firstChild,a=!1;for(let o=0;o>1,l=Math.min(o,s.length);for(;a-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let c=ZS.create(this.top,s[o],r,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}}findNodeMatch(s,r,n,a){let o=-1,l;if(a>=this.preMatch.index&&(l=this.preMatch.matches[a-this.preMatch.index]).parent==this.top&&l.matchesNode(s,r,n))o=this.top.children.indexOf(l,this.index);else for(let i=this.index,c=Math.min(this.top.children.length,i+5);i0;){let i;for(;;)if(n){let u=r.children[n-1];if(u instanceof ZS)r=u,n=u.children.length;else{i=u,n--;break}}else{if(r==s)break e;n=r.parent.children.indexOf(r),r=r.parent}let c=i.node;if(c){if(c!=t.child(a-1))break;--a,o.set(i,a),l.push(i)}}return{index:a,matched:o,matches:l.reverse()}}function HDt(t,s){return t.type.side-s.type.side}function WDt(t,s,r,n){let a=s.locals(t),o=0;if(a.length==0){for(let u=0;uo;)i.push(a[l++]);let _=o+g.nodeSize;if(g.isText){let w=_;l!w.inline):i.slice();n(g,j,s.forChild(o,g),b),o=_}}function GDt(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 KDt(t,s,r,n){for(let a=0,o=0;a=r){if(o>=n&&c.slice(n-s.length-i,n-i)==s)return n-s.length;let u=i=0&&u+s.length+i>=r)return i+u;if(r==n&&c.length>=n+s.length-i&&c.slice(n-i,n-i+s.length)==s)return n}}return-1}function E1e(t,s,r,n,a){let o=[];for(let l=0,i=0;l=r||p<=s?o.push(c):(ur&&o.push(c.slice(r-u,c.size,n)))}return o}function LNe(t,s=null){let r=t.domSelectionRange(),n=t.state.doc;if(!r.focusNode)return null;let a=t.docView.nearestDesc(r.focusNode),o=a&&a.size==0,l=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(l<0)return null;let i=n.resolve(l),c,u;if(Tue(r)){for(c=l;a&&!a.node;)a=a.parent;let f=a.node;if(a&&f.isAtom&&Wa.isSelectable(f)&&a.parent&&!(f.isInline&&_Dt(r.focusNode,r.focusOffset,a.dom))){let g=a.posBefore;u=new Wa(l==g?i:n.resolve(g))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let f=l,g=l;for(let b=0;b{(r.anchorNode!=n||r.anchorOffset!=a)&&(s.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!CQe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function YDt(t){let s=t.domSelection();if(!s)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?s.collapse(r.parentNode,bh(r)+1):s.collapse(r,0),!n&&!t.state.selection.visible&&Tp&&J_<=11&&(r.disabled=!0,r.disabled=!1)}function MQe(t,s){if(s instanceof Wa){let r=t.docView.descAt(s.from);r!=t.lastSelectedViewDesc&&(eLe(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else eLe(t)}function eLe(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function DNe(t,s,r,n){return t.someProp("createSelectionBetween",a=>a(t,s,r))||ei.between(s,r,n)}function tLe(t){return t.editable&&!t.hasFocus()?!1:TQe(t)}function TQe(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 XDt(t){let s=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return KS(s.node,s.offset,r.anchorNode,r.anchorOffset)}function P1e(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&&fi.findFrom(o,s)}function Kb(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function sLe(t,s,r){let n=t.state.selection;if(n instanceof ei)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 Kb(t,new ei(n.$anchor,l))}else if(n.empty){if(t.endOfTextblock(s>0?"forward":"backward")){let a=P1e(t.state,s);return a&&a instanceof Wa?Kb(t,a):!1}else if(!(cx&&r.indexOf("m")>-1)){let a=n.$head,o=a.textOffset?null:s<0?a.nodeBefore:a.nodeAfter,l;if(!o||o.isText)return!1;let i=s<0?a.pos-o.nodeSize:a.pos;return o.isAtom||(l=t.docView.descAt(i))&&!l.contentDOM?Wa.isSelectable(o)?Kb(t,new Wa(s<0?t.state.doc.resolve(a.pos-o.nodeSize):a)):UO?Kb(t,new ei(t.state.doc.resolve(s<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof Wa&&n.node.isInline)return Kb(t,new ei(s>0?n.$to:n.$from));{let a=P1e(t.state,s);return a?Kb(t,a):!1}}}function tle(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function t8(t,s){let r=t.pmViewDesc;return r&&r.size==0&&(s<0||t.nextSibling||t.nodeName!="BR")}function N5(t,s){return s<0?QDt(t):JDt(t)}function QDt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a,o,l=!1;for(Ax&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let i=r.childNodes[n-1];if(t8(i,-1))a=r,o=--n;else if(i.nodeType==3)r=i,n=r.nodeValue.length;else break}}else{if(AQe(r))break;{let i=r.previousSibling;for(;i&&t8(i,-1);)a=r.parentNode,o=bh(i),i=i.previousSibling;if(i)r=i,n=tle(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}l?I1e(t,r,n):a&&I1e(t,a,o)}function JDt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=tle(r),o,l;for(;;)if(n{t.state==a&&x1(t)},50)}function rLe(t,s){let r=t.state.doc.resolve(s);if(!(Xu||fQe)&&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 nLe(t,s,r){let n=t.state.selection;if(n instanceof ei&&!n.empty||r.indexOf("s")>-1||cx&&r.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||t.endOfTextblock(s<0?"up":"down")){let l=P1e(t.state,s);if(l&&l instanceof Wa)return Kb(t,l)}if(!a.parent.inlineContent){let l=s<0?a:o,i=n instanceof bf?fi.near(l,s):fi.findFrom(l,s);return i?Kb(t,i):!1}return!1}function aLe(t,s){if(!(t.state.selection instanceof ei))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 iLe(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function sOt(t){if(!Qh||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;iLe(t,n,"true"),setTimeout(()=>iLe(t,n,"false"),20)}return!1}function rOt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function nOt(t,s){let r=s.keyCode,n=rOt(s);if(r==8||cx&&r==72&&n=="c")return aLe(t,-1)||N5(t,-1);if(r==46&&!s.shiftKey||cx&&r==68&&n=="c")return aLe(t,1)||N5(t,1);if(r==13||r==27)return!0;if(r==37||cx&&r==66&&n=="c"){let a=r==37?rLe(t,t.state.selection.from)=="ltr"?-1:1:-1;return sLe(t,a,n)||N5(t,a)}else if(r==39||cx&&r==70&&n=="c"){let a=r==39?rLe(t,t.state.selection.from)=="ltr"?1:-1:1;return sLe(t,a,n)||N5(t,a)}else{if(r==38||cx&&r==80&&n=="c")return nLe(t,-1,n)||N5(t,-1);if(r==40||cx&&r==78&&n=="c")return sOt(t)||nLe(t,1,n)||N5(t,1);if(n==(cx?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function ONe(t,s){t.someProp("transformCopied",b=>{s=b(s,t)});let r=[],{content:n,openStart:a,openEnd:o}=s;for(;a>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){a--,o--;let b=n.firstChild;r.push(b.type.name,b.attrs!=b.type.defaultAttrs?b.attrs:null),n=b.content}let l=t.someProp("clipboardSerializer")||vC.fromSchema(t.state.schema),i=OQe(),c=i.createElement("div");c.appendChild(l.serializeFragment(n,{document:i}));let u=c.firstChild,p,f=0;for(;u&&u.nodeType==1&&(p=DQe[u.nodeName.toLowerCase()]);){for(let b=p.length-1;b>=0;b--){let _=i.createElement(p[b]);for(;c.firstChild;)_.appendChild(c.firstChild);c.appendChild(_),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${a} ${o}${f?` -${f}`:""} ${JSON.stringify(r)}`);let g=t.someProp("clipboardTextSerializer",b=>b(s,t))||s.content.textBetween(0,s.content.size,` `);return{dom:c,text:g,slice:s}}function EQe(t,s,r,n,a){let o=a.parent.type.spec.code,l,i;if(!r&&!s)return null;let c=!!s&&(n||o||!r);if(c){if(t.someProp("transformPastedText",g=>{s=g(s,o||n,t)}),o)return i=new jn(Dr.from(t.state.schema.text(s.replace(/\r\n?/g,` `))),0,0),t.someProp("transformPasted",g=>{i=g(i,t,!0)}),i;let f=t.someProp("clipboardTextParser",g=>g(s,a,n,t));if(f)i=f;else{let g=a.marks(),{schema:b}=t.state,_=vC.fromSchema(b);l=document.createElement("div"),s.split(/(?:\r\n?|\n)+/).forEach(j=>{let w=l.appendChild(document.createElement("p"));j&&w.appendChild(_.serializeNode(b.text(j,g)))})}}else t.someProp("transformPastedHTML",f=>{r=f(r,t)}),l=lOt(r),UO&&cOt(l);let u=l&&l.querySelector("[data-pm-slice]"),p=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(p&&p[3])for(let f=+p[3];f>0;f--){let g=l.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;l=g}if(i||(i=(t.someProp("clipboardParser")||t.someProp("domParser")||QL.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(c||p),context:a,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!aOt.test(g.parentNode.nodeName)?{ignore:!0}:null}})),p)i=dOt(oLe(i,+p[1],+p[2]),p[4]);else if(i=jn.maxOpen(iOt(i.content,a),!0),i.openStart||i.openEnd){let f=0,g=0;for(let b=i.content.firstChild;f{i=f(i,t,c)}),i}const aOt=/^(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 iOt(t,s){if(t.childCount<2)return t;for(let r=s.depth;r>=0;r--){let a=s.node(r).contentMatchAt(s.index(r)),o,l=[];if(t.forEach(i=>{if(!l)return;let c=a.findWrapping(i.type),u;if(!c)return l=null;if(u=l.length&&o.length&&IQe(c,o,i,l[l.length-1],0))l[l.length-1]=u;else{l.length&&(l[l.length-1]=LQe(l[l.length-1],o.length));let p=PQe(i,c);l.push(p),a=a.matchType(p.type),o=c}}),l)return Dr.from(l)}return t}function PQe(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,Dr.from(t));return t}function IQe(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(Dr.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function oLe(t,s,r){return sr})),ige.createHTML(t)):t}function lOt(t){let s=/^(\s*]*>)*/.exec(t);s&&(t=t.slice(s[0].length));let r=OQe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),a;if((a=n&&DQe[n[1].toLowerCase()])&&(t=a.map(o=>"<"+o+">").join("")+t+a.map(o=>"").reverse().join("")),r.innerHTML=oOt(t),a)for(let o=0;o=0;i-=2){let c=r.nodes[n[i]];if(!c||c.hasRequiredAttrs())break;a=Dr.from(c.create(n[i+1],a)),o++,l++}return new jn(a,o,l)}const qm={},Um={},uOt={touchstart:!0,touchmove:!0};class hOt{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 mOt(t){for(let s in qm){let r=qm[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{fOt(t,n)&&!RNe(t,n)&&(t.editable||!(n.type in Um))&&r(t,n)},uOt[s]?{passive:!0}:void 0)}Qh&&t.dom.addEventListener("input",()=>null),D1e(t)}function S_(t,s){t.input.lastSelectionOrigin=s,t.input.lastSelectionTime=Date.now()}function pOt(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 D1e(t){t.someProp("handleDOMEvents",s=>{for(let r in s)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>RNe(t,n))})}function RNe(t,s){return t.someProp("handleDOMEvents",r=>{let n=r[s.type];return n?n(t,s)||s.defaultPrevented:!1})}function fOt(t,s){if(!s.bubbles)return!0;if(s.defaultPrevented)return!1;for(let r=s.target;r!=t.dom;r=r.parentNode)if(!r||r.nodeType==11||r.pmViewDesc&&r.pmViewDesc.stopEvent(s))return!1;return!0}function xOt(t,s){!RNe(t,s)&&qm[s.type]&&(t.editable||!(s.type in Um))&&qm[s.type](t,s)}Um.keydown=(t,s)=>{let r=s;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!FQe(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Zv&&Xu&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),WT&&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,d4(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||nOt(t,r)?r.preventDefault():S_(t,"key")};Um.keyup=(t,s)=>{s.keyCode==16&&(t.input.shiftKey=!1)};Um.keypress=(t,s)=>{let r=s;if(FQe(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||cx&&r.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof ei)||!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 Eue(t){return{left:t.clientX,top:t.clientY}}function gOt(t,s){let r=s.x-t.clientX,n=s.y-t.clientY;return r*r+n*n<100}function FNe(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 tT(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 yOt(t,s){if(s==-1)return!1;let r=t.state.doc.resolve(s),n=r.nodeAfter;return n&&n.isAtom&&Wa.isSelectable(n)?(tT(t,new Wa(r)),!0):!1}function vOt(t,s){if(s==-1)return!1;let r=t.state.selection,n,a;r instanceof Wa&&(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(Wa.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?(tT(t,Wa.create(t.state.doc,a)),!0):!1}function bOt(t,s,r,n,a){return FNe(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?vOt(t,r):yOt(t,r))}function _Ot(t,s,r,n){return FNe(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function wOt(t,s,r,n){return FNe(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||jOt(t,r,n)}function jOt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(tT(t,ei.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)tT(t,ei.create(n,i+1,i+1+l.content.size));else if(Wa.isSelectable(l))tT(t,Wa.create(n,i));else continue;return!0}}function zNe(t){return sle(t)}const RQe=cx?"metaKey":"ctrlKey";qm.mousedown=(t,s)=>{let r=s;t.input.shiftKey=r.shiftKey;let n=zNe(t),a=Date.now(),o="singleClick";a-t.input.lastClick.time<500&&gOt(r,t.input.lastClick)&&!r[RQe]&&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(Eue(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new NOt(t,l,r,!!n)):(o=="doubleClick"?_Ot:wOt)(t,l.pos,l.inside,r)?r.preventDefault():S_(t,"pointer"))};class NOt{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[RQe],this.allowDefault=n.shiftKey;let o,l;if(r.inside>-1)o=s.state.doc.nodeAt(r.inside),l=r.inside;else{let p=s.state.doc.resolve(r.pos);o=p.parent,l=p.depth?p.before():0}const i=a?null:n.target,c=i?s.docView.nearestDesc(i,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=s.state;(n.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||u instanceof Wa&&u.from<=l&&u.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ax&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),s.root.addEventListener("mouseup",this.up=this.up.bind(this)),s.root.addEventListener("mousemove",this.move=this.move.bind(this)),S_(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(()=>x1(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(Eue(s))),this.updateAllowDefault(s),this.allowDefault||!r?S_(this.view,"pointer"):bOt(this.view,r.pos,r.inside,s,this.selectNode)?s.preventDefault():s.button==0&&(this.flushed||Qh&&this.mightDrag&&!this.mightDrag.node.isAtom||Xu&&!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)?(tT(this.view,fi.near(this.view.state.doc.resolve(r.pos))),s.preventDefault()):S_(this.view,"pointer")}move(s){this.updateAllowDefault(s),S_(this.view,"pointer"),s.buttons==0&&this.done()}updateAllowDefault(s){!this.allowDefault&&(Math.abs(this.event.x-s.clientX)>4||Math.abs(this.event.y-s.clientY)>4)&&(this.allowDefault=!0)}}qm.touchstart=t=>{t.input.lastTouch=Date.now(),zNe(t),S_(t,"pointer")};qm.touchmove=t=>{t.input.lastTouch=Date.now(),S_(t,"pointer")};qm.contextmenu=t=>zNe(t);function FQe(t,s){return t.composing?!0:Qh&&Math.abs(s.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const kOt=Zv?5e3:-1;Um.compositionstart=Um.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:s}=t,r=s.selection.$to;if(s.selection instanceof ei&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||Xu&&fQe&&SOt(t)))t.markCursor=t.state.storedMarks||r.marks(),sle(t,!0),t.markCursor=null;else if(sle(t,!s.selection.empty),Ax&&s.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let n=t.domSelectionRange();for(let a=n.focusNode,o=n.focusOffset;a&&a.nodeType==1&&o!=0;){let l=o<0?a.lastChild:a.childNodes[o-1];if(!l)break;if(l.nodeType==3){let i=t.domSelection();i&&i.collapse(l,l.nodeValue.length);break}else a=l,o=-1}}t.input.composing=!0}zQe(t,kOt)};function SOt(t){let{focusNode:s,focusOffset:r}=t.domSelectionRange();if(!s||s.nodeType!=1||r>=s.childNodes.length)return!1;let n=s.childNodes[r];return n.nodeType==1&&n.contentEditable=="false"}Um.compositionend=(t,s)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=s.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,zQe(t,20))};function zQe(t,s){clearTimeout(t.input.composingTimeout),s>-1&&(t.input.composingTimeout=setTimeout(()=>sle(t),s))}function BQe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=MOt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function COt(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=vDt(s.focusNode,s.focusOffset),n=bDt(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 MOt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function sle(t,s=!1){if(!(Zv&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),BQe(t),s||t.docView&&t.docView.dirty){let r=LNe(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 TOt(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 cD=Tp&&J_<15||WT&&NDt<604;qm.copy=Um.cut=(t,s)=>{let r=s,n=t.state.selection,a=r.type=="cut";if(n.empty)return;let o=cD?null:r.clipboardData,l=n.content(),{dom:i,text:c}=ONe(t,l);o?(r.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",c)):TOt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function AOt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function EOt(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?dD(t,n.value,null,a,s):dD(t,n.textContent,n.innerHTML,a,s)},50)}function dD(t,s,r,n,a){let o=EQe(t,s,r,n,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,a,o||jn.empty)))return!0;if(!o)return!1;let l=AOt(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 $Qe(t){let s=t.getData("text/plain")||t.getData("Text");if(s)return s;let r=t.getData("text/uri-list");return r?r.replace(/\r?\n/g," "):""}Um.paste=(t,s)=>{let r=s;if(t.composing&&!Zv)return;let n=cD?null:r.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&dD(t,$Qe(n),n.getData("text/html"),a,r)?r.preventDefault():EOt(t,r)};class qQe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const POt=cx?"altKey":"ctrlKey";function UQe(t,s){let r=t.someProp("dragCopies",n=>!n(s));return r??!s[POt]}qm.dragstart=(t,s)=>{let r=s,n=t.input.mouseDown;if(n&&n.done(),!r.dataTransfer)return;let a=t.state.selection,o=a.empty?null:t.posAtCoords(Eue(r)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof Wa?a.to-1:a.to))){if(n&&n.mightDrag)l=Wa.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=Wa.create(t.state.doc,f.posBefore))}}let i=(l||t.state.selection).content(),{dom:c,text:u,slice:p}=ONe(t,i);(!r.dataTransfer.files.length||!Xu||pQe>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(cD?"Text":"text/html",c.innerHTML),r.dataTransfer.effectAllowed="copyMove",cD||r.dataTransfer.setData("text/plain",u),t.dragging=new qQe(p,UQe(t,r),l)};qm.dragend=t=>{let s=t.dragging;window.setTimeout(()=>{t.dragging==s&&(t.dragging=null)},50)};Um.dragover=Um.dragenter=(t,s)=>s.preventDefault();Um.drop=(t,s)=>{try{IOt(t,s,t.dragging)}finally{t.dragging=null}};function IOt(t,s,r){if(!s.dataTransfer)return;let n=t.posAtCoords(Eue(s));if(!n)return;let a=t.state.doc.resolve(n.pos),o=r&&r.slice;o?t.someProp("transformPasted",b=>{o=b(o,t,!1)}):o=EQe(t,$Qe(s.dataTransfer),cD?null:s.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&UQe(t,s));if(t.someProp("handleDrop",b=>b(t,s,o||jn.empty,l))){s.preventDefault();return}if(!o)return;s.preventDefault();let i=o?aQe(t.state.doc,a.pos,o):a.pos;i==null&&(i=a.pos);let c=t.state.tr;if(l){let{node:b}=r;b?b.replace(c):c.deleteSelection()}let u=c.mapping.map(i),p=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(p?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o),c.doc.eq(f))return;let g=c.doc.resolve(u);if(p&&Wa.isSelectable(o.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new Wa(g));else{let b=c.mapping.map(i);c.mapping.maps[c.mapping.maps.length-1].forEach((_,j,w,k)=>b=k),c.setSelection(DNe(t,g,c.doc.resolve(b)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}qm.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&x1(t)},20))};qm.blur=(t,s)=>{let r=s;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),r.relatedTarget&&t.dom.contains(r.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};qm.beforeinput=(t,s)=>{if(Xu&&Zv&&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,d4(8,"Backspace")))))return;let{$cursor:a}=t.state.selection;a&&a.pos>0&&t.dispatch(t.state.tr.delete(a.pos-1,a.pos).scrollIntoView())},50)}};for(let t in Um)qm[t]=Um[t];function uD(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 rle{constructor(s,r){this.toDOM=s,this.spec=r||_S,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 Mm(o-n,o-n,this)}valid(){return!0}eq(s){return this==s||s instanceof rle&&(this.spec.key&&this.spec.key==s.spec.key||this.toDOM==s.toDOM&&uD(this.spec,s.spec))}destroy(s){this.spec.destroy&&this.spec.destroy(s)}}class tw{constructor(s,r){this.attrs=s,this.spec=r||_S}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 Mm(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==Bh||s.maps.length==0?this:this.mapInner(s,r,0,0,n||_S)}mapInner(s,r,n,a,o){let l;for(let i=0;i{let u=c+n,p;if(p=HQe(r,i,u)){for(a||(a=this.children.slice());oi&&f.to=s){this.children[i]==s&&(n=this.children[i+2]);break}let o=s+1,l=o+r.content.size;for(let i=0;io&&c.type instanceof tw){let u=Math.max(o,c.from)-o,p=Math.min(l,c.to)-o;ua.map(s,r,_S));return n_.from(n)}forChild(s,r){if(r.isLeaf)return fd.empty;let n=[];for(let a=0;ar instanceof fd)?s:s.reduce((r,n)=>r.concat(n instanceof fd?n:n.members),[]))}}forEachSet(s){for(let r=0;r{let w=j-_-(b-g);for(let k=0;kS+p-f)continue;let M=i[k]+p-f;b>=M?i[k+1]=g<=M?-2:-1:g>=p&&w&&(i[k]+=w,i[k+1]+=w)}f+=w}),p=r.maps[u].map(p,-1)}let c=!1;for(let u=0;u=n.content.size){c=!0;continue}let g=r.map(t[u+1]+o,-1),b=g-a,{index:_,offset:j}=n.content.findIndex(f),w=n.maybeChild(_);if(w&&j==f&&j+w.nodeSize==b){let k=i[u+2].mapInner(r,w,p+1,t[u]+o+1,l);k!=Bh?(i[u]=f,i[u+1]=b,i[u+2]=k):(i[u+1]=-2,c=!0)}else c=!0}if(c){let u=DOt(i,t,s,r,a,o,l),p=nle(u,n,0,l);s=p.local;for(let f=0;fr&&l.to{let u=HQe(t,i,c+r);if(u){o=!0;let p=nle(u,i,r+c+1,n);p!=Bh&&a.push(c,c+i.nodeSize,p)}});let l=VQe(o?WQe(t):t,-r).sort(wS);for(let i=0;i0;)s++;t.splice(s,0,r)}function oge(t){let s=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=Bh&&s.push(n)}),t.cursorWrapper&&s.push(fd.create(t.state.doc,[t.cursorWrapper.deco])),n_.from(s)}const OOt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ROt=Tp&&J_<=11;class FOt{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 zOt{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new FOt,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()}),ROt&&(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,OOt)),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(tLe(this.view)){if(this.suppressingSelectionUpdates)return x1(this.view);if(Tp&&J_<=11&&!this.view.state.selection.empty){let s=this.view.domSelectionRange();if(s.focusNode&&KS(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=HT(o))r.add(o);for(let o=s.anchorNode;o;o=HT(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)&&tLe(s)&&!this.ignoreSelectionChange(n),o=-1,l=-1,i=!1,c=[];if(s.editable)for(let p=0;pf.nodeName=="BR");if(p.length==2){let[f,g]=p;f.parentNode&&f.parentNode.parentNode==g.parentNode?g.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let g of p){let b=g.parentNode;b&&b.nodeName=="LI"&&(!f||qOt(s,f)!=b)&&g.remove()}}}else if((Xu||Qh)&&c.some(p=>p.nodeName=="BR")&&(s.input.lastKeyCode==8||s.input.lastKeyCode==46)){for(let p of c)if(p.nodeName=="BR"&&p.parentNode){let f=p.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&p.parentNode.removeChild(p)}}let u=null;o<0&&a&&s.input.lastFocus>Date.now()-200&&Math.max(s.input.lastTouch,s.input.lastClick.time)-1||a)&&(o>-1&&(s.docView.markDirty(o,l),BOt(s)),this.handleDOMChange(o,l,i,c),s.docView&&s.docView.dirty?s.updateState(s.state):this.currentSelection.eq(n)||x1(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 k=n.childNodes[w-1],S=k.pmViewDesc;if(k.nodeName=="BR"&&!S){o=w;break}if(!S||S.size)break}let f=t.state.doc,g=t.someProp("domParser")||QL.fromSchema(t.state.schema),b=f.resolve(l),_=null,j=g.parse(n,{topNode:b.parent,topMatch:b.parent.contentMatchAt(b.index()),topOpen:!0,from:a,to:o,preserveWhitespace:b.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:VOt,context:b});if(u&&u[0].pos!=null){let w=u[0].pos,k=u[1]&&u[1].pos;k==null&&(k=w),_={anchor:w+l,head:k+l}}return{doc:j,sel:_,from:l,to:i}}function VOt(t){let s=t.pmViewDesc;if(s)return s.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Qh&&/^(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||Qh&&/^(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 HOt=/^(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 WOt(t,s,r,n,a){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,s<0){let q=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,U=LNe(t,q);if(U&&!t.state.selection.eq(U)){if(Xu&&Zv&&t.input.lastKeyCode===13&&Date.now()-100V(t,d4(13,"Enter"))))return;let B=t.state.tr.setSelection(U);q=="pointer"?B.setMeta("pointer",!0):q=="key"&&B.scrollIntoView(),o&&B.setMeta("composition",o),t.dispatch(B)}return}let l=t.state.doc.resolve(s),i=l.sharedDepth(r);s=l.before(i+1),r=t.state.doc.resolve(r).after(i+1);let c=t.state.selection,u=UOt(t,s,r),p=t.state.doc,f=p.slice(u.from,u.to),g,b;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Zv)&&a.some(q=>q.nodeType==1&&!HOt.test(q.nodeName))&&(!_||_.endA>=_.endB)&&t.someProp("handleKeyDown",q=>q(t,d4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!_)if(n&&c instanceof ei&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))_={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let q=mLe(t,t.state.doc,u.sel);if(q&&!q.eq(t.state.selection)){let U=t.state.tr.setSelection(q);o&&U.setMeta("composition",o),t.dispatch(U)}}return}t.state.selection.fromt.state.selection.from&&_.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?_.start=t.state.selection.from:_.endA=t.state.selection.to-2&&t.state.selection.to<=u.to&&(_.endB+=t.state.selection.to-_.endA,_.endA=t.state.selection.to)),Tp&&J_<=11&&_.endB==_.start+1&&_.endA==_.start&&_.start>u.from&&u.doc.textBetween(_.start-u.from-1,_.start-u.from+1)=="  "&&(_.start--,_.endA--,_.endB--);let j=u.doc.resolveNoCache(_.start-u.from),w=u.doc.resolveNoCache(_.endB-u.from),k=p.resolve(_.start),S=j.sameParent(w)&&j.parent.inlineContent&&k.end()>=_.endA;if((WT&&t.input.lastIOSEnter>Date.now()-225&&(!S||a.some(q=>q.nodeName=="DIV"||q.nodeName=="P"))||!S&&j.posq(t,d4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>_.start&&KOt(p,_.start,_.endA,j,w)&&t.someProp("handleKeyDown",q=>q(t,d4(8,"Backspace")))){Zv&&Xu&&t.domObserver.suppressSelectionUpdates();return}Xu&&_.endB==_.start&&(t.input.lastChromeDelete=Date.now()),Zv&&!S&&j.start()!=w.start()&&w.parentOffset==0&&j.depth==w.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==_.endA&&(_.endB-=2,w=u.doc.resolveNoCache(_.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(q){return q(t,d4(13,"Enter"))})},20));let M=_.start,L=_.endA,I=q=>{let U=q||t.state.tr.replace(M,L,u.doc.slice(_.start-u.from,_.endB-u.from));if(u.sel){let B=mLe(t,U.doc,u.sel);B&&!(Xu&&t.composing&&B.empty&&(_.start!=_.endB||t.input.lastChromeDeletex1(t),20));let q=I(t.state.tr.delete(M,L)),U=p.resolve(_.start).marksAcross(p.resolve(_.endA));U&&q.ensureMarks(U),t.dispatch(q)}else if(_.endA==_.endB&&(O=GOt(j.parent.content.cut(j.parentOffset,w.parentOffset),k.parent.content.cut(k.parentOffset,_.endA-k.start())))){let q=I(t.state.tr);O.type=="add"?q.addMark(M,L,O.mark):q.removeMark(M,L,O.mark),t.dispatch(q)}else if(j.parent.child(j.index()).isText&&j.index()==w.index()-(w.textOffset?0:1)){let q=j.parent.textBetween(j.parentOffset,w.parentOffset),U=()=>I(t.state.tr.insertText(q,M,L));t.someProp("handleTextInput",B=>B(t,M,L,q,U))||t.dispatch(U())}else t.dispatch(I());else t.dispatch(I())}function mLe(t,s,r){return Math.max(r.anchor,r.head)>s.content.size?null:DNe(t,s.resolve(r.anchor),s.resolve(r.head))}function GOt(t,s){let r=t.firstChild.marks,n=s.firstChild.marks,a=r,o=n,l,i,c;for(let p=0;pp.mark(i.addToSet(p.marks));else if(a.length==0&&o.length==1)i=o[0],l="remove",c=p=>p.mark(i.removeFromSet(p.marks));else return null;let u=[];for(let p=0;pr||lge(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 ZOt(t,s,r,n,a){let o=t.findDiffStart(s,r);if(o==null)return null;let{a:l,b:i}=t.findDiffEnd(s,r+t.size,r+s.size);if(a=="end"){let c=Math.max(0,o-Math.min(l,i));n-=l+c-o}if(l=l?o-n:0;o-=c,o&&o=i?o-n:0;o-=c,o&&o=56320&&s<=57343&&r>=55296&&r<=56319}class GQe{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 hOt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(vLe),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=gLe(this),xLe(this),this.nodeViews=yLe(this),this.docView=ZIe(this.state.doc,fLe(this),oge(this),this.dom,this),this.domObserver=new zOt(this,(n,a,o,l)=>WOt(this,n,a,o,l)),this.domObserver.start(),mOt(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&&D1e(this);let r=this._props;this._props=s,s.plugins&&(s.plugins.forEach(vLe),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&&(BQe(this),l=!0),this.state=s;let i=a.plugins!=s.plugins||this._props.plugins!=r.plugins;if(i||this._props.plugins!=r.plugins||this._props.nodeViews!=r.nodeViews){let b=yLe(this);XOt(b,this.nodeViews)&&(this.nodeViews=b,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&D1e(this),this.editable=gLe(this),xLe(this);let c=oge(this),u=fLe(this),p=a.plugins!=s.plugins&&!a.doc.eq(s.doc)?"reset":s.scrollToSelection>a.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(s.doc,u,c);(f||!s.selection.eq(a.selection))&&(l=!0);let g=p=="preserve"&&l&&this.dom.style.overflowAnchor==null&&CDt(this);if(l){this.domObserver.stop();let b=f&&(Tp||Xu)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&YOt(a.selection,s.selection);if(f){let _=Xu?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=COt(this)),(o||!this.docView.update(s.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=ZIe(s.doc,u,c,this.dom,this)),_&&!this.trackWrites&&(b=!0)}b||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&XDt(this))?x1(this,b):(MQe(this,s.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(a),!((n=this.dragging)===null||n===void 0)&&n.node&&!a.doc.eq(s.doc)&&this.updateDraggedNode(this.dragging,a),p=="reset"?this.dom.scrollTop=0:p=="to selection"?this.scrollToSelection():g&&MDt(g)}scrollToSelection(){let s=this.domSelectionRange().focusNode;if(!(!s||!this.dom.contains(s.nodeType==1?s:s.parentNode))){if(!this.someProp("handleScrollToSelection",r=>r(this)))if(this.state.selection instanceof Wa){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&UIe(this,r.getBoundingClientRect(),s)}else UIe(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 qQe(s.slice,s.move,a<0?void 0:Wa.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 LDt(this,s)}coordsAtPos(s,r=1){return bQe(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 zDt(this,r||this.state,s)}pasteHTML(s,r){return dD(this,"",s,!1,r||new ClipboardEvent("paste"))}pasteText(s,r){return dD(this,s,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(s){return ONe(this,s)}destroy(){this.docView&&(pOt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],oge(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,gDt())}get isDestroyed(){return this.docView==null}dispatchEvent(s){return xOt(this,s)}domSelectionRange(){let s=this.domSelection();return s?Qh&&this.root.nodeType===11&&wDt(this.dom.ownerDocument)==this.dom&&$Ot(this,s)||s:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}GQe.prototype.dispatch=function(t){let s=this._props.dispatchTransaction;s?s.call(this,t):this.updateState(this.state.apply(t))};function fLe(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"),[Mm.node(0,t.state.doc.content.size,s)]}function xLe(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:Mm.widget(t.state.selection.from,s,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function gLe(t){return!t.someProp("editable",s=>s(t.state)===!1)}function YOt(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 yLe(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 XOt(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 vLe(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 gw={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:"'"},ale={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},QOt=typeof navigator<"u"&&/Mac/.test(navigator.platform),JOt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var _h=0;_h<10;_h++)gw[48+_h]=gw[96+_h]=String(_h);for(var _h=1;_h<=24;_h++)gw[_h+111]="F"+_h;for(var _h=65;_h<=90;_h++)gw[_h]=String.fromCharCode(_h+32),ale[_h]=String.fromCharCode(_h);for(var cge in gw)ale.hasOwnProperty(cge)||(ale[cge]=gw[cge]);function eRt(t){var s=QOt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||JOt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?ale:gw)[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 tRt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),sRt=typeof navigator<"u"&&/Win/.test(navigator.platform);function rRt(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 KQe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const ZQe=(t,s,r)=>{let n=KQe(t,r);if(!n)return!1;let a=VNe(n);if(!a){let l=n.blockRange(),i=l&&rE(l);return i==null?!1:(s&&s(t.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(nJe(t,a,s,-1))return!0;if(n.parent.content.size==0&&(GT(o,"end")||Wa.isSelectable(o)))for(let l=n.depth;;l--){let i=Cue(t.doc,n.before(l),n.after(l),jn.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},iRt=(t,s,r)=>{let n=KQe(t,r);if(!n)return!1;let a=VNe(n);return a?YQe(t,a,s):!1},oRt=(t,s,r)=>{let n=QQe(t,r);if(!n)return!1;let a=HNe(n);return a?YQe(t,a,s):!1};function YQe(t,s,r){let n=s.nodeBefore,a=n,o=s.pos-1;for(;!a.isTextblock;o--){if(a.type.spec.isolating)return!1;let p=a.lastChild;if(!p)return!1;a=p}let l=s.nodeAfter,i=l,c=s.pos+1;for(;!i.isTextblock;c++){if(i.type.spec.isolating)return!1;let p=i.firstChild;if(!p)return!1;i=p}let u=Cue(t.doc,o,c,jn.empty);if(!u||u.from!=o||u instanceof Zu&&u.slice.size>=c-o)return!1;if(r){let p=t.tr.step(u);p.setSelection(ei.create(p.doc,o)),r(p.scrollIntoView())}return!0}function GT(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 XQe=(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=VNe(n)}let l=o&&o.nodeBefore;return!l||!Wa.isSelectable(l)?!1:(s&&s(t.tr.setSelection(Wa.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function VNe(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 QQe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("forward",t):r.parentOffset{let n=QQe(t,r);if(!n)return!1;let a=HNe(n);if(!a)return!1;let o=a.nodeAfter;if(nJe(t,a,s,1))return!0;if(n.parent.content.size==0&&(GT(o,"start")||Wa.isSelectable(o))){let l=Cue(t.doc,n.before(),n.after(),jn.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 Wa,a;if(n){if(r.node.isTextblock||!Lw(t.doc,r.from))return!1;a=r.from}else if(a=Sue(t.doc,r.from,-1),a==null)return!1;if(s){let o=t.tr.join(a);n&&o.setSelection(Wa.create(o.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),s(o.scrollIntoView())}return!0},cRt=(t,s)=>{let r=t.selection,n;if(r instanceof Wa){if(r.node.isTextblock||!Lw(t.doc,r.to))return!1;n=r.to}else if(n=Sue(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},dRt=(t,s)=>{let{$from:r,$to:n}=t.selection,a=r.blockRange(n),o=a&&rE(a);return o==null?!1:(s&&s(t.tr.lift(a,o).scrollIntoView()),!0)},tJe=(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 WNe(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=WNe(a.contentMatchAt(o));if(!l||!a.canReplaceWith(o,o,l))return!1;if(s){let i=r.after(),c=t.tr.replaceWith(i,i,l.createAndFill());c.setSelection(fi.near(c.doc.resolve(i),1)),s(c.scrollIntoView())}return!0},sJe=(t,s)=>{let r=t.selection,{$from:n,$to:a}=r;if(r instanceof bf||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=WNe(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(f1(t.doc,o))return s&&s(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),a=n&&rE(n);return a==null?!1:(s&&s(t.tr.lift(n,a).scrollIntoView()),!0)};function hRt(t){return(s,r)=>{let{$from:n,$to:a}=s.selection;if(s.selection instanceof Wa&&s.selection.node.isBlock)return!n.parentOffset||!f1(s.doc,n.pos)?!1:(r&&r(s.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],l,i,c=!1,u=!1;for(let b=n.depth;;b--)if(n.node(b).isBlock){c=n.end(b)==n.pos+(n.depth-b),u=n.start(b)==n.pos-(n.depth-b),i=WNe(n.node(b-1).contentMatchAt(n.indexAfter(b-1))),o.unshift(c&&i?{type:i}:null),l=b;break}else{if(b==1)return!1;o.unshift(null)}let p=s.tr;(s.selection instanceof ei||s.selection instanceof bf)&&p.deleteSelection();let f=p.mapping.map(n.pos),g=f1(p.doc,f,o.length,o);if(g||(o[0]=i?{type:i}:null,g=f1(p.doc,f,o.length,o)),!g)return!1;if(p.split(f,o.length,o),!c&&u&&n.node(l).type!=i){let b=p.mapping.map(n.before(l)),_=p.doc.resolve(b);i&&n.node(l-1).canReplaceWith(_.index(),_.index()+1,i)&&p.setNodeMarkup(p.mapping.map(n.before(l)),i)}return r&&r(p.scrollIntoView()),!0}}const mRt=hRt(),pRt=(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(Wa.create(t.doc,a))),!0)};function fRt(t,s,r){let n=s.nodeBefore,a=s.nodeAfter,o=s.index();return!n||!a||!n.type.compatibleContent(a.type)?!1:!n.content.size&&s.parent.canReplace(o-1,o)?(r&&r(t.tr.delete(s.pos-n.nodeSize,s.pos).scrollIntoView()),!0):!s.parent.canReplace(o,o+1)||!(a.isTextblock||Lw(t.doc,s.pos))?!1:(r&&r(t.tr.join(s.pos).scrollIntoView()),!0)}function nJe(t,s,r,n){let a=s.nodeBefore,o=s.nodeAfter,l,i,c=a.type.spec.isolating||o.type.spec.isolating;if(!c&&fRt(t,s,r))return!0;let u=!c&&s.parent.canReplace(s.index(),s.index()+1);if(u&&(l=(i=a.contentMatchAt(a.childCount)).findWrapping(o.type))&&i.matchType(l[0]||o.type).validEnd){if(r){let b=s.pos+o.nodeSize,_=Dr.empty;for(let k=l.length-1;k>=0;k--)_=Dr.from(l[k].create(null,_));_=Dr.from(a.copy(_));let j=t.tr.step(new rh(s.pos-1,b,s.pos,b,new jn(_,1,0),l.length,!0)),w=j.doc.resolve(b+2*l.length);w.nodeAfter&&w.nodeAfter.type==a.type&&Lw(j.doc,w.pos)&&j.join(w.pos),r(j.scrollIntoView())}return!0}let p=o.type.spec.isolating||n>0&&c?null:fi.findFrom(s,1),f=p&&p.$from.blockRange(p.$to),g=f&&rE(f);if(g!=null&&g>=s.depth)return r&&r(t.tr.lift(f,g).scrollIntoView()),!0;if(u&>(o,"start",!0)&>(a,"end")){let b=a,_=[];for(;_.push(b),!b.isTextblock;)b=b.lastChild;let j=o,w=1;for(;!j.isTextblock;j=j.firstChild)w++;if(b.canReplace(b.childCount,b.childCount,j.content)){if(r){let k=Dr.empty;for(let M=_.length-1;M>=0;M--)k=Dr.from(_[M].copy(k));let S=t.tr.step(new rh(s.pos-_.length,s.pos+o.nodeSize,s.pos+w,s.pos+o.nodeSize-w,new jn(k,_.length,0),0,!0));r(S.scrollIntoView())}return!0}}return!1}function aJe(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(ei.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const xRt=aJe(-1),gRt=aJe(1);function yRt(t,s=null){return function(r,n){let{$from:a,$to:o}=r.selection,l=a.blockRange(o),i=l&&ANe(l,t,s);return i?(n&&n(r.tr.wrap(l,i).scrollIntoView()),!0):!1}}function bLe(t,s=null){return function(r,n){let a=!1;for(let o=0;o{if(a)return!1;if(!(!c.isTextblock||c.hasMarkup(t,s)))if(c.type==t)a=!0;else{let p=r.doc.resolve(u),f=p.index();a=p.parent.canReplaceWith(f,f+1,t)}})}if(!a)return!1;if(n){let o=r.tr;for(let l=0;l=2&&s.$from.node(s.depth-1).type.compatibleContent(r)&&s.startIndex==0){if(s.$from.index(s.depth-1)==0)return!1;let c=l.resolve(s.start-2);o=new Qoe(c,c,s.depth),s.endIndex=0;p--)o=Dr.from(r[p].type.create(r[p].attrs,o));t.step(new rh(s.start-(n?2:0),s.end,s.start,s.end,new jn(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?jRt(s,r,t,o):NRt(s,r,o):!0:!1}}function jRt(t,s,r,n){let a=t.tr,o=n.end,l=n.$to.end(n.depth);oj;_--)b-=a.child(_).nodeSize,n.delete(b-1,b+1);let o=n.doc.resolve(r.start),l=o.nodeAfter;if(n.mapping.map(r.end)!=r.start+o.nodeAfter.nodeSize)return!1;let i=r.startIndex==0,c=r.endIndex==a.childCount,u=o.node(-1),p=o.index(-1);if(!u.canReplace(p+(i?0:1),p+1,l.content.append(c?Dr.empty:Dr.from(a))))return!1;let f=o.pos,g=f+l.nodeSize;return n.step(new rh(f-(i?1:0),g+(c?1:0),f+1,g-1,new jn((i?Dr.empty:Dr.from(a.copy(Dr.empty))).append(c?Dr.empty:Dr.from(a.copy(Dr.empty))),i?0:1,c?0:1),i?0:1)),s(n.scrollIntoView()),!0}function kRt(t){return function(s,r){let{$from:n,$to:a}=s.selection,o=n.blockRange(a,u=>u.childCount>0&&u.firstChild.type==t);if(!o)return!1;let l=o.startIndex;if(l==0)return!1;let i=o.parent,c=i.child(l-1);if(c.type!=t)return!1;if(r){let u=c.lastChild&&c.lastChild.type==i.type,p=Dr.from(u?t.create():null),f=new jn(Dr.from(t.create(null,Dr.from(i.type.create(null,p)))),u?3:1,0),g=o.start,b=o.end;r(s.tr.step(new rh(g-(u?3:1),b,g,b,f,1,!0)).scrollIntoView())}return!0}}function Pue(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 Iue{constructor(s){this.editor=s.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=s.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:s,editor:r,state:n}=this,{view:a}=r,{tr:o}=n,l=this.buildProps(o);return Object.fromEntries(Object.entries(s).map(([i,c])=>[i,(...p)=>{const f=c(...p)(l);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(o),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i=[],c=!!s,u=s||o.tr,p=()=>(!c&&r&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(u),i.every(g=>g===!0)),f={...Object.fromEntries(Object.entries(n).map(([g,b])=>[g,(...j)=>{const w=this.buildProps(u,r),k=b(...j)(w);return i.push(k),f}])),run:p};return f}createCan(s){const{rawCommands:r,state:n}=this,a=!1,o=s||n.tr,l=this.buildProps(o,a);return{...Object.fromEntries(Object.entries(r).map(([c,u])=>[c,(...p)=>u(...p)({...l,dispatch:void 0})])),chain:()=>this.createChain(o,a)}}buildProps(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i={tr:s,editor:a,view:l,state:Pue({state:o,transaction:s}),dispatch:r?()=>{}:void 0,chain:()=>this.createChain(s,r),can:()=>this.createCan(s),get commands(){return Object.fromEntries(Object.entries(n).map(([c,u])=>[c,(...p)=>u(...p)(i)]))}};return i}}let SRt=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 oa(t,s,r){return t.config[s]===void 0&&t.parent?oa(t.parent,s,r):typeof t.config[s]=="function"?t.config[s].bind({...r,parent:t.parent?oa(t.parent,s,r):null}):t.config[s]}function Lue(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 iJe(t){const s=[],{nodeExtensions:r,markExtensions:n}=Lue(t),a=[...r,...n],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage,extensions:a},c=oa(l,"addGlobalAttributes",i);if(!c)return;c().forEach(p=>{p.types.forEach(f=>{Object.entries(p.attributes).forEach(([g,b])=>{s.push({type:f,name:g,attribute:{...o,...b}})})})})}),a.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage},c=oa(l,"addAttributes",i);if(!c)return;const u=c();Object.entries(u).forEach(([p,f])=>{const g={...o,...f};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,s.push({type:l.name,name:p,attribute:g})})}),s}function ih(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 Hc(...t){return t.filter(s=>!!s).reduce((s,r)=>{const n={...s};return Object.entries(r).forEach(([a,o])=>{if(!n[a]){n[a]=o;return}if(a==="class"){const i=o?String(o).split(" "):[],c=n[a]?n[a].split(" "):[],u=i.filter(p=>!c.includes(p));n[a]=[...c,...u].join(" ")}else if(a==="style"){const i=o?o.split(";").map(p=>p.trim()).filter(Boolean):[],c=n[a]?n[a].split(";").map(p=>p.trim()).filter(Boolean):[],u=new Map;c.forEach(p=>{const[f,g]=p.split(":").map(b=>b.trim());u.set(f,g)}),i.forEach(p=>{const[f,g]=p.split(":").map(b=>b.trim());u.set(f,g)}),n[a]=Array.from(u.entries()).map(([p,f])=>`${p}: ${f}`).join("; ")}else n[a]=o}),n},{})}function O1e(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)=>Hc(r,n),{})}function oJe(t){return typeof t=="function"}function eo(t,s=void 0,...r){return oJe(t)?s?t.bind(s)(...r):t(...r):t}function CRt(t={}){return Object.keys(t).length===0&&t.constructor===Object}function MRt(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function _Le(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):MRt(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function wLe(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&CRt(r)?!1:r!=null))}function TRt(t,s){var r;const n=iJe(t),{nodeExtensions:a,markExtensions:o}=Lue(t),l=(r=a.find(u=>oa(u,"topNode")))===null||r===void 0?void 0:r.name,i=Object.fromEntries(a.map(u=>{const p=n.filter(k=>k.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},g=t.reduce((k,S)=>{const M=oa(S,"extendNodeSchema",f);return{...k,...M?M(u):{}}},{}),b=wLe({...g,content:eo(oa(u,"content",f)),marks:eo(oa(u,"marks",f)),group:eo(oa(u,"group",f)),inline:eo(oa(u,"inline",f)),atom:eo(oa(u,"atom",f)),selectable:eo(oa(u,"selectable",f)),draggable:eo(oa(u,"draggable",f)),code:eo(oa(u,"code",f)),whitespace:eo(oa(u,"whitespace",f)),linebreakReplacement:eo(oa(u,"linebreakReplacement",f)),defining:eo(oa(u,"defining",f)),isolating:eo(oa(u,"isolating",f)),attrs:Object.fromEntries(p.map(k=>{var S;return[k.name,{default:(S=k==null?void 0:k.attribute)===null||S===void 0?void 0:S.default}]}))}),_=eo(oa(u,"parseHTML",f));_&&(b.parseDOM=_.map(k=>_Le(k,p)));const j=oa(u,"renderHTML",f);j&&(b.toDOM=k=>j({node:k,HTMLAttributes:O1e(k,p)}));const w=oa(u,"renderText",f);return w&&(b.toText=w),[u.name,b]})),c=Object.fromEntries(o.map(u=>{const p=n.filter(w=>w.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},g=t.reduce((w,k)=>{const S=oa(k,"extendMarkSchema",f);return{...w,...S?S(u):{}}},{}),b=wLe({...g,inclusive:eo(oa(u,"inclusive",f)),excludes:eo(oa(u,"excludes",f)),group:eo(oa(u,"group",f)),spanning:eo(oa(u,"spanning",f)),code:eo(oa(u,"code",f)),attrs:Object.fromEntries(p.map(w=>{var k;return[w.name,{default:(k=w==null?void 0:w.attribute)===null||k===void 0?void 0:k.default}]}))}),_=eo(oa(u,"parseHTML",f));_&&(b.parseDOM=_.map(w=>_Le(w,p)));const j=oa(u,"renderHTML",f);return j&&(b.toDOM=w=>j({mark:w,HTMLAttributes:O1e(w,p)})),[u.name,b]}));return new KXe({topNode:l,nodes:i,marks:c})}function uge(t,s){return s.nodes[t]||s.marks[t]||null}function jLe(t,s){return Array.isArray(s)?s.some(r=>(typeof r=="string"?r:r.name)===t.name):s}function KNe(t,s){const r=vC.fromSchema(s).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(r),a.innerHTML}const ARt=(t,s=500)=>{let r="";const n=t.parentOffset;return t.parent.nodesBetween(Math.max(0,n-s),n,(a,o,l,i)=>{var c,u;const p=((u=(c=a.type.spec).toText)===null||u===void 0?void 0:u.call(c,{node:a,pos:o,parent:l,index:i}))||a.textContent||"%leaf%";r+=a.isAtom&&!a.isText?p:p.slice(0,Math.max(0,n-o))}),r};function ZNe(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class Due{constructor(s){this.find=s.find,this.handler=s.handler}}const ERt=(t,s)=>{if(ZNe(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 dz(t){var s;const{editor:r,from:n,to:a,text:o,rules:l,plugin:i}=t,{view:c}=r;if(c.composing)return!1;const u=c.state.doc.resolve(n);if(u.parent.type.spec.code||!((s=u.nodeBefore||u.nodeAfter)===null||s===void 0)&&s.marks.find(g=>g.type.spec.code))return!1;let p=!1;const f=ARt(u)+o;return l.forEach(g=>{if(p)return;const b=ERt(f,g.find);if(!b)return;const _=c.state.tr,j=Pue({state:c.state,transaction:_}),w={from:n-(b[0].length-o.length),to:a},{commands:k,chain:S,can:M}=new Iue({editor:r,state:j});g.handler({state:j,range:w,match:b,commands:k,chain:S,can:M})===null||!_.steps.length||(_.setMeta(i,{transform:_,from:n,to:a,text:o}),c.dispatch(_),p=!0)}),p}function PRt(t){const{editor:s,rules:r}=t,n=new Iu({state:{init(){return null},apply(a,o,l){const i=a.getMeta(n);if(i)return i;const c=a.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:p}=c;typeof p=="string"?p=p:p=KNe(Dr.from(p),l.schema);const{from:f}=c,g=f+p.length;dz({editor:s,from:f,to:g,text:p,rules:r,plugin:n})}),a.selectionSet||a.docChanged?null:o}},props:{handleTextInput(a,o,l,i){return dz({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&dz({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?dz({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function IRt(t){return Object.prototype.toString.call(t).slice(8,-1)}function uz(t){return IRt(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Oue(t,s){const r={...t};return uz(t)&&uz(s)&&Object.keys(s).forEach(n=>{uz(s[n])&&uz(t[n])?r[n]=Oue(t[n],s[n]):r[n]=s[n]}),r}class ly{constructor(s={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=eo(oa(this,"addOptions",{name:this.name}))),this.storage=eo(oa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new ly(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Oue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new ly(s);return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=eo(oa(r,"addOptions",{name:r.name})),r.storage=eo(oa(r,"addStorage",{name:r.name,options:r.options})),r}static handleExit({editor:s,mark:r}){const{tr:n}=s.state,a=s.state.selection.$from;if(a.pos===a.end()){const l=a.marks();if(!!!l.find(u=>(u==null?void 0:u.type.name)===r.name))return!1;const c=l.find(u=>(u==null?void 0:u.type.name)===r.name);return c&&n.removeStoredMark(c),n.insertText(" ",a.pos),s.view.dispatch(n),!0}return!1}}function LRt(t){return typeof t=="number"}class DRt{constructor(s){this.find=s.find,this.handler=s.handler}}const ORt=(t,s,r)=>{if(ZNe(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 RRt(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:c,chain:u,can:p}=new Iue({editor:s,state:r}),f=[];return r.doc.nodesBetween(n,a,(b,_)=>{if(!b.isTextblock||b.type.spec.code)return;const j=Math.max(n,_),w=Math.min(a,_+b.content.size),k=b.textBetween(j-_,w-_,void 0,"");ORt(k,o.find,l).forEach(M=>{if(M.index===void 0)return;const L=j+M.index+1,I=L+M[0].length,O={from:r.tr.mapping.map(L),to:r.tr.mapping.map(I)},q=o.handler({state:r,range:O,match:M,commands:c,chain:u,can:p,pasteEvent:l,dropEvent:i});f.push(q)})}),f.every(b=>b!==null)}let hz=null;const FRt=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 zRt(t){const{editor:s,rules:r}=t;let n=null,a=!1,o=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,i;try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}const c=({state:p,from:f,to:g,rule:b,pasteEvt:_})=>{const j=p.tr,w=Pue({state:p,transaction:j});if(!(!RRt({editor:s,state:w,from:Math.max(f-1,0),to:g.b-1,rule:b,pasteEvent:_,dropEvent:i})||!j.steps.length)){try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,j}};return r.map(p=>new Iu({view(f){const g=_=>{var j;n=!((j=f.dom.parentElement)===null||j===void 0)&&j.contains(_.target)?f.dom.parentElement:null,n&&(hz=s)},b=()=>{hz&&(hz=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",b),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",b)}}},props:{handleDOMEvents:{drop:(f,g)=>{if(o=n===f.dom.parentElement,i=g,!o){const b=hz;b!=null&&b.isEditable&&setTimeout(()=>{const _=b.state.selection;_&&b.commands.deleteRange({from:_.from,to:_.to})},10)}return!1},paste:(f,g)=>{var b;const _=(b=g.clipboardData)===null||b===void 0?void 0:b.getData("text/html");return l=g,a=!!(_!=null&&_.includes("data-pm-slice")),!1}}},appendTransaction:(f,g,b)=>{const _=f[0],j=_.getMeta("uiEvent")==="paste"&&!a,w=_.getMeta("uiEvent")==="drop"&&!o,k=_.getMeta("applyPasteRules"),S=!!k;if(!j&&!w&&!S)return;if(S){let{text:I}=k;typeof I=="string"?I=I:I=KNe(Dr.from(I),b.schema);const{from:O}=k,q=O+I.length,U=FRt(I);return c({rule:p,state:b,from:O,to:{b:q},pasteEvt:U})}const M=g.doc.content.findDiffStart(b.doc.content),L=g.doc.content.findDiffEnd(b.doc.content);if(!(!LRt(M)||!L||M===L.b))return c({rule:p,state:b,from:M,to:L,pasteEvt:l})}}))}function BRt(t){const s=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(s))}class dM{constructor(s,r){this.splittableMarks=[],this.editor=r,this.extensions=dM.resolve(s),this.schema=TRt(this.extensions,r),this.setupExtensions()}static resolve(s){const r=dM.sort(dM.flatten(s)),n=BRt(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=oa(r,"addExtensions",n);return a?[r,...this.flatten(a())]:r}).flat(10)}static sort(s){return s.sort((n,a)=>{const o=oa(n,"priority")||100,l=oa(a,"priority")||100;return o>l?-1:o{const n={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:uge(r.name,this.schema)},a=oa(r,"addCommands",n);return a?{...s,...a()}:s},{})}get plugins(){const{editor:s}=this,r=dM.sort([...this.extensions].reverse()),n=[],a=[],o=r.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:s,type:uge(l.name,this.schema)},c=[],u=oa(l,"addKeyboardShortcuts",i);let p={};if(l.type==="mark"&&oa(l,"exitable",i)&&(p.ArrowRight=()=>ly.handleExit({editor:s,mark:l})),u){const j=Object.fromEntries(Object.entries(u()).map(([w,k])=>[w,()=>k({editor:s})]));p={...p,...j}}const f=aRt(p);c.push(f);const g=oa(l,"addInputRules",i);jLe(l,s.options.enableInputRules)&&g&&n.push(...g());const b=oa(l,"addPasteRules",i);jLe(l,s.options.enablePasteRules)&&b&&a.push(...b());const _=oa(l,"addProseMirrorPlugins",i);if(_){const j=_();c.push(...j)}return c}).flat();return[PRt({editor:s,rules:n}),...zRt({editor:s,rules:a}),...o]}get attributes(){return iJe(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=Lue(this.extensions);return Object.fromEntries(r.filter(n=>!!oa(n,"addNodeView")).map(n=>{const a=this.attributes.filter(c=>c.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:s,type:ih(n.name,this.schema)},l=oa(n,"addNodeView",o);if(!l)return[];const i=(c,u,p,f,g)=>{const b=O1e(c,a);return l()({node:c,view:u,getPos:p,decorations:f,innerDecorations:g,editor:s,extension:n,HTMLAttributes:b})};return[n.name,i]}))}setupExtensions(){this.extensions.forEach(s=>{var r;this.editor.extensionStorage[s.name]=s.storage;const n={name:s.name,options:s.options,storage:s.storage,editor:this.editor,type:uge(s.name,this.schema)};s.type==="mark"&&(!((r=eo(oa(s,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(s.name);const a=oa(s,"onBeforeCreate",n),o=oa(s,"onCreate",n),l=oa(s,"onUpdate",n),i=oa(s,"onSelectionUpdate",n),c=oa(s,"onTransaction",n),u=oa(s,"onFocus",n),p=oa(s,"onBlur",n),f=oa(s,"onDestroy",n);a&&this.editor.on("beforeCreate",a),o&&this.editor.on("create",o),l&&this.editor.on("update",l),i&&this.editor.on("selectionUpdate",i),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),p&&this.editor.on("blur",p),f&&this.editor.on("destroy",f)})}}class Ih{constructor(s={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=eo(oa(this,"addOptions",{name:this.name}))),this.storage=eo(oa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new Ih(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Oue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new Ih({...this.config,...s});return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=eo(oa(r,"addOptions",{name:r.name})),r.storage=eo(oa(r,"addStorage",{name:r.name,options:r.options})),r}}function lJe(t,s,r){const{from:n,to:a}=s,{blockSeparator:o=` `,textSerializers:l={}}=r||{};let i="";return t.nodesBetween(n,a,(c,u,p,f)=>{var g;c.isBlock&&u>n&&(i+=o);const b=l==null?void 0:l[c.type.name];if(b)return p&&(i+=b({node:c,pos:u,parent:p,index:f,range:s})),!1;c.isText&&(i+=(g=c==null?void 0:c.text)===null||g===void 0?void 0:g.slice(Math.max(n,u)-u,a-u))}),i}function cJe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,s])=>s.spec.toText).map(([s,r])=>[s,r.spec.toText]))}const $Rt=Ih.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Iu({key:new tm("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:s,schema:r}=t,{doc:n,selection:a}=s,{ranges:o}=a,l=Math.min(...o.map(p=>p.$from.pos)),i=Math.max(...o.map(p=>p.$to.pos)),c=cJe(r);return lJe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),qRt=()=>({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),URt=(t=!1)=>({commands:s})=>s.setContent("",t),VRt=()=>({state:t,tr:s,dispatch:r})=>{const{selection:n}=s,{ranges:a}=n;return r&&a.forEach(({$from:o,$to:l})=>{t.doc.nodesBetween(o.pos,l.pos,(i,c)=>{if(i.type.isText)return;const{doc:u,mapping:p}=s,f=u.resolve(p.map(c)),g=u.resolve(p.map(c+i.nodeSize)),b=f.blockRange(g);if(!b)return;const _=rE(b);if(i.type.isTextblock){const{defaultType:j}=f.parent.contentMatchAt(f.index());s.setNodeMarkup(b.start,j)}(_||_===0)&&s.lift(b,_)})}),!0},HRt=t=>s=>t(s),WRt=()=>({state:t,dispatch:s})=>sJe(t,s),GRt=(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 ei(n.doc.resolve(Math.max(l-1,0)))),!0},KRt=()=>({tr:t,dispatch:s})=>{const{selection:r}=t,n=r.$anchor.node();if(n.content.size>0)return!1;const a=t.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===n.type){if(s){const i=a.before(o),c=a.after(o);t.delete(i,c).scrollIntoView()}return!0}return!1},ZRt=t=>({tr:s,state:r,dispatch:n})=>{const a=ih(t,r.schema),o=s.selection.$anchor;for(let l=o.depth;l>0;l-=1)if(o.node(l).type===a){if(n){const c=o.before(l),u=o.after(l);s.delete(c,u).scrollIntoView()}return!0}return!1},YRt=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},XRt=()=>({state:t,dispatch:s})=>UNe(t,s),QRt=()=>({commands:t})=>t.keyboardShortcut("Enter"),JRt=()=>({state:t,dispatch:s})=>uRt(t,s);function ile(t,s,r={strict:!0}){const n=Object.keys(s);return n.length?n.every(a=>r.strict?s[a]===t[a]:ZNe(s[a])?s[a].test(t[a]):s[a]===t[a]):!0}function dJe(t,s,r={}){return t.find(n=>n.type===s&&ile(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function NLe(t,s,r={}){return!!dJe(t,s,r)}function YNe(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),!dJe([...a.node.marks],s,r)))return;let l=a.index,i=t.start()+a.offset,c=l+1,u=i+a.node.nodeSize;for(;l>0&&NLe([...t.parent.child(l-1).marks],s,r);)l-=1,i-=t.parent.child(l).nodeSize;for(;c({tr:r,state:n,dispatch:a})=>{const o=Ow(t,n.schema),{doc:l,selection:i}=r,{$from:c,from:u,to:p}=i;if(a){const f=YNe(c,o,s);if(f&&f.from<=u&&f.to>=p){const g=ei.create(l,f.from,f.to);r.setSelection(g)}}return!0},tFt=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=()=>{(XNe()||sFt())&&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&&!uJe(r.state.selection))return l(),!0;const i=hJe(a.doc,t)||r.state.selection,c=r.state.selection.eq(i);return o&&(c||a.setSelection(i),c&&a.storedMarks&&a.setStoredMarks(a.storedMarks),l()),!0},nFt=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),aFt=(t,s)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,s),mJe=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&&mJe(n)}return t};function mz(t){const s=`${t}`,r=new window.DOMParser().parseFromString(s,"text/html").body;return mJe(r)}function hD(t,s,r){if(t instanceof Q_||t instanceof Dr)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 Dr.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),hD("",s,r)}if(a){if(r.errorOnInvalidContent){let l=!1,i="";const c=new KXe({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?QL.fromSchema(c).parseSlice(mz(t),r.parseOptions):QL.fromSchema(c).parse(mz(t),r.parseOptions),r.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=QL.fromSchema(s);return r.slice?o.parseSlice(mz(t),r.parseOptions).content:o.parse(mz(t),r.parseOptions)}return hD("",s,r)}function iFt(t,s,r){const n=t.steps.length-1;if(n{l===0&&(l=p)}),t.setSelection(fi.near(t.doc.resolve(l),r))}const oFt=t=>!("type"in t),lFt=(t,s,r)=>({tr:n,dispatch:a,editor:o})=>{var l;if(a){r={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...r};let i;const c=w=>{o.emit("contentError",{editor:o,error:w,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{hD(s,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(w){c(w)}try{i=hD(s,o.schema,{parseOptions:u,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})}catch(w){return c(w),!1}let{from:p,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,b=!0;if((oFt(i)?i:[i]).forEach(w=>{w.check(),g=g?w.isText&&w.marks.length===0:!1,b=b?w.isBlock:!1}),p===f&&b){const{parent:w}=n.doc.resolve(p);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(p-=1,f+=1)}let j;if(g){if(Array.isArray(s))j=s.map(w=>w.text||"").join("");else if(s instanceof Dr){let w="";s.forEach(k=>{k.text&&(w+=k.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&&iFt(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},cFt=()=>({state:t,dispatch:s})=>lRt(t,s),dFt=()=>({state:t,dispatch:s})=>cRt(t,s),uFt=()=>({state:t,dispatch:s})=>ZQe(t,s),hFt=()=>({state:t,dispatch:s})=>JQe(t,s),mFt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=Sue(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},pFt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=Sue(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},fFt=()=>({state:t,dispatch:s})=>iRt(t,s),xFt=()=>({state:t,dispatch:s})=>oRt(t,s);function pJe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function gFt(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=gFt(t).split(/-(?!$)/),l=o.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),i=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),c=s.captureTransaction(()=>{r.someProp("handleKeyDown",u=>u(r,i))});return c==null||c.steps.forEach(u=>{const p=u.map(n.mapping);p&&a&&n.maybeStep(p)}),!0};function mD(t,s,r={}){const{from:n,to:a,empty:o}=t.selection,l=s?ih(s,t.schema):null,i=[];t.doc.nodesBetween(n,a,(f,g)=>{if(f.isText)return;const b=Math.max(n,g),_=Math.min(a,g+f.nodeSize);i.push({node:f,from:b,to:_})});const c=a-n,u=i.filter(f=>l?l.name===f.node.type.name:!0).filter(f=>ile(f.node.attrs,r,{strict:!1}));return o?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=c}const vFt=(t,s={})=>({state:r,dispatch:n})=>{const a=ih(t,r.schema);return mD(r,a,s)?dRt(r,n):!1},bFt=()=>({state:t,dispatch:s})=>rJe(t,s),_Ft=t=>({state:s,dispatch:r})=>{const n=ih(t,s.schema);return wRt(n)(s,r)},wFt=()=>({state:t,dispatch:s})=>tJe(t,s);function Rue(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function kLe(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 jFt=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Rue(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=ih(t,n.schema)),i==="mark"&&(l=Ow(t,n.schema)),a&&r.selection.ranges.forEach(c=>{n.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,p)=>{o&&o===u.type&&r.setNodeMarkup(p,void 0,kLe(u.attrs,s)),l&&u.marks.length&&u.marks.forEach(f=>{l===f.type&&r.addMark(p,p+u.nodeSize,l.create(kLe(f.attrs,s)))})})}),!0):!1},NFt=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),kFt=()=>({tr:t,dispatch:s})=>{if(s){const r=new bf(t.doc);t.setSelection(r)}return!0},SFt=()=>({state:t,dispatch:s})=>XQe(t,s),CFt=()=>({state:t,dispatch:s})=>eJe(t,s),MFt=()=>({state:t,dispatch:s})=>pRt(t,s),TFt=()=>({state:t,dispatch:s})=>gRt(t,s),AFt=()=>({state:t,dispatch:s})=>xRt(t,s);function R1e(t,s,r={},n={}){return hD(t,s,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const EFt=(t,s=!1,r={},n={})=>({editor:a,tr:o,dispatch:l,commands:i})=>{var c,u;const{doc:p}=o;if(r.preserveWhitespace!=="full"){const f=R1e(t,a.schema,r,{errorOnInvalidContent:(c=n.errorOnInvalidContent)!==null&&c!==void 0?c:a.options.enableContentCheck});return l&&o.replaceWith(0,p.content.size,f).setMeta("preventUpdate",!s),!0}return l&&o.setMeta("preventUpdate",!s),i.insertContentAt({from:0,to:p.content.size},t,{parseOptions:r,errorOnInvalidContent:(u=n.errorOnInvalidContent)!==null&&u!==void 0?u:a.options.enableContentCheck})};function fJe(t,s){const r=Ow(s,t.schema),{from:n,to:a,empty:o}=t.selection,l=[];o?(t.storedMarks&&l.push(...t.storedMarks),l.push(...t.selection.$head.marks())):t.doc.nodesBetween(n,a,c=>{l.push(...c.marks)});const i=l.find(c=>c.type.name===r.name);return i?{...i.attrs}:{}}function PFt(t,s){const r=new ENe(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function IFt(t){for(let s=0;s{r(a)&&n.push({node:a,pos:o})}),n}function xJe(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 QNe(t){return s=>xJe(s.$from,t)}function DFt(t,s){const r={from:0,to:t.content.size};return lJe(t,r,s)}function OFt(t,s){const r=ih(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 gJe(t,s){const r=Rue(typeof s=="string"?s:s.name,t.schema);return r==="node"?OFt(t,s):r==="mark"?fJe(t,s):{}}function RFt(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 FFt(t){const s=RFt(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 zFt(t){const{mapping:s,steps:r}=t,n=[];return s.maps.forEach((a,o)=>{const l=[];if(a.ranges.length)a.forEach((i,c)=>{l.push({from:i,to:c})});else{const{from:i,to:c}=r[o];if(i===void 0||c===void 0)return;l.push({from:i,to:c})}l.forEach(({from:i,to:c})=>{const u=s.slice(o).map(i,-1),p=s.slice(o).map(c),f=s.invert().map(u,-1),g=s.invert().map(p);n.push({oldRange:{from:f,to:g},newRange:{from:u,to:p}})})}),FFt(n)}function JNe(t,s,r){const n=[];return t===s?r.resolve(t).marks().forEach(a=>{const o=r.resolve(t),l=YNe(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 kie(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 F1e(t,s,r={}){const{empty:n,ranges:a}=t.selection,o=s?Ow(s,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>ile(f.attrs,r,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:f,$to:g})=>{const b=f.pos,_=g.pos;t.doc.nodesBetween(b,_,(j,w)=>{if(!j.isText&&!j.marks.length)return;const k=Math.max(b,w),S=Math.min(_,w+j.nodeSize),M=S-k;l+=M,i.push(...j.marks.map(L=>({mark:L,from:k,to:S})))})}),l===0)return!1;const c=i.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>ile(f.mark.attrs,r,{strict:!1})).reduce((f,g)=>f+g.to-g.from,0),u=i.filter(f=>o?f.mark.type!==o&&f.mark.type.excludes(o):!0).reduce((f,g)=>f+g.to-g.from,0);return(c>0?c+u:c)>=l}function BFt(t,s,r={}){if(!s)return mD(t,null,r)||F1e(t,null,r);const n=Rue(s,t.schema);return n==="node"?mD(t,s,r):n==="mark"?F1e(t,s,r):!1}function SLe(t,s){const{nodeExtensions:r}=Lue(s),n=r.find(l=>l.name===t);if(!n)return!1;const a={name:n.name,options:n.options,storage:n.storage},o=eo(oa(n,"group",a));return typeof o!="string"?!1:o.split(" ").includes("list")}function eke(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&&(eke(o,{ignoreWhitespace:r,checkChildren:s})||(a=!1))}),a}return!1}function $Ft(t){return t instanceof Wa}function qFt(t,s,r){var n;const{selection:a}=s;let o=null;if(uJe(a)&&(o=a.$cursor),o){const i=(n=t.storedMarks)!==null&&n!==void 0?n:o.marks();return!!r.isInSet(i)||!i.some(c=>c.type.excludes(r))}const{ranges:l}=a;return l.some(({$from:i,$to:c})=>{let u=i.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):!1;return t.doc.nodesBetween(i.pos,c.pos,(p,f,g)=>{if(u)return!1;if(p.isInline){const b=!g||g.type.allowsMarkType(r),_=!!r.isInSet(p.marks)||!p.marks.some(j=>j.type.excludes(r));u=b&&_}return!u}),u})}const UFt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{const{selection:o}=r,{empty:l,ranges:i}=o,c=Ow(t,n.schema);if(a)if(l){const u=fJe(n,c);r.addStoredMark(c.create({...u,...s}))}else i.forEach(u=>{const p=u.$from.pos,f=u.$to.pos;n.doc.nodesBetween(p,f,(g,b)=>{const _=Math.max(b,p),j=Math.min(b+g.nodeSize,f);g.marks.find(k=>k.type===c)?g.marks.forEach(k=>{c===k.type&&r.addMark(_,j,c.create({...k.attrs,...s}))}):r.addMark(_,j,c.create(s))})});return qFt(n,r,c)},VFt=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),HFt=(t,s={})=>({state:r,dispatch:n,chain:a})=>{const o=ih(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})=>bLe(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>bLe(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},WFt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,a=N4(t,0,n.content.size),o=Wa.create(n,a);s.setSelection(o)}return!0},GFt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=ei.atStart(n).from,i=ei.atEnd(n).to,c=N4(a,l,i),u=N4(o,l,i),p=ei.create(n,c,u);s.setSelection(p)}return!0},KFt=t=>({state:s,dispatch:r})=>{const n=ih(t,s.schema);return kRt(n)(s,r)};function CLe(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 ZFt=({keepMarks:t=!0}={})=>({tr:s,state:r,dispatch:n,editor:a})=>{const{selection:o,doc:l}=s,{$from:i,$to:c}=o,u=a.extensionManager.attributes,p=kie(u,i.node().type.name,i.node().attrs);if(o instanceof Wa&&o.node.isBlock)return!i.parentOffset||!f1(l,i.pos)?!1:(n&&(t&&CLe(r,a.extensionManager.splittableMarks),s.split(i.pos).scrollIntoView()),!0);if(!i.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,g=i.depth===0?void 0:IFt(i.node(-1).contentMatchAt(i.indexAfter(-1)));let b=f&&g?[{type:g,attrs:p}]:void 0,_=f1(s.doc,s.mapping.map(i.pos),1,b);if(!b&&!_&&f1(s.doc,s.mapping.map(i.pos),1,g?[{type:g}]:void 0)&&(_=!0,b=g?[{type:g,attrs:p}]:void 0),n){if(_&&(o instanceof ei&&s.deleteSelection(),s.split(s.mapping.map(i.pos),1,b),g&&!f&&!i.parentOffset&&i.parent.type!==g)){const j=s.mapping.map(i.before()),w=s.doc.resolve(j);i.node(-1).canReplaceWith(w.index(),w.index()+1,g)&&s.setNodeMarkup(s.mapping.map(i.before()),g)}t&&CLe(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return _},YFt=(t,s={})=>({tr:r,state:n,dispatch:a,editor:o})=>{var l;const i=ih(t,n.schema),{$from:c,$to:u}=n.selection,p=n.selection.node;if(p&&p.isBlock||c.depth<2||!c.sameParent(u))return!1;const f=c.node(-1);if(f.type!==i)return!1;const g=o.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==i||c.index(-2)!==c.node(-2).childCount-1)return!1;if(a){let k=Dr.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let U=c.depth-S;U>=c.depth-3;U-=1)k=Dr.from(c.node(U).copy(k));const M=c.indexAfter(-1){if(q>-1)return!1;U.isTextblock&&U.content.size===0&&(q=B+1)}),q>-1&&r.setSelection(ei.near(r.doc.resolve(q))),r.scrollIntoView()}return!0}const b=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,_={...kie(g,f.type.name,f.attrs),...s},j={...kie(g,c.node().type.name,c.node().attrs),...s};r.delete(c.pos,u.pos);const w=b?[{type:i,attrs:_},{type:b,attrs:j}]:[{type:i,attrs:_}];if(!f1(r.doc,c.pos,2))return!1;if(a){const{selection:k,storedMarks:S}=n,{splittableMarks:M}=o.extensionManager,L=S||k.$to.parentOffset&&k.$from.marks();if(r.split(c.pos,2,w).scrollIntoView(),!L||!a)return!0;const I=L.filter(O=>M.includes(O.type.name));r.ensureMarks(I)}return!0},hge=(t,s)=>{const r=QNe(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)&&Lw(t.doc,r.pos)&&t.join(r.pos),!0},mge=(t,s)=>{const r=QNe(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)&&Lw(t.doc,n)&&t.join(n),!0},XFt=(t,s,r,n={})=>({editor:a,tr:o,state:l,dispatch:i,chain:c,commands:u,can:p})=>{const{extensions:f,splittableMarks:g}=a.extensionManager,b=ih(t,l.schema),_=ih(s,l.schema),{selection:j,storedMarks:w}=l,{$from:k,$to:S}=j,M=k.blockRange(S),L=w||j.$to.parentOffset&&j.$from.marks();if(!M)return!1;const I=QNe(O=>SLe(O.type.name,f))(j);if(M.depth>=1&&I&&M.depth-I.depth<=1){if(I.node.type===b)return u.liftListItem(_);if(SLe(I.node.type.name,f)&&b.validContent(I.node.content)&&i)return c().command(()=>(o.setNodeMarkup(I.pos,b),!0)).command(()=>hge(o,b)).command(()=>mge(o,b)).run()}return!r||!L||!i?c().command(()=>p().wrapInList(b,n)?!0:u.clearNodes()).wrapInList(b,n).command(()=>hge(o,b)).command(()=>mge(o,b)).run():c().command(()=>{const O=p().wrapInList(b,n),q=L.filter(U=>g.includes(U.type.name));return o.ensureMarks(q),O?!0:u.clearNodes()}).wrapInList(b,n).command(()=>hge(o,b)).command(()=>mge(o,b)).run()},QFt=(t,s={},r={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=r,l=Ow(t,n.schema);return F1e(n,l,s)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,s)},JFt=(t,s,r={})=>({state:n,commands:a})=>{const o=ih(t,n.schema),l=ih(s,n.schema),i=mD(n,o,r);let c;return n.selection.$anchor.sameParent(n.selection.$head)&&(c=n.selection.$anchor.parent.attrs),i?a.setNode(l,c):a.setNode(o,{...c,...r})},e7t=(t,s={})=>({state:r,commands:n})=>{const a=ih(t,r.schema);return mD(r,a,s)?n.lift(a):n.wrapIn(a,s)},t7t=()=>({state:t,dispatch:s})=>{const r=t.plugins;for(let n=0;n=0;c-=1)l.step(i.steps[c].invert(i.docs[c]));if(o.text){const c=l.doc.resolve(o.from).marks();l.replaceWith(o.from,o.to,t.schema.text(o.text,c))}else l.delete(o.from,o.to)}return!0}}return!1},s7t=()=>({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},r7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{var o;const{extendEmptyMarkRange:l=!1}=s,{selection:i}=r,c=Ow(t,n.schema),{$from:u,empty:p,ranges:f}=i;if(!a)return!0;if(p&&l){let{from:g,to:b}=i;const _=(o=u.marks().find(w=>w.type===c))===null||o===void 0?void 0:o.attrs,j=YNe(u,c,_);j&&(g=j.from,b=j.to),r.removeMark(g,b,c)}else f.forEach(g=>{r.removeMark(g.$from.pos,g.$to.pos,c)});return r.removeStoredMark(c),!0},n7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Rue(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=ih(t,n.schema)),i==="mark"&&(l=Ow(t,n.schema)),a&&r.selection.ranges.forEach(c=>{const u=c.$from.pos,p=c.$to.pos;let f,g,b,_;r.selection.empty?n.doc.nodesBetween(u,p,(j,w)=>{o&&o===j.type&&(b=Math.max(w,u),_=Math.min(w+j.nodeSize,p),f=w,g=j)}):n.doc.nodesBetween(u,p,(j,w)=>{w=u&&w<=p&&(o&&o===j.type&&r.setNodeMarkup(w,void 0,{...j.attrs,...s}),l&&j.marks.length&&j.marks.forEach(k=>{if(l===k.type){const S=Math.max(w,u),M=Math.min(w+j.nodeSize,p);r.addMark(S,M,l.create({...k.attrs,...s}))}}))}),g&&(f!==void 0&&r.setNodeMarkup(f,void 0,{...g.attrs,...s}),l&&g.marks.length&&g.marks.forEach(j=>{l===j.type&&r.addMark(b,_,l.create({...j.attrs,...s}))}))}),!0):!1},a7t=(t,s={})=>({state:r,dispatch:n})=>{const a=ih(t,r.schema);return yRt(a,s)(r,n)},i7t=(t,s={})=>({state:r,dispatch:n})=>{const a=ih(t,r.schema);return vRt(a,s)(r,n)};var o7t=Object.freeze({__proto__:null,blur:qRt,clearContent:URt,clearNodes:VRt,command:HRt,createParagraphNear:WRt,cut:GRt,deleteCurrentNode:KRt,deleteNode:ZRt,deleteRange:YRt,deleteSelection:XRt,enter:QRt,exitCode:JRt,extendMarkRange:eFt,first:tFt,focus:rFt,forEach:nFt,insertContent:aFt,insertContentAt:lFt,joinBackward:uFt,joinDown:dFt,joinForward:hFt,joinItemBackward:mFt,joinItemForward:pFt,joinTextblockBackward:fFt,joinTextblockForward:xFt,joinUp:cFt,keyboardShortcut:yFt,lift:vFt,liftEmptyBlock:bFt,liftListItem:_Ft,newlineInCode:wFt,resetAttributes:jFt,scrollIntoView:NFt,selectAll:kFt,selectNodeBackward:SFt,selectNodeForward:CFt,selectParentNode:MFt,selectTextblockEnd:TFt,selectTextblockStart:AFt,setContent:EFt,setMark:UFt,setMeta:VFt,setNode:HFt,setNodeSelection:WFt,setTextSelection:GFt,sinkListItem:KFt,splitBlock:ZFt,splitListItem:YFt,toggleList:XFt,toggleMark:QFt,toggleNode:JFt,toggleWrap:e7t,undoInputRule:t7t,unsetAllMarks:s7t,unsetMark:r7t,updateAttributes:n7t,wrapIn:a7t,wrapInList:i7t});const l7t=Ih.create({name:"commands",addCommands(){return{...o7t}}}),c7t=Ih.create({name:"drop",addProseMirrorPlugins(){return[new Iu({key:new tm("tiptapDrop"),props:{handleDrop:(t,s,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:s,slice:r,moved:n})}}})]}}),d7t=Ih.create({name:"editable",addProseMirrorPlugins(){return[new Iu({key:new tm("editable"),props:{editable:()=>this.editor.options.editable}})]}}),u7t=new tm("focusEvents"),h7t=Ih.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Iu({key:u7t,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}}}})]}}),m7t=Ih.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:i})=>{const{selection:c,doc:u}=i,{empty:p,$anchor:f}=c,{pos:g,parent:b}=f,_=f.parent.isTextblock&&g>0?i.doc.resolve(g-1):f,j=_.parent.type.spec.isolating,w=f.pos-f.parentOffset,k=j&&_.parent.childCount===1?w===f.pos:fi.atStart(u).from===g;return!p||!b.type.isTextblock||b.textContent.length||!k||k&&f.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),s=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:s,"Mod-Delete":s,"Mod-a":()=>this.editor.commands.selectAll()},a={...n},o={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":s,"Ctrl-Alt-Backspace":s,"Alt-Delete":s,"Alt-d":s,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return XNe()||pJe()?o:a},addProseMirrorPlugins(){return[new Iu({key:new tm("clearDocument"),appendTransaction:(t,s,r)=>{if(t.some(j=>j.getMeta("composition")))return;const n=t.some(j=>j.docChanged)&&!s.doc.eq(r.doc),a=t.some(j=>j.getMeta("preventClearDocument"));if(!n||a)return;const{empty:o,from:l,to:i}=s.selection,c=fi.atStart(s.doc).from,u=fi.atEnd(s.doc).to;if(o||!(l===c&&i===u)||!eke(r.doc))return;const g=r.tr,b=Pue({state:r,transaction:g}),{commands:_}=new Iue({editor:this.editor,state:b});if(_.clearNodes(),!!g.steps.length)return g}})]}}),p7t=Ih.create({name:"paste",addProseMirrorPlugins(){return[new Iu({key:new tm("tiptapPaste"),props:{handlePaste:(t,s,r)=>{this.editor.emit("paste",{editor:this.editor,event:s,slice:r})}}})]}}),f7t=Ih.create({name:"tabindex",addProseMirrorPlugins(){return[new Iu({key:new tm("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class u4{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 u4(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 u4(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 u4(s,this.editor)}get children(){const s=[];return this.node.content.forEach((r,n)=>{const a=r.isBlock&&!r.isTextblock,o=r.isAtom&&!r.isText,l=this.pos+n+(o?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const i=this.resolvedPos.doc.resolve(l);if(!a&&i.depth<=this.depth)return;const c=new u4(i,this.editor,a,a?r:null);a&&(c.actualDepth=this.depth+1),s.push(new u4(i,this.editor,a,a?r:null))}),s}get firstChild(){return this.children[0]||null}get lastChild(){const s=this.children;return s[s.length-1]||null}closest(s,r={}){let n=null,a=this.parent;for(;a&&!n;){if(a.node.type.name===s)if(Object.keys(r).length>0){const o=a.node.attrs,l=Object.keys(r);for(let i=0;i{n&&a.length>0||(l.node.type.name===s&&o.every(c=>r[c]===l.node.attrs[c])&&a.push(l),!(n&&a.length>0)&&(a=a.concat(l.querySelectorAll(s,r,n))))}),a}setAttribute(s){const{tr:r}=this.editor.state;r.setNodeMarkup(this.from,void 0,{...this.node.attrs,...s}),this.editor.view.dispatch(r)}}const x7t=`.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 g7t(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 y7t extends SRt{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=g7t(x7t,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=oJe(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?[d7t,$Rt.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),l7t,h7t,m7t,f7t,c7t,p7t].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 dM(a,this)}createCommandManager(){this.commandManager=new Iue({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var s;let r;try{r=R1e(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=R1e(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=hJe(r,this.options.autofocus);this.view=new GQe(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:cM.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 gJe(this.state,s)}isActive(s,r){const n=typeof s=="string"?s:null,a=typeof s=="string"?r:s;return BFt(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return KNe(this.state.doc.content,this.schema)}getText(s){const{blockSeparator:r=` `,textSerializers:n={}}=s||{};return DFt(this.state.doc,{blockSeparator:r,textSerializers:{...cJe(this.schema),...n}})}get isEmpty(){return eke(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 u4(r,this)}get $doc(){return this.$pos(0)}}function KT(t){return new Due({find:t.find,handler:({state:s,range:r,match:n})=>{const a=eo(t.getAttributes,void 0,n);if(a===!1||a===null)return null;const{tr:o}=s,l=n[n.length-1],i=n[0];if(l){const c=i.search(/\S/),u=r.from+i.indexOf(l),p=u+l.length;if(JNe(r.from,r.to,s.doc).filter(b=>b.mark.type.excluded.find(j=>j===t.type&&j!==b.mark.type)).filter(b=>b.to>u).length)return null;pr.from&&o.delete(r.from+c,u);const g=r.from+c+l.length;o.addMark(r.from+c,g,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}function yJe(t){return new Due({find:t.find,handler:({state:s,range:r,match:n})=>{const a=eo(t.getAttributes,void 0,n)||{},{tr:o}=s,l=r.from;let i=r.to;const c=t.type.create(a);if(n[1]){const u=n[0].lastIndexOf(n[1]);let p=l+u;p>i?p=i:i=p+n[1].length;const f=n[0][n[0].length-1];o.insertText(f,l+n[0].length-1),o.replaceWith(p,i,c)}else if(n[0]){const u=t.type.isInline?l:l-1;o.insert(u,t.type.create(a)).delete(o.mapping.map(l),o.mapping.map(i))}o.scrollIntoView()}})}function z1e(t){return new Due({find:t.find,handler:({state:s,range:r,match:n})=>{const a=s.doc.resolve(r.from),o=eo(t.getAttributes,void 0,n)||{};if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),t.type))return null;s.tr.delete(r.from,r.to).setBlockType(r.from,r.from,t.type,o)}})}function pD(t){return new Due({find:t.find,handler:({state:s,range:r,match:n,chain:a})=>{const o=eo(t.getAttributes,void 0,n)||{},l=s.tr.delete(r.from,r.to),c=l.doc.resolve(r.from).blockRange(),u=c&&ANe(c,t.type,o);if(!u)return null;if(l.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:g}=s,{splittableMarks:b}=t.editor.extensionManager,_=g||f.$to.parentOffset&&f.$from.marks();if(_){const j=_.filter(w=>b.includes(w.type.name));l.ensureMarks(j)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(f,o).run()}const p=l.doc.resolve(r.from-1).nodeBefore;p&&p.type===t.type&&Lw(l.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,p))&&l.join(r.from-1)}})}let sm=class B1e{constructor(s={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=eo(oa(this,"addOptions",{name:this.name}))),this.storage=eo(oa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new B1e(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Oue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new B1e(s);return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=eo(oa(r,"addOptions",{name:r.name})),r.storage=eo(oa(r,"addStorage",{name:r.name,options:r.options})),r}};function YS(t){return new DRt({find:t.find,handler:({state:s,range:r,match:n,pasteEvent:a})=>{const o=eo(t.getAttributes,void 0,n,a);if(o===!1||o===null)return null;const{tr:l}=s,i=n[n.length-1],c=n[0];let u=r.to;if(i){const p=c.search(/\S/),f=r.from+c.indexOf(i),g=f+i.length;if(JNe(r.from,r.to,s.doc).filter(_=>_.mark.type.excluded.find(w=>w===t.type&&w!==_.mark.type)).filter(_=>_.to>f).length)return null;gr.from&&l.delete(r.from+p,f),u=r.from+p+i.length,l.addMark(r.from+p,u,t.type.create(o||{})),l.removeStoredMark(t.type)}}})}function v7t(t,s){const{selection:r}=t,{$from:n}=r;if(r instanceof Wa){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 b7t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var vJe={exports:{}},pge={};/** * @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 MLe;function _7t(){if(MLe)return pge;MLe=1;var t=ht;function s(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var r=typeof Object.is=="function"?Object.is:s,n=t.useState,a=t.useEffect,o=t.useLayoutEffect,l=t.useDebugValue;function i(f,g){var b=g(),_=n({inst:{value:b,getSnapshot:g}}),j=_[0].inst,w=_[1];return o(function(){j.value=b,j.getSnapshot=g,c(j)&&w({inst:j})},[f,b,g]),a(function(){return c(j)&&w({inst:j}),f(function(){c(j)&&w({inst:j})})},[f]),l(b),b}function c(f){var g=f.getSnapshot;f=f.value;try{var b=g();return!r(f,b)}catch{return!0}}function u(f,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:i;return pge.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,pge}vJe.exports=_7t();var tke=vJe.exports;const w7t=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},j7t=({contentComponent:t})=>{const s=tke.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return ht.createElement(ht.Fragment,null,Object.values(s))};function N7t(){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]:d2e.createPortal(n.reactElement,n.element,r)},t.forEach(a=>a())},removeRenderer(r){const n={...s};delete n[r],s=n,t.forEach(a=>a())}}}class k7t extends ht.Component{constructor(s){var r;super(s),this.editorContentRef=ht.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((r=s.editor)===null||r===void 0)&&r.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const s=this.props.editor;if(s&&!s.isDestroyed&&s.options.element){if(s.contentComponent)return;const r=this.editorContentRef.current;r.append(...s.options.element.childNodes),s.setOptions({element:r}),s.contentComponent=N7t(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=s.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),s.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const s=this.props.editor;if(!s||(this.initialized=!1,s.isDestroyed||s.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),s.contentComponent=null,!s.options.element.firstChild))return;const r=document.createElement("div");r.append(...s.options.element.childNodes),s.setOptions({element:r})}render(){const{editor:s,innerRef:r,...n}=this.props;return ht.createElement(ht.Fragment,null,ht.createElement("div",{ref:w7t(r,this.editorContentRef),...n}),(s==null?void 0:s.contentComponent)&&ht.createElement(j7t,{contentComponent:s.contentComponent}))}}const S7t=N.forwardRef((t,s)=>{const r=ht.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ht.createElement(k7t,{key:r,innerRef:s,...t})}),ske=ht.memo(S7t);var C7t=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},M7t=b7t(C7t),bJe={exports:{}},fge={};/** * @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 TLe;function T7t(){if(TLe)return fge;TLe=1;var t=ht,s=tke;function r(u,p){return u===p&&(u!==0||1/u===1/p)||u!==u&&p!==p}var n=typeof Object.is=="function"?Object.is:r,a=s.useSyncExternalStore,o=t.useRef,l=t.useEffect,i=t.useMemo,c=t.useDebugValue;return fge.useSyncExternalStoreWithSelector=function(u,p,f,g,b){var _=o(null);if(_.current===null){var j={hasValue:!1,value:null};_.current=j}else j=_.current;_=i(function(){function k(O){if(!S){if(S=!0,M=O,O=g(O),b!==void 0&&j.hasValue){var q=j.value;if(b(q,O))return L=q}return L=O}if(q=L,n(M,O))return q;var U=g(O);return b!==void 0&&b(q,U)?q:(M=O,L=U)}var S=!1,M,L,I=f===void 0?null:f;return[function(){return k(p())},I===null?void 0:function(){return k(I())}]},[p,f,g,b]);var w=a(u,_[0],_[1]);return l(function(){j.hasValue=!0,j.value=w},[w]),c(w),w},fge}bJe.exports=T7t();var A7t=bJe.exports;const E7t=typeof window<"u"?N.useLayoutEffect:N.useEffect;class P7t{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 I7t(t){var s;const[r]=N.useState(()=>new P7t(t.editor)),n=A7t.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:M7t);return E7t(()=>r.watch(t.editor),[t.editor,r]),N.useDebugValue(n),n}const L7t=!1,$1e=typeof window>"u",D7t=$1e||!!(typeof window<"u"&&window.next);class rke{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?$1e||D7t?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 y7t(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?rke.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 nke(t={},s=[]){const r=N.useRef(t);r.current=t;const[n]=N.useState(()=>new rke(r)),a=tke.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return N.useDebugValue(a),N.useEffect(n.onRender(s)),I7t({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const O7t=N.createContext({editor:null});O7t.Consumer;const R7t=N.createContext({onDragStart:void 0}),F7t=()=>N.useContext(R7t);ht.forwardRef((t,s)=>{const{onDragStart:r}=F7t(),n=t.as||"div";return ht.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const z7t=/^\s*>\s$/,B7t=sm.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",Hc(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[pD({find:z7t,type:this.type})]}}),$7t=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,q7t=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,U7t=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,V7t=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,H7t=ly.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",Hc(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[KT({find:$7t,type:this.type}),KT({find:U7t,type:this.type})]},addPasteRules(){return[YS({find:q7t,type:this.type}),YS({find:V7t,type:this.type})]}}),W7t="listItem",ALe="textStyle",ELe=/^\s*([-+*])\s$/,G7t=sm.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",Hc(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(W7t,this.editor.getAttributes(ALe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=pD({find:ELe,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=pD({find:ELe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ALe),editor:this.editor})),[t]}}),K7t=/(^|[^`])`([^`]+)`(?!`)/,Z7t=/(^|[^`])`([^`]+)`(?!`)/g,Y7t=ly.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Hc(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[KT({find:K7t,type:this.type})]},addPasteRules(){return[YS({find:Z7t,type:this.type})]}}),X7t=/^```([a-z]+)?[\s\n]$/,Q7t=/^~~~([a-z]+)?[\s\n]$/,J7t=sm.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",Hc(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(fi.near(n.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[z1e({find:X7t,type:this.type,getAttributes:t=>({language:t[1]})}),z1e({find:Q7t,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Iu({key:new tm("codeBlockVSCodeHandler"),props:{handlePaste:(t,s)=>{if(!s.clipboardData||this.editor.isActive(this.type.name))return!1;const r=s.clipboardData.getData("text/plain"),n=s.clipboardData.getData("vscode-editor-data"),a=n?JSON.parse(n):void 0,o=a==null?void 0:a.mode;if(!r||!o)return!1;const{tr:l,schema:i}=t.state,c=i.text(r.replace(/\r\n?/g,` `));return l.replaceSelectionWith(this.type.create({language:o},c)),l.selection.$from.parent.type!==this.type&&l.setSelection(ei.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),ezt=sm.create({name:"doc",topNode:!0,content:"block+"});function tzt(t={}){return new Iu({view(s){return new szt(s,t)}})}class szt{constructor(s,r){var n;this.editorView=s,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=r.width)!==null&&n!==void 0?n:1,this.color=r.color===!1?void 0:r.color||"black",this.class=r.class,this.handlers=["dragover","dragend","drop","dragleave"].map(a=>{let o=l=>{this[a](l)};return s.dom.addEventListener(a,o),{name:a,handler:o}})}destroy(){this.handlers.forEach(({name:s,handler:r})=>this.editorView.dom.removeEventListener(s,r))}update(s,r){this.cursorPos!=null&&r.doc!=s.state.doc&&(this.cursorPos>s.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(s){s!=this.cursorPos&&(this.cursorPos=s,s==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let s=this.editorView.state.doc.resolve(this.cursorPos),r=!s.parent.inlineContent,n,a=this.editorView.dom,o=a.getBoundingClientRect(),l=o.width/a.offsetWidth,i=o.height/a.offsetHeight;if(r){let f=s.nodeBefore,g=s.nodeAfter;if(f||g){let b=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(b){let _=b.getBoundingClientRect(),j=f?_.bottom:_.top;f&&g&&(j=(j+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*i;n={left:_.left,right:_.right,top:j-w,bottom:j+w}}}}if(!n){let f=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*l;n={left:f.left-g,right:f.left+g,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r);let u,p;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,p=-pageYOffset;else{let f=c.getBoundingClientRect(),g=f.width/c.offsetWidth,b=f.height/c.offsetHeight;u=f.left-c.scrollLeft*g,p=f.top-c.scrollTop*b}this.element.style.left=(n.left-u)/l+"px",this.element.style.top=(n.top-p)/i+"px",this.element.style.width=(n.right-n.left)/l+"px",this.element.style.height=(n.bottom-n.top)/i+"px"}scheduleRemoval(s){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),s)}dragover(s){if(!this.editorView.editable)return;let r=this.editorView.posAtCoords({left:s.clientX,top:s.clientY}),n=r&&r.inside>=0&&this.editorView.state.doc.nodeAt(r.inside),a=n&&n.type.spec.disableDropCursor,o=typeof a=="function"?a(this.editorView,r,s):a;if(r&&!o){let l=r.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let i=aQe(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 rzt=Ih.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[tzt(this.options)]}});class xd extends fi{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return xd.valid(n)?new xd(n):fi.near(n)}content(){return jn.empty}eq(s){return s instanceof xd&&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 xd(s.resolve(r.pos))}getBookmark(){return new ake(this.anchor)}static valid(s){let r=s.parent;if(r.isTextblock||!nzt(s)||!azt(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&&xd.valid(s))return s;let a=s.pos,o=null;for(let l=s.depth;;l--){let i=s.node(l);if(r>0?s.indexAfter(l)0){o=i.child(r>0?s.indexAfter(l):s.index(l)-1);break}else if(l==0)return null;a+=r;let c=s.doc.resolve(a);if(xd.valid(c))return c}for(;;){let l=r>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!Wa.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(xd.valid(i))return i}return null}}}xd.prototype.visible=!1;xd.findFrom=xd.findGapCursorFrom;fi.jsonID("gapcursor",xd);class ake{constructor(s){this.pos=s}map(s){return new ake(s.map(this.pos))}resolve(s){let r=s.resolve(this.pos);return xd.valid(r)?new xd(r):fi.near(r)}}function _Je(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function nzt(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||_Je(a.type))return!0;if(a.inlineContent)return!1}}return!0}function azt(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||_Je(a.type))return!0;if(a.inlineContent)return!1}}return!0}function izt(){return new Iu({props:{decorations:dzt,createSelectionBetween(t,s,r){return s.pos==r.pos&&xd.valid(r)?new xd(r):null},handleClick:lzt,handleKeyDown:ozt,handleDOMEvents:{beforeinput:czt}}})}const ozt=qNe({ArrowLeft:pz("horiz",-1),ArrowRight:pz("horiz",1),ArrowUp:pz("vert",-1),ArrowDown:pz("vert",1)});function pz(t,s){const r=t=="vert"?s>0?"down":"up":s>0?"right":"left";return function(n,a,o){let l=n.selection,i=s>0?l.$to:l.$from,c=l.empty;if(l instanceof ei){if(!o.endOfTextblock(r)||i.depth==0)return!1;c=!1,i=n.doc.resolve(s>0?i.after():i.before())}let u=xd.findGapCursorFrom(i,s,c);return u?(a&&a(n.tr.setSelection(new xd(u))),!0):!1}}function lzt(t,s,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(s);if(!xd.valid(n))return!1;let a=t.posAtCoords({left:r.clientX,top:r.clientY});return a&&a.inside>-1&&Wa.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new xd(n))),!0)}function czt(t,s){if(s.inputType!="insertCompositionText"||!(t.state.selection instanceof xd))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=Dr.empty;for(let l=n.length-1;l>=0;l--)a=Dr.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new jn(a,0,0));return o.setSelection(ei.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function dzt(t){if(!(t.selection instanceof xd))return null;let s=document.createElement("div");return s.className="ProseMirror-gapcursor",fd.create(t.doc,[Mm.widget(t.selection.head,s,{key:"gapcursor"})])}const uzt=Ih.create({name:"gapCursor",addProseMirrorPlugins(){return[izt()]},extendNodeSchema(t){var s;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(s=eo(oa(t,"allowGapCursor",r)))!==null&&s!==void 0?s:null}}}),hzt=sm.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",Hc(this.options.HTMLAttributes,t)]},renderText(){return` `},addCommands(){return{setHardBreak:()=>({commands:t,chain:s,state:r,editor:n})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:a,storedMarks:o}=r;if(a.$from.parent.type.spec.isolating)return!1;const{keepMarks:l}=this.options,{splittableMarks:i}=n.extensionManager,c=o||a.$to.parentOffset&&a.$from.marks();return s().insertContent({type:this.name}).command(({tr:u,dispatch:p})=>{if(p&&c&&l){const f=c.filter(g=>i.includes(g.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),mzt=sm.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]}`,Hc(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=>z1e({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var ole=200,nh=function(){};nh.prototype.append=function(s){return s.length?(s=nh.from(s),!this.length&&s||s.length=r?nh.empty:this.sliceInner(Math.max(0,s),Math.min(this.length,r))};nh.prototype.get=function(s){if(!(s<0||s>=this.length))return this.getInner(s)};nh.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)};nh.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};nh.from=function(s){return s instanceof nh?s:s&&s.length?new wJe(s):nh.empty};var wJe=function(t){function s(n){t.call(this),this.values=n}t&&(s.__proto__=t),s.prototype=Object.create(t&&t.prototype),s.prototype.constructor=s;var r={length:{configurable:!0},depth:{configurable:!0}};return s.prototype.flatten=function(){return this.values},s.prototype.sliceInner=function(a,o){return a==0&&o==this.length?this:new s(this.values.slice(a,o))},s.prototype.getInner=function(a){return this.values[a]},s.prototype.forEachInner=function(a,o,l,i){for(var c=o;c=l;c--)if(a(this.values[c],i+c)===!1)return!1},s.prototype.leafAppend=function(a){if(this.length+a.length<=ole)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=ole)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}(nh);nh.empty=new wJe([]);var pzt=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}(nh);const fzt=500;class Ug{constructor(s,r){this.items=s,this.eventCount=r}popEvent(s,r){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let a,o;r&&(a=this.remapping(n,this.items.length),o=a.maps.length);let l=s.tr,i,c,u=[],p=[];return this.items.forEach((f,g)=>{if(!f.step){a||(a=this.remapping(n,g+1),o=a.maps.length),o--,p.push(f);return}if(a){p.push(new Wy(f.map));let b=f.step.map(a.slice(o)),_;b&&l.maybeStep(b).doc&&(_=l.mapping.maps[l.mapping.maps.length-1],u.push(new Wy(_,void 0,void 0,u.length+p.length))),o--,_&&a.appendMap(_,o)}else l.maybeStep(f.step);if(f.selection)return i=a?f.selection.map(a.slice(o)):f.selection,c=new Ug(this.items.slice(0,n).append(p.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:l,selection:i}}addTransform(s,r,n,a){let o=[],l=this.eventCount,i=this.items,c=!a&&i.length?i.get(i.length-1):null;for(let p=0;pgzt&&(i=xzt(i,u),l-=u),new Ug(i.append(o),l)}remapping(s,r){let n=new oD;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 Ug(this.items.append(s.map(r=>new Wy(r))),this.eventCount)}rebased(s,r){if(!this.eventCount)return this;let n=[],a=Math.max(0,this.items.length-r),o=s.mapping,l=s.steps.length,i=this.eventCount;this.items.forEach(g=>{g.selection&&i--},a);let c=r;this.items.forEach(g=>{let b=o.getMirror(--c);if(b==null)return;l=Math.min(l,b);let _=o.maps[b];if(g.step){let j=s.steps[b].invert(s.docs[b]),w=g.selection&&g.selection.map(o.slice(c+1,b));w&&i++,n.push(new Wy(_,j,w))}else n.push(new Wy(_))},a);let u=[];for(let g=r;gfzt&&(f=f.compress(this.items.length-n.length)),f}emptyItemCount(){let s=0;return this.items.forEach(r=>{r.step||s++}),s}compress(s=this.items.length){let r=this.remapping(0,s),n=r.maps.length,a=[],o=0;return this.items.forEach((l,i)=>{if(i>=s)a.push(l),l.selection&&o++;else if(l.step){let c=l.step.map(r.slice(n)),u=c&&c.getMap();if(n--,u&&r.appendMap(u,n),c){let p=l.selection&&l.selection.map(r.slice(n));p&&o++;let f=new Wy(u.invert(),c,p),g,b=a.length-1;(g=a.length&&a[b].merge(f))?a[b]=g:a.push(f)}}else l.map&&n--},this.items.length,0),new Ug(nh.from(a.reverse()),o)}}Ug.empty=new Ug(nh.empty,0);function xzt(t,s){let r;return t.forEach((n,a)=>{if(n.selection&&s--==0)return r=a,!1}),t.slice(r)}class Wy{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 Wy(r.getMap().invert(),r,this.selection)}}}class Zb{constructor(s,r,n,a,o){this.done=s,this.undone=r,this.prevRanges=n,this.prevTime=a,this.prevComposition=o}}const gzt=20;function yzt(t,s,r,n){let a=r.getMeta(jS),o;if(a)return a.historyState;r.getMeta(_zt)&&(t=new Zb(t.done,t.undone,null,0,-1));let l=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(l&&l.getMeta(jS))return l.getMeta(jS).redo?new Zb(t.done.addTransform(r,void 0,n,Sie(s)),t.undone,PLe(r.mapping.maps),t.prevTime,t.prevComposition):new Zb(t.done,t.undone.addTransform(r,void 0,n,Sie(s)),null,t.prevTime,t.prevComposition);if(r.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let i=r.getMeta("composition"),c=t.prevTime==0||!l&&t.prevComposition!=i&&(t.prevTime<(r.time||0)-n.newGroupDelay||!vzt(r,t.prevRanges)),u=l?xge(t.prevRanges,r.mapping):PLe(r.mapping.maps);return new Zb(t.done.addTransform(r,c?s.selection.getBookmark():void 0,n,Sie(s)),Ug.empty,u,r.time,i??t.prevComposition)}else return(o=r.getMeta("rebased"))?new Zb(t.done.rebased(r,o),t.undone.rebased(r,o),xge(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new Zb(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),xge(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function vzt(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 PLe(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 xge(t,s){if(!t)return null;let r=[];for(let n=0;n{let a=jS.getState(r);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(n){let o=bzt(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const NJe=jJe(!1,!0),kJe=jJe(!0,!0),jzt=Ih.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:s})=>NJe(t,s),redo:()=>({state:t,dispatch:s})=>kJe(t,s)}},addProseMirrorPlugins(){return[wzt(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()}}}),Nzt=sm.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Hc(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:s})=>{if(!v7t(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}):$Ft(r)?o.insertContentAt(a.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:l,dispatch:i})=>{var c;if(i){const{$to:u}=l.selection,p=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?l.setSelection(ei.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(Wa.create(l.doc,u.pos)):l.setSelection(ei.create(l.doc,u.pos));else{const f=(c=u.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();f&&(l.insert(p,f),l.setSelection(ei.create(l.doc,p+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[yJe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),kzt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Szt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Czt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Mzt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Tzt=ly.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",Hc(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[KT({find:kzt,type:this.type}),KT({find:Czt,type:this.type})]},addPasteRules(){return[YS({find:Szt,type:this.type}),YS({find:Mzt,type:this.type})]}}),Azt=sm.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Hc(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)}}}),Ezt="listItem",LLe="textStyle",DLe=/^(\d+)\.\s$/,Pzt=sm.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",Hc(this.options.HTMLAttributes,r),0]:["ol",Hc(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(Ezt,this.editor.getAttributes(LLe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=pD({find:DLe,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=pD({find:DLe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(LLe)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),Izt=sm.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Hc(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Lzt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Dzt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Ozt=ly.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",Hc(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[KT({find:Lzt,type:this.type})]},addPasteRules(){return[YS({find:Dzt,type:this.type})]}}),Rzt=sm.create({name:"text",group:"inline"}),ike=Ih.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(H7t.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(B7t.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(G7t.configure(this.options.bulletList)),this.options.code!==!1&&t.push(Y7t.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(J7t.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(ezt.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(rzt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(uzt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(hzt.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(mzt.configure(this.options.heading)),this.options.history!==!1&&t.push(jzt.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(Nzt.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(Tzt.configure(this.options.italic)),this.options.listItem!==!1&&t.push(Azt.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(Pzt.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(Izt.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(Ozt.configure(this.options.strike)),this.options.text!==!1&&t.push(Rzt.configure(this.options.text)),t}}),Fzt="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",zzt="ελ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",q1e="numeric",U1e="ascii",V1e="alpha",s8="asciinumeric",SI="alphanumeric",H1e="domain",SJe="emoji",Bzt="scheme",$zt="slashscheme",yge="whitespace";function qzt(t,s){return t in s||(s[t]=[]),s[t]}function k4(t,s,r){s[q1e]&&(s[s8]=!0,s[SI]=!0),s[U1e]&&(s[s8]=!0,s[V1e]=!0),s[s8]&&(s[SI]=!0),s[V1e]&&(s[SI]=!0),s[SI]&&(s[H1e]=!0),s[SJe]&&(s[H1e]=!0);for(const n in s){const a=qzt(n,r);a.indexOf(t)<0&&a.push(t)}}function Uzt(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function xp(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}xp.groups={};xp.prototype={accepts(){return!!this.t},go(t){const s=this,r=s.j[t];if(r)return r;for(let n=0;nt.ta(s,r,n,a),od=(t,s,r,n,a)=>t.tr(s,r,n,a),OLe=(t,s,r,n,a)=>t.ts(s,r,n,a),Xr=(t,s,r,n,a)=>t.tt(s,r,n,a),Mv="WORD",W1e="UWORD",CJe="ASCIINUMERICAL",MJe="ALPHANUMERICAL",fD="LOCALHOST",G1e="TLD",K1e="UTLD",Cie="SCHEME",V5="SLASH_SCHEME",oke="NUM",Z1e="WS",lke="NL",r8="OPENBRACE",n8="CLOSEBRACE",lle="OPENBRACKET",cle="CLOSEBRACKET",dle="OPENPAREN",ule="CLOSEPAREN",hle="OPENANGLEBRACKET",mle="CLOSEANGLEBRACKET",ple="FULLWIDTHLEFTPAREN",fle="FULLWIDTHRIGHTPAREN",xle="LEFTCORNERBRACKET",gle="RIGHTCORNERBRACKET",yle="LEFTWHITECORNERBRACKET",vle="RIGHTWHITECORNERBRACKET",ble="FULLWIDTHLESSTHAN",_le="FULLWIDTHGREATERTHAN",wle="AMPERSAND",jle="APOSTROPHE",Nle="ASTERISK",Yb="AT",kle="BACKSLASH",Sle="BACKTICK",Cle="CARET",a_="COLON",cke="COMMA",Mle="DOLLAR",Gy="DOT",Tle="EQUALS",dke="EXCLAMATION",rx="HYPHEN",a8="PERCENT",Ale="PIPE",Ele="PLUS",Ple="POUND",i8="QUERY",uke="QUOTE",TJe="FULLWIDTHMIDDLEDOT",hke="SEMI",Ky="SLASH",o8="TILDE",Ile="UNDERSCORE",AJe="EMOJI",Lle="SYM";var EJe=Object.freeze({__proto__:null,ALPHANUMERICAL:MJe,AMPERSAND:wle,APOSTROPHE:jle,ASCIINUMERICAL:CJe,ASTERISK:Nle,AT:Yb,BACKSLASH:kle,BACKTICK:Sle,CARET:Cle,CLOSEANGLEBRACKET:mle,CLOSEBRACE:n8,CLOSEBRACKET:cle,CLOSEPAREN:ule,COLON:a_,COMMA:cke,DOLLAR:Mle,DOT:Gy,EMOJI:AJe,EQUALS:Tle,EXCLAMATION:dke,FULLWIDTHGREATERTHAN:_le,FULLWIDTHLEFTPAREN:ple,FULLWIDTHLESSTHAN:ble,FULLWIDTHMIDDLEDOT:TJe,FULLWIDTHRIGHTPAREN:fle,HYPHEN:rx,LEFTCORNERBRACKET:xle,LEFTWHITECORNERBRACKET:yle,LOCALHOST:fD,NL:lke,NUM:oke,OPENANGLEBRACKET:hle,OPENBRACE:r8,OPENBRACKET:lle,OPENPAREN:dle,PERCENT:a8,PIPE:Ale,PLUS:Ele,POUND:Ple,QUERY:i8,QUOTE:uke,RIGHTCORNERBRACKET:gle,RIGHTWHITECORNERBRACKET:vle,SCHEME:Cie,SEMI:hke,SLASH:Ky,SLASH_SCHEME:V5,SYM:Lle,TILDE:o8,TLD:G1e,UNDERSCORE:Ile,UTLD:K1e,UWORD:W1e,WORD:Mv,WS:Z1e});const wv=/[a-z]/,YP=new RegExp("\\p{L}","u"),vge=new RegExp("\\p{Emoji}","u"),jv=/\d/,bge=/\s/,RLe="\r",_ge=` `,Vzt="️",Hzt="‍",wge="";let fz=null,xz=null;function Wzt(t=[]){const s={};xp.groups=s;const r=new xp;fz==null&&(fz=FLe(Fzt)),xz==null&&(xz=FLe(zzt)),Xr(r,"'",jle),Xr(r,"{",r8),Xr(r,"}",n8),Xr(r,"[",lle),Xr(r,"]",cle),Xr(r,"(",dle),Xr(r,")",ule),Xr(r,"<",hle),Xr(r,">",mle),Xr(r,"(",ple),Xr(r,")",fle),Xr(r,"「",xle),Xr(r,"」",gle),Xr(r,"『",yle),Xr(r,"』",vle),Xr(r,"<",ble),Xr(r,">",_le),Xr(r,"&",wle),Xr(r,"*",Nle),Xr(r,"@",Yb),Xr(r,"`",Sle),Xr(r,"^",Cle),Xr(r,":",a_),Xr(r,",",cke),Xr(r,"$",Mle),Xr(r,".",Gy),Xr(r,"=",Tle),Xr(r,"!",dke),Xr(r,"-",rx),Xr(r,"%",a8),Xr(r,"|",Ale),Xr(r,"+",Ele),Xr(r,"#",Ple),Xr(r,"?",i8),Xr(r,'"',uke),Xr(r,"/",Ky),Xr(r,";",hke),Xr(r,"~",o8),Xr(r,"_",Ile),Xr(r,"\\",kle),Xr(r,"・",TJe);const n=od(r,jv,oke,{[q1e]:!0});od(n,jv,n);const a=od(n,wv,CJe,{[s8]:!0}),o=od(n,YP,MJe,{[SI]:!0}),l=od(r,wv,Mv,{[U1e]:!0});od(l,jv,a),od(l,wv,l),od(a,jv,a),od(a,wv,a);const i=od(r,YP,W1e,{[V1e]:!0});od(i,wv),od(i,jv,o),od(i,YP,i),od(o,jv,o),od(o,wv),od(o,YP,o);const c=Xr(r,_ge,lke,{[yge]:!0}),u=Xr(r,RLe,Z1e,{[yge]:!0}),p=od(r,bge,Z1e,{[yge]:!0});Xr(r,wge,p),Xr(u,_ge,c),Xr(u,wge,p),od(u,bge,p),Xr(p,RLe),Xr(p,_ge),od(p,bge,p),Xr(p,wge,p);const f=od(r,vge,AJe,{[SJe]:!0});Xr(f,"#"),od(f,vge,f),Xr(f,Vzt,f);const g=Xr(f,Hzt);Xr(g,"#"),od(g,vge,f);const b=[[wv,l],[jv,a]],_=[[wv,null],[YP,i],[jv,o]];for(let j=0;jj[0]>w[0]?1:-1);for(let j=0;j=0?S[H1e]=!0:wv.test(w)?jv.test(w)?S[s8]=!0:S[U1e]=!0:S[q1e]=!0,OLe(r,w,w,S)}return OLe(r,"localhost",fD,{ascii:!0}),r.jd=new xp(Lle),{start:r,tokens:Object.assign({groups:s},EJe)}}function PJe(t,s){const r=Gzt(s.replace(/[A-Z]/g,i=>i.toLowerCase())),n=r.length,a=[];let o=0,l=0;for(;l=0&&(f+=r[l].length,g++),u+=r[l].length,o+=r[l].length,l++;o-=f,l-=g,u-=f,a.push({t:p.t,v:s.slice(o-u,o),s:o-u,e:o})}return a}function Gzt(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 Lb(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 xD={defaultProtocol:"http",events:null,format:zLe,formatHref:zLe,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function mke(t,s=null){let r=Object.assign({},xD);t&&(r=Object.assign(r,t instanceof mke?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=xD.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const s=this,r=this.toHref(t.get("defaultProtocol")),n=t.get("formatHref",r,this),a=t.get("tagName",r,s),o=this.toFormattedString(t),l={},i=t.get("className",r,s),c=t.get("target",r,s),u=t.get("rel",r,s),p=t.getObj("attributes",r,s),f=t.getObj("events",r,s);return l.href=n,i&&(l.class=i),c&&(l.target=c),u&&(l.rel=u),p&&Object.assign(l,p),{tagName:a,attributes:l,content:o,eventListeners:f}}};function Fue(t,s){class r extends IJe{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 BLe=Fue("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),$Le=Fue("text"),Kzt=Fue("nl"),gz=Fue("url",{isLink:!0,toHref(t=xD.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==fD&&t[1].t===a_}}),Yf=t=>new xp(t);function Zzt({groups:t}){const s=t.domain.concat([wle,Nle,Yb,kle,Sle,Cle,Mle,Tle,rx,oke,a8,Ale,Ele,Ple,Ky,Lle,o8,Ile]),r=[jle,a_,cke,Gy,dke,a8,i8,uke,hke,hle,mle,r8,n8,cle,lle,dle,ule,ple,fle,xle,gle,yle,vle,ble,_le],n=[wle,jle,Nle,kle,Sle,Cle,Mle,Tle,rx,r8,n8,a8,Ale,Ele,Ple,i8,Ky,Lle,o8,Ile],a=Yf(),o=Xr(a,o8);Ji(o,n,o),Ji(o,t.domain,o);const l=Yf(),i=Yf(),c=Yf();Ji(a,t.domain,l),Ji(a,t.scheme,i),Ji(a,t.slashscheme,c),Ji(l,n,o),Ji(l,t.domain,l);const u=Xr(l,Yb);Xr(o,Yb,u),Xr(i,Yb,u),Xr(c,Yb,u);const p=Xr(o,Gy);Ji(p,n,o),Ji(p,t.domain,o);const f=Yf();Ji(u,t.domain,f),Ji(f,t.domain,f);const g=Xr(f,Gy);Ji(g,t.domain,f);const b=Yf(BLe);Ji(g,t.tld,b),Ji(g,t.utld,b),Xr(u,fD,b);const _=Xr(f,rx);Xr(_,rx,_),Ji(_,t.domain,f),Ji(b,t.domain,f),Xr(b,Gy,g),Xr(b,rx,_);const j=Xr(b,a_);Ji(j,t.numeric,BLe);const w=Xr(l,rx),k=Xr(l,Gy);Xr(w,rx,w),Ji(w,t.domain,l),Ji(k,n,o),Ji(k,t.domain,l);const S=Yf(gz);Ji(k,t.tld,S),Ji(k,t.utld,S),Ji(S,t.domain,l),Ji(S,n,o),Xr(S,Gy,k),Xr(S,rx,w),Xr(S,Yb,u);const M=Xr(S,a_),L=Yf(gz);Ji(M,t.numeric,L);const I=Yf(gz),O=Yf();Ji(I,s,I),Ji(I,r,O),Ji(O,s,I),Ji(O,r,O),Xr(S,Ky,I),Xr(L,Ky,I);const q=Xr(i,a_),U=Xr(c,a_),B=Xr(U,Ky),V=Xr(B,Ky);Ji(i,t.domain,l),Xr(i,Gy,k),Xr(i,rx,w),Ji(c,t.domain,l),Xr(c,Gy,k),Xr(c,rx,w),Ji(q,t.domain,I),Xr(q,Ky,I),Xr(q,i8,I),Ji(V,t.domain,I),Ji(V,s,I),Xr(V,Ky,I);const Z=[[r8,n8],[lle,cle],[dle,ule],[hle,mle],[ple,fle],[xle,gle],[yle,vle],[ble,_le]];for(let X=0;X=0&&g++,a++,p++;if(g<0)a-=p,a0&&(o.push(jge($Le,s,l)),l=[]),a-=g,p-=g;const b=f.t,_=r.slice(a-p,a);o.push(jge(b,s,_))}}return l.length>0&&o.push(jge($Le,s,l)),o}function jge(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 Xzt=typeof console<"u"&&console&&console.warn||(()=>{}),Qzt="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",xc={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Jzt(){return xp.groups={},xc.scanner=null,xc.parser=null,xc.tokenQueue=[],xc.pluginQueue=[],xc.customSchemes=[],xc.initialized=!1,xc}function qLe(t,s=!1){if(xc.initialized&&Xzt(`linkifyjs: already initialized - will not register custom scheme "${t}" ${Qzt}`),!/^[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`);xc.customSchemes.push([t,s])}function e9t(){xc.scanner=Wzt(xc.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=PFt(r.doc,[...s]);if(zFt(i).forEach(({newRange:u})=>{const p=LFt(n.doc,u,b=>b.isTextblock);let f,g;if(p.length>1)f=p[0],g=n.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(p.length){const b=n.doc.textBetween(u.from,u.to," "," ");if(!s9t.test(b))return;f=p[0],g=n.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const b=g.split(t9t).filter(Boolean);if(b.length<=0)return!1;const _=b[b.length-1],j=f.pos+g.lastIndexOf(_);if(!_)return!1;const w=pke(_).map(k=>k.toObject(t.defaultProtocol));if(!n9t(w))return!1;w.filter(k=>k.isLink).map(k=>({...k,from:j+k.start+1,to:j+k.end+1})).filter(k=>n.schema.marks.code?!n.doc.rangeHasMark(k.from,k.to,n.schema.marks.code):!0).filter(k=>t.validate(k.value)).filter(k=>t.shouldAutoLink(k.value)).forEach(k=>{JNe(k.from,k.to,n.doc).some(S=>S.mark.type===t.type)||l.addMark(k.from,k.to,t.type.create({href:k.href}))})}}),!!l.steps.length)return l}})}function i9t(t){return new Iu({key:new tm("handleClickLink"),props:{handleClick:(s,r,n)=>{var a,o;if(n.button!==0||!s.editable)return!1;let l=n.target;const i=[];for(;l.nodeName!=="DIV";)i.push(l),l=l.parentNode;if(!i.find(g=>g.nodeName==="A"))return!1;const c=gJe(s.state,t.type.name),u=n.target,p=(a=u==null?void 0:u.href)!==null&&a!==void 0?a:c.href,f=(o=u==null?void 0:u.target)!==null&&o!==void 0?o:c.target;return u&&p?(window.open(p,f),!0):!1}}})}function o9t(t){return new Iu({key:new tm("handlePasteLink"),props:{handlePaste:(s,r,n)=>{const{state:a}=s,{selection:o}=a,{empty:l}=o;if(l)return!1;let i="";n.content.forEach(u=>{i+=u.textContent});const c=LJe(i,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===i);return!i||!c?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function z2(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(r9t,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const xke=ly.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"){qLe(t);return}qLe(t.scheme,t.optionalSlashes)})},onDestroy(){Jzt()},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)=>!!z2(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=>!!z2(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=>!!z2(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Hc(this.options.HTMLAttributes,t),0]:["a",Hc(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!z2(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=>!!z2(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[YS({find:t=>{const s=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,a=LJe(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!z2(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(a9t({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!z2(a,s),protocols:s,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(i9t({type:this.type})),this.options.linkOnPaste&&t.push(o9t({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),gke=Ih.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")}}}),l9t=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}`)})},yke=ly.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&l9t(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Hc(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}}}}),c9t=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,d9t=sm.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",Hc(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:s})=>s.insertContent({type:this.name,attrs:t})}},addInputRules(){return[yJe({find:c9t,type:this.type,getAttributes:t=>{const[,,s,r,n]=t;return{src:r,alt:s,title:n}}})]}});let Y1e,X1e;if(typeof WeakMap<"u"){let t=new WeakMap;Y1e=s=>t.get(s),X1e=(s,r)=>(t.set(s,r),r)}else{const t=[];let r=0;Y1e=n=>{for(let a=0;a(r==10&&(r=0),t[r++]=n,t[r++]=a)}var gd=class{constructor(t,s,r,n){this.width=t,this.height=s,this.map=r,this.problems=n}findCell(t){for(let s=0;s=r){(o||(o=[])).push({type:"overlong_rowspan",pos:p,n:k-M});break}const L=a+M*s;for(let I=0;In&&(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 m9t(t,s,r){t.problems||(t.problems=[]);const n={};for(let a=0;a0;s--)if(t.node(s).type.spec.tableRole=="row")return t.node(0).resolve(t.before(s+1));return null}function f9t(t){for(let s=t.depth;s>0;s--){const r=t.node(s).type.spec.tableRole;if(r==="cell"||r==="header_cell")return t.node(s)}return null}function hy(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 zue(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=nE(s.$head)||x9t(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function x9t(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 Q1e(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function g9t(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function vke(t,s){return t.depth==s.depth&&t.pos>=s.start(-1)&&t.pos<=s.end(-1)}function DJe(t,s,r){const n=t.node(-1),a=gd.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 XS(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 OJe(t,s,r=1){const n={...t,colspan:t.colspan+r};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let a=0;ap!=r.pos-o);c.unshift(r.pos-o);const u=c.map(p=>{const f=n.nodeAt(p);if(!f)throw new RangeError(`No cell with offset ${p} found`);const g=o+p+1;return new dQe(i.resolve(g),i.resolve(g+f.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=s,this.$headCell=r}map(s,r){const n=s.resolve(r.map(this.$anchorCell.pos)),a=s.resolve(r.map(this.$headCell.pos));if(Q1e(n)&&Q1e(a)&&vke(n,a)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?Tv.rowSelection(n,a):o&&this.isColSelection()?Tv.colSelection(n,a):new Tv(n,a)}return ei.between(n,a)}content(){const s=this.$anchorCell.node(-1),r=gd.get(s),n=this.$anchorCell.start(-1),a=r.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},l=[];for(let c=a.top;c0||w>0){let k=_.attrs;if(j>0&&(k=XS(k,0,j)),w>0&&(k=XS(k,k.colspan-w,w)),b.lefta.bottom){const k={..._.attrs,rowspan:Math.min(b.bottom,a.bottom)-Math.max(b.top,a.top)};b.top0)return!1;const n=s+this.$anchorCell.nodeAfter.attrs.rowspan,a=r+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,a)==this.$headCell.node(-1).childCount}static colSelection(s,r=s){const n=s.node(-1),a=gd.get(n),o=s.start(-1),l=a.findCell(s.pos-o),i=a.findCell(r.pos-o),c=s.node(0);return l.top<=i.top?(l.top>0&&(s=c.resolve(o+a.map[l.left])),i.bottom0&&(r=c.resolve(o+a.map[i.left])),l.bottom0)return!1;const l=a+this.$anchorCell.nodeAfter.attrs.colspan,i=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,i)==r.width}eq(s){return s instanceof Tv&&s.$anchorCell.pos==this.$anchorCell.pos&&s.$headCell.pos==this.$headCell.pos}static rowSelection(s,r=s){const n=s.node(-1),a=gd.get(n),o=s.start(-1),l=a.findCell(s.pos-o),i=a.findCell(r.pos-o),c=s.node(0);return l.left<=i.left?(l.left>0&&(s=c.resolve(o+a.map[l.top*a.width])),i.right0&&(r=c.resolve(o+a.map[i.top*a.width])),l.right{s.push(Mm.node(n,n+r.nodeSize,{class:"selectedCell"}))}),fd.create(t.doc,s)}function _9t({$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 w9t({$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 j9t(t,s,r){const n=(s||t).selection,a=(s||t).doc;let o,l;if(n instanceof Wa&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=ic.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=ic.rowSelection(i,i)}else if(!r){const i=gd.get(n.node),c=n.from+1,u=c+i.map[i.width*i.height-1];o=ic.create(a,c+1,u)}}else n instanceof ei&&_9t(n)?o=ei.create(a,n.from):n instanceof ei&&w9t(n)&&(o=ei.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const N9t=new tm("fix-tables");function FJe(t,s,r,n){const a=t.childCount,o=s.childCount;e:for(let l=0,i=0;l{a.type.spec.tableRole=="table"&&(r=k9t(t,a,o,r))};return s?s.doc!=t.doc&&FJe(s.doc,t.doc,0,n):t.doc.descendants(n),r}function k9t(t,s,r,n){const a=gd.get(s);if(!a.problems)return n;n||(n=t.tr);const o=[];for(let c=0;c0){let b="cell";p.firstChild&&(b=p.firstChild.type.spec.tableRole);const _=[];for(let w=0;w0?-1:0;y9t(s,n,a+o)&&(o=a==0||a==s.width?null:0);for(let l=0;l0&&a0&&s.map[i-1]==c||a0?-1:0;A9t(s,n,a+i)&&(i=a==0||a==s.height?null:0);for(let u=0,p=s.width*a;u0&&a0&&f==s.map[p-s.width]){const g=r.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(i).map(f+n),null,{...g,rowspan:g.rowspan-1}),u+=g.colspan-1}else if(a0&&r[o]==r[o-1]||n.right0&&r[a]==r[a-t]||n.bottom0){const p=c+1+u.content.size,f=ULe(u)?c+1:p;o.replaceWith(f+n.tableStart,p+n.tableStart,i)}o.setSelection(new ic(o.doc.resolve(c+n.tableStart))),s(o)}return!0}function HLe(t,s){const r=Jh(t.schema);return O9t(({node:n})=>r[n.type.spec.tableRole])(t,s)}function O9t(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof ic){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=f9t(n.$from),!a)return!1;o=(l=nE(n.$from))===null||l===void 0?void 0:l.pos}if(a==null||o==null||a.attrs.colspan==1&&a.attrs.rowspan==1)return!1;if(r){let i=a.attrs;const c=[],u=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const p=z0(s),f=s.tr;for(let b=0;b{l.attrs[t]!==s&&o.setNodeMarkup(i,null,{...l.attrs,[t]:s})}):o.setNodeMarkup(a.pos,null,{...a.nodeAfter.attrs,[t]:s}),n(o)}return!0}}function F9t(t){return function(s,r){if(!hy(s))return!1;if(r){const n=Jh(s.schema),a=z0(s),o=s.tr,l=a.map.cellsInRect(t=="column"?{left:a.left,top:0,right:a.right,bottom:a.map.height}:t=="row"?{left:0,top:a.top,right:a.map.width,bottom:a.bottom}:a),i=l.map(c=>a.table.nodeAt(c));for(let c=0;c{const b=g+o.tableStart,_=l.doc.nodeAt(b);_&&l.setNodeMarkup(b,f,_.attrs)}),n(l)}return!0}}gD("row",{useDeprecatedLogic:!0});gD("column",{useDeprecatedLogic:!0});const z9t=gD("cell",{useDeprecatedLogic:!0});function B9t(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 yz(t,s){const r=t.selection;if(!(r instanceof ic))return!1;if(s){const n=t.tr,a=Jh(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 jn(a,0,0))}),n.docChanged&&s(n)}return!0}function q9t(t){if(t.size===0)return null;let{content:s,openStart:r,openEnd:n}=t;for(;s.childCount==1&&(r>0&&n>0||s.child(0).type.spec.tableRole=="table");)r--,n--,s=s.child(0).content;const a=s.child(0),o=a.type.spec.tableRole,l=a.type.schema,i=[];if(o=="row")for(let c=0;c=0;l--){const{rowspan:i,colspan:c}=o.child(l).attrs;for(let u=a;u=s.length&&s.push(Dr.empty),r[a]n&&(g=g.type.createChecked(XS(g.attrs,g.attrs.colspan,p+g.attrs.colspan-n),g.content)),u.push(g),p+=g.attrs.colspan;for(let b=1;ba&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,a-f.attrs.rowspan)},f.content)),c.push(f)}o.push(Dr.from(c))}r=o,s=a}return{width:t,height:s,rows:r}}function H9t(t,s,r,n,a,o,l){const i=t.doc.type.schema,c=Jh(i);let u,p;if(a>s.width)for(let f=0,g=0;fs.height){const f=[];for(let _=0,j=(s.height-1)*s.width;_=s.width?!1:r.nodeAt(s.map[j+_]).type==c.header_cell;f.push(w?p||(p=c.header_cell.createAndFill()):u||(u=c.cell.createAndFill()))}const g=c.row.create(null,Dr.from(f)),b=[];for(let _=s.height;_{if(!a)return!1;const o=r.selection;if(o instanceof ic)return Mie(r,n,fi.near(o.$headCell,s));if(t!="horiz"&&!o.empty)return!1;const l=qJe(a,t,s);if(l==null)return!1;if(t=="horiz")return Mie(r,n,fi.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),c=DJe(i,t,s);let u;return c?u=fi.near(c,1):s<0?u=fi.near(r.doc.resolve(i.before(-1)),-1):u=fi.near(r.doc.resolve(i.after(-1)),1),Mie(r,n,u)}}}function bz(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof ic)l=o;else{const c=qJe(a,t,s);if(c==null)return!1;l=new ic(r.doc.resolve(c))}const i=DJe(l.$headCell,t,s);return i?Mie(r,n,new ic(l.$anchorCell,i)):!1}}function G9t(t,s){const r=t.state.doc,n=nE(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new ic(n))),!0):!1}function K9t(t,s,r){if(!hy(t.state))return!1;let n=q9t(r);const a=t.state.selection;if(a instanceof ic){n||(n={width:1,height:1,rows:[Dr.from(J1e(Jh(t.state.schema).cell,r))]});const o=a.$anchorCell.node(-1),l=a.$anchorCell.start(-1),i=gd.get(o).rectBetween(a.$anchorCell.pos-l,a.$headCell.pos-l);return n=V9t(n,i.right-i.left,i.bottom-i.top),YLe(t.state,t.dispatch,l,i,n),!0}else if(n){const o=zue(t.state),l=o.start(-1);return YLe(t.state,t.dispatch,l,gd.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function Z9t(t,s){var r;if(s.ctrlKey||s.metaKey)return;const n=XLe(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof ic)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=nE(t.state.selection.$anchor))!=null&&((r=Nge(t,s))===null||r===void 0?void 0:r.pos)!=a.pos)o(a,s),s.preventDefault();else if(!n)return;function o(c,u){let p=Nge(t,u);const f=i_.getState(t.state)==null;if(!p||!vke(c,p))if(f)p=c;else return;const g=new ic(c,p);if(f||!t.state.selection.eq(g)){const b=t.state.tr.setSelection(g);f&&b.setMeta(i_,c.pos),t.dispatch(b)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",i),i_.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(i_,-1))}function i(c){const u=c,p=i_.getState(t.state);let f;if(p!=null)f=t.state.doc.resolve(p);else if(XLe(t,u.target)!=n&&(f=Nge(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 qJe(t,s,r){if(!(t.state.selection instanceof ei))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 XLe(t,s){for(;s&&s!=t.dom;s=s.parentNode)if(s.nodeName=="TD"||s.nodeName=="TH")return s;return null}function Nge(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 nE(t.state.doc.resolve(n))}var Y9t=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")),ebe(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,ebe(s,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(s){return s.type=="attributes"&&(s.target==this.table||this.colgroup.contains(s.target))}};function ebe(t,s,r,n,a,o){let l=0,i=!0,c=s.firstChild;const u=t.firstChild;if(u){for(let f=0,g=0;fnew n(f,r,g)),new Q9t(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=cf.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{J9t(l,i,t,a)},mouseleave:l=>{eBt(l)},mousedown:(l,i)=>{tBt(l,i,s,r)}},decorations:l=>{const i=cf.getState(l);if(i&&i.activeHandle>-1)return iBt(l,i.activeHandle)},nodeViews:{}}});return o}var Q9t=class Tie{constructor(s,r){this.activeHandle=s,this.dragging=r}apply(s){const r=this,n=s.getMeta(cf);if(n&&n.setHandle!=null)return new Tie(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new Tie(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&s.docChanged){let a=s.mapping.map(r.activeHandle,-1);return Q1e(s.doc.resolve(a))||(a=-1),new Tie(a,r.dragging)}return r}};function J9t(t,s,r,n){if(!t.editable)return;const a=cf.getState(t.state);if(a&&!a.dragging){const o=rBt(s.target);let l=-1;if(o){const{left:i,right:c}=o.getBoundingClientRect();s.clientX-i<=r?l=QLe(t,s,"left",r):c-s.clientX<=r&&(l=QLe(t,s,"right",r))}if(l!=a.activeHandle){if(!n&&l!==-1){const i=t.state.doc.resolve(l),c=i.node(-1),u=gd.get(c),p=i.start(-1);if(u.colCount(i.pos-p)+i.nodeAfter.attrs.colspan-1==u.width-1)return}UJe(t,l)}}}function eBt(t){if(!t.editable)return;const s=cf.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&UJe(t,-1)}function tBt(t,s,r,n){var a;if(!t.editable)return!1;const o=(a=t.dom.ownerDocument.defaultView)!==null&&a!==void 0?a:window,l=cf.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=t.state.doc.nodeAt(l.activeHandle),c=sBt(t,l.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(cf,{setDragging:{startX:s.clientX,startWidth:c}}));function u(f){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",p);const g=cf.getState(t.state);g!=null&&g.dragging&&(nBt(t,g.activeHandle,JLe(g.dragging,f,r)),t.dispatch(t.state.tr.setMeta(cf,{setDragging:null})))}function p(f){if(!f.which)return u(f);const g=cf.getState(t.state);if(g&&g.dragging){const b=JLe(g.dragging,f,r);e8e(t,g.activeHandle,b,n)}}return e8e(t,l.activeHandle,c,n),o.addEventListener("mouseup",u),o.addEventListener("mousemove",p),s.preventDefault(),!0}function sBt(t,s,{colspan:r,colwidth:n}){const a=n&&n[n.length-1];if(a)return a;const o=t.domAtPos(s);let l=o.node.childNodes[o.offset].offsetWidth,i=r;if(n)for(let c=0;c{const n=t.nodes[r];n.spec.tableRole&&(s[n.spec.tableRole]=n)}),t.cached.tableNodeTypes=s,s}function uBt(t,s,r,n,a){const o=dBt(t),l=[],i=[];for(let u=0;u{const{selection:s}=t.state;if(!hBt(s))return!1;let r=0;const n=xJe(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},mBt=sm.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:lBt,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}=cBt(t,this.options.cellMinWidth),o=["table",Hc(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=uBt(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(ei.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>S9t(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>C9t(t,s),deleteColumn:()=>({state:t,dispatch:s})=>T9t(t,s),addRowBefore:()=>({state:t,dispatch:s})=>E9t(t,s),addRowAfter:()=>({state:t,dispatch:s})=>P9t(t,s),deleteRow:()=>({state:t,dispatch:s})=>L9t(t,s),deleteTable:()=>({state:t,dispatch:s})=>$9t(t,s),mergeCells:()=>({state:t,dispatch:s})=>VLe(t,s),splitCell:()=>({state:t,dispatch:s})=>HLe(t,s),toggleHeaderColumn:()=>({state:t,dispatch:s})=>gD("column")(t,s),toggleHeaderRow:()=>({state:t,dispatch:s})=>gD("row")(t,s),toggleHeaderCell:()=>({state:t,dispatch:s})=>z9t(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>VLe(t,s)?!0:HLe(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>R9t(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>GLe(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>GLe(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&zJe(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=ic.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:_z,"Mod-Backspace":_z,Delete:_z,"Mod-Delete":_z}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[X9t({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],oBt({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:eo(oa(t,"tableRole",s))}}}),pBt=sm.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Hc(this.options.HTMLAttributes,t),0]}}),fBt=sm.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",Hc(this.options.HTMLAttributes,t),0]}}),xBt=sm.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",Hc(this.options.HTMLAttributes,t),0]}});function my({content:t,onChange:s,placeholder:r="Enter content...",minHeight:n="150px",compact:a=!1}){const[o,l]=N.useState(!1),[i,c]=N.useState(""),[u,p]=N.useState(!0),f=nke({extensions:[ike,xke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),gke.configure({types:["heading","paragraph"]}),yke,d9t.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}),mBt.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}),pBt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null}}}}),fBt.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}}}}),xBt.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 S;const k=(S=w.clipboardData)==null?void 0:S.items;if(!k)return!1;for(const M of Array.from(k))if(M.type.startsWith("image/")){w.preventDefault();const L=M.getAsFile();if(!L)continue;const I=new FileReader;return I.onload=O=>{var U;const q=(U=O.target)==null?void 0:U.result;j.dispatch(j.state.tr.replaceSelectionWith(j.state.schema.nodes.image.create({src:q})))},I.readAsDataURL(L),!0}return!1}}});N.useEffect(()=>{f&&t!==f.getHTML()&&f.commands.setContent(t)},[t,f]);const g=()=>{if(!f)return;const j=f.getAttributes("link").href||"",w=f.getAttributes("link").target;c(j),p(w==="_blank"),l(!0)},b=()=>{f&&(i===""?f.chain().focus().extendMarkRange("link").unsetLink().run():f.chain().focus().extendMarkRange("link").setLink({href:i,target:u?"_blank":null,rel:u?"noopener noreferrer nofollow":null}).run(),l(!1),c(""))},_=()=>{f&&f.chain().focus().extendMarkRange("link").unsetLink().run()};return f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleHeading({level:1}).run(),className:f.isActive("heading",{level:1})?"bg-muted":"",title:"Heading 1",children:e.jsx(AM,{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(EM,{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(Z4,{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(tS,{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(Mh,{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(m0,{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(W4,{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(H4,{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(G4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:g,className:f.isActive("link")?"bg-muted":"",title:"Add Link",children:e.jsx(Bo,{className:"h-4 w-4"})}),f.isActive("link")&&e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:_,title:"Remove Link",children:e.jsx(Bo,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().undo().run(),disabled:!f.can().undo(),title:"Undo",children:e.jsx(fS,{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(hS,{className:"h-4 w-4"})})]}),e.jsx(ske,{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(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{id:"link-url",value:i,onChange:j=>c(j.target.value),placeholder:"https://example.com"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qr,{id:"link-new-tab",checked:u,onCheckedChange:p}),e.jsx(ve,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"button",onClick:b,children:i?"Apply Link":"Remove Link"})]})]})})]}):null}var gBt=Object.defineProperty,yBt=(t,s,r)=>s in t?gBt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,Ic=(t,s,r)=>yBt(t,typeof s!="symbol"?s+"":s,r);const Dle={x:0,y:0,width:0,height:0,unit:"px"},k5=(t,s,r)=>Math.min(Math.max(t,s),r),vBt=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),r8e=(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 bBt(t,s,r,n){const a=Zy(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==="%"?Xb(a,r,n):a}function _Bt(t,s,r){const n=Zy(t,s,r);return n.x=(s-n.width)/2,n.y=(r-n.height)/2,t.unit==="%"?Xb(n,s,r):n}function Xb(t,s,r){return t.unit==="%"?{...Dle,...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 Zy(t,s,r){return t.unit?t.unit==="px"?{...Dle,...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}:{...Dle,...t,unit:"px"}}function n8e(t,s,r,n,a,o=0,l=0,i=n,c=a){const u={...t};let p=Math.min(o,n),f=Math.min(l,a),g=Math.min(i,n),b=Math.min(c,a);s&&(s>1?(p=l?l*s:p,f=p/s,g=i*s):(f=o?o/s:f,p=f*s,b=c/s)),u.y<0&&(u.height=Math.max(u.height+u.y,f),u.y=0),u.x<0&&(u.width=Math.max(u.width+u.x,p),u.x=0);const _=n-(u.x+u.width);_<0&&(u.x=Math.min(u.x,n-p),u.width+=_);const j=a-(u.y+u.height);if(j<0&&(u.y=Math.min(u.y,a-f),u.height+=j),u.widthg&&((r==="sw"||r=="nw")&&(u.x-=g-u.width),u.width=g),u.height>b&&((r==="nw"||r=="ne")&&(u.y-=b-u.height),u.height=b),s){const w=u.width/u.height;if(ws){const k=Math.max(u.height*s,p);(r==="sw"||r=="nw")&&(u.x-=k-u.width),u.width=k}}return u}function wBt(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 S5={capture:!0,passive:!1};let jBt=0;const Ub=class Mg extends N.PureComponent{constructor(){super(...arguments),Ic(this,"docMoveBound",!1),Ic(this,"mouseDownOnCrop",!1),Ic(this,"dragStarted",!1),Ic(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),Ic(this,"componentRef",N.createRef()),Ic(this,"mediaRef",N.createRef()),Ic(this,"resizeObserver"),Ic(this,"initChangeCalled",!1),Ic(this,"instanceId",`rc-${jBt++}`),Ic(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),Ic(this,"onCropPointerDown",s=>{const{crop:r,disabled:n}=this.props,a=this.getBox();if(!r)return;const o=Zy(r,a.width,a.height);if(n)return;s.cancelable&&s.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const l=s.target.dataset.ord,i=!!l;let c=s.clientX,u=s.clientY,p=o.x,f=o.y;if(l){const g=s.clientX-a.x,b=s.clientY-a.y;let _=0,j=0;l==="ne"||l=="e"?(_=g-(o.x+o.width),j=b-o.y,p=o.x,f=o.y+o.height):l==="se"||l==="s"?(_=g-(o.x+o.width),j=b-(o.y+o.height),p=o.x,f=o.y):l==="sw"||l=="w"?(_=g-o.x,j=b-(o.y+o.height),p=o.x+o.width,f=o.y):(l==="nw"||l=="n")&&(_=g-o.x,j=b-o.y,p=o.x+o.width,f=o.y+o.height),c=p+a.x+_,u=f+a.y+j}this.evData={startClientX:c,startClientY:u,startCropX:p,startCropY:f,clientX:s.clientX,clientY:s.clientY,isResize:i,ord:l},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),Ic(this,"onComponentPointerDown",s=>{const{crop:r,disabled:n,locked:a,keepSelection:o,onChange:l}=this.props,i=this.getBox();if(n||a||o&&r)return;s.cancelable&&s.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const c=s.clientX-i.x,u=s.clientY-i.y,p={unit:"px",x:c,y:u,width:0,height:0};this.evData={startClientX:s.clientX,startClientY:s.clientY,startCropX:c,startCropY:u,clientX:s.clientX,clientY:s.clientY,isResize:!0},this.mouseDownOnCrop=!0,l(Zy(p,i.width,i.height),Xb(p,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),Ic(this,"onDocPointerMove",s=>{const{crop:r,disabled:n,onChange:a,onDragStart:o}=this.props,l=this.getBox();if(n||!r||!this.mouseDownOnCrop)return;s.cancelable&&s.preventDefault(),this.dragStarted||(this.dragStarted=!0,o&&o(s));const{evData:i}=this;i.clientX=s.clientX,i.clientY=s.clientY;let c;i.isResize?c=this.resizeCrop():c=this.dragCrop(),r8e(r,c)||a(Zy(c,l.width,l.height),Xb(c,l.width,l.height))}),Ic(this,"onComponentKeyDown",s=>{const{crop:r,disabled:n,onChange:a,onComplete:o}=this.props;if(n)return;const l=s.key;let i=!1;if(!r)return;const c=this.getBox(),u=this.makePixelCrop(c),p=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?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=k5(u.x,0,c.width-u.width),u.y=k5(u.y,0,c.height-u.height);const f=Zy(u,c.width,c.height),g=Xb(u,c.width,c.height);a(f,g),o&&o(f,g)}}),Ic(this,"onHandlerKeyDown",(s,r)=>{const{aspect:n=0,crop:a,disabled:o,minWidth:l=0,minHeight:i=0,maxWidth:c,maxHeight:u,onChange:p,onComplete:f}=this.props,g=this.getBox();if(o||!a)return;if(s.key==="ArrowUp"||s.key==="ArrowDown"||s.key==="ArrowLeft"||s.key==="ArrowRight")s.stopPropagation(),s.preventDefault();else return;const b=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?Mg.nudgeStepLarge:s.shiftKey?Mg.nudgeStepMedium:Mg.nudgeStep,_=Zy(a,g.width,g.height),j=wBt(_,s.key,b,r),w=n8e(j,n,r,g.width,g.height,l,i,c,u);if(!r8e(a,w)){const k=Xb(w,g.width,g.height);p(w,k),f&&f(w,k)}}),Ic(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(Zy(r,l.width,l.height),Xb(r,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),Ic(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(Zy(r,a,o),Xb(r,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,S5),this.document.addEventListener("pointerup",this.onDocPointerDone,S5),this.document.addEventListener("pointercancel",this.onDocPointerDone,S5),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,S5),this.document.removeEventListener("pointerup",this.onDocPointerDone,S5),this.document.removeEventListener("pointercancel",this.onDocPointerDone,S5),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=k5(s.startCropX+a,0,r.width-n.width),n.y=k5(s.startCropY+o,0,r.height-n.height),n}getPointRegion(s,r,n,a){const{evData:o}=this,l=o.clientX-s.x,i=o.clientY-s.y;let c;a&&r?c=r==="nw"||r==="n"||r==="ne":c=i1?o?[o,o/r]:[l*r,l]:l?[l*r,l]:[o,o/r]}resizeCrop(){const{evData:s}=this,{aspect:r=0,maxWidth:n,maxHeight:a}=this.props,o=this.getBox(),[l,i]=this.resolveMinDimensions(o,r,this.props.minWidth,this.props.minHeight);let c=this.makePixelCrop(o);const u=this.getPointRegion(o,s.ord,l,i),p=s.ord||u;let f=s.clientX-s.startClientX,g=s.clientY-s.startClientY;(l&&p==="nw"||p==="w"||p==="sw")&&(f=Math.min(f,-l)),(i&&p==="nw"||p==="n"||p==="ne")&&(g=Math.min(g,-i));const b={unit:"px",x:0,y:0,width:0,height:0};u==="ne"?(b.x=s.startCropX,b.width=f,r?(b.height=b.width/r,b.y=s.startCropY-b.height):(b.height=Math.abs(g),b.y=s.startCropY-b.height)):u==="se"?(b.x=s.startCropX,b.y=s.startCropY,b.width=f,r?b.height=b.width/r:b.height=g):u==="sw"?(b.x=s.startCropX+f,b.y=s.startCropY,b.width=Math.abs(f),r?b.height=b.width/r:b.height=g):u==="nw"&&(b.x=s.startCropX+f,b.width=Math.abs(f),r?(b.height=b.width/r,b.y=s.startCropY-b.height):(b.height=Math.abs(g),b.y=s.startCropY+g));const _=n8e(b,r,u,o.width,o.height,l,i,n,a);return r||Mg.xyOrds.indexOf(p)>-1?c=_:Mg.xOrds.indexOf(p)>-1?(c.x=_.x,c.width=_.width):Mg.yOrds.indexOf(p)>-1&&(c.y=_.y,c.height=_.height),c.x=k5(c.x,0,o.width-c.width),c.y=k5(c.y,0,o.height-c.height),c}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 ht.createElement("div",{style:i,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":s.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!r&&!n&&ht.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},ht.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),ht.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),ht.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),ht.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":s.nwDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"nw"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":s.nDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"n"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":s.neDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"ne"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":s.eDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"e"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":s.seDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"se"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":s.sDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"s"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":s.swDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"sw"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":s.wDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"w"),role:"button"})),a&&ht.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:c=>c.stopPropagation()},a(this.state)),o&&ht.createElement(ht.Fragment,null,ht.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),ht.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(s){const r={...Dle,...this.props.crop||{}};return Zy(r,s.width,s.height)}render(){const{aspect:s,children:r,circularCrop:n,className:a,crop:o,disabled:l,locked:i,style:c,ruleOfThirds:u}=this.props,{cropIsActive:p,newCropIsBeingDrawn:f}=this.state,g=o?this.renderCropSelection():null,b=vBt("ReactCrop",a,p&&"ReactCrop--active",l&&"ReactCrop--disabled",i&&"ReactCrop--locked",f&&"ReactCrop--new-crop",o&&s&&"ReactCrop--fixed-aspect",o&&n&&"ReactCrop--circular-crop",o&&u&&"ReactCrop--rule-of-thirds",!this.dragStarted&&o&&!o.width&&!o.height&&"ReactCrop--invisible-crop",n&&"ReactCrop--no-animate");return ht.createElement("div",{ref:this.componentRef,className:b,style:c},ht.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},r),o?ht.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},ht.createElement("defs",null,ht.createElement("mask",{id:`hole-${this.instanceId}`},ht.createElement("rect",{width:"100%",height:"100%",fill:"white"}),n?ht.createElement("ellipse",{cx:`${o.x+o.width/2}${o.unit}`,cy:`${o.y+o.height/2}${o.unit}`,rx:`${o.width/2}${o.unit}`,ry:`${o.height/2}${o.unit}`,fill:"black"}):ht.createElement("rect",{x:`${o.x}${o.unit}`,y:`${o.y}${o.unit}`,width:`${o.width}${o.unit}`,height:`${o.height}${o.unit}`,fill:"black"}))),ht.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,g)}};Ic(Ub,"xOrds",["e","w"]),Ic(Ub,"yOrds",["n","s"]),Ic(Ub,"xyOrds",["nw","ne","se","sw"]),Ic(Ub,"nudgeStep",1),Ic(Ub,"nudgeStepMedium",10),Ic(Ub,"nudgeStepLarge",100),Ic(Ub,"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 NBt=Ub;var VJe=["PageUp","PageDown"],HJe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],WJe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},aE="Slider",[sbe,kBt,SBt]=fO(aE),[GJe]=ad(aE,[SBt]),[CBt,Bue]=GJe(aE),KJe=N.forwardRef((t,s)=>{const{name:r,min:n=0,max:a=100,step:o=1,orientation:l="horizontal",disabled:i=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[n],value:p,onValueChange:f=()=>{},onValueCommit:g=()=>{},inverted:b=!1,form:_,...j}=t,w=N.useRef(new Set),k=N.useRef(0),M=l==="horizontal"?MBt:TBt,[L=[],I]=ah({prop:p,defaultProp:u,onChange:Z=>{var ee;(ee=[...w.current][k.current])==null||ee.focus(),f(Z)}}),O=N.useRef(L);function q(Z){const X=LBt(L,Z);V(Z,X)}function U(Z){V(Z,k.current)}function B(){const Z=O.current[k.current];L[k.current]!==Z&&g(L)}function V(Z,X,{commit:ee}={commit:!1}){const Q=FBt(o),ie=zBt(Math.round((Z-n)/o)*o+n,Q),re=X8(ie,[n,a]);I((oe=[])=>{const ce=PBt(oe,re,X);if(RBt(ce,c*o)){k.current=ce.indexOf(re);const xe=String(ce)!==String(oe);return xe&&ee&&g(ce),xe?ce:oe}else return oe})}return e.jsx(CBt,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:k,thumbs:w.current,values:L,orientation:l,form:_,children:e.jsx(sbe.Provider,{scope:t.__scopeSlider,children:e.jsx(sbe.Slot,{scope:t.__scopeSlider,children:e.jsx(M,{"aria-disabled":i,"data-disabled":i?"":void 0,...j,ref:s,onPointerDown:Ir(j.onPointerDown,()=>{i||(O.current=L)}),min:n,max:a,inverted:b,onSlideStart:i?void 0:q,onSlideMove:i?void 0:U,onSlideEnd:i?void 0:B,onHomeKeyDown:()=>!i&&V(n,0,{commit:!0}),onEndKeyDown:()=>!i&&V(a,L.length-1,{commit:!0}),onStepKeyDown:({event:Z,direction:X})=>{if(!i){const ie=VJe.includes(Z.key)||Z.shiftKey&&HJe.includes(Z.key)?10:1,re=k.current,oe=L[re],ce=o*ie*X;V(oe+ce,re,{commit:!0})}}})})})})});KJe.displayName=aE;var[ZJe,YJe]=GJe(aE,{startEdge:"left",endEdge:"right",size:"width",direction:1}),MBt=N.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:c,onStepKeyDown:u,...p}=t,[f,g]=N.useState(null),b=qa(s,M=>g(M)),_=N.useRef(void 0),j=Mw(a),w=j==="ltr",k=w&&!o||!w&&o;function S(M){const L=_.current||f.getBoundingClientRect(),I=[0,L.width],q=bke(I,k?[r,n]:[n,r]);return _.current=L,q(M-L.left)}return e.jsx(ZJe,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:e.jsx(XJe,{dir:j,"data-orientation":"horizontal",...p,ref:b,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:M=>{const L=S(M.clientX);l==null||l(L)},onSlideMove:M=>{const L=S(M.clientX);i==null||i(L)},onSlideEnd:()=>{_.current=void 0,c==null||c()},onStepKeyDown:M=>{const I=WJe[k?"from-left":"from-right"].includes(M.key);u==null||u({event:M,direction:I?-1:1})}})})}),TBt=N.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:c,...u}=t,p=N.useRef(null),f=qa(s,p),g=N.useRef(void 0),b=!a;function _(j){const w=g.current||p.current.getBoundingClientRect(),k=[0,w.height],M=bke(k,b?[n,r]:[r,n]);return g.current=w,M(j-w.top)}return e.jsx(ZJe,{scope:t.__scopeSlider,startEdge:b?"bottom":"top",endEdge:b?"top":"bottom",size:"height",direction:b?1:-1,children:e.jsx(XJe,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:j=>{const w=_(j.clientY);o==null||o(w)},onSlideMove:j=>{const w=_(j.clientY);l==null||l(w)},onSlideEnd:()=>{g.current=void 0,i==null||i()},onStepKeyDown:j=>{const k=WJe[b?"from-bottom":"from-top"].includes(j.key);c==null||c({event:j,direction:k?-1:1})}})})}),XJe=N.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:c,...u}=t,p=Bue(aE,r);return e.jsx(nn.span,{...u,ref:s,onKeyDown:Ir(t.onKeyDown,f=>{f.key==="Home"?(l(f),f.preventDefault()):f.key==="End"?(i(f),f.preventDefault()):VJe.concat(HJe).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:Ir(t.onPointerDown,f=>{const g=f.target;g.setPointerCapture(f.pointerId),f.preventDefault(),p.thumbs.has(g)?g.focus():n(f)}),onPointerMove:Ir(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:Ir(t.onPointerUp,f=>{const g=f.target;g.hasPointerCapture(f.pointerId)&&(g.releasePointerCapture(f.pointerId),o(f))})})}),QJe="SliderTrack",JJe=N.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Bue(QJe,r);return e.jsx(nn.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});JJe.displayName=QJe;var rbe="SliderRange",eet=N.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Bue(rbe,r),o=YJe(rbe,r),l=N.useRef(null),i=qa(s,l),c=a.values.length,u=a.values.map(g=>ret(g,a.min,a.max)),p=c>1?Math.min(...u):0,f=100-Math.max(...u);return e.jsx(nn.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:i,style:{...t.style,[o.startEdge]:p+"%",[o.endEdge]:f+"%"}})});eet.displayName=rbe;var nbe="SliderThumb",tet=N.forwardRef((t,s)=>{const r=kBt(t.__scopeSlider),[n,a]=N.useState(null),o=qa(s,i=>a(i)),l=N.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(ABt,{...t,ref:o,index:l})}),ABt=N.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=Bue(nbe,r),i=YJe(nbe,r),[c,u]=N.useState(null),p=qa(s,S=>u(S)),f=c?l.form||!!c.closest("form"):!0,g=yO(c),b=l.values[n],_=b===void 0?0:ret(b,l.min,l.max),j=IBt(n,l.values.length),w=g==null?void 0:g[i.size],k=w?DBt(w,_,i.direction):0;return N.useEffect(()=>{if(c)return l.thumbs.add(c),()=>{l.thumbs.delete(c)}},[c,l.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${_}% + ${k}px)`},children:[e.jsx(sbe.ItemSlot,{scope:t.__scopeSlider,children:e.jsx(nn.span,{role:"slider","aria-label":t["aria-label"]||j,"aria-valuemin":l.min,"aria-valuenow":b,"aria-valuemax":l.max,"aria-orientation":l.orientation,"data-orientation":l.orientation,"data-disabled":l.disabled?"":void 0,tabIndex:l.disabled?void 0:0,...o,ref:p,style:b===void 0?{display:"none"}:t.style,onFocus:Ir(t.onFocus,()=>{l.valueIndexToChangeRef.current=n})})}),f&&e.jsx(set,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:b},n)]})});tet.displayName=nbe;var EBt="RadioBubbleInput",set=N.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=N.useRef(null),o=qa(a,n),l=EO(s);return N.useEffect(()=>{const i=a.current;if(!i)return;const c=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(c,"value").set;if(l!==s&&p){const f=new Event("input",{bubbles:!0});p.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(nn.input,{style:{display:"none"},...r,ref:o,defaultValue:s})});set.displayName=EBt;function PBt(t=[],s,r){const n=[...t];return n[r]=s,n.sort((a,o)=>a-o)}function ret(t,s,r){const o=100/(r-s)*(t-s);return X8(o,[0,100])}function IBt(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function LBt(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 DBt(t,s,r){const n=t/2,o=bke([0,50],[0,n]);return(n-o(s)*r)*r}function OBt(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function RBt(t,s){if(s>0){const r=OBt(t);return Math.min(...r)>=s}return!0}function bke(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 FBt(t){return(String(t).split(".")[1]||"").length}function zBt(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var net=KJe,BBt=JJe,$Bt=eet,qBt=tet;const Gg=N.forwardRef(({className:t,...s},r)=>e.jsxs(net,{ref:r,className:It("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx(BBt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx($Bt,{className:"absolute h-full bg-primary"})}),e.jsx(qBt,{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"})]}));Gg.displayName=net.displayName;function UBt(t,s,r){return _Bt(bBt({unit:"%",width:90},r,t,s),t,s)}const _ke=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=N.useRef(null),[l,i]=N.useState(),[c,u]=N.useState(),[p,f]=N.useState(1),[g,b]=N.useState(0),_=N.useCallback(k=>{const{width:S,height:M}=k.currentTarget;i(UBt(S,M,a))},[a]),j=N.useCallback(async()=>{const k=o.current;if(!k||!c)return;const S=document.createElement("canvas"),M=S.getContext("2d");if(!M)return;const L=k.naturalWidth/k.width,I=k.naturalHeight/k.height,O=400;S.width=O,S.height=O,M.imageSmoothingQuality="high";const q=c.x*L,U=c.y*I,B=c.width*L,V=c.height*I,Z=g*Math.PI/180,X=S.width/2,ee=S.height/2;return M.save(),M.translate(X,ee),M.rotate(Z),M.scale(p,p),M.translate(-X,-ee),M.drawImage(k,q,U,B,V,0,0,O,O),M.restore(),new Promise((Q,ie)=>{S.toBlob(re=>{re?Q(re):ie(new Error("Canvas is empty"))},"image/jpeg",.95)})},[c,p,g]),w=async()=>{try{const k=await j();k&&(n(k),s())}catch(k){console.error("Error cropping image:",k)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(_s,{children:e.jsx(vs,{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(NBt,{crop:l,onChange:(k,S)=>i(S),onComplete:k=>u(k),aspect:a,circularCrop:!0,className:"max-h-[400px]",children:e.jsx("img",{ref:o,src:r,alt:"Crop preview",style:{transform:`scale(${p}) rotate(${g}deg)`,maxHeight:"400px",width:"auto"},onLoad:_})})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(VM,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Gg,{value:[p],min:.5,max:3,step:.1,onValueChange:([k])=>f(k),className:"flex-1"}),e.jsx(G_,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(wL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Gg,{value:[g],min:-180,max:180,step:1,onValueChange:([k])=>b(k),className:"flex-1"}),e.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[g,"°"]})]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(K,{onClick:w,children:"Save Photo"})]})]})})},VBt=()=>{const{user:t}=Ds(),{toast:s}=Ua(),[r,n]=N.useState(!1),[a,o]=N.useState(!1),[l,i]=N.useState(null);N.useEffect(()=>{t&&c()},[t]);const c=async()=>{n(!0);try{const{data:f}=await H.from("profiles").select("subscription_status, subscription_product_id, subscription_end_date, is_grandfathered").eq("id",t==null?void 0:t.id).single();f&&i({status:f.subscription_status||"none",productId:f.subscription_product_id,endDate:f.subscription_end_date,isGrandfathered:f.is_grandfathered||!1})}catch(f){console.error("Error loading subscription:",f)}finally{n(!1)}},u=async()=>{o(!0);try{const{data:{session:f}}=await H.auth.getSession();if(!f)throw new Error("Not authenticated");const{data:g,error:b}=await H.functions.invoke("customer-portal",{headers:{Authorization:`Bearer ${f.access_token}`}});if(b)throw b;g!=null&&g.url&&window.open(g.url,"_blank")}catch(f){console.error("Error opening customer portal:",f),s({title:"Error",description:f.message||"Failed to open billing portal",variant:"destructive"})}finally{o(!1)}},p=()=>{if(l!=null&&l.isGrandfathered)return e.jsx(tt,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return e.jsx(tt,{className:"bg-green-500",children:"Active"});case"trialing":return e.jsx(tt,{className:"bg-blue-500",children:"Trial"});case"past_due":return e.jsx(tt,{variant:"destructive",children:"Past Due"});case"canceled":return e.jsx(tt,{variant:"secondary",children:"Canceled"});default:return e.jsx(tt,{variant:"outline",children:"No Subscription"})}};return r?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Cx,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx(De,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Cx,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(gr,{children:"Manage your subscription and billing"})]}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Status"}),e.jsx("div",{className:"mt-1",children:p()})]}),(l==null?void 0:l.endDate)&&l.status==="active"&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Next billing date"}),e.jsx("p",{className:"font-medium",children:new Date(l.endDate).toLocaleDateString()})]})]}),l!=null&&l.isGrandfathered?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your account was upgraded from LevelUp 1.0. To update/manage your subscription please reach out to support."}):(l==null?void 0:l.status)==="active"||(l==null?void 0:l.status)==="trialing"?e.jsxs(e.Fragment,{children:[(l==null?void 0:l.status)==="trialing"&&(l==null?void 0:l.endDate)&&e.jsxs("p",{className:"text-sm text-muted-foreground mb-3",children:["Your trial ends on ",new Date(l.endDate).toLocaleDateString(),". After the trial, you'll be charged automatically."]}),e.jsxs(K,{onClick:u,variant:"outline",disabled:a,children:[a?e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(tn,{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."})]})]})},HBt=()=>{const{user:t}=Ds(),s=fr(),{toast:r}=Ua(),[n]=Cc(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:c,subscribe:u,unsubscribe:p}=RYe(),[f,g]=N.useState(!1),[b,_]=N.useState(""),[j,w]=N.useState(!1),[k,S]=N.useState(!1),[M,L]=N.useState(""),[I,O]=N.useState({name:"",email:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[q,U]=N.useState(!1),[B,V]=N.useState(!1),[Z,X]=N.useState({newPassword:"",confirmPassword:""});N.useEffect(()=>{t&&ee()},[t]),N.useEffect(()=>{o&&t&&setTimeout(()=>{var ce;(ce=document.getElementById("change-password-section"))==null||ce.scrollIntoView({behavior:"smooth",block:"center"})},500)},[o,t]);const ee=async()=>{var ce,xe,ge;if(!(t!=null&&t.id)){console.log("No user ID available yet");return}try{console.log("Loading profile for user:",t.id);const{data:ue,error:pe}=await H.from("profiles").select("name, email, digest_opt_out, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url, email_signature, use_email_signature").eq("id",t.id).maybeSingle();if(pe)throw console.error("Profile query error:",pe),pe;ue?(console.log("Profile loaded successfully:",ue),O({name:ue.name||"",email:ue.email||"",title:ue.title||"",bio:ue.bio||"",areas_served:ue.areas_served||"",years_experience:((ce=ue.years_experience)==null?void 0:ce.toString())||"",instagram_url:ue.instagram_url||"",facebook_url:ue.facebook_url||"",linkedin_url:ue.linkedin_url||"",email_signature:ue.email_signature||"",use_email_signature:ue.use_email_signature||!1}),U(ue.digest_opt_out||!1)):(console.warn("No profile found for user"),O({name:((xe=t.user_metadata)==null?void 0:xe.name)||((ge=t.email)==null?void 0:ge.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:be}=await H.storage.from("avatars").list(`${t.id}`);if(be&&be.length>0){const{data:Me}=H.storage.from("avatars").getPublicUrl(`${t.id}/${be[0].name}`);_(Me.publicUrl)}}catch(ue){console.error("Error loading profile:",ue),r({title:"Error",description:ue.message||"Failed to load profile",variant:"destructive"})}},Q=ce=>{var ue;const xe=(ue=ce.target.files)==null?void 0:ue[0];if(!xe)return;const ge=new FileReader;ge.onloadend=()=>{L(ge.result),S(!0)},ge.readAsDataURL(xe),ce.target.value=""},ie=async ce=>{if(t){w(!0);try{const{data:xe}=await H.storage.from("avatars").list(`${t.id}`);xe&&xe.length>0&&await H.storage.from("avatars").remove(xe.map(Ne=>`${t.id}/${Ne.name}`));const ue=`${t.id}/avatar.jpg`,{error:pe}=await H.storage.from("avatars").upload(ue,ce,{upsert:!0,contentType:"image/jpeg"});if(pe)throw pe;const{data:be}=H.storage.from("avatars").getPublicUrl(ue),Me=be.publicUrl;_(`${Me}?t=${Date.now()}`),await H.from("profiles").update({avatar_url:Me}).eq("id",t.id),r({title:"Success",description:"Profile photo updated successfully"})}catch(xe){console.error("Error uploading avatar:",xe),r({title:"Error",description:xe.message||"Failed to upload photo",variant:"destructive"})}finally{w(!1)}}},re=async()=>{if(!I.name.trim()||!I.email.trim()){r({title:"Error",description:"Name and email are required",variant:"destructive"});return}g(!0);try{const{error:ce}=await H.from("profiles").update({name:I.name.trim(),email:I.email.trim(),title:I.title.trim()||null,bio:I.bio.trim()||null,areas_served:I.areas_served.trim()||null,years_experience:I.years_experience?parseInt(I.years_experience):null,instagram_url:I.instagram_url.trim()||null,facebook_url:I.facebook_url.trim()||null,linkedin_url:I.linkedin_url.trim()||null,email_signature:I.email_signature||"",use_email_signature:I.use_email_signature}).eq("id",t==null?void 0:t.id);if(ce)throw ce;r({title:"Success",description:"Profile updated successfully"})}catch(ce){console.error("Error updating profile:",ce),r({title:"Error",description:ce.message||"Failed to update profile",variant:"destructive"})}finally{g(!1)}},oe=async()=>{if(!Z.newPassword){r({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(Z.newPassword.length<6){r({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(Z.newPassword!==Z.confirmPassword){r({title:"Error",description:"Passwords do not match",variant:"destructive"});return}g(!0);try{const{error:ce}=await H.auth.updateUser({password:Z.newPassword});if(ce)throw ce;r({title:"Success",description:"Password updated successfully"}),X({newPassword:"",confirmPassword:""}),a&&setTimeout(()=>s("/dashboard"),1e3)}catch(ce){console.error("Error updating password:",ce),r({title:"Error",description:ce.message||"Failed to update password",variant:"destructive"})}finally{g(!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 ce;(ce=document.getElementById("change-password-section"))==null||ce.scrollIntoView({behavior:"smooth",block:"center"})},className:"gap-2",children:[e.jsx(sS,{className:"h-4 w-4"}),"Change Password"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Profile Photo"}),e.jsx(gr,{children:"Upload a professional photo for your profile"})]}),e.jsxs(De,{className:"flex items-center gap-6",children:[e.jsxs(Nn,{className:"h-24 w-24",children:[e.jsx($a,{src:b}),e.jsx(kn,{className:"text-2xl",children:I.name.split(" ").map(ce=>ce[0]).join("").toUpperCase()||"U"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{type:"file",id:"avatar-upload",accept:"image/*",className:"hidden",onChange:Q,disabled:j}),e.jsxs(K,{variant:"outline",onClick:()=>{var ce;return(ce=document.getElementById("avatar-upload"))==null?void 0:ce.click()},disabled:j,children:[e.jsx(li,{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(Pt,{children:[e.jsx(Rt,{children:"Personal Information"}),e.jsx(gr,{children:"Update your profile details"})]}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",value:I.name,onChange:ce=>O({...I,name:ce.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:I.email,onChange:ce=>O({...I,email:ce.target.value}),maxLength:255})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Job Title"}),e.jsx(ze,{id:"title",value:I.title,onChange:ce=>O({...I,title:ce.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(Er,{id:"bio",value:I.bio,onChange:ce=>O({...I,bio:ce.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(ze,{id:"areas_served",value:I.areas_served,onChange:ce=>O({...I,areas_served:ce.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(ze,{id:"years_experience",type:"number",min:"0",value:I.years_experience,onChange:ce=>O({...I,years_experience:ce.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(ze,{value:I.linkedin_url,onChange:ce=>O({...I,linkedin_url:ce.target.value}),placeholder:"LinkedIn URL"}),e.jsx(ze,{value:I.instagram_url,onChange:ce=>O({...I,instagram_url:ce.target.value}),placeholder:"Instagram URL"}),e.jsx(ze,{value:I.facebook_url,onChange:ce=>O({...I,facebook_url:ce.target.value}),placeholder:"Facebook URL"})]})]}),e.jsxs(K,{onClick:re,disabled:f,children:[e.jsx(qc,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Fv,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(gr,{children:"Add a signature that will be appended to emails sent via Gmail"})]}),e.jsxs(De,{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:I.use_email_signature?"Your signature will be added to every email sent via Gmail":"Signature is currently disabled"})]}),e.jsx(qr,{checked:I.use_email_signature,onCheckedChange:ce=>O({...I,use_email_signature:ce})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Signature"}),e.jsx(my,{content:I.email_signature,onChange:ce=>O({...I,email_signature:ce}),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:re,disabled:f,children:[e.jsx(qc,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),e.jsxs(Ee,{id:"change-password-section",children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:a?"Set Your Password":"Change Password"}),e.jsx(gr,{children:a?"Create a secure password for your account":"Update your password to keep your account secure"})]}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"newPassword",children:"New Password"}),e.jsx(ze,{id:"newPassword",type:"password",value:Z.newPassword,onChange:ce=>X({...Z,newPassword:ce.target.value}),placeholder:"Min 6 characters"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(ze,{id:"confirmPassword",type:"password",value:Z.confirmPassword,onChange:ce=>X({...Z,confirmPassword:ce.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(K,{onClick:oe,disabled:f,children:[e.jsx(qc,{className:"mr-2 h-4 w-4"}),a?"Complete Setup":"Update Password"]}),a&&e.jsx(K,{variant:"outline",onClick:()=>s("/dashboard"),className:"ml-2",children:"Skip for Now"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[i?e.jsx(Lm,{className:"h-5 w-5"}):e.jsx(t1,{className:"h-5 w-5"}),"Push Notifications"]}),e.jsx(gr,{children:"Receive browser notifications when new content is added"})]}),e.jsx(De,{children:l?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:i?"Notifications enabled":"Notifications disabled"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?"You'll receive notifications about new templates, videos, and events":"Enable to get notified about new content"})]}),e.jsx(qr,{checked:i,onCheckedChange:ce=>{ce?u():p()},disabled:c})]}):e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:"Push notifications are not supported in this browser."}),e.jsxs("p",{className:"text-xs",children:[e.jsx("strong",{children:"Desktop:"})," Use Chrome, Firefox, or Edge.",e.jsx("br",{}),e.jsx("strong",{children:"iPhone/iPad:"}),' Open this site in Safari, tap the Share button, then "Add to Home Screen". Push notifications will work from the installed app.']})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[q?e.jsx(uL,{className:"h-5 w-5"}):e.jsx(cr,{className:"h-5 w-5"}),"Email Preferences"]}),e.jsx(gr,{children:"Manage your email subscription settings"})]}),e.jsx(De,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q?"You won't receive weekly digest emails":"Receive a weekly summary of new content, events, and your progress"})]}),e.jsx(qr,{checked:!q,onCheckedChange:async ce=>{V(!0);try{const{error:xe}=await H.from("profiles").update({digest_opt_out:!ce}).eq("id",t==null?void 0:t.id);if(xe)throw xe;U(!ce),r({title:ce?"Subscribed":"Unsubscribed",description:ce?"You will now receive weekly digest emails":"You will no longer receive weekly digest emails"})}catch(xe){r({title:"Error",description:xe.message||"Failed to update preference",variant:"destructive"})}finally{V(!1)}},disabled:B})]})})]}),e.jsx(w8t,{}),e.jsx(VBt,{})]}),e.jsx(_ke,{open:k,onClose:()=>S(!1),imageSrc:M,onCropComplete:ie,aspectRatio:1})]})})};var WBt="AspectRatio",aet=N.forwardRef((t,s)=>{const{ratio:r=1/1,style:n,...a}=t;return e.jsx("div",{style:{position:"relative",width:"100%",paddingBottom:`${100/r}%`},"data-radix-aspect-ratio-wrapper":"",children:e.jsx(nn.div,{...a,ref:s,style:{...n,position:"absolute",top:0,right:0,bottom:0,left:0}})})});aet.displayName=WBt;var GBt=aet;const KBt=GBt;function ZBt(){const{user:t}=Ds(),s=Qt(),[r,n]=N.useState(!1),[a,o]=N.useState(!1),{data:l,isLoading:i}=mt({queryKey:["calendar-token",t==null?void 0:t.id],queryFn:async()=>{const{data:_,error:j}=await H.from("profiles").select("calendar_token").eq("id",t==null?void 0:t.id).single();if(j)throw j;return _},enabled:!!t&&a}),c=Dt({mutationFn:async()=>{const _=new Uint8Array(12);crypto.getRandomValues(_);const j=btoa(String.fromCharCode(..._)).replace(/\+/g,"x").replace(/\//g,"y").replace(/=/g,"").substring(0,16),{error:w}=await H.from("profiles").update({calendar_token:j}).eq("id",t==null?void 0:t.id);if(w)throw w;return j},onSuccess:()=>{s.invalidateQueries({queryKey:["calendar-token",t==null?void 0:t.id]}),me.success("Calendar subscription URL generated!")},onError:_=>{me.error("Failed to generate calendar URL: "+_.message)}}),u=l!=null&&l.calendar_token?`https://dashboard.relevelup.com/api/calendar/${l.calendar_token}.ics`:null,p=async()=>{u&&(await navigator.clipboard.writeText(u),n(!0),me.success("Calendar URL copied to clipboard!"),setTimeout(()=>n(!1),2e3))},f=()=>{u&&(window.location.href=u.replace("https://","webcal://"))},g=()=>{if(u){const _=u.replace("https://","webcal://"),j=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(_)}`;window.open(j,"_blank")}},b=()=>{if(u){const _=`https://outlook.live.com/calendar/0/addfromweb?url=${encodeURIComponent(u)}&name=Level%20Up%20Events`;window.open(_,"_blank")}};return e.jsxs(fs,{open:a,onOpenChange:o,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5 text-primary"}),"Subscribe to Events Calendar"]}),e.jsx(Gr,{children:"Add all Level Up events to your personal calendar. Events will sync automatically and update when we add or change events."})]}),e.jsx("div",{className:"space-y-4 py-4",children:i?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):u?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Your Calendar URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:u,readOnly:!0,className:"text-xs font-mono"}),e.jsx(K,{variant:"outline",size:"icon",onClick:p,children:r?e.jsx(va,{className:"h-4 w-4 text-green-500"}):e.jsx(gi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Quick Add"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:f,children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),"Add to Apple Calendar",e.jsx(tn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:g,children:[e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("path",{d:"M19.5 22h-15A2.5 2.5 0 0 1 2 19.5v-15A2.5 2.5 0 0 1 4.5 2H9v2H4.5a.5.5 0 0 0-.5.5v15a.5.5 0 0 0 .5.5h15a.5.5 0 0 0 .5-.5V15h2v4.5a2.5 2.5 0 0 1-2.5 2.5z"}),e.jsx("path",{d:"M12 2v8.5a1.5 1.5 0 0 0 1.5 1.5H22V2h-10z",fill:"#4285F4"}),e.jsx("path",{d:"M12 12V2H4.5A2.5 2.5 0 0 0 2 4.5V12h10z",fill:"#34A853"}),e.jsx("path",{d:"M2 12v7.5A2.5 2.5 0 0 0 4.5 22H12v-10H2z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 22h7.5a2.5 2.5 0 0 0 2.5-2.5V12h-10v10z",fill:"#EA4335"})]}),"Add to Google Calendar",e.jsx(tn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:b,children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M7.88 12.04q0 .45-.11.87-.1.41-.33.74-.22.33-.58.52-.37.2-.87.2t-.85-.2q-.35-.21-.57-.55-.22-.33-.33-.75-.1-.42-.1-.86t.1-.87q.1-.43.34-.76.22-.34.59-.54.36-.2.87-.2t.86.2q.35.21.57.55.22.34.31.77.1.43.1.88zM24 12v9.38q0 .46-.33.8-.33.32-.8.32H7.13q-.46 0-.8-.33-.32-.33-.32-.8V18H1q-.41 0-.7-.3-.3-.29-.3-.7V7q0-.41.3-.7Q.58 6 1 6h6.5V2.55q0-.44.3-.75.3-.3.75-.3h12.9q.44 0 .75.3.3.3.3.75V12zm-6-8.25v3h3v-3zm0 4.5v3h3v-3zm0 4.5v1.83l3.05-1.83zm-5.25-9v3h3.75v-3zm0 4.5v3h3.75v-3zm0 4.5v2.03l2.41 1.5 1.34-.81v-2.72zM9 3.75V6h2l.13.01.12.04v-2.3zM5.98 15.98q.9 0 1.6-.3.7-.32 1.19-.86.48-.55.73-1.28.25-.74.25-1.61 0-.83-.25-1.55-.24-.71-.71-1.24t-1.15-.83q-.68-.3-1.55-.3-.92 0-1.64.3-.71.3-1.2.85-.5.54-.75 1.3-.25.74-.25 1.63 0 .85.26 1.56.26.72.74 1.23.48.52 1.17.81.69.3 1.56.3zM7.5 21h12.39L12 16.08V17q0 .41-.3.7-.29.3-.7.3H7.5zm15-.13v-7.24l-5.9 3.54Z"})}),"Add to Outlook",e.jsx(tn,{className:"h-3 w-3 ml-auto opacity-50"})]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center pt-2",children:"Events sync automatically. If your membership expires, the calendar will show as empty."})]}):e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generate your personal calendar subscription URL to get started."}),e.jsx(K,{onClick:()=>c.mutate(),disabled:c.isPending,className:"w-full",children:c.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}var $ue="Tabs",[YBt]=ad($ue,[Tw]),iet=Tw(),[XBt,wke]=YBt($ue),oet=N.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:c="automatic",...u}=t,p=Mw(i),[f,g]=ah({prop:n,onChange:a,defaultProp:o??"",caller:$ue});return e.jsx(XBt,{scope:r,baseId:Tu(),value:f,onValueChange:g,orientation:l,dir:p,activationMode:c,children:e.jsx(nn.div,{dir:p,"data-orientation":l,...u,ref:s})})});oet.displayName=$ue;var cet="TabsList",det=N.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=wke(cet,r),l=iet(r);return e.jsx(Lde,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:n,children:e.jsx(nn.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})});det.displayName=cet;var uet="TabsTrigger",het=N.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=t,l=wke(uet,r),i=iet(r),c=fet(l.baseId,n),u=xet(l.baseId,n),p=n===l.value;return e.jsx(Dde,{asChild:!0,...i,focusable:!a,active:p,children:e.jsx(nn.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:c,...o,ref:s,onMouseDown:Ir(t.onMouseDown,f=>{!a&&f.button===0&&f.ctrlKey===!1?l.onValueChange(n):f.preventDefault()}),onKeyDown:Ir(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&l.onValueChange(n)}),onFocus:Ir(t.onFocus,()=>{const f=l.activationMode!=="manual";!p&&!a&&f&&l.onValueChange(n)})})})});het.displayName=uet;var met="TabsContent",pet=N.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...l}=t,i=wke(met,r),c=fet(i.baseId,n),u=xet(i.baseId,n),p=n===i.value,f=N.useRef(p);return N.useEffect(()=>{const g=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(g)},[]),e.jsx(Fd,{present:a||p,children:({present:g})=>e.jsx(nn.div,{"data-state":p?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":c,hidden:!g,id:u,tabIndex:0,...l,ref:s,style:{...t.style,animationDuration:f.current?"0s":void 0},children:g&&o})})});pet.displayName=met;function fet(t,s){return`${t}-trigger-${s}`}function xet(t,s){return`${t}-content-${s}`}var QBt=oet,get=det,yet=het,vet=pet;const ba=QBt,pa=N.forwardRef(({className:t,...s},r)=>e.jsx(get,{ref:r,className:It("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));pa.displayName=get.displayName;const ns=N.forwardRef(({className:t,...s},r)=>e.jsx(yet,{ref:r,className:It("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t),...s}));ns.displayName=yet.displayName;const bs=N.forwardRef(({className:t,...s},r)=>e.jsx(vet,{ref:r,className:It("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));bs.displayName=vet.displayName;const JBt={first_timer:Jn,regular:o1,dedicated:Nc,veteran:xo,streak_master:eh,century:xo},e$t={first_timer:"bg-green-500/10 text-green-500 border-green-500/20",regular:"bg-blue-500/10 text-blue-500 border-blue-500/20",dedicated:"bg-purple-500/10 text-purple-500 border-purple-500/20",veteran:"bg-amber-500/10 text-amber-500 border-amber-500/20",streak_master:"bg-orange-500/10 text-orange-500 border-orange-500/20",century:"bg-yellow-500/10 text-yellow-500 border-yellow-500/20"};function a8e(t){return t===1?e.jsx(xo,{className:"h-5 w-5 text-yellow-500"}):t===2?e.jsx(o1,{className:"h-5 w-5 text-gray-400"}):t===3?e.jsx(Nc,{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 bet({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=Ds(),{data:o,isLoading:l}=iXe(s?5:10,r),{data:i}=oXe(a==null?void 0:a.id),{data:c}=cXe(a==null?void 0:a.id),{data:u}=lXe(a==null?void 0:a.id);return l?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((p,f)=>e.jsx(ys,{className:"h-12 w-full"},f))})})]}):e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsxs(De,{children:[t&&i&&e.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-primary/5 border border-primary/10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Your Stats"}),c&&e.jsxs(tt,{variant:"secondary",className:"text-xs",children:["Rank #",c]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-primary",children:i.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Points"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold",children:i.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Events"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(eh,{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=JBt[p.badge_type]||Jn;return e.jsxs(tt,{variant:"outline",className:`text-xs ${e$t[p.badge_type]||""}`,title:p.badge_description||"",children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),p.badge_name]},p.id)}),u.length>4&&e.jsxs(tt,{variant:"outline",className:"text-xs",children:["+",u.length-4," more"]})]})]}),e.jsxs(ba,{defaultValue:"points",className:"w-full",children:[e.jsxs(pa,{className:"w-full mb-3",children:[e.jsx(ns,{value:"points",className:"flex-1",children:"By Points"}),e.jsx(ns,{value:"events",className:"flex-1",children:"By Events"})]}),e.jsx(bs,{value:"points",className:"mt-0",children:e.jsxs("div",{className:"space-y-2",children:[o==null?void 0:o.map((p,f)=>{var g,b,_;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${p.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${f===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:a8e(f+1)}),e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{className:"text-xs",children:((b=(g=p.profile)==null?void 0:g.name)==null?void 0:b.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((_=p.profile)==null?void 0:_.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_events_attended," events"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold text-primary",children:p.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"pts"})]})]},p.user_id)}),(!o||o.length===0)&&e.jsx("div",{className:"text-center text-muted-foreground py-4 text-sm",children:"No attendance data yet. Attend an event to get on the leaderboard!"})]})}),e.jsx(bs,{value:"events",className:"mt-0",children:e.jsx("div",{className:"space-y-2",children:[...o||[]].sort((p,f)=>f.total_events_attended-p.total_events_attended).map((p,f)=>{var g,b,_;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${p.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${f===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:a8e(f+1)}),e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{className:"text-xs",children:((b=(g=p.profile)==null?void 0:g.name)==null?void 0:b.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((_=p.profile)==null?void 0:_.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_points," points"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold",children:p.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"events"})]})]},p.user_id)})})})]})]})]})}function t$t(){const t=fr(),{user:s,isAdmin:r}=Ds(),n=Qt(),{data:a,isLoading:o}=mt({queryKey:["public-events"],queryFn:async()=>{const{data:j,error:w}=await H.from("events").select("*").order("event_date",{ascending:!0});if(w)throw w;return j}}),{data:l}=mt({queryKey:["my-registrations"],queryFn:async()=>{if(!s)return[];const{data:j,error:w}=await H.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",s.id);if(w)throw w;return j},enabled:!!s}),{data:i}=mt({queryKey:["event-registration-counts"],queryFn:async()=>{let j=[],w=0;const k=1e3;for(;;){const{data:M,error:L}=await H.from("event_registrations").select("event_id").range(w,w+k-1);if(L)throw L;if(!M||M.length===0||(j=j.concat(M),M.length{S[M.event_id]=(S[M.event_id]||0)+1}),S}}),c=Dt({mutationFn:async j=>{await H.auth.refreshSession();const{data:w,error:k}=await H.functions.invoke("zoom-register",{body:{event_id:j}});if(k)throw k;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?me.success("Successfully registered! You'll receive a Zoom confirmation email."):me.success("Successfully registered for the event!")},onError:j=>{me.error("Failed to register: "+j.message)}}),u=Dt({mutationFn:async j=>{const{data:w,error:k}=await H.functions.invoke("zoom-unregister",{body:{event_id:j}});if(k)throw k;if(w!=null&&w.error)throw new Error(w.error);return w},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),me.success("Registration cancelled and removed from Zoom")},onError:j=>{me.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(k=>k.event_id===j);return w==null?void 0:w.zoom_join_url},g=j=>j.capacity?((i==null?void 0:i[j.id])||0)>=j.capacity:!1,b=(a==null?void 0:a.filter(j=>QM(j.event_date)!=="ended"))||[],_=(a==null?void 0:a.filter(j=>QM(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(ZBt,{}),r&&e.jsx(K,{variant:"outline",onClick:()=>t("/admin/events"),children:"Manage Events"})]})]}),e.jsxs("div",{className:`grid grid-cols-1 ${r?"lg:grid-cols-3":""} gap-6`,children:[e.jsxs("div",{className:r?"lg:col-span-2":"",children:[o?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading events..."}):b.length===0?e.jsx(Ee,{className:"text-center py-12",children:e.jsx(De,{children:e.jsx("p",{className:"text-muted-foreground",children:"No upcoming events at the moment. Check back soon!"})})}):e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:b.map(j=>{const w=QM(j.event_date),k=yNe(j.event_date),S=w==="live",M=w==="starting_soon";return e.jsxs(Ee,{className:`flex flex-col overflow-hidden cursor-pointer hover:shadow-lg transition-all ${S?"border-red-500 ring-2 ring-red-500/20":M?"border-amber-500 ring-2 ring-amber-500/20":"hover:border-primary/50"}`,onClick:()=>t(`/events/${j.id}`),children:[k&&e.jsxs("div",{className:`${S?"bg-red-500":"bg-amber-500"} text-white px-3 py-1.5 flex items-center gap-2 text-sm font-medium`,children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-white opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-white"})]}),S?e.jsxs(e.Fragment,{children:[e.jsx(d1,{className:"h-3.5 w-3.5"}),"LIVE NOW"]}):e.jsxs(e.Fragment,{children:[e.jsx(un,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),j.image_url&&e.jsx(KBt,{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(Pt,{children:[e.jsx(Rt,{className:"line-clamp-2",children:j.title}),j.description&&e.jsx(gr,{className:"line-clamp-2",children:j.description.replace(/<[^>]*>/g,"")})]}),e.jsxs(De,{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(hn,{className:"h-4 w-4"}),new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(j.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(un,{className:"h-4 w-4"}),nD(new Date(j.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(pr,{className:"h-4 w-4"}),(i==null?void 0:i[j.id])||0," registered",j.capacity&&` / ${j.capacity} spots`]})]}),e.jsx($L,{className:"flex gap-2",onClick:L=>L.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(Rr,{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(tn,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):e.jsx(K,{className:"w-full",onClick:()=>c.mutate(j.id),disabled:c.isPending||g(j),children:g(j)?"Event Full":e.jsxs(e.Fragment,{children:[e.jsx(va,{className:"h-4 w-4 mr-2"}),"Register"]})})})]},j.id)})}),_.length>0&&e.jsxs("div",{className:"mt-12",children:[e.jsx("h3",{className:"text-xl font-semibold mb-4 text-muted-foreground",children:"Past Events"}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:_.map(j=>e.jsx(Ee,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>t(`/events/${j.id}`),children:e.jsxs(Pt,{children:[e.jsx(Rt,{className:"text-base line-clamp-1",children:j.title}),e.jsx(gr,{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(bet,{showUserStats:!0})})]})]})})}const kge=[{value:"all",label:"All Roles",icon:pr},{value:"newest",label:"Newest Members",icon:un},{value:"brokerage_manager",label:"Brokerage Managers",icon:LL},{value:"admin",label:"Admins",icon:th}];function s$t({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var Be,nt;const{user:o,isAdmin:l,isBrokerageManager:i}=Ds(),[c,u]=N.useState([]),[p,f]=N.useState([]),[g,b]=N.useState([]),[_,j]=N.useState([]),[w,k]=N.useState(""),[S,M]=N.useState(""),[L,I]=N.useState(""),[O,q]=N.useState(!1),[U,B]=N.useState(!1),[V,Z]=N.useState("agents"),[X,ee]=N.useState("all"),[Q,ie]=N.useState({}),re=l||i;N.useEffect(()=>{t&&o&&(l?oe():ce())},[t,o,l]),N.useEffect(()=>{t||(b([]),j([]),k(""),M(""),I(""),Z("agents"),ee("all"))},[t]);const oe=async()=>{if(o){q(!0);try{const{data:Ae,error:ft}=await H.from("brokerages").select("id, name").order("name");if(ft)throw ft;const fe=1e3,Ve={};let at=0,et=!0;for(;et;){const{data:Ge,error:ct}=await H.from("profiles").select("brokerage_id").range(at*fe,(at+1)*fe-1);if(ct)throw ct;Ge==null||Ge.forEach(qe=>{qe.brokerage_id&&(Ve[qe.brokerage_id]=(Ve[qe.brokerage_id]||0)+1)}),et=(Ge==null?void 0:Ge.length)===fe,at++}f((Ae==null?void 0:Ae.map(Ge=>({...Ge,agent_count:Ve[Ge.id]||0})))||[]);const Ce=[];for(at=0,et=!0;et;){const{data:Ge,error:ct}=await H.from("profiles").select("id, name, email, brokerage_id, created_at, brokerages(name)").neq("id",o.id).order("name").range(at*fe,(at+1)*fe-1);if(ct)throw ct;Ge&&Ce.push(...Ge),et=(Ge==null?void 0:Ge.length)===fe,at++}const rt={};for(at=0,et=!0;et;){const{data:Ge,error:ct}=await H.from("user_roles").select("user_id, role").range(at*fe,(at+1)*fe-1);if(ct)throw ct;Ge==null||Ge.forEach(qe=>{rt[qe.user_id]||(rt[qe.user_id]=[]),rt[qe.user_id].push(qe.role)}),et=(Ge==null?void 0:Ge.length)===fe,at++}ie(rt),u(Ce.map(Ge=>{var ct;return{id:Ge.id,name:Ge.name,email:Ge.email,brokerage_name:((ct=Ge.brokerages)==null?void 0:ct.name)||"No Brokerage",roles:rt[Ge.id]||[],created_at:Ge.created_at}}))}catch(Ae){console.error("Error loading data:",Ae),me.error("Failed to load agents and brokerages")}finally{q(!1)}}},ce=async()=>{if(o){q(!0);try{const{data:Ae}=await H.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(Ae!=null&&Ae.brokerage_id)){me.error("You must be part of a brokerage to share resources"),s(!1);return}const{data:ft,error:fe}=await H.from("profiles").select("id, name, email").eq("brokerage_id",Ae.brokerage_id).neq("id",o.id).order("name");if(fe)throw fe;u(ft||[])}catch(Ae){console.error("Error loading agents:",Ae),me.error("Failed to load agents")}finally{q(!1)}}},xe=c.filter(Ae=>{var fe;const ft=Ae.name.toLowerCase().includes(w.toLowerCase())||Ae.email.toLowerCase().includes(w.toLowerCase())||((fe=Ae.brokerage_name)==null?void 0:fe.toLowerCase().includes(w.toLowerCase()));if(l&&X!=="all"&&X!=="newest"){const Ve=Q[Ae.id]||[];return ft&&Ve.includes(X)}return ft}).sort((Ae,ft)=>X==="newest"?(ft.created_at||"").localeCompare(Ae.created_at||""):0),ge=p.filter(Ae=>Ae.name.toLowerCase().includes(S.toLowerCase())),ue=()=>{g.length===xe.length?b([]):b(xe.map(Ae=>Ae.id))},pe=()=>{_.length===ge.length?j([]):j(ge.map(Ae=>Ae.id))},be=Ae=>{if(!re){b([Ae]);return}b(ft=>ft.includes(Ae)?ft.filter(fe=>fe!==Ae):[...ft,Ae])},Me=Ae=>{j(ft=>ft.includes(Ae)?ft.filter(fe=>fe!==Ae):[...ft,Ae])},Ne=async()=>{if(!(g.length>0||_.length>0)){me.error("Please select at least one agent or brokerage to share with");return}B(!0);try{const{data:ft,error:fe}=await H.functions.invoke("send-share-notification",{body:{recipientIds:g,brokerageIds:_,resourceType:r,resourceId:n,resourceTitle:a,message:L.trim()||void 0}});if(fe)throw fe;const Ve=(ft==null?void 0:ft.sharesCreated)||g.length;me.success(`Shared with ${Ve} agent${Ve!==1?"s":""}`),s(!1)}catch(ft){console.error("Error sharing resource:",ft),me.error("Failed to share resource")}finally{B(!1)}},Pe=Ae=>Ae.split(" ").map(ft=>ft[0]).join("").toUpperCase().slice(0,2),Oe=Ae=>{const ft=Q[Ae]||[];return ft.includes("admin")?e.jsx(tt,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):ft.includes("brokerage_manager")?e.jsx(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},Te=g.length+_.length,ke=X!=="all"&&X!=="newest"?xe.length:null;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{className:"flex-shrink-0",children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Bn,{className:"h-5 w-5 text-primary"}),"Share Resource"]}),e.jsxs(Gr,{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(ba,{value:V,onValueChange:Z,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[e.jsxs(ns,{value:"agents",className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),e.jsx("span",{children:"Agents"}),g.length>0&&e.jsx(tt,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:g.length})]}),e.jsxs(ns,{value:"brokerages",className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4"}),e.jsx("span",{children:"Brokerages"}),_.length>0&&e.jsx(tt,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:_.length})]})]}),e.jsxs(bs,{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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or brokerage...",value:w,onChange:Ae=>k(Ae.target.value),className:"pl-9"})]}),e.jsxs(Zs,{value:X,onValueChange:ee,children:[e.jsxs(Ws,{className:"w-[180px]",children:[e.jsx(Xg,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(Xs,{placeholder:"Filter by role"})]}),e.jsx(Gs,{children:kge.map(Ae=>e.jsx(Mt,{value:Ae.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae.icon,{className:"h-4 w-4"}),e.jsx("span",{children:Ae.label})]})},Ae.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:ue,className:"text-xs h-8",disabled:xe.length===0,children:[e.jsx(pr,{className:"h-3.5 w-3.5 mr-1.5"}),g.length===xe.length&&xe.length>0?"Deselect All":"Select All"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[ke!==null&&e.jsxs("span",{className:"text-primary font-medium",children:[ke," ",(Be=kge.find(Ae=>Ae.value===X))==null?void 0:Be.label]}),e.jsxs("span",{className:"font-medium",children:[g.length," selected"]})]})]}),e.jsx(Gi,{className:"h-[300px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):xe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(pr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:X!=="all"?`No ${(nt=kge.find(Ae=>Ae.value===X))==null?void 0:nt.label.toLowerCase()} found`:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:xe.map(Ae=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${g.includes(Ae.id)?"bg-accent":""}`,onClick:()=>be(Ae.id),children:[e.jsx(Oo,{checked:g.includes(Ae.id),onCheckedChange:()=>be(Ae.id),className:"flex-shrink-0"}),e.jsx(Nn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(kn,{className:"text-xs bg-primary/10 text-primary",children:Pe(Ae.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:Ae.name}),Oe(Ae.id)]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[Ae.email,Ae.brokerage_name&&e.jsxs("span",{className:"ml-1 opacity-75",children:["• ",Ae.brokerage_name]})]})]})]},Ae.id))})})]}),e.jsxs(bs,{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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search brokerages...",value:S,onChange:Ae=>M(Ae.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:pe,className:"text-xs h-8",disabled:ge.length===0,children:[e.jsx(ka,{className:"h-3.5 w-3.5 mr-1.5"}),_.length===ge.length&&ge.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[_.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground px-1 flex-shrink-0",children:"Selecting a brokerage will send to all agents in that brokerage."}),e.jsx(Gi,{className:"h-[250px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[180px]",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):ge.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[180px] text-muted-foreground",children:[e.jsx(ka,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No brokerages found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:ge.map(Ae=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${_.includes(Ae.id)?"bg-accent":""}`,onClick:()=>Me(Ae.id),children:[e.jsx(Oo,{checked:_.includes(Ae.id),onCheckedChange:()=>Me(Ae.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(ka,{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:Ae.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Ae.agent_count," agent",Ae.agent_count!==1?"s":""]})]})]},Ae.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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:w,onChange:Ae=>k(Ae.target.value),className:"pl-9"})]}),re&&e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:ue,className:"text-xs h-8",disabled:xe.length===0,children:[e.jsx(pr,{className:"h-3.5 w-3.5 mr-1.5"}),g.length===xe.length&&xe.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[g.length," selected"]})]}),e.jsx(Gi,{className:"h-[300px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):xe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(pr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:xe.map(Ae=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${g.includes(Ae.id)?"bg-accent":""}`,onClick:()=>be(Ae.id),children:[e.jsx(Oo,{checked:g.includes(Ae.id),onCheckedChange:()=>be(Ae.id),className:"flex-shrink-0"}),e.jsx(Nn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(kn,{className:"text-xs bg-primary/10 text-primary",children:Pe(Ae.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Ae.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ae.email})]})]},Ae.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(Er,{id:"message",placeholder:"I thought you might find this useful...",value:L,onChange:Ae=>I(Ae.target.value),rows:2,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2 flex-shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:Ne,disabled:Te===0||U,children:U?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function iE({resourceType:t,resourceId:s,resourceTitle:r,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=N.useState(!1),{user:c}=Ds();return c?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:n,size:a,onClick:()=>i(!0),className:o,children:[e.jsx(_d,{className:"h-4 w-4 mr-2"}),"Share"]}),e.jsx(s$t,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function r$t(){const{eventId:t}=yo(),s=fr(),{user:r}=Ds(),[n,a]=N.useState(null),[o,l]=N.useState(null),[i,c]=N.useState(0),[u,p]=N.useState(!0),[f,g]=N.useState(!1);N.useEffect(()=>{t&&b()},[t,r]);const b=async()=>{try{const{data:M,error:L}=await H.from("events").select("*").eq("id",t).single();if(L)throw L;a(M);const{count:I}=await H.from("event_registrations").select("*",{count:"exact",head:!0}).eq("event_id",t);if(c(I||0),r){const{data:O}=await H.from("event_registrations").select("id, zoom_join_url").eq("event_id",t).eq("user_id",r.id).maybeSingle();l(O)}}catch(M){console.error("Error loading event:",M),me.error("Failed to load event"),s("/events")}finally{p(!1)}},_=async()=>{if(!(!r||!n)){g(!0);try{const{error:M}=await H.auth.refreshSession();if(M){console.error("Session refresh failed:",M),me.error("Your session has expired. Please log in again.");return}if(o){const{error:L}=await H.functions.invoke("zoom-unregister",{body:{event_id:n.id}});if(L)throw L;me.success("Successfully cancelled registration"),l(null),c(I=>I-1)}else{const{data:L,error:I}=await H.functions.invoke("zoom-register",{body:{event_id:n.id}});if(I)throw I;me.success("Successfully registered for event!"),l({id:L.registration_id,zoom_join_url:L.zoom_join_url}),c(O=>O+1)}}catch(M){console.error("Registration error:",M),me.error(o?"Failed to cancel registration":"Failed to register for event")}finally{g(!1)}}},j=M=>{var L,I,O;if(M.includes("iframe.mediadelivery.net")||M.includes("video.bunnycdn.com")){const q=M.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(q)return`https://iframe.mediadelivery.net/embed/${q[1]}/${q[2]}?autoplay=false&preload=true`}if(M.includes("youtube.com")||M.includes("youtu.be")){const q=M.includes("youtu.be")?(L=M.split("youtu.be/")[1])==null?void 0:L.split("?")[0]:(I=M.split("v=")[1])==null?void 0:I.split("&")[0];if(q)return`https://www.youtube.com/embed/${q}`}if(M.includes("vimeo.com")){const q=(O=M.split("vimeo.com/")[1])==null?void 0:O.split("?")[0];if(q)return`https://player.vimeo.com/video/${q}`}return M};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=b0(new Date(n.event_date)),k=n.capacity&&i>=n.capacity,S=(o==null?void 0:o.zoom_join_url)||n.zoom_link;return e.jsx(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(Ja,{className:"h-4 w-4"}),"Back to Events"]}),n.image_url&&e.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden mb-6",children:[e.jsx("img",{src:n.image_url,alt:n.title,className:"w-full h-full object-cover"}),w&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(tt,{variant:"secondary",className:"text-lg px-4 py-2",children:"Event Ended"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground",children:n.title}),e.jsx(iE,{resourceType:"event",resourceId:n.id,resourceTitle:n.title})]}),n.description&&e.jsx("div",{className:"prose prose-sm max-w-none text-muted-foreground dark:prose-invert",dangerouslySetInnerHTML:{__html:n.description}})]}),n.video_url&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(pp,{className:"h-5 w-5"}),"Event Preview"]}),e.jsx("div",{className:"relative w-full aspect-video rounded-xl overflow-hidden border bg-muted",children:e.jsx("iframe",{src: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(De,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(hn,{className:"h-5 w-5 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(n.event_date))}),e.jsx("p",{className:"text-sm text-muted-foreground",children:nD(new Date(n.event_date))})]})]}),n.capacity&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(pr,{className:"h-5 w-5 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[i," / ",n.capacity]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Registered"})]})]}),o&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-500/10 rounded-lg",children:[e.jsx(xi,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:"You're registered!"})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[!w&&e.jsx(e.Fragment,{children:o?e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"w-full gap-2",onClick:()=>window.open(S,"_blank"),children:[e.jsx(tn,{className:"h-4 w-4"}),"Join Event"]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:_,disabled:f,children:[f?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):e.jsx(K,{className:"w-full gap-2",onClick:_,disabled:f||(k??!1),children:f?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):k?"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(tn,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const n$t=[{id:"quickvid",name:"QuickVid",description:"Record, manage, and share personalized video messages",icon:e.jsx(An,{className:"h-6 w-6"}),path:"/mission-control/video/record",category:"Marketing",color:"bg-rose-500/15 text-rose-600"},{id:"smart-card",name:"Smart Card",description:"Your digital business card — share your info with a single link",icon:e.jsx(Cx,{className:"h-6 w-6"}),path:"/mission-control/my-card",category:"Marketing",color:"bg-sky-500/15 text-sky-600"},{id:"smart-presentations",name:"Smart Presentations",description:"Create beautiful listing and buyer presentations",icon:e.jsx(Jg,{className:"h-6 w-6"}),path:"/mission-control/presentations",category:"Marketing",color:"bg-amber-500/15 text-amber-600"},{id:"landing-pages",name:"Landing Pages",description:"Build custom landing pages to capture leads",icon:e.jsx(Sn,{className:"h-6 w-6"}),path:"/mission-control/landing-pages",category:"Marketing",color:"bg-emerald-500/15 text-emerald-600"},{id:"guest-book",name:"Guest Book",description:"Digital open house sign-in to capture visitor info",icon:e.jsx(Sh,{className:"h-6 w-6"}),path:"/mission-control/guest-book",category:"Open House",color:"bg-orange-500/15 text-orange-600"},{id:"card-studio",name:"Card Studio",description:"Send beautiful animated digital cards for birthdays, anniversaries & milestones",icon:e.jsx(pn,{className:"h-6 w-6"}),path:"/mission-control/card-studio",category:"Marketing",color:"bg-pink-500/15 text-pink-600"},{id:"direct-mail",name:"Direct Mail",description:"Send professional postcards to your contacts via direct mail",icon:e.jsx(cr,{className:"h-6 w-6"}),path:"/mission-control/direct-mail",category:"Marketing",adminOnly:!0,beta:!0,color:"bg-indigo-500/15 text-indigo-600"},{id:"reelflow",name:"ReelFlow",description:"Turn property photos into cinematic video clips and reels — powered by AI",icon:e.jsx(gu,{className:"h-6 w-6"}),path:"/admin/beta/homereel",category:"Marketing",beta:!0,isNew:!0,color:"bg-violet-500/15 text-violet-600"},{id:"mass-emails",name:"Mass Emails",description:"Create and send bulk email campaigns to your contacts",icon:e.jsx(Bn,{className:"h-6 w-6"}),path:"/admin/email-campaigns",category:"Marketing",beta:!0,color:"bg-teal-500/15 text-teal-600"}],a$t=()=>{const{user:t,isAdmin:s}=Ds(),r=fr(),[n,a]=N.useState([]),[o,l]=N.useState(!0),[i,c]=N.useState(""),[u,p]=N.useState("all"),[f,g]=N.useState(new Set),[b,_]=N.useState(new Set);N.useEffect(()=>{j()},[t]);const j=async()=>{try{const{data:B}=await H.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),V=(B==null?void 0:B.map(xe=>xe.tag))||[],{data:Z,error:X}=await H.from("app_tiles").select("*").order("name");if(X)throw X;const[{data:ee},{data:Q}]=await Promise.all([H.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),H.from("user_tool_favorites").select("tool_id").eq("user_id",t==null?void 0:t.id)]),ie=new Set((ee==null?void 0:ee.map(xe=>xe.app_id))||[]);g(ie);const re=new Set((Q||[]).map(xe=>xe.tool_id));_(re);const ce=((Z==null?void 0:Z.filter(xe=>!xe.required_tags||xe.required_tags.length===0?!0:xe.required_tags.some(ge=>V.includes(ge))))||[]).sort((xe,ge)=>xe.name==="LevelUp Members Portal"?-1:ge.name==="LevelUp Members Portal"?1:0);a(ce)}catch(B){console.error("Error loading apps:",B),me.error("Failed to load apps")}finally{l(!1)}},w=async B=>{var Z;const V=window.open("about:blank","_blank");try{const{data:X,error:ee}=await H.auth.getSession();if(ee||!X.session){V==null||V.close(),me.error("Session expired. Please refresh the page and try again.");return}const Q=X.session.access_token;await H.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:B.app_id,app_name:B.name,user_agent:navigator.userAgent});const{data:ie,error:re}=await H.functions.invoke("sso-launch",{body:{app_id:B.app_id},headers:{Authorization:`Bearer ${Q}`}});if(re)throw re;ie!=null&&ie.redirect_url?V&&!V.closed?(V.location.href=ie.redirect_url,(Z=V.focus)==null||Z.call(V)):window.location.assign(ie.redirect_url):(V==null||V.close(),me.error("Launch link unavailable"))}catch(X){V==null||V.close(),console.error("Error launching app:",X),me.error("Failed to launch app. Please try again.")}},k=async(B,V)=>{B.stopPropagation();const Z=f.has(V);try{if(Z){const{error:X}=await H.from("user_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("app_id",V);if(X)throw X;g(ee=>{const Q=new Set(ee);return Q.delete(V),Q}),me.success("Removed from favorites")}else{const{error:X}=await H.from("user_favorites").insert({user_id:t==null?void 0:t.id,app_id:V});if(X)throw X;g(ee=>new Set(ee).add(V)),me.success("Added to favorites")}}catch(X){console.error("Error toggling favorite:",X),me.error("Failed to update favorites")}},S=async(B,V)=>{B.stopPropagation();const Z=b.has(V);try{if(Z){const{error:X}=await H.from("user_tool_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("tool_id",V);if(X)throw X;_(ee=>{const Q=new Set(ee);return Q.delete(V),Q}),me.success("Removed from favorites")}else{const{error:X}=await H.from("user_tool_favorites").insert({user_id:t==null?void 0:t.id,tool_id:V});if(X)throw X;_(ee=>new Set(ee).add(V)),me.success("Added to favorites")}}catch(X){console.error("Error toggling tool favorite:",X),me.error("Failed to update favorites")}},M=n.filter(B=>{var Z;const V=B.name.toLowerCase().includes(i.toLowerCase())||((Z=B.description)==null?void 0:Z.toLowerCase().includes(i.toLowerCase()));return u==="favorites"?V&&f.has(B.id):V}),L=n$t.filter(B=>{if(B.adminOnly&&!s)return!1;const V=B.name.toLowerCase().includes(i.toLowerCase())||B.description.toLowerCase().includes(i.toLowerCase());return u==="favorites"?V&&b.has(B.id):V}),I=L.reduce((B,V)=>(B[V.category]||(B[V.category]=[]),B[V.category].push(V),B),{}),O=[{id:"all",label:"All"},{id:"tools",label:"Built-in Tools"},{id:"apps",label:"Connected Apps"},{id:"favorites",label:"Favorites"}];if(o)return e.jsx(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 q=u==="all"||u==="tools"||u==="favorites",U=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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search apps & tools...",className:"pl-10 bg-muted/50 border-0 focus-visible:ring-1",value:i,onChange:B=>c(B.target.value)})]})]}),e.jsx("div",{className:"flex gap-6 border-b border-border mb-8",children:O.map(B=>e.jsxs("button",{onClick:()=>p(B.id),className:It("pb-3 text-sm font-medium transition-colors relative",u===B.id?"text-primary":"text-muted-foreground hover:text-foreground"),children:[B.label,u===B.id&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]},B.id))}),q&&Object.keys(I).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(ey,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Built-in Tools"})]}),Object.entries(I).map(([B,V])=>e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground bg-muted px-2.5 py-1 rounded-full",children:B})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:V.map(Z=>{const X=b.has(Z.id);return e.jsxs("div",{onClick:()=>r(Z.path),className:It("group flex items-start gap-4 p-5 bg-card rounded-xl border transition-all duration-200 hover:shadow-lg cursor-pointer relative overflow-hidden",Z.isNew?"border-primary/40 ring-1 ring-primary/20 hover:border-primary/60":"border-border hover:border-primary/30"),children:[Z.isNew&&e.jsx("div",{className:"absolute top-0 right-0 bg-gradient-to-r from-violet-500 to-indigo-500 text-white text-[10px] font-bold uppercase px-3 py-0.5 rounded-bl-lg tracking-wider shadow-sm",children:"✨ New"}),e.jsx("div",{className:It("flex-shrink-0 w-14 h-14 rounded-xl flex items-center justify-center transition-transform group-hover:scale-105",Z.color||"bg-primary/10 text-primary"),children:Z.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:[Z.name,Z.beta&&e.jsx("span",{className:"text-[10px] font-semibold bg-amber-100 text-amber-700 px-1.5 py-0.5 rounded-full border border-amber-200",children:"Beta"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:Z.description})]}),e.jsx("button",{className:It("flex-shrink-0 p-1 transition-colors",X?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:ee=>S(ee,Z.id),children:e.jsx(Nx,{className:It("h-5 w-5",X&&"fill-current")})})]},Z.id)})})]},B))]}),U&&e.jsxs("div",{children:[u==="all"&&M.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(tn,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Connected Apps"})]}),M.length===0&&u!=="all"&&!(u==="favorites"&&L.length>0)?e.jsx("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:u==="favorites"?e.jsxs(e.Fragment,{children:[e.jsx(Nx,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No favorites yet"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:"Click the bookmark icon on any app or tool to add it to your favorites"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Th,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No apps available"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:s?"Get started by adding apps in the admin panel":"Contact your administrator to get access to apps"}),s&&e.jsx(K,{className:"mt-4",onClick:()=>r("/admin/apps"),children:"Add Apps"})]})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:M.map(B=>{const V=f.has(B.id),Z=B.name.toLowerCase().includes("agent review")||B.app_id==="agent_review";return e.jsxs("div",{className:"group flex flex-col p-5 bg-card rounded-xl border border-border transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"flex items-start gap-4 cursor-pointer",onClick:()=>w(B),children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center text-3xl",children:B.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate",children:B.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:B.description})]}),e.jsx("button",{className:It("flex-shrink-0 p-1 transition-colors",V?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:X=>k(X,B.id),children:e.jsx(Nx,{className:It("h-5 w-5",V&&"fill-current")})})]}),Z&&e.jsx("a",{href:"https://forms.gle/vXnrzgSnPbw7CKPV6",target:"_blank",rel:"noopener noreferrer",onClick:X=>X.stopPropagation(),className:"mt-3 text-sm text-primary hover:underline flex items-center gap-1",children:"Create your account with this link →"})]},B.id)})})]}),q&&U&&M.length===0&&L.length===0&&i&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:[e.jsx(cn,{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"})]})]})},i$t=()=>{const t=fr(),[s,r]=N.useState(""),[n,a]=N.useState("all"),[o,l]=N.useState("all"),[i,c]=N.useState("grid"),{data:u=[]}=mt({queryKey:["template-categories"],queryFn:async()=>{const{data:k,error:S}=await H.from("template_categories").select("*").order("name");if(S)throw S;return k}}),{data:p=[]}=mt({queryKey:["template-types"],queryFn:async()=>{const{data:k,error:S}=await H.from("template_types").select("*").order("name");if(S)throw S;return k}}),{data:f=[],isLoading:g}=mt({queryKey:["canva-templates"],queryFn:async()=>{const{data:k,error:S}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(S)throw S;const{data:M,error:L}=await H.from("template_links").select("*").order("sort_order");if(L)throw L;const{data:I}=await H.from("template_likes").select("template_id"),{data:O}=await H.from("template_comments").select("template_id"),q=new Map;I==null||I.forEach(V=>{q.set(V.template_id,(q.get(V.template_id)||0)+1)});const U=new Map;return O==null||O.forEach(V=>{U.set(V.template_id,(U.get(V.template_id)||0)+1)}),(k||[]).map(V=>({...V,links:(M||[]).filter(Z=>Z.template_id===V.id)||[],likesCount:q.get(V.id)||0,commentsCount:U.get(V.id)||0}))}}),b=f.filter(k=>{var I;const S=k.name.toLowerCase().includes(s.toLowerCase())||((I=k.description)==null?void 0:I.toLowerCase().includes(s.toLowerCase())),M=n==="all"||k.category_id===n,L=o==="all"||k.type_id===o;return S&&M&&L}),_=()=>{r(""),a("all"),l("all")},j=s||n!=="all"||o!=="all",w=k=>{t(`/templates/${k}`)};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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search templates...",value:s,onChange:k=>r(k.target.value),className:"pl-9"})]}),e.jsxs(Zs,{value:n,onValueChange:a,children:[e.jsx(Ws,{className:"w-full sm:w-48",children:e.jsx(Xs,{placeholder:"All Categories"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Categories"}),u.map(k=>e.jsx(Mt,{value:k.id,children:k.name},k.id))]})]}),e.jsxs(Zs,{value:o,onValueChange:l,children:[e.jsx(Ws,{className:"w-full sm:w-48",children:e.jsx(Xs,{placeholder:"All Types"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),p.map(k=>e.jsx(Mt,{value:k.id,children:k.name},k.id))]})]}),e.jsxs("div",{className:"flex gap-2",children:[j&&e.jsx(K,{variant:"outline",size:"sm",onClick:_,children:"Clear Filters"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:i==="grid"?"secondary":"outline",size:"icon",onClick:()=>c("grid"),className:"rounded-full",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:i==="list"?"secondary":"outline",size:"icon",onClick:()=>c("list"),className:"rounded-full",children:e.jsx(Mh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[b.length," template",b.length!==1?"s":""," found"]}),g&&e.jsx("div",{className:i==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(8)].map((k,S)=>e.jsx(Ee,{children:e.jsxs(De,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ys,{className:"h-5 w-16"}),e.jsx(ys,{className:"h-5 w-20"})]})]})},S))}),!g&&b.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:j?"No templates match your filters":"No templates available yet"}),j&&e.jsx(K,{variant:"outline",onClick:_,children:"Clear Filters"})]}),!g&&b.length>0&&e.jsx("div",{className:i==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:b.map(k=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>w(k.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${i==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[k.preview_image_url?e.jsx("img",{src:k.preview_image_url,alt:k.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),k.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(tt,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[e.jsx(Bo,{className:"h-3 w-3"}),k.links.length]})})]}),e.jsxs(De,{className:`p-4 flex flex-col ${i==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:k.name}),k.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:wde(k.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[k.category&&e.jsx(tt,{variant:"secondary",className:"text-xs",children:k.category.name}),k.type&&e.jsx(tt,{variant:"outline",className:"text-xs",children:k.type.name})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:"h-3.5 w-3.5"}),k.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($c,{className:"h-3.5 w-3.5"}),k.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:S=>{S.stopPropagation(),w(k.id)},children:[e.jsx(tn,{className:"h-4 w-4"}),"View Template"]})]})]},k.id))})]})})};var o$t="Separator",i8e="horizontal",l$t=["horizontal","vertical"],_et=N.forwardRef((t,s)=>{const{decorative:r,orientation:n=i8e,...a}=t,o=c$t(n)?n:i8e,i=r?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return e.jsx(nn.div,{"data-orientation":o,...i,...a,ref:s})});_et.displayName=o$t;function c$t(t){return l$t.includes(t)}var wet=_et;const rl=N.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(wet,{ref:a,decorative:r,orientation:s,className:It("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));rl.displayName=wet.displayName;const HO=()=>({trackEngagement:N.useCallback(async(s,r,n,a="view")=>{try{const{data:{user:o}}=await H.auth.getUser();if(!o)return;await H.from("content_engagement_logs").insert({user_id:o.id,resource_type:s,resource_id:r,resource_title:n,action_type:a})}catch(o){console.error("Error tracking engagement:",o)}},[])}),d$t=()=>{const{templateId:t}=yo(),s=fr(),{user:r,isAdmin:n}=Ds(),{toast:a}=Ua(),o=Qt(),{trackEngagement:l}=HO(),[i,c]=N.useState(""),{data:u,isLoading:p}=mt({queryKey:["template-detail",t],queryFn:async()=>{const{data:L,error:I}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("id",t).single();if(I)throw I;const{data:O}=await H.from("template_links").select("*").eq("template_id",t).order("sort_order"),{data:q}=await H.from("template_guides").select("*").eq("template_id",t).order("sort_order");return{...L,links:O||[],guides:q||[]}},enabled:!!t}),{data:f=[]}=mt({queryKey:["template-linked-toolkits",t],queryFn:async()=>{const{data:L,error:I}=await H.from("resource_kit_templates").select("kit_id, resource_kits:kit_id(id, name, featured_image_url)").eq("template_id",t);if(I)throw I;return(L||[]).map(O=>O.resource_kits).filter(Boolean)},enabled:!!t});N.useEffect(()=>{u&&l("template",u.id,u.name,"view")},[u==null?void 0:u.id]);const{data:g=[]}=mt({queryKey:["template-likes",t],queryFn:async()=>{const{data:L,error:I}=await H.from("template_likes").select("*").eq("template_id",t);if(I)throw I;return L},enabled:!!t}),{data:b=[]}=mt({queryKey:["template-comments",t],queryFn:async()=>{const{data:L,error:I}=await H.from("template_comments").select("*").eq("template_id",t).order("created_at",{ascending:!1});if(I)throw I;const O=[...new Set(L.map(B=>B.user_id))],{data:q}=await H.from("profiles").select("id, name").in("id",O),U=new Map((q==null?void 0:q.map(B=>[B.id,B.name]))||[]);return L.map(B=>({...B,user_name:U.get(B.user_id)||"Unknown User"}))},enabled:!!t}),_=Dt({mutationFn:async L=>{const{error:I}=await H.from("template_comments").insert({template_id:t,user_id:r.id,content:L});if(I)throw I},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),c(""),a({title:"Comment added!"})},onError:L=>{a({title:"Error adding comment",description:L.message,variant:"destructive"})}}),j=Dt({mutationFn:async L=>{const{error:I}=await H.from("template_comments").delete().eq("id",L);if(I)throw I},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),a({title:"Comment deleted"})}}),w=Dt({mutationFn:async()=>{const L=g.find(I=>I.user_id===(r==null?void 0:r.id));if(L){const{error:I}=await H.from("template_likes").delete().eq("id",L.id);if(I)throw I}else{const{error:I}=await H.from("template_likes").insert({template_id:t,user_id:r.id});if(I)throw I}},onSuccess:()=>{o.invalidateQueries({queryKey:["template-likes",t]})}}),k=g.some(L=>L.user_id===(r==null?void 0:r.id)),S=L=>L.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),M=L=>{L.preventDefault(),!(!i.trim()||!r)&&_.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(Pi,{to:"/templates",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Templates"]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:u.name}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.category&&e.jsx(tt,{variant:"secondary",children:u.category.name}),u.type&&e.jsx(tt,{variant:"outline",children:u.type.name})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(Pi,{to:`/admin/templates?edit=${u.id}`,children:[e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(iE,{resourceType:"template",resourceId:u.id,resourceTitle:u.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:k?"default":"outline",className:"gap-2 rounded-full",onClick:()=>w.mutate(),disabled:!r||w.isPending,children:[e.jsx(sh,{className:`h-4 w-4 ${k?"fill-current":""}`}),g.length," ",g.length===1?"Like":"Likes"]})]})]}),u.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert [&>p]:mb-4 [&>p:last-child]:mb-0 whitespace-pre-line",dangerouslySetInnerHTML:{__html:u.description}})]}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Bo,{className:"h-4 w-4"}),u.links.length===1?"Template Link":"Template Links"]}),e.jsx("div",{className:"grid gap-2",children:u.links.map(L=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_canva"),window.open(L.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:L.title}),e.jsx(tn,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]})}),u.video_url&&e.jsx(Ee,{children:e.jsx(De,{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(De,{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"}),"Guide Files"]}),e.jsx("div",{className:"grid gap-2",children:u.guides.map(L=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_pdf"),window.open(L.file_url,"_blank")},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:L.name}),L.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(L.file_size/1024).toFixed(0)," KB)"]})]}),e.jsx(yi,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]})}),f.length>0&&e.jsx(Ee,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Ml,{className:"h-4 w-4"}),"Related Toolkits"]}),e.jsx("div",{className:"grid gap-2",children:f.map(L=>e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-3 h-auto py-3",onClick:()=>s(`/toolbox/${L.id}`),children:[L.featured_image_url?e.jsx("img",{src:L.featured_image_url,alt:"",className:"w-10 h-10 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(Ml,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"font-medium",children:L.name})]},L.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($c,{className:"h-5 w-5"}),"Comments (",b.length,")"]}),r?e.jsxs("form",{onSubmit:M,className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Add a comment...",value:i,onChange:L=>c(L.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!i.trim()||_.isPending,children:e.jsx(Bn,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:b.length===0?e.jsx(Ee,{children:e.jsx(De,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):b.map(L=>e.jsx(Ee,{children:e.jsx(De,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(kn,{className:"text-sm",children:S(L.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:L.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Uc(new Date(L.created_at),{addSuffix:!0})}),L.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>j.mutate(L.id),children:e.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:L.content})]})]})})},L.id))})]})]})}):e.jsx(Ms,{title:"Templates",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Bo,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Template not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This template may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(Pi,{to:"/templates",children:"Back to Templates"})})]})})},u$t=()=>{const{user:t}=Ds(),[s,r]=N.useState(""),[n,a]=N.useState("all"),{data:o=[]}=mt({queryKey:["academy-categories"],queryFn:async()=>{const{data:g,error:b}=await H.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(b)throw b;return g}}),{data:l=[],isLoading:i}=mt({queryKey:["academy-videos"],queryFn:async()=>{const{data:g,error:b}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("is_published",!0).order("publish_date",{ascending:!1});if(b)throw b;const{data:_,error:j}=await H.from("academy_resources").select("*").order("sort_order");if(j)throw j;return g.map(k=>({...k,resources:(_==null?void 0:_.filter(S=>S.video_id===k.id))||[]}))}}),{data:c=[]}=mt({queryKey:["academy-video-likes"],queryFn:async()=>{const{data:g,error:b}=await H.from("academy_video_likes").select("video_id, user_id");if(b)throw b;return g}}),u=l.filter(g=>{var j;const b=s===""||g.title.toLowerCase().includes(s.toLowerCase())||((j=g.description)==null?void 0:j.toLowerCase().includes(s.toLowerCase())),_=n==="all"||g.category_id===n;return b&&_}),p=g=>c.filter(b=>b.video_id===g).length,f=g=>c.some(b=>b.video_id===g&&b.user_id===(t==null?void 0:t.id));return e.jsx(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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search videos...",value:s,onChange:g=>r(g.target.value),className:"pl-10"})]})}),e.jsx(ba,{value:n,onValueChange:a,children:e.jsxs(pa,{className:"w-full justify-start flex-wrap h-auto gap-2 bg-transparent p-0",children:[e.jsx(ns,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(g=>e.jsx(ns,{value:g.id,className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:g.name},g.id))]})}),i?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):u.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(An,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No videos found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:s?"Try adjusting your search terms":"Check back soon for new content"})]})}):e.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-3",children:u.map(g=>e.jsx(Pi,{to:`/academy/${g.id}`,children:e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow group h-full",children:[e.jsxs("div",{className:"relative aspect-video bg-muted",children:[g.thumbnail_url?e.jsx("img",{src:g.thumbnail_url,alt:g.title,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(An,{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(nl,{className:"h-8 w-8 text-primary-foreground ml-1"})})}),g.duration&&e.jsxs("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-2 py-1 rounded flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),g.duration]})]}),e.jsxs(Pt,{className:"pb-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsx(Rt,{className:"text-lg line-clamp-2",children:g.title})}),g.category&&e.jsx(tt,{variant:"secondary",className:"w-fit",children:g.category.name})]}),e.jsxs(De,{className:"pt-0",children:[g.description&&e.jsx(gr,{className:"line-clamp-2",children:g.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 mt-3 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:`h-4 w-4 ${f(g.id)?"fill-primary text-primary":""}`}),p(g.id)]}),g.resources&&g.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-4 w-4"}),g.resources.length]})]})]})]})},g.id))})]})})};function jet({resourceType:t,resourceId:s}){const{data:r=[]}=mt({queryKey:["linked-templates",t,s],queryFn:async()=>{if(t==="academy_video"){const{data:n,error:a}=await H.from("academy_video_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("video_id",s);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}else{const{data:n,error:a}=await H.from("resource_kit_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("kit_id",s);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}},enabled:!!s});return r.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-sm",children:[e.jsx(ac,{className:"h-4 w-4"}),"Related Templates"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(n=>e.jsx(Pi,{to:`/templates/${n.id}`,children:e.jsxs(tt,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 transition-colors gap-1.5 px-3 py-1.5 text-xs font-medium rounded-full",children:[e.jsx(ac,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const h$t=(t,s)=>{if(s==="bunny_stream"){let r=t.replace("iframe.mediadelivery.net","player.mediadelivery.net");return r.includes("?")||(r+="?autoplay=false&loop=false&muted=false&preload=true&responsive=true"),r}if(s==="youtube"){const r=/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,n=t.match(r);if(n)return`https://www.youtube.com/embed/${n[1]}`}if(s==="vimeo"){const r=/vimeo\.com\/(?:video\/)?(\d+)/,n=t.match(r);if(n)return`https://player.vimeo.com/video/${n[1]}`}if(s==="loom"){const r=/loom\.com\/share\/([a-zA-Z0-9]+)/,n=t.match(r);if(n)return`https://www.loom.com/embed/${n[1]}`}return t},m$t=()=>{const{videoId:t}=yo();fr();const{user:s,isAdmin:r}=Ds(),{toast:n}=Ua(),a=Qt(),{trackEngagement:o}=HO(),[l,i]=N.useState(""),{data:c,isLoading:u}=mt({queryKey:["academy-video",t],queryFn:async()=>{const{data:M,error:L}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("id",t).eq("is_published",!0).single();if(L)throw L;const{data:I}=await H.from("academy_resources").select("*").eq("video_id",t).order("sort_order");return{...M,resources:I||[]}},enabled:!!t});N.useEffect(()=>{c&&o("academy_video",c.id,c.title,"view")},[c==null?void 0:c.id]);const{data:p=[]}=mt({queryKey:["academy-video-likes",t],queryFn:async()=>{const{data:M,error:L}=await H.from("academy_video_likes").select("*").eq("video_id",t);if(L)throw L;return M},enabled:!!t}),{data:f=[]}=mt({queryKey:["academy-video-comments",t],queryFn:async()=>{const{data:M,error:L}=await H.from("academy_video_comments").select("*").eq("video_id",t).order("created_at",{ascending:!1});if(L)throw L;const I=[...new Set(M.map(U=>U.user_id))],{data:O}=await H.from("profiles").select("id, name").in("id",I),q=new Map((O==null?void 0:O.map(U=>[U.id,U.name]))||[]);return M.map(U=>({...U,user_name:q.get(U.user_id)||"Unknown User"}))},enabled:!!t}),g=Dt({mutationFn:async M=>{const{error:L}=await H.from("academy_video_comments").insert({video_id:t,user_id:s.id,content:M});if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),i(""),n({title:"Comment added!"})},onError:M=>{n({title:"Error adding comment",description:M.message,variant:"destructive"})}}),b=Dt({mutationFn:async M=>{const{error:L}=await H.from("academy_video_comments").delete().eq("id",M);if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),n({title:"Comment deleted"})}}),_=Dt({mutationFn:async()=>{const M=p.find(L=>L.user_id===(s==null?void 0:s.id));if(M){const{error:L}=await H.from("academy_video_likes").delete().eq("id",M.id);if(L)throw L}else{const{error:L}=await H.from("academy_video_likes").insert({video_id:t,user_id:s.id});if(L)throw L}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-likes",t]})}}),j=p.some(M=>M.user_id===(s==null?void 0:s.id)),w=M=>{switch(M==null?void 0:M.toLowerCase()){case"pdf":return"📄";case"pptx":case"ppt":return"📊";case"xlsx":case"xls":return"📈";case"docx":case"doc":return"📝";case"zip":return"📦";default:return"📁"}},k=M=>M.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),S=M=>{M.preventDefault(),!(!l.trim()||!s)&&g.mutate(l.trim())};return u?e.jsx(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"})})}):c?e.jsx(Ms,{title:c.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Pi,{to:"/academy",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Academy"]})}),e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-black",style:{paddingTop:"56.25%"},children:["youtube","vimeo","loom","bunny_stream"].includes(c.video_type)?e.jsx("iframe",{src:h$t(c.video_url,c.video_type),loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,height:"100%",width:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-white gap-4",children:[e.jsx(An,{className:"h-16 w-16 opacity-50"}),e.jsx(K,{variant:"secondary",asChild:!0,children:e.jsxs("a",{href:c.video_url,target:"_blank",rel:"noopener noreferrer",className:"gap-2",children:[e.jsx(tn,{className:"h-4 w-4"}),"Open Video"]})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:c.title}),c.category&&e.jsx(tt,{variant:"secondary",children:c.category.name})]}),e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(Pi,{to:`/admin/academy?edit=${c.id}`,children:[e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(iE,{resourceType:"academy_video",resourceId:c.id,resourceTitle:c.title}),e.jsxs(K,{variant:j?"default":"outline",className:"gap-2 w-fit",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(sh,{className:`h-4 w-4 ${j?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),c.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:c.description}})]}),c.resources&&c.resources.length>0&&e.jsx(Ee,{children:e.jsxs(De,{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"}),"Resources"]}),e.jsx("div",{className:"grid gap-2",children:c.resources.map(M=>e.jsxs("a",{href:M.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-3 rounded-lg border hover:bg-muted transition-colors",children:[e.jsx("span",{className:"text-2xl",children:w(M.file_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:M.title}),e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:M.file_type})]}),e.jsx(yi,{className:"h-4 w-4 text-muted-foreground"})]},M.id))})]})}),e.jsx(jet,{resourceType:"academy_video",resourceId:c.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($c,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Add a comment...",value:l,onChange:M=>i(M.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||g.isPending,children:e.jsx(Bn,{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(De,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(M=>e.jsx(Ee,{children:e.jsx(De,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(kn,{className:"text-sm",children:k(M.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:M.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Uc(new Date(M.created_at),{addSuffix:!0})}),M.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>b.mutate(M.id),children:e.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:M.content})]})]})})},M.id))})]})]})}):e.jsx(Ms,{title:"Academy",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(An,{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(Pi,{to:"/academy",children:"Back to Academy"})})]})})};function p$t(){const t=fr(),[s,r]=N.useState(""),{data:n,isLoading:a}=mt({queryKey:["resource-kits-published"],queryFn:async()=>{const{data:b,error:_}=await H.from("resource_kits").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(_)throw _;return b}}),{data:o}=mt({queryKey:["resource-kit-files-all"],queryFn:async()=>{const{data:b,error:_}=await H.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(_)throw _;return b}}),{data:l}=mt({queryKey:["resource-kit-likes-all"],queryFn:async()=>{const{data:b,error:_}=await H.from("resource_kit_likes").select("kit_id");if(_)throw _;return b}}),{data:i}=mt({queryKey:["resource-kit-comments-all"],queryFn:async()=>{const{data:b,error:_}=await H.from("resource_kit_comments").select("kit_id");if(_)throw _;return b}}),c=n==null?void 0:n.filter(b=>{var _;return b.name.toLowerCase().includes(s.toLowerCase())||((_=b.description)==null?void 0:_.toLowerCase().includes(s.toLowerCase()))}),u=b=>(o==null?void 0:o.filter(_=>_.kit_id===b))||[],p=b=>(l==null?void 0:l.filter(_=>_.kit_id===b).length)||0,f=b=>(i==null?void 0:i.filter(_=>_.kit_id===b).length)||0,g=b=>{t(`/toolbox/${b}`)};return e.jsx(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(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search resource kits...",value:s,onChange:b=>r(b.target.value),className:"pl-10"})]}),!a&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(c==null?void 0:c.length)||0," resource kit",(c==null?void 0:c.length)!==1?"s":""," available"]}),a?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(8)].map((b,_)=>e.jsx(Ee,{children:e.jsxs(De,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"}),e.jsx(ys,{className:"h-4 w-2/3"})]})},_))}):(c==null?void 0:c.length)===0?e.jsxs(Ee,{className:"p-12 text-center",children:[e.jsx(Ml,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No resource kits found"}),e.jsx("p",{className:"text-muted-foreground",children:s?"Try adjusting your search terms":"Check back later for new resources"})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:c==null?void 0:c.map(b=>{const _=u(b.id).length,j=p(b.id),w=f(b.id);return e.jsxs(Ee,{className:"group overflow-hidden cursor-pointer hover:shadow-lg transition-all duration-200",onClick:()=>g(b.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:b.featured_image_url?e.jsx("img",{src:b.featured_image_url,alt:b.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Ml,{className:"h-16 w-16 text-muted-foreground"})})}),e.jsxs(De,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:b.name}),b.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:wde(b.description)}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-4 w-4"}),_," file",_!==1?"s":""]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:"h-3.5 w-3.5"}),j]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($c,{className:"h-3.5 w-3.5"}),w]})]})]})]})]},b.id)})})]})})}const f$t=()=>{const{kitId:t}=yo(),{user:s,isAdmin:r}=Ds(),{toast:n}=Ua(),a=Qt(),{trackEngagement:o}=HO(),[l,i]=N.useState(""),{data:c,isLoading:u}=mt({queryKey:["resource-kit-detail",t],queryFn:async()=>{const{data:M,error:L}=await H.from("resource_kits").select("*").eq("id",t).eq("is_published",!0).single();if(L)throw L;const{data:I}=await H.from("resource_kit_files").select("*").eq("kit_id",t).order("sort_order"),{data:O}=await H.from("resource_kit_links").select("*").eq("kit_id",t).order("sort_order");return{...M,files:I||[],links:O||[]}},enabled:!!t});N.useEffect(()=>{c&&o("toolbox",c.id,c.name,"view")},[c==null?void 0:c.id]);const{data:p=[]}=mt({queryKey:["resource-kit-likes",t],queryFn:async()=>{const{data:M,error:L}=await H.from("resource_kit_likes").select("*").eq("kit_id",t);if(L)throw L;return M},enabled:!!t}),{data:f=[]}=mt({queryKey:["resource-kit-comments",t],queryFn:async()=>{const{data:M,error:L}=await H.from("resource_kit_comments").select("*").eq("kit_id",t).order("created_at",{ascending:!1});if(L)throw L;const I=[...new Set(M.map(U=>U.user_id))],{data:O}=await H.from("profiles").select("id, name").in("id",I),q=new Map((O==null?void 0:O.map(U=>[U.id,U.name]))||[]);return M.map(U=>({...U,user_name:q.get(U.user_id)||"Unknown User"}))},enabled:!!t}),g=Dt({mutationFn:async M=>{const{error:L}=await H.from("resource_kit_comments").insert({kit_id:t,user_id:s.id,content:M});if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),i(""),n({title:"Comment added!"})},onError:M=>{n({title:"Error adding comment",description:M.message,variant:"destructive"})}}),b=Dt({mutationFn:async M=>{const{error:L}=await H.from("resource_kit_comments").delete().eq("id",M);if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),n({title:"Comment deleted"})}}),_=Dt({mutationFn:async()=>{const M=p.find(L=>L.user_id===(s==null?void 0:s.id));if(M){const{error:L}=await H.from("resource_kit_likes").delete().eq("id",M.id);if(L)throw L}else{const{error:L}=await H.from("resource_kit_likes").insert({kit_id:t,user_id:s.id});if(L)throw L}},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-likes",t]})}}),j=p.some(M=>M.user_id===(s==null?void 0:s.id)),w=M=>M.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),k=M=>M?M<1024?M+" B":M<1024*1024?(M/1024).toFixed(1)+" KB":(M/(1024*1024)).toFixed(1)+" MB":"",S=M=>{M.preventDefault(),!(!l.trim()||!s)&&g.mutate(l.trim())};return u?e.jsx(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"})})}):c?e.jsx(Ms,{title:c.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Pi,{to:"/toolbox",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Toolbox"]})}),c.featured_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:c.featured_image_url,alt:c.name,className:"w-full max-h-[400px] object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:c.name})}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(Pi,{to:`/admin/toolbox?edit=${c.id}`,children:[e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(iE,{resourceType:"resource_kit",resourceId:c.id,resourceTitle:c.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:j?"default":"outline",className:"gap-2 rounded-full",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(sh,{className:`h-4 w-4 ${j?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),c.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:c.description}})]}),c.files&&c.files.length>0&&e.jsx(Ee,{children:e.jsxs(De,{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"}),"Included Resources (",c.files.length,")"]}),e.jsx("div",{className:"grid gap-2",children:c.files.map(M=>e.jsxs("a",{href:M.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("toolbox",c.id,c.name,"click_pdf"),className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(Sn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:M.name}),M.file_size&&e.jsx("div",{className:"text-xs text-muted-foreground",children:k(M.file_size)})]})]}),e.jsx(yi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},M.id))})]})}),c.links&&c.links.length>0&&e.jsx(Ee,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(tn,{className:"h-4 w-4"}),"Canva Templates (",c.links.length,")"]}),e.jsx("div",{className:"grid gap-2",children:c.links.map(M=>e.jsxs("a",{href:M.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("toolbox",c.id,c.name,"click_canva"),className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-purple-500/10",children:e.jsx(tn,{className:"h-4 w-4 text-purple-600"})}),e.jsx("div",{className:"font-medium text-sm",children:M.title})]}),e.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-primary transition-colors",children:"Open in Canva"})]},M.id))})]})}),e.jsx(jet,{resourceType:"resource_kit",resourceId:c.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($c,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Add a comment...",value:l,onChange:M=>i(M.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||g.isPending,children:e.jsx(Bn,{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(De,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(M=>e.jsx(Ee,{children:e.jsx(De,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(kn,{className:"text-sm",children:w(M.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:M.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Uc(new Date(M.created_at),{addSuffix:!0})}),M.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>b.mutate(M.id),children:e.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:M.content})]})]})})},M.id))})]})]})}):e.jsx(Ms,{title:"Toolbox",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ml,{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(Pi,{to:"/toolbox",children:"Back to Toolbox"})})]})})},x$t=()=>{const t=fr(),[s,r]=N.useState(""),[n,a]=N.useState("grid"),{data:o=[],isLoading:l}=mt({queryKey:["social-swag"],queryFn:async()=>{const{data:u,error:p}=await H.from("social_swag").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(p)throw p;const{data:f,error:g}=await H.from("social_swag_links").select("*").order("sort_order");if(g)throw g;const{data:b}=await H.from("social_swag_likes").select("swag_id"),{data:_}=await H.from("social_swag_comments").select("swag_id"),j=new Map;b==null||b.forEach(S=>{j.set(S.swag_id,(j.get(S.swag_id)||0)+1)});const w=new Map;return _==null||_.forEach(S=>{w.set(S.swag_id,(w.get(S.swag_id)||0)+1)}),(u||[]).map(S=>({...S,links:(f||[]).filter(M=>M.swag_id===S.id)||[],likesCount:j.get(S.id)||0,commentsCount:w.get(S.id)||0}))}}),i=o.filter(u=>{var f;return u.title.toLowerCase().includes(s.toLowerCase())||((f=u.description)==null?void 0:f.toLowerCase().includes(s.toLowerCase()))}),c=u=>{t(`/social-swag/${u}`)};return e.jsx(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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search social swag...",value:s,onChange:u=>r(u.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Mh,{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(De,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"})]})},p))}),!l&&i.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No items match your search":"No social swag available yet"}),s&&e.jsx(K,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&i.length>0&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:i.map(u=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${n==="list"?"flex flex-row":""}`,onClick:()=>c(u.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${n==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[u.preview_image_url?e.jsx("img",{src:u.preview_image_url,alt:u.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),u.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(tt,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[e.jsx(Bo,{className:"h-3 w-3"}),u.links.length]})})]}),e.jsxs(De,{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(sh,{className:"h-3.5 w-3.5"}),u.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($c,{className:"h-3.5 w-3.5"}),u.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:p=>{p.stopPropagation(),c(u.id)},children:[e.jsx(tn,{className:"h-4 w-4"}),"View Details"]})]})]},u.id))})]})})};var Ni=function(){return Ni=Object.assign||function(s){for(var r,n=1,a=arguments.length;n1&&(c||!u),f=s>1&&(u||!c),g=function(){n&&o(n)},b=function(){a&&o(a)};return e.jsx(Z$t,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:f,nextMonth:a,previousMonth:n,onPreviousClick:g,onNextClick:b})}function Y$t(t){var s,r=lc(),n=r.classNames,a=r.disableNavigation,o=r.styles,l=r.captionLayout,i=r.components,c=(s=i==null?void 0:i.CaptionLabel)!==null&&s!==void 0?s:Cet,u;return a?u=e.jsx(c,{id:t.id,displayMonth:t.displayMonth}):l==="dropdown"?u=e.jsx(o8e,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?u=e.jsxs(e.Fragment,{children:[e.jsx(o8e,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(l8e,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):u=e.jsxs(e.Fragment,{children:[e.jsx(c,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(l8e,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:u})}function X$t(t){var s=lc(),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 Q$t(t,s,r){for(var n=r?T1(new Date):Xh(new Date,{locale:t,weekStartsOn:s}),a=[],o=0;o<7;o++){var l=El(n,o);a.push(l)}return a}function J$t(){var t=lc(),s=t.classNames,r=t.styles,n=t.showWeekNumber,a=t.locale,o=t.weekStartsOn,l=t.ISOWeek,i=t.formatters.formatWeekdayName,c=t.labels.labelWeekday,u=Q$t(a,o,l);return e.jsxs("tr",{style:r.head_row,className:s.head_row,children:[n&&e.jsx("td",{style:r.head_cell,className:s.head_cell}),u.map(function(p,f){return e.jsx("th",{scope:"col",className:s.head_cell,style:r.head_cell,"aria-label":c(p,{locale:a}),children:i(p,{locale:a})},f)})]})}function eqt(){var t,s=lc(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:J$t;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function tqt(t){var s=lc(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var jke=N.createContext(void 0);function sqt(t){if(!WO(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(jke.Provider,{value:s,children:t.children})}return e.jsx(rqt,{initialProps:t.initialProps,children:t.children})}function rqt(t){var s=t.initialProps,r=t.children,n=s.selected,a=s.min,o=s.max,l=function(u,p,f){var g,b;(g=s.onDayClick)===null||g===void 0||g.call(s,u,p,f);var _=!!(p.selected&&a&&(n==null?void 0:n.length)===a);if(!_){var j=!!(!p.selected&&o&&(n==null?void 0:n.length)===o);if(!j){var w=n?Net([],n):[];if(p.selected){var k=w.findIndex(function(S){return Cl(u,S)});w.splice(k,1)}else w.push(u);(b=s.onSelect)===null||b===void 0||b.call(s,w,u,p,f)}}},i={disabled:[]};n&&i.disabled.push(function(u){var p=o&&n.length>o-1,f=n.some(function(g){return Cl(g,u)});return!!(p&&!f)});var c={selected:n,onDayClick:l,modifiers:i};return e.jsx(jke.Provider,{value:c,children:r})}function Nke(){var t=N.useContext(jke);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function nqt(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:qS(n,t)?{from:t,to:a}:{from:n,to:t}:a?qS(t,a)?{from:a,to:t}:{from:t,to:a}:n?US(t,n)?{from:t,to:n}:{from:n,to:t}:{from:t,to:void 0}}var kke=N.createContext(void 0);function aqt(t){if(!GO(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(kke.Provider,{value:s,children:t.children})}return e.jsx(iqt,{initialProps:t.initialProps,children:t.children})}function iqt(t){var s=t.initialProps,r=t.children,n=s.selected,a=n||{},o=a.from,l=a.to,i=s.min,c=s.max,u=function(b,_,j){var w,k;(w=s.onDayClick)===null||w===void 0||w.call(s,b,_,j);var S=nqt(b,n);(k=s.onSelect)===null||k===void 0||k.call(s,S,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:hie(o,i-1),before:El(o,i-1)}),o&&l&&p.disabled.push({after:o,before:El(o,i-1)}),!o&&l&&p.disabled.push({after:hie(l,i-1),before:El(l,i-1)})),c){if(o&&!l&&(p.disabled.push({before:El(o,-c+1)}),p.disabled.push({after:El(o,c-1)})),o&&l){var f=hf(l,o)+1,g=c-f;p.disabled.push({before:hie(o,g)}),p.disabled.push({after:El(l,g)})}!o&&l&&(p.disabled.push({before:El(l,-c+1)}),p.disabled.push({after:El(l,c-1)}))}return e.jsx(kke.Provider,{value:{selected:n,onDayClick:u,modifiers:p},children:r})}function Ske(){var t=N.useContext(kke);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function Aie(t){return Array.isArray(t)?Net([],t):t!==void 0?[t]:[]}function oqt(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=Aie(a)}),s}var cy;(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"})(cy||(cy={}));var lqt=cy.Selected,Nv=cy.Disabled,cqt=cy.Hidden,dqt=cy.Today,Sge=cy.RangeEnd,Cge=cy.RangeMiddle,Mge=cy.RangeStart,uqt=cy.Outside;function hqt(t,s,r){var n,a=(n={},n[lqt]=Aie(t.selected),n[Nv]=Aie(t.disabled),n[cqt]=Aie(t.hidden),n[dqt]=[t.today],n[Sge]=[],n[Cge]=[],n[Mge]=[],n[uqt]=[],n);return t.fromDate&&a[Nv].push({before:t.fromDate}),t.toDate&&a[Nv].push({after:t.toDate}),WO(t)?a[Nv]=a[Nv].concat(s.modifiers[Nv]):GO(t)&&(a[Nv]=a[Nv].concat(r.modifiers[Nv]),a[Mge]=r.modifiers[Mge],a[Cge]=r.modifiers[Cge],a[Sge]=r.modifiers[Sge]),a}var Aet=N.createContext(void 0);function mqt(t){var s=lc(),r=Nke(),n=Ske(),a=hqt(s,r,n),o=oqt(s.modifiers),l=Ni(Ni({},a),o);return e.jsx(Aet.Provider,{value:l,children:t.children})}function Eet(){var t=N.useContext(Aet);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function pqt(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function fqt(t){return!!(t&&typeof t=="object"&&"from"in t)}function xqt(t){return!!(t&&typeof t=="object"&&"after"in t)}function gqt(t){return!!(t&&typeof t=="object"&&"before"in t)}function yqt(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function vqt(t,s){var r,n=s.from,a=s.to;if(n&&a){var o=hf(a,n)<0;o&&(r=[a,n],n=r[0],a=r[1]);var l=hf(t,n)>=0&&hf(a,t)>=0;return l}return a?Cl(a,t):n?Cl(n,t):!1}function bqt(t){return mje(t)}function _qt(t){return Array.isArray(t)&&t.every(mje)}function wqt(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(bqt(r))return Cl(t,r);if(_qt(r))return r.includes(t);if(fqt(r))return vqt(t,r);if(yqt(r))return r.dayOfWeek.includes(t.getDay());if(pqt(r)){var n=hf(r.before,t),a=hf(r.after,t),o=n>0,l=a<0,i=qS(r.before,r.after);return i?l&&o:o||l}return xqt(r)?hf(t,r.after)>0:gqt(r)?hf(r.before,t)>0:typeof r=="function"?r(t):!1})}function Cke(t,s,r){var n=Object.keys(s).reduce(function(o,l){var i=s[l];return wqt(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!tue(t,r)&&(a.outside=!0),a}function jqt(t,s){for(var r=Fc(t[0]),n=lx(t[t.length-1]),a,o,l=r;l<=n;){var i=Cke(l,s),c=!i.disabled&&!i.hidden;if(!c){l=El(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=El(l,1)}return o||a}var Nqt=365;function Pet(t,s){var r=s.moveBy,n=s.direction,a=s.context,o=s.modifiers,l=s.retry,i=l===void 0?{count:0,lastFocused:t}:l,c=a.weekStartsOn,u=a.fromDate,p=a.toDate,f=a.locale,g={day:El,week:g4,month:Bm,year:l4t,startOfWeek:function(w){return a.ISOWeek?T1(w):Xh(w,{locale:f,weekStartsOn:c})},endOfWeek:function(w){return a.ISOWeek?wGe(w):Jde(w,{locale:f,weekStartsOn:c})}},b=g[r](t,n==="after"?1:-1);n==="before"&&u?b=c4t([u,b]):n==="after"&&p&&(b=d4t([p,b]));var _=!0;if(o){var j=Cke(b,o);_=!j.disabled&&!j.hidden}return _?b:i.count>Nqt?i.lastFocused:Pet(b,{moveBy:r,direction:n,context:a,modifiers:o,retry:Ni(Ni({},i),{count:i.count+1})})}var Iet=N.createContext(void 0);function kqt(t){var s=KO(),r=Eet(),n=N.useState(),a=n[0],o=n[1],l=N.useState(),i=l[0],c=l[1],u=jqt(s.displayMonths,r),p=a??(i&&s.isDateDisplayed(i))?i:u,f=function(){c(a),o(void 0)},g=function(w){o(w)},b=lc(),_=function(w,k){if(a){var S=Pet(a,{moveBy:w,direction:k,context:b,modifiers:r});Cl(a,S)||(s.goToDate(S,a),g(S))}},j={focusedDay:a,focusTarget:p,blur:f,focus:g,focusDayAfter:function(){return _("day","after")},focusDayBefore:function(){return _("day","before")},focusWeekAfter:function(){return _("week","after")},focusWeekBefore:function(){return _("week","before")},focusMonthBefore:function(){return _("month","before")},focusMonthAfter:function(){return _("month","after")},focusYearBefore:function(){return _("year","before")},focusYearAfter:function(){return _("year","after")},focusStartOfWeek:function(){return _("startOfWeek","before")},focusEndOfWeek:function(){return _("endOfWeek","after")}};return e.jsx(Iet.Provider,{value:j,children:t.children})}function Mke(){var t=N.useContext(Iet);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function Sqt(t,s){var r=Eet(),n=Cke(t,r,s);return n}var Tke=N.createContext(void 0);function Cqt(t){if(!que(t.initialProps)){var s={selected:void 0};return e.jsx(Tke.Provider,{value:s,children:t.children})}return e.jsx(Mqt,{initialProps:t.initialProps,children:t.children})}function Mqt(t){var s=t.initialProps,r=t.children,n=function(o,l,i){var c,u,p;if((c=s.onDayClick)===null||c===void 0||c.call(s,o,l,i),l.selected&&!s.required){(u=s.onSelect)===null||u===void 0||u.call(s,void 0,o,l,i);return}(p=s.onSelect)===null||p===void 0||p.call(s,o,o,l,i)},a={selected:s.selected,onDayClick:n};return e.jsx(Tke.Provider,{value:a,children:r})}function Let(){var t=N.useContext(Tke);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function Tqt(t,s){var r=lc(),n=Let(),a=Nke(),o=Ske(),l=Mke(),i=l.focusDayAfter,c=l.focusDayBefore,u=l.focusWeekAfter,p=l.focusWeekBefore,f=l.blur,g=l.focus,b=l.focusMonthBefore,_=l.focusMonthAfter,j=l.focusYearBefore,w=l.focusYearAfter,k=l.focusStartOfWeek,S=l.focusEndOfWeek,M=function(oe){var ce,xe,ge,ue;que(r)?(ce=n.onDayClick)===null||ce===void 0||ce.call(n,t,s,oe):WO(r)?(xe=a.onDayClick)===null||xe===void 0||xe.call(a,t,s,oe):GO(r)?(ge=o.onDayClick)===null||ge===void 0||ge.call(o,t,s,oe):(ue=r.onDayClick)===null||ue===void 0||ue.call(r,t,s,oe)},L=function(oe){var ce;g(t),(ce=r.onDayFocus)===null||ce===void 0||ce.call(r,t,s,oe)},I=function(oe){var ce;f(),(ce=r.onDayBlur)===null||ce===void 0||ce.call(r,t,s,oe)},O=function(oe){var ce;(ce=r.onDayMouseEnter)===null||ce===void 0||ce.call(r,t,s,oe)},q=function(oe){var ce;(ce=r.onDayMouseLeave)===null||ce===void 0||ce.call(r,t,s,oe)},U=function(oe){var ce;(ce=r.onDayPointerEnter)===null||ce===void 0||ce.call(r,t,s,oe)},B=function(oe){var ce;(ce=r.onDayPointerLeave)===null||ce===void 0||ce.call(r,t,s,oe)},V=function(oe){var ce;(ce=r.onDayTouchCancel)===null||ce===void 0||ce.call(r,t,s,oe)},Z=function(oe){var ce;(ce=r.onDayTouchEnd)===null||ce===void 0||ce.call(r,t,s,oe)},X=function(oe){var ce;(ce=r.onDayTouchMove)===null||ce===void 0||ce.call(r,t,s,oe)},ee=function(oe){var ce;(ce=r.onDayTouchStart)===null||ce===void 0||ce.call(r,t,s,oe)},Q=function(oe){var ce;(ce=r.onDayKeyUp)===null||ce===void 0||ce.call(r,t,s,oe)},ie=function(oe){var ce;switch(oe.key){case"ArrowLeft":oe.preventDefault(),oe.stopPropagation(),r.dir==="rtl"?i():c();break;case"ArrowRight":oe.preventDefault(),oe.stopPropagation(),r.dir==="rtl"?c():i();break;case"ArrowDown":oe.preventDefault(),oe.stopPropagation(),u();break;case"ArrowUp":oe.preventDefault(),oe.stopPropagation(),p();break;case"PageUp":oe.preventDefault(),oe.stopPropagation(),oe.shiftKey?j():b();break;case"PageDown":oe.preventDefault(),oe.stopPropagation(),oe.shiftKey?w():_();break;case"Home":oe.preventDefault(),oe.stopPropagation(),k();break;case"End":oe.preventDefault(),oe.stopPropagation(),S();break}(ce=r.onDayKeyDown)===null||ce===void 0||ce.call(r,t,s,oe)},re={onClick:M,onFocus:L,onBlur:I,onKeyDown:ie,onKeyUp:Q,onMouseEnter:O,onMouseLeave:q,onPointerEnter:U,onPointerLeave:B,onTouchCancel:V,onTouchEnd:Z,onTouchMove:X,onTouchStart:ee};return re}function Aqt(){var t=lc(),s=Let(),r=Nke(),n=Ske(),a=que(t)?s.selected:WO(t)?r.selected:GO(t)?n.selected:void 0;return a}function Eqt(t){return Object.values(cy).includes(t)}function Pqt(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(Eqt(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function Iqt(t,s){var r=Ni({},t.styles.day);return Object.keys(s).forEach(function(n){var a;r=Ni(Ni({},r),(a=t.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function Lqt(t,s,r){var n,a,o,l=lc(),i=Mke(),c=Sqt(t,s),u=Tqt(t,c),p=Aqt(),f=!!(l.onDayClick||l.mode!=="default");N.useEffect(function(){var O;c.outside||i.focusedDay&&f&&Cl(i.focusedDay,t)&&((O=r.current)===null||O===void 0||O.focus())},[i.focusedDay,t,r,f,c.outside]);var g=Pqt(l,c).join(" "),b=Iqt(l,c),_=!!(c.outside&&!l.showOutsideDays||c.hidden),j=(o=(a=l.components)===null||a===void 0?void 0:a.DayContent)!==null&&o!==void 0?o:tqt,w=e.jsx(j,{date:t,displayMonth:s,activeModifiers:c}),k={style:b,className:g,children:w,role:"gridcell"},S=i.focusTarget&&Cl(i.focusTarget,t)&&!c.outside,M=i.focusedDay&&Cl(i.focusedDay,t),L=Ni(Ni(Ni({},k),(n={disabled:c.disabled,role:"gridcell"},n["aria-selected"]=c.selected,n.tabIndex=M||S?0:-1,n)),u),I={isButton:f,isHidden:_,activeModifiers:c,selectedDays:p,buttonProps:L,divProps:k};return I}function Dqt(t){var s=N.useRef(null),r=Lqt(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(Ole,Ni({name:"day",ref:s},r.buttonProps)):e.jsx("div",Ni({},r.divProps))}function Oqt(t){var s=t.number,r=t.dates,n=lc(),a=n.onWeekNumberClick,o=n.styles,l=n.classNames,i=n.locale,c=n.labels.labelWeekNumber,u=n.formatters.formatWeekNumber,p=u(Number(s),{locale:i});if(!a)return e.jsx("span",{className:l.weeknumber,style:o.weeknumber,children:p});var f=c(Number(s),{locale:i}),g=function(b){a(s,r,b)};return e.jsx(Ole,{name:"week-number","aria-label":f,className:l.weeknumber,style:o.weeknumber,onClick:g,children:p})}function Rqt(t){var s,r,n=lc(),a=n.styles,o=n.classNames,l=n.showWeekNumber,i=n.components,c=(s=i==null?void 0:i.Day)!==null&&s!==void 0?s:Dqt,u=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:Oqt,p;return l&&(p=e.jsx("td",{className:o.cell,style:a.cell,children:e.jsx(u,{number:t.weekNumber,dates:t.dates})})),e.jsxs("tr",{className:o.row,style:a.row,children:[p,t.dates.map(function(f){return e.jsx("td",{className:o.cell,style:a.cell,role:"presentation",children:e.jsx(c,{displayMonth:t.displayMonth,date:f})},mSt(f))})]})}function c8e(t,s,r){for(var n=r!=null&&r.ISOWeek?wGe(s):Jde(s,r),a=r!=null&&r.ISOWeek?T1(t):Xh(t,r),o=hf(n,a),l=[],i=0;i<=o;i++)l.push(El(a,i));var c=l.reduce(function(u,p){var f=r!=null&&r.ISOWeek?pje(p):xje(p,r),g=u.find(function(b){return b.weekNumber===f});return g?(g.dates.push(p),u):(u.push({weekNumber:f,dates:[p]}),u)},[]);return c}function Fqt(t,s){var r=c8e(Fc(t),lx(t),s);if(s!=null&&s.useFixedWeeks){var n=fSt(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=g4(o,6-n),i=c8e(g4(o,1),l,s);r.push.apply(r,i)}}return r}function zqt(t){var s,r,n,a=lc(),o=a.locale,l=a.classNames,i=a.styles,c=a.hideHead,u=a.fixedWeeks,p=a.components,f=a.weekStartsOn,g=a.firstWeekContainsDate,b=a.ISOWeek,_=Fqt(t.displayMonth,{useFixedWeeks:!!u,ISOWeek:b,locale:o,weekStartsOn:f,firstWeekContainsDate:g}),j=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:eqt,w=(r=p==null?void 0:p.Row)!==null&&r!==void 0?r:Rqt,k=(n=p==null?void 0:p.Footer)!==null&&n!==void 0?n:X$t;return e.jsxs("table",{id:t.id,className:l.table,style:i.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!c&&e.jsx(j,{}),e.jsx("tbody",{className:l.tbody,style:i.tbody,children:_.map(function(S){return e.jsx(w,{displayMonth:t.displayMonth,dates:S.dates,weekNumber:S.weekNumber},S.weekNumber)})}),e.jsx(k,{displayMonth:t.displayMonth})]})}function Bqt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var $qt=Bqt()?N.useLayoutEffect:N.useEffect,Tge=!1,qqt=0;function d8e(){return"react-day-picker-".concat(++qqt)}function Uqt(t){var s,r=t??(Tge?d8e():null),n=N.useState(r),a=n[0],o=n[1];return $qt(function(){a===null&&o(d8e())},[]),N.useEffect(function(){Tge===!1&&(Tge=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function Vqt(t){var s,r,n=lc(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,c=KO().displayMonths,u=Uqt(n.id?"".concat(n.id,"-").concat(t.displayIndex):void 0),p=n.id?"".concat(n.id,"-grid-").concat(t.displayIndex):void 0,f=[o.month],g=l.month,b=t.displayIndex===0,_=t.displayIndex===c.length-1,j=!b&&!_;a==="rtl"&&(s=[b,_],_=s[0],b=s[1]),b&&(f.push(o.caption_start),g=Ni(Ni({},g),l.caption_start)),_&&(f.push(o.caption_end),g=Ni(Ni({},g),l.caption_end)),j&&(f.push(o.caption_between),g=Ni(Ni({},g),l.caption_between));var w=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:Y$t;return e.jsxs("div",{className:f.join(" "),style:g,children:[e.jsx(w,{id:u,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(zqt,{id:p,"aria-labelledby":u,displayMonth:t.displayMonth})]},t.displayIndex)}function Hqt(t){var s=lc(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function Wqt(t){var s,r,n=t.initialProps,a=lc(),o=Mke(),l=KO(),i=N.useState(!1),c=i[0],u=i[1];N.useEffect(function(){a.initialFocus&&o.focusTarget&&(c||(o.focus(o.focusTarget),u(!0)))},[a.initialFocus,c,o.focus,o.focusTarget,o]);var p=[a.classNames.root,a.className];a.numberOfMonths>1&&p.push(a.classNames.multiple_months),a.showWeekNumber&&p.push(a.classNames.with_weeknumber);var f=Ni(Ni({},a.styles.root),a.style),g=Object.keys(n).filter(function(_){return _.startsWith("data-")}).reduce(function(_,j){var w;return Ni(Ni({},_),(w={},w[j]=n[j],w))},{}),b=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:Hqt;return e.jsx("div",Ni({className:p.join(" "),style:f,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},g,{children:e.jsx(b,{children:l.displayMonths.map(function(_,j){return e.jsx(Vqt,{displayIndex:j,displayMonth:_},j)})})}))}function Gqt(t){var s=t.children,r=g$t(t,["children"]);return e.jsx(O$t,{initialProps:r,children:e.jsx(W$t,{children:e.jsx(Cqt,{initialProps:r,children:e.jsx(sqt,{initialProps:r,children:e.jsx(aqt,{initialProps:r,children:e.jsx(mqt,{children:e.jsx(kqt,{children:s})})})})})})})}function Kqt(t){return e.jsx(Gqt,Ni({},t,{children:e.jsx(Wqt,{initialProps:t})}))}function _f({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(Kqt,{showOutsideDays:r,className:It("p-3",t),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:It(K8({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:It(K8({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(cl,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(da,{className:"h-4 w-4"})},...n})}_f.displayName="Calendar";var Uue="Popover",[Det]=ad(Uue,[O0]),ZO=O0(),[Zqt,Rw]=Det(Uue),Oet=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=ZO(s),c=N.useRef(null),[u,p]=N.useState(!1),[f,g]=ah({prop:n,defaultProp:a??!1,onChange:o,caller:Uue});return e.jsx(vO,{...i,children:e.jsx(Zqt,{scope:s,contentId:Tu(),triggerRef:c,open:f,onOpenChange:g,onOpenToggle:N.useCallback(()=>g(b=>!b),[g]),hasCustomAnchor:u,onCustomAnchorAdd:N.useCallback(()=>p(!0),[]),onCustomAnchorRemove:N.useCallback(()=>p(!1),[]),modal:l,children:r})})};Oet.displayName=Uue;var Ret="PopoverAnchor",Yqt=N.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Rw(Ret,r),o=ZO(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return N.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx($A,{...o,...n,ref:s})});Yqt.displayName=Ret;var Fet="PopoverTrigger",zet=N.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Rw(Fet,r),o=ZO(r),l=qa(s,a.triggerRef),i=e.jsx(nn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Vet(a.open),...n,ref:l,onClick:Ir(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx($A,{asChild:!0,...o,children:i})});zet.displayName=Fet;var Ake="PopoverPortal",[Xqt,Qqt]=Det(Ake,{forceMount:void 0}),Bet=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=Rw(Ake,s);return e.jsx(Xqt,{scope:s,forceMount:r,children:e.jsx(Fd,{present:r||o.open,children:e.jsx(RA,{asChild:!0,container:a,children:n})})})};Bet.displayName=Ake;var ZT="PopoverContent",$et=N.forwardRef((t,s)=>{const r=Qqt(ZT,t.__scopePopover),{forceMount:n=r.forceMount,...a}=t,o=Rw(ZT,t.__scopePopover);return e.jsx(Fd,{present:n||o.open,children:o.modal?e.jsx(eUt,{...a,ref:s}):e.jsx(tUt,{...a,ref:s})})});$et.displayName=ZT;var Jqt=ow("PopoverContent.RemoveScroll"),eUt=N.forwardRef((t,s)=>{const r=Rw(ZT,t.__scopePopover),n=N.useRef(null),a=qa(s,n),o=N.useRef(!1);return N.useEffect(()=>{const l=n.current;if(l)return Ode(l)},[]),e.jsx(kO,{as:Jqt,allowPinchZoom:!0,children:e.jsx(qet,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ir(t.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Ir(t.onPointerDownOutside,l=>{const i=l.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0,u=i.button===2||c;o.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Ir(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),tUt=N.forwardRef((t,s)=>{const r=Rw(ZT,t.__scopePopover),n=N.useRef(!1),a=N.useRef(!1);return e.jsx(qet,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,i;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(n.current||(i=r.triggerRef.current)==null||i.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{var c,u;(c=t.onInteractOutside)==null||c.call(t,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((u=r.triggerRef.current)==null?void 0:u.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),qet=N.forwardRef((t,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:p,...f}=t,g=Rw(ZT,r),b=ZO(r);return Ide(),e.jsx(jO,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(Nw,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:p,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>g.onOpenChange(!1),children:e.jsx(bO,{"data-state":Vet(g.open),role:"dialog",id:g.contentId,...b,...f,ref:s,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Uet="PopoverClose",sUt=N.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Rw(Uet,r);return e.jsx(nn.button,{type:"button",...n,ref:s,onClick:Ir(t.onClick,()=>a.onOpenChange(!1))})});sUt.displayName=Uet;var rUt="PopoverArrow",nUt=N.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=ZO(r);return e.jsx(_O,{...a,...n,ref:s})});nUt.displayName=rUt;function Vet(t){return t?"open":"closed"}var aUt=Oet,iUt=zet,oUt=Bet,Het=$et;const $o=aUt,qo=iUt,Ro=N.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(oUt,{children:e.jsx(Het,{ref:a,align:s,sideOffset:r,className:It("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));Ro.displayName=Het.displayName;const lUt=mC("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"}}),Eke=N.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:It(lUt({variant:s}),t),...r}));Eke.displayName="Alert";const cUt=N.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:It("mb-1 font-medium leading-none tracking-tight",t),...s}));cUt.displayName="AlertTitle";const Pke=N.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("text-sm [&_p]:leading-relaxed",t),...s}));Pke.displayName="AlertDescription";function dUt({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=Qt(),[c,u]=N.useState(a),[p,f]=N.useState([]),[g,b]=N.useState(null),[_,j]=N.useState("now"),[w,k]=N.useState(i6e(h6e(new Date),1)),[S,M]=N.useState("12"),[L,I]=N.useState("00"),[O,q]=N.useState("PM");N.useEffect(()=>{if(t){u(a),j("now"),f([]);const be=i6e(h6e(new Date),1);k(be);const Me=be.getHours();M(String(Me>12?Me-12:Me===0?12:Me)),I("00"),q(Me>=12?"PM":"AM")}},[t,a]);const U=()=>{if(!w)return null;let be=parseInt(S);const Me=parseInt(L);return O==="PM"&&be!==12&&(be+=12),O==="AM"&&be===12&&(be=0),UL(qL(w,be),Me)},{data:B,isLoading:V}=mt({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:be}}=await H.auth.getUser();if(!be)return[];const{data:Me,error:Ne}=await H.from("social_accounts").select("*").eq("user_id",be.id).eq("is_active",!0).order("platform",{ascending:!0});if(Ne)throw Ne;return console.log("Fetched social accounts for posting:",Me),Me},enabled:t,staleTime:0}),Z=Dt({mutationFn:async({accountId:be,platform:Me})=>{b(be);const{data:Ne,error:Pe}=await H.functions.invoke("social-post",{body:{platform:Me,accountId:be,imageUrl:r,caption:c}});if(Pe)throw Pe;if(Ne!=null&&Ne.error)throw new Error(Ne.error);return Ne},onSuccess:be=>{const Me=be.platform==="facebook"?"Facebook":be.platform==="instagram"?"Instagram":be.platform==="linkedin"?"LinkedIn":"Google Business";me.success(`Posted to ${Me}!`)},onError:be=>{me.error(`Failed to post: ${be.message}`)},onSettled:()=>{b(null)}}),X=Dt({mutationFn:async({accountId:be,platform:Me,scheduledFor:Ne})=>{const{data:{user:Pe}}=await H.auth.getUser();if(!Pe)throw new Error("Not authenticated");const{error:Oe}=await H.from("scheduled_posts").insert({user_id:Pe.id,social_account_id:be,platform:Me,image_url:r,caption:c,swag_item_id:o||null,reel_id:l||null,scheduled_for:Ne.toISOString(),status:"scheduled"});if(Oe)throw Oe;return{platform:Me}},onSuccess:be=>{const Me=be.platform==="facebook"?"Facebook":be.platform==="instagram"?"Instagram":"LinkedIn";me.success(`Post scheduled for ${Me}!`)},onError:be=>{me.error(`Failed to schedule: ${be.message}`)}}),ee=async()=>{if(p.length===0){me.error("Please select at least one account");return}if(_==="schedule"){const be=U();if(!be||be<=new Date){me.error("Please select a future date and time");return}for(const Me of p){const Ne=B==null?void 0:B.find(Pe=>Pe.id===Me);Ne&&await X.mutateAsync({accountId:Me,platform:Ne.platform,scheduledFor:be})}i.invalidateQueries({queryKey:["scheduled-posts"]}),me.success(`${p.length} post(s) scheduled for ${ms(be,"PPp")}`)}else for(const be of p){const Me=B==null?void 0:B.find(Ne=>Ne.id===be);Me&&await Z.mutateAsync({accountId:be,platform:Me.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),u(""),f([]),s(!1)},Q=be=>{f(Me=>Me.includes(be)?Me.filter(Ne=>Ne!==be):[...Me,be])},ie=(B==null?void 0:B.filter(be=>be.platform==="facebook"))||[],re=(B==null?void 0:B.filter(be=>be.platform==="instagram"))||[],oe=(B==null?void 0:B.filter(be=>be.platform==="linkedin"))||[],ce=(B==null?void 0:B.filter(be=>be.platform==="google_business"))||[],xe=((B==null?void 0:B.length)||0)>0,ge=Z.isPending||X.isPending,ue=Array.from({length:12},(be,Me)=>String(Me+1)),pe=["00","15","30","45"];return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create Social Post"}),e.jsx(Gr,{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(Er,{id:"caption",placeholder:"Write a caption for your post...",value:c,onChange:be=>u(be.target.value),rows:3}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.length,"/2200 characters"]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(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:It("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",_==="now"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Post Now"}),e.jsx("button",{type:"button",onClick:()=>j("schedule"),className:It("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",_==="schedule"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Schedule"})]})]}),_==="schedule"&&e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(un,{className:"h-4 w-4"}),"Schedule for"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("justify-start text-left font-normal flex-1",!w&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),w?ms(w,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:w,onSelect:k,disabled:be=>bee.jsx(Mt,{value:be,children:be},be))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(Zs,{value:L,onValueChange:I,children:[e.jsx(Ws,{className:"w-[70px]",children:e.jsx(Xs,{})}),e.jsx(Gs,{children:pe.map(be=>e.jsx(Mt,{value:be,children:be},be))})]}),e.jsxs(Zs,{value:O,onValueChange:be=>q(be),children:[e.jsx(Ws,{className:"w-[70px]",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"AM",children:"AM"}),e.jsx(Mt,{value:"PM",children:"PM"})]})]})]})]}),w&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",ms(U()||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(ws,{className:"h-6 w-6 animate-spin"})}),!V&&!xe&&e.jsxs(Eke,{children:[e.jsx(kl,{className:"h-4 w-4"}),e.jsxs(Pke,{className:"flex flex-col gap-2",children:[e.jsx("span",{children:"No social accounts connected yet."}),e.jsxs(Pi,{to:"/social-connections",className:"inline-flex items-center gap-1.5 text-primary hover:underline font-medium",children:[e.jsx(Xo,{className:"h-3.5 w-3.5"}),"Connect your Facebook, Instagram & LinkedIn"]})]})]}),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(Su,{className:"h-4 w-4 text-blue-600"})," Facebook"]}),ie.map(be=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Oo,{checked:p.includes(be.id),onCheckedChange:()=>Q(be.id),disabled:g===be.id}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:be.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Su,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:be.page_name||be.platform_username}),g===be.id&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]},be.id))]}),re.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Mu,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),re.map(be=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Oo,{checked:p.includes(be.id),onCheckedChange:()=>Q(be.id),disabled:g===be.id}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:be.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Mu,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",be.platform_username]}),g===be.id&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]},be.id))]}),oe.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Mp,{className:"h-4 w-4 text-blue-700"})," LinkedIn"]}),oe.map(be=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Oo,{checked:p.includes(be.id),onCheckedChange:()=>Q(be.id),disabled:g===be.id}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:be.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Mp,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:be.platform_username}),g===be.id&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]},be.id))]}),ce.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(ma,{className:"h-4 w-4 text-red-600"})," Google Business"]}),ce.map(be=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Oo,{checked:p.includes(be.id),onCheckedChange:()=>Q(be.id),disabled:g===be.id}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:be.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(ma,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:be.page_name||be.platform_username}),g===be.id&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]},be.id))]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:ee,disabled:p.length===0||ge,className:"gap-2",children:[ge?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):_==="schedule"?e.jsx(hn,{className:"h-4 w-4"}):e.jsx(Bn,{className:"h-4 w-4"}),_==="schedule"?`Schedule ${p.length} post${p.length!==1?"s":""}`:`Post to ${p.length} account${p.length!==1?"s":""}`]})]})]})})}function uUt(){const t=Qt(),[s,r]=N.useState(void 0),[n,a]=N.useState("all"),[o,l]=N.useState(null),[i,c]=N.useState(""),[u,p]=N.useState(void 0),[f,g]=N.useState("12"),[b,_]=N.useState("00"),[j,w]=N.useState("PM"),{data:k=[],isLoading:S}=mt({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:ce,error:xe}=await H.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(xe)throw xe;return ce}}),M=k.filter(ce=>{if(n!=="all"&&ce.status!==n)return!1;if(s&&ce.scheduled_for){const xe=new Date(ce.scheduled_for);if(!Cl(xe,s))return!1}return!0}),L=k.filter(ce=>ce.scheduled_for).map(ce=>$m(new Date(ce.scheduled_for))),I=Dt({mutationFn:async ce=>{const{error:xe}=await H.from("scheduled_posts").update({caption:ce.caption,scheduled_for:ce.scheduled_for}).eq("id",ce.id);if(xe)throw xe},onSuccess:()=>{me.success("Post updated!"),t.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:ce=>{me.error(`Failed to update: ${ce.message}`)}}),O=Dt({mutationFn:async ce=>{const{error:xe}=await H.from("scheduled_posts").update({status:"cancelled"}).eq("id",ce);if(xe)throw xe},onSuccess:()=>{me.success("Post cancelled"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:ce=>{me.error(`Failed to cancel: ${ce.message}`)}}),q=Dt({mutationFn:async ce=>{const{error:xe}=await H.from("scheduled_posts").delete().eq("id",ce);if(xe)throw xe},onSuccess:()=>{me.success("Post deleted"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:ce=>{me.error(`Failed to delete: ${ce.message}`)}}),U=Dt({mutationFn:async ce=>{const{data:xe,error:ge}=await H.functions.invoke("social-post",{body:{platform:ce.platform,accountId:ce.social_account_id,imageUrl:ce.image_url,caption:ce.caption}});if(ge)throw ge;if(xe!=null&&xe.error)throw new Error(xe.error);return await H.from("scheduled_posts").update({status:"posted",posted_at:new Date().toISOString(),post_id:xe.postId}).eq("id",ce.id),xe},onSuccess:ce=>{const xe=ce.platform==="facebook"?"Facebook":ce.platform==="instagram"?"Instagram":"LinkedIn";me.success(`Posted to ${xe}!`),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:ce=>{me.error(`Failed to post: ${ce.message}`)}}),B=ce=>{if(l(ce),c(ce.caption||""),ce.scheduled_for){const xe=new Date(ce.scheduled_for);p(xe);const ge=xe.getHours();g(String(ge>12?ge-12:ge===0?12:ge)),_(String(xe.getMinutes()).padStart(2,"0")),w(ge>=12?"PM":"AM")}},V=()=>{if(!o||!u)return;let ce=parseInt(f);const xe=parseInt(b);j==="PM"&&ce!==12&&(ce+=12),j==="AM"&&ce===12&&(ce=0);const ge=UL(qL(u,ce),xe);I.mutate({id:o.id,caption:i,scheduled_for:ge.toISOString()})},Z=ce=>{switch(ce){case"facebook":return e.jsx(Su,{className:"h-4 w-4 text-blue-600"});case"instagram":return e.jsx(Mu,{className:"h-4 w-4 text-pink-600"});case"linkedin":return e.jsx(Mp,{className:"h-4 w-4 text-blue-700"});default:return null}},X=ce=>{switch(ce){case"scheduled":return e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(tt,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(xi,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(tt,{variant:"destructive",className:"gap-1",children:[e.jsx(vc,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return e.jsxs(tt,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(kl,{className:"h-3 w-3"}),"Cancelled"]});default:return e.jsx(tt,{variant:"outline",children:ce})}},ee=Array.from({length:12},(ce,xe)=>String(xe+1)),Q=["00","15","30","45"],ie=k.filter(ce=>ce.status==="scheduled").length,re=k.filter(ce=>ce.status==="posted").length,oe=k.filter(ce=>ce.status==="scheduled"&&ce.scheduled_for&&xSt(new Date(ce.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:ie}),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:oe}),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:re}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Posted"})]}),e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:k.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total"})]})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[e.jsxs(Ee,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Dd,{className:"h-5 w-5"}),e.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),e.jsx(_f,{mode:"single",selected:s,onSelect:r,className:It("pointer-events-auto"),modifiers:{hasPost:L},modifiersStyles:{hasPost:{fontWeight:"bold",backgroundColor:"hsl(var(--primary) / 0.1)",borderRadius:"50%"}}}),s&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>r(void 0),className:"w-full mt-2",children:"Clear date filter"})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xg,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:["all","scheduled","posted","failed","cancelled"].map(ce=>e.jsx(K,{variant:n===ce?"default":"outline",size:"sm",onClick:()=>a(ce),className:"capitalize",children:ce},ce))})]}),S&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!S&&M.length===0&&e.jsxs(Ee,{className:"p-8 text-center",children:[e.jsx(hn,{className:"h-12 w-12 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"font-medium mb-2",children:"No posts found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?`No posts scheduled for ${ms(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:M.map(ce=>{var xe,ge;return e.jsx(Ee,{className:"overflow-hidden",children:e.jsxs("div",{className:"flex flex-col sm:flex-row",children:[e.jsx("div",{className:"sm:w-32 h-32 sm:h-auto bg-muted flex-shrink-0",children:e.jsx("img",{src:ce.image_url,alt:"Post preview",className:"w-full h-full object-cover"})}),e.jsxs(De,{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:[Z(ce.platform),e.jsx("span",{className:"font-medium",children:((xe=ce.social_accounts)==null?void 0:xe.page_name)||((ge=ce.social_accounts)==null?void 0:ge.platform_username)||"Unknown"}),X(ce.status)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[ce.status==="scheduled"&&e.jsxs(z1,{children:[e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>B(ce),children:e.jsx(Ra,{className:"h-4 w-4"})})}),e.jsx(Yl,{children:"Edit post"})]}),e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>U.mutate(ce),disabled:U.isPending,children:U.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4"})})}),e.jsx(Yl,{children:"Post now"})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Cancel this scheduled post?"}),e.jsx(tc,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Keep"}),e.jsx(Ol,{onClick:()=>O.mutate(ce.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),e.jsx(Ol,{onClick:()=>q.mutate(ce.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(ce.status==="posted"||ce.status==="cancelled"||ce.status==="failed")&&e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Delete this post?"}),e.jsx(tc,{children:"This will permanently remove this post from your history."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:()=>q.mutate(ce.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}),ce.caption&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:ce.caption}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),ce.status==="posted"&&ce.posted_at?`Posted ${ms(new Date(ce.posted_at),"PPp")}`:ce.scheduled_for?`Scheduled for ${ms(new Date(ce.scheduled_for),"PPp")}`:"Not scheduled"]}),ce.status==="failed"&&ce.error_message&&e.jsxs("p",{className:"text-xs text-destructive mt-2",children:["Error: ",ce.error_message]})]})]})},ce.id)})})]})]}),e.jsx(fs,{open:!!o,onOpenChange:ce=>!ce&&l(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Edit Scheduled Post"}),e.jsx(Gr,{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(Er,{value:i,onChange:ce=>c(ce.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($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("justify-start text-left font-normal flex-1",!u&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),u?ms(u,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:u,onSelect:p,disabled:ce=>cee.jsx(Mt,{value:ce,children:ce},ce))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(Zs,{value:b,onValueChange:_,children:[e.jsx(Ws,{className:"w-[70px]",children:e.jsx(Xs,{})}),e.jsx(Gs,{children:Q.map(ce=>e.jsx(Mt,{value:ce,children:ce},ce))})]}),e.jsxs(Zs,{value:j,onValueChange:ce=>w(ce),children:[e.jsx(Ws,{className:"w-[70px]",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"AM",children:"AM"}),e.jsx(Mt,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{onClick:V,disabled:I.isPending,children:[I.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function wz(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 Wet={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 wz=="function"&&wz;if(!p&&f)return f(u,!0);if(i)return i(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var b=a[u]={exports:{}};n[u][0].call(b.exports,function(_){var j=n[u][1][_];return l(j||_)},b,b.exports,r,n,a,o)}return a[u].exports}for(var i=typeof wz=="function"&&wz,c=0;c>2,b=(3&u)<<4|p>>4,_=1>6:64,j=2>4,p=(15&g)<<4|(b=i.indexOf(c.charAt(j++)))>>2,f=(3&b)<<6|(_=i.indexOf(c.charAt(j++))),S[w++]=u,b!==64&&(S[w++]=p),_!==64&&(S[w++]=f);return S}},{"./support":30,"./utils":32}],2:[function(r,n,a){var o=r("./external"),l=r("./stream/DataWorker"),i=r("./stream/Crc32Probe"),c=r("./stream/DataLengthProbe");function u(p,f,g,b,_){this.compressedSize=p,this.uncompressedSize=f,this.crc32=g,this.compression=b,this.compressedContent=_}u.prototype={getContentWorker:function(){var p=new l(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return p.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),p},getCompressedWorker:function(){return new l(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(p,f,g){return p.pipe(new i).pipe(new c("uncompressedSize")).pipe(f.compressWorker(g)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},n.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(r,n,a){var o=r("./stream/GenericWorker");a.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},a.DEFLATE=r("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(r,n,a){var o=r("./utils"),l=function(){for(var i,c=[],u=0;u<256;u++){i=u;for(var p=0;p<8;p++)i=1&i?3988292384^i>>>1:i>>>1;c[u]=i}return c}();n.exports=function(i,c){return i!==void 0&&i.length?o.getTypeOf(i)!=="string"?function(u,p,f,g){var b=l,_=g+f;u^=-1;for(var j=g;j<_;j++)u=u>>>8^b[255&(u^p[j])];return-1^u}(0|c,i,i.length,0):function(u,p,f,g){var b=l,_=g+f;u^=-1;for(var j=g;j<_;j++)u=u>>>8^b[255&(u^p.charCodeAt(j))];return-1^u}(0|c,i,i.length,0):0}},{"./utils":32}],5:[function(r,n,a){a.base64=!1,a.binary=!1,a.dir=!1,a.createFolders=!0,a.date=null,a.compression=null,a.compressionOptions=null,a.comment=null,a.unixPermissions=null,a.dosPermissions=null},{}],6:[function(r,n,a){var o=null;o=typeof Promise<"u"?Promise:r("lie"),n.exports={Promise:o}},{lie:37}],7:[function(r,n,a){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",l=r("pako"),i=r("./utils"),c=r("./stream/GenericWorker"),u=o?"uint8array":"array";function p(f,g){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}a.magic="\b\0",i.inherits(p,c),p.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(u,f.data),!1)},p.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},p.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},p.prototype._createPako=function(){this._pako=new l[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(g){f.push({data:g,meta:f.meta})}},a.compressWorker=function(f){return new p("Deflate",f)},a.uncompressWorker=function(){return new p("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,n,a){function o(b,_){var j,w="";for(j=0;j<_;j++)w+=String.fromCharCode(255&b),b>>>=8;return w}function l(b,_,j,w,k,S){var M,L,I=b.file,O=b.compression,q=S!==u.utf8encode,U=i.transformTo("string",S(I.name)),B=i.transformTo("string",u.utf8encode(I.name)),V=I.comment,Z=i.transformTo("string",S(V)),X=i.transformTo("string",u.utf8encode(V)),ee=B.length!==I.name.length,Q=X.length!==V.length,ie="",re="",oe="",ce=I.dir,xe=I.date,ge={crc32:0,compressedSize:0,uncompressedSize:0};_&&!j||(ge.crc32=b.crc32,ge.compressedSize=b.compressedSize,ge.uncompressedSize=b.uncompressedSize);var ue=0;_&&(ue|=8),q||!ee&&!Q||(ue|=2048);var pe=0,be=0;ce&&(pe|=16),k==="UNIX"?(be=798,pe|=function(Ne,Pe){var Oe=Ne;return Ne||(Oe=Pe?16893:33204),(65535&Oe)<<16}(I.unixPermissions,ce)):(be=20,pe|=function(Ne){return 63&(Ne||0)}(I.dosPermissions)),M=xe.getUTCHours(),M<<=6,M|=xe.getUTCMinutes(),M<<=5,M|=xe.getUTCSeconds()/2,L=xe.getUTCFullYear()-1980,L<<=4,L|=xe.getUTCMonth()+1,L<<=5,L|=xe.getUTCDate(),ee&&(re=o(1,1)+o(p(U),4)+B,ie+="up"+o(re.length,2)+re),Q&&(oe=o(1,1)+o(p(Z),4)+X,ie+="uc"+o(oe.length,2)+oe);var Me="";return Me+=` \0`,Me+=o(ue,2),Me+=O.magic,Me+=o(M,2),Me+=o(L,2),Me+=o(ge.crc32,4),Me+=o(ge.compressedSize,4),Me+=o(ge.uncompressedSize,4),Me+=o(U.length,2),Me+=o(ie.length,2),{fileRecord:f.LOCAL_FILE_HEADER+Me+U+ie,dirRecord:f.CENTRAL_FILE_HEADER+o(be,2)+Me+o(Z.length,2)+"\0\0\0\0"+o(pe,4)+o(w,4)+U+ie+Z}}var i=r("../utils"),c=r("../stream/GenericWorker"),u=r("../utf8"),p=r("../crc32"),f=r("../signature");function g(b,_,j,w){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=_,this.zipPlatform=j,this.encodeFileName=w,this.streamFiles=b,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(g,c),g.prototype.push=function(b){var _=b.meta.percent||0,j=this.entriesCount,w=this._sources.length;this.accumulate?this.contentBuffer.push(b):(this.bytesWritten+=b.data.length,c.prototype.push.call(this,{data:b.data,meta:{currentFile:this.currentFile,percent:j?(_+100*(j-w-1))/j:100}}))},g.prototype.openedSource=function(b){this.currentSourceOffset=this.bytesWritten,this.currentFile=b.file.name;var _=this.streamFiles&&!b.file.dir;if(_){var j=l(b,_,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:j.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(b){this.accumulate=!1;var _=this.streamFiles&&!b.file.dir,j=l(b,_,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(j.dirRecord),_)this.push({data:function(w){return f.DATA_DESCRIPTOR+o(w.crc32,4)+o(w.compressedSize,4)+o(w.uncompressedSize,4)}(b),meta:{percent:100}});else for(this.push({data:j.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var b=this.bytesWritten,_=0;_=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=i,u},readString:function(i){return o.transformTo("string",this.readData(i))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var i=this.readInt(4);return new Date(Date.UTC(1980+(i>>25&127),(i>>21&15)-1,i>>16&31,i>>11&31,i>>5&63,(31&i)<<1))}},n.exports=l},{"../utils":32}],19:[function(r,n,a){var o=r("./Uint8ArrayReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.readData=function(i){this.checkOffset(i);var c=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,c},n.exports=l},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,n,a){var o=r("./DataReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.byteAt=function(i){return this.data.charCodeAt(this.zero+i)},l.prototype.lastIndexOfSignature=function(i){return this.data.lastIndexOf(i)-this.zero},l.prototype.readAndCheckSignature=function(i){return i===this.readData(4)},l.prototype.readData=function(i){this.checkOffset(i);var c=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,c},n.exports=l},{"../utils":32,"./DataReader":18}],21:[function(r,n,a){var o=r("./ArrayReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.readData=function(i){if(this.checkOffset(i),i===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+i);return this.index+=i,c},n.exports=l},{"../utils":32,"./ArrayReader":17}],22:[function(r,n,a){var o=r("../utils"),l=r("../support"),i=r("./ArrayReader"),c=r("./StringReader"),u=r("./NodeBufferReader"),p=r("./Uint8ArrayReader");n.exports=function(f){var g=o.getTypeOf(f);return o.checkSupport(g),g!=="string"||l.uint8array?g==="nodebuffer"?new u(f):l.uint8array?new p(o.transformTo("uint8array",f)):new i(o.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(r,n,a){a.LOCAL_FILE_HEADER="PK",a.CENTRAL_FILE_HEADER="PK",a.CENTRAL_DIRECTORY_END="PK",a.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",a.ZIP64_CENTRAL_DIRECTORY_END="PK",a.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(r,n,a){var o=r("./GenericWorker"),l=r("../utils");function i(c){o.call(this,"ConvertWorker to "+c),this.destType=c}l.inherits(i,o),i.prototype.processChunk=function(c){this.push({data:l.transformTo(this.destType,c.data),meta:c.meta})},n.exports=i},{"../utils":32,"./GenericWorker":28}],25:[function(r,n,a){var o=r("./GenericWorker"),l=r("../crc32");function i(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(i,o),i.prototype.processChunk=function(c){this.streamInfo.crc32=l(c.data,this.streamInfo.crc32||0),this.push(c)},n.exports=i},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,n,a){var o=r("../utils"),l=r("./GenericWorker");function i(c){l.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}o.inherits(i,l),i.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}l.prototype.processChunk.call(this,c)},n.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(r,n,a){var o=r("../utils"),l=r("./GenericWorker");function i(c){l.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(p){u.dataIsReady=!0,u.data=p,u.max=p&&p.length||0,u.type=o.getTypeOf(p),u.isPaused||u._tickAndRepeat()},function(p){u.error(p)})}o.inherits(i,l),i.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=i},{"../utils":32,"./GenericWorker":28}],28:[function(r,n,a){function o(l){this.name=l||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(l){this.emit("data",l)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(l){this.emit("error",l)}return!0},error:function(l){return!this.isFinished&&(this.isPaused?this.generatedError=l:(this.isFinished=!0,this.emit("error",l),this.previous&&this.previous.error(l),this.cleanUp()),!0)},on:function(l,i){return this._listeners[l].push(i),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(l,i){if(this._listeners[l])for(var c=0;c "+l:l}},n.exports=o},{}],29:[function(r,n,a){var o=r("../utils"),l=r("./ConvertWorker"),i=r("./GenericWorker"),c=r("../base64"),u=r("../support"),p=r("../external"),f=null;if(u.nodestream)try{f=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(_,j){return new p.Promise(function(w,k){var S=[],M=_._internalType,L=_._outputType,I=_._mimeType;_.on("data",function(O,q){S.push(O),j&&j(q)}).on("error",function(O){S=[],k(O)}).on("end",function(){try{var O=function(q,U,B){switch(q){case"blob":return o.newBlob(o.transformTo("arraybuffer",U),B);case"base64":return c.encode(U);default:return o.transformTo(q,U)}}(L,function(q,U){var B,V=0,Z=null,X=0;for(B=0;B"u")a.blob=!1;else{var o=new ArrayBuffer(0);try{a.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var l=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);l.append(o),a.blob=l.getBlob("application/zip").size===0}catch{a.blob=!1}}}try{a.nodestream=!!r("readable-stream").Readable}catch{a.nodestream=!1}},{"readable-stream":16}],31:[function(r,n,a){for(var o=r("./utils"),l=r("./support"),i=r("./nodejsUtils"),c=r("./stream/GenericWorker"),u=new Array(256),p=0;p<256;p++)u[p]=252<=p?6:248<=p?5:240<=p?4:224<=p?3:192<=p?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function g(){c.call(this,"utf-8 encode")}a.utf8encode=function(b){return l.nodebuffer?i.newBufferFrom(b,"utf-8"):function(_){var j,w,k,S,M,L=_.length,I=0;for(S=0;S>>6:(w<65536?j[M++]=224|w>>>12:(j[M++]=240|w>>>18,j[M++]=128|w>>>12&63),j[M++]=128|w>>>6&63),j[M++]=128|63&w);return j}(b)},a.utf8decode=function(b){return l.nodebuffer?o.transformTo("nodebuffer",b).toString("utf-8"):function(_){var j,w,k,S,M=_.length,L=new Array(2*M);for(j=w=0;j>10&1023,L[w++]=56320|1023&k)}return L.length!==w&&(L.subarray?L=L.subarray(0,w):L.length=w),o.applyFromCharCode(L)}(b=o.transformTo(l.uint8array?"uint8array":"array",b))},o.inherits(f,c),f.prototype.processChunk=function(b){var _=o.transformTo(l.uint8array?"uint8array":"array",b.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var j=_;(_=new Uint8Array(j.length+this.leftOver.length)).set(this.leftOver,0),_.set(j,this.leftOver.length)}else _=this.leftOver.concat(_);this.leftOver=null}var w=function(S,M){var L;for((M=M||S.length)>S.length&&(M=S.length),L=M-1;0<=L&&(192&S[L])==128;)L--;return L<0||L===0?M:L+u[S[L]]>M?L:M}(_),k=_;w!==_.length&&(l.uint8array?(k=_.subarray(0,w),this.leftOver=_.subarray(w,_.length)):(k=_.slice(0,w),this.leftOver=_.slice(w,_.length))),this.push({data:a.utf8decode(k),meta:b.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:a.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},a.Utf8DecodeWorker=f,o.inherits(g,c),g.prototype.processChunk=function(b){this.push({data:a.utf8encode(b.data),meta:b.meta})},a.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(r,n,a){var o=r("./support"),l=r("./base64"),i=r("./nodejsUtils"),c=r("./external");function u(j){return j}function p(j,w){for(var k=0;k>8;this.dir=!!(16&this.externalFileAttributes),b==0&&(this.dosPermissions=63&this.externalFileAttributes),b==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var b=o(this.extraFields[1].value);this.uncompressedSize===l.MAX_VALUE_32BITS&&(this.uncompressedSize=b.readInt(8)),this.compressedSize===l.MAX_VALUE_32BITS&&(this.compressedSize=b.readInt(8)),this.localHeaderOffset===l.MAX_VALUE_32BITS&&(this.localHeaderOffset=b.readInt(8)),this.diskNumberStart===l.MAX_VALUE_32BITS&&(this.diskNumberStart=b.readInt(4))}},readExtraFields:function(b){var _,j,w,k=b.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});b.index+4>>6:(b<65536?g[w++]=224|b>>>12:(g[w++]=240|b>>>18,g[w++]=128|b>>>12&63),g[w++]=128|b>>>6&63),g[w++]=128|63&b);return g},a.buf2binstring=function(f){return p(f,f.length)},a.binstring2buf=function(f){for(var g=new o.Buf8(f.length),b=0,_=g.length;b<_;b++)g[b]=f.charCodeAt(b);return g},a.buf2string=function(f,g){var b,_,j,w,k=g||f.length,S=new Array(2*k);for(b=_=0;b>10&1023,S[_++]=56320|1023&j)}return p(S,_)},a.utf8border=function(f,g){var b;for((g=g||f.length)>f.length&&(g=f.length),b=g-1;0<=b&&(192&f[b])==128;)b--;return b<0||b===0?g:b+c[f[b]]>g?b:g}},{"./common":41}],43:[function(r,n,a){n.exports=function(o,l,i,c){for(var u=65535&o|0,p=o>>>16&65535|0,f=0;i!==0;){for(i-=f=2e3>>1:l>>>1;i[c]=l}return i}();n.exports=function(l,i,c,u){var p=o,f=u+c;l^=-1;for(var g=u;g>>8^p[255&(l^i[g])];return-1^l}},{}],46:[function(r,n,a){var o,l=r("../utils/common"),i=r("./trees"),c=r("./adler32"),u=r("./crc32"),p=r("./messages"),f=0,g=4,b=0,_=-2,j=-1,w=4,k=2,S=8,M=9,L=286,I=30,O=19,q=2*L+1,U=15,B=3,V=258,Z=V+B+1,X=42,ee=113,Q=1,ie=2,re=3,oe=4;function ce(fe,Ve){return fe.msg=p[Ve],Ve}function xe(fe){return(fe<<1)-(4fe.avail_out&&(at=fe.avail_out),at!==0&&(l.arraySet(fe.output,Ve.pending_buf,Ve.pending_out,at,fe.next_out),fe.next_out+=at,Ve.pending_out+=at,fe.total_out+=at,fe.avail_out-=at,Ve.pending-=at,Ve.pending===0&&(Ve.pending_out=0))}function pe(fe,Ve){i._tr_flush_block(fe,0<=fe.block_start?fe.block_start:-1,fe.strstart-fe.block_start,Ve),fe.block_start=fe.strstart,ue(fe.strm)}function be(fe,Ve){fe.pending_buf[fe.pending++]=Ve}function Me(fe,Ve){fe.pending_buf[fe.pending++]=Ve>>>8&255,fe.pending_buf[fe.pending++]=255&Ve}function Ne(fe,Ve){var at,et,Ce=fe.max_chain_length,rt=fe.strstart,Ge=fe.prev_length,ct=fe.nice_match,qe=fe.strstart>fe.w_size-Z?fe.strstart-(fe.w_size-Z):0,Ze=fe.window,Qe=fe.w_mask,He=fe.prev,Je=fe.strstart+V,it=Ze[rt+Ge-1],Lt=Ze[rt+Ge];fe.prev_length>=fe.good_match&&(Ce>>=2),ct>fe.lookahead&&(ct=fe.lookahead);do if(Ze[(at=Ve)+Ge]===Lt&&Ze[at+Ge-1]===it&&Ze[at]===Ze[rt]&&Ze[++at]===Ze[rt+1]){rt+=2,at++;do;while(Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&rtqe&&--Ce!=0);return Ge<=fe.lookahead?Ge:fe.lookahead}function Pe(fe){var Ve,at,et,Ce,rt,Ge,ct,qe,Ze,Qe,He=fe.w_size;do{if(Ce=fe.window_size-fe.lookahead-fe.strstart,fe.strstart>=He+(He-Z)){for(l.arraySet(fe.window,fe.window,He,He,0),fe.match_start-=He,fe.strstart-=He,fe.block_start-=He,Ve=at=fe.hash_size;et=fe.head[--Ve],fe.head[Ve]=He<=et?et-He:0,--at;);for(Ve=at=He;et=fe.prev[--Ve],fe.prev[Ve]=He<=et?et-He:0,--at;);Ce+=He}if(fe.strm.avail_in===0)break;if(Ge=fe.strm,ct=fe.window,qe=fe.strstart+fe.lookahead,Ze=Ce,Qe=void 0,Qe=Ge.avail_in,Ze=B)for(rt=fe.strstart-fe.insert,fe.ins_h=fe.window[rt],fe.ins_h=(fe.ins_h<=B&&(fe.ins_h=(fe.ins_h<=B)if(et=i._tr_tally(fe,fe.strstart-fe.match_start,fe.match_length-B),fe.lookahead-=fe.match_length,fe.match_length<=fe.max_lazy_match&&fe.lookahead>=B){for(fe.match_length--;fe.strstart++,fe.ins_h=(fe.ins_h<=B&&(fe.ins_h=(fe.ins_h<=B&&fe.match_length<=fe.prev_length){for(Ce=fe.strstart+fe.lookahead-B,et=i._tr_tally(fe,fe.strstart-1-fe.prev_match,fe.prev_length-B),fe.lookahead-=fe.prev_length-1,fe.prev_length-=2;++fe.strstart<=Ce&&(fe.ins_h=(fe.ins_h<fe.pending_buf_size-5&&(at=fe.pending_buf_size-5);;){if(fe.lookahead<=1){if(Pe(fe),fe.lookahead===0&&Ve===f)return Q;if(fe.lookahead===0)break}fe.strstart+=fe.lookahead,fe.lookahead=0;var et=fe.block_start+at;if((fe.strstart===0||fe.strstart>=et)&&(fe.lookahead=fe.strstart-et,fe.strstart=et,pe(fe,!1),fe.strm.avail_out===0)||fe.strstart-fe.block_start>=fe.w_size-Z&&(pe(fe,!1),fe.strm.avail_out===0))return Q}return fe.insert=0,Ve===g?(pe(fe,!0),fe.strm.avail_out===0?re:oe):(fe.strstart>fe.block_start&&(pe(fe,!1),fe.strm.avail_out),Q)}),new ke(4,4,8,4,Oe),new ke(4,5,16,8,Oe),new ke(4,6,32,32,Oe),new ke(4,4,16,16,Te),new ke(8,16,32,32,Te),new ke(8,16,128,128,Te),new ke(8,32,128,256,Te),new ke(32,128,258,1024,Te),new ke(32,258,258,4096,Te)],a.deflateInit=function(fe,Ve){return ft(fe,Ve,S,15,8,0)},a.deflateInit2=ft,a.deflateReset=Ae,a.deflateResetKeep=nt,a.deflateSetHeader=function(fe,Ve){return fe&&fe.state?fe.state.wrap!==2?_:(fe.state.gzhead=Ve,b):_},a.deflate=function(fe,Ve){var at,et,Ce,rt;if(!fe||!fe.state||5>8&255),be(et,et.gzhead.time>>16&255),be(et,et.gzhead.time>>24&255),be(et,et.level===9?2:2<=et.strategy||et.level<2?4:0),be(et,255&et.gzhead.os),et.gzhead.extra&&et.gzhead.extra.length&&(be(et,255&et.gzhead.extra.length),be(et,et.gzhead.extra.length>>8&255)),et.gzhead.hcrc&&(fe.adler=u(fe.adler,et.pending_buf,et.pending,0)),et.gzindex=0,et.status=69):(be(et,0),be(et,0),be(et,0),be(et,0),be(et,0),be(et,et.level===9?2:2<=et.strategy||et.level<2?4:0),be(et,3),et.status=ee);else{var Ge=S+(et.w_bits-8<<4)<<8;Ge|=(2<=et.strategy||et.level<2?0:et.level<6?1:et.level===6?2:3)<<6,et.strstart!==0&&(Ge|=32),Ge+=31-Ge%31,et.status=ee,Me(et,Ge),et.strstart!==0&&(Me(et,fe.adler>>>16),Me(et,65535&fe.adler)),fe.adler=1}if(et.status===69)if(et.gzhead.extra){for(Ce=et.pending;et.gzindex<(65535&et.gzhead.extra.length)&&(et.pending!==et.pending_buf_size||(et.gzhead.hcrc&&et.pending>Ce&&(fe.adler=u(fe.adler,et.pending_buf,et.pending-Ce,Ce)),ue(fe),Ce=et.pending,et.pending!==et.pending_buf_size));)be(et,255&et.gzhead.extra[et.gzindex]),et.gzindex++;et.gzhead.hcrc&&et.pending>Ce&&(fe.adler=u(fe.adler,et.pending_buf,et.pending-Ce,Ce)),et.gzindex===et.gzhead.extra.length&&(et.gzindex=0,et.status=73)}else et.status=73;if(et.status===73)if(et.gzhead.name){Ce=et.pending;do{if(et.pending===et.pending_buf_size&&(et.gzhead.hcrc&&et.pending>Ce&&(fe.adler=u(fe.adler,et.pending_buf,et.pending-Ce,Ce)),ue(fe),Ce=et.pending,et.pending===et.pending_buf_size)){rt=1;break}rt=et.gzindexCe&&(fe.adler=u(fe.adler,et.pending_buf,et.pending-Ce,Ce)),rt===0&&(et.gzindex=0,et.status=91)}else et.status=91;if(et.status===91)if(et.gzhead.comment){Ce=et.pending;do{if(et.pending===et.pending_buf_size&&(et.gzhead.hcrc&&et.pending>Ce&&(fe.adler=u(fe.adler,et.pending_buf,et.pending-Ce,Ce)),ue(fe),Ce=et.pending,et.pending===et.pending_buf_size)){rt=1;break}rt=et.gzindexCe&&(fe.adler=u(fe.adler,et.pending_buf,et.pending-Ce,Ce)),rt===0&&(et.status=103)}else et.status=103;if(et.status===103&&(et.gzhead.hcrc?(et.pending+2>et.pending_buf_size&&ue(fe),et.pending+2<=et.pending_buf_size&&(be(et,255&fe.adler),be(et,fe.adler>>8&255),fe.adler=0,et.status=ee)):et.status=ee),et.pending!==0){if(ue(fe),fe.avail_out===0)return et.last_flush=-1,b}else if(fe.avail_in===0&&xe(Ve)<=xe(at)&&Ve!==g)return ce(fe,-5);if(et.status===666&&fe.avail_in!==0)return ce(fe,-5);if(fe.avail_in!==0||et.lookahead!==0||Ve!==f&&et.status!==666){var ct=et.strategy===2?function(qe,Ze){for(var Qe;;){if(qe.lookahead===0&&(Pe(qe),qe.lookahead===0)){if(Ze===f)return Q;break}if(qe.match_length=0,Qe=i._tr_tally(qe,0,qe.window[qe.strstart]),qe.lookahead--,qe.strstart++,Qe&&(pe(qe,!1),qe.strm.avail_out===0))return Q}return qe.insert=0,Ze===g?(pe(qe,!0),qe.strm.avail_out===0?re:oe):qe.last_lit&&(pe(qe,!1),qe.strm.avail_out===0)?Q:ie}(et,Ve):et.strategy===3?function(qe,Ze){for(var Qe,He,Je,it,Lt=qe.window;;){if(qe.lookahead<=V){if(Pe(qe),qe.lookahead<=V&&Ze===f)return Q;if(qe.lookahead===0)break}if(qe.match_length=0,qe.lookahead>=B&&0qe.lookahead&&(qe.match_length=qe.lookahead)}if(qe.match_length>=B?(Qe=i._tr_tally(qe,1,qe.match_length-B),qe.lookahead-=qe.match_length,qe.strstart+=qe.match_length,qe.match_length=0):(Qe=i._tr_tally(qe,0,qe.window[qe.strstart]),qe.lookahead--,qe.strstart++),Qe&&(pe(qe,!1),qe.strm.avail_out===0))return Q}return qe.insert=0,Ze===g?(pe(qe,!0),qe.strm.avail_out===0?re:oe):qe.last_lit&&(pe(qe,!1),qe.strm.avail_out===0)?Q:ie}(et,Ve):o[et.level].func(et,Ve);if(ct!==re&&ct!==oe||(et.status=666),ct===Q||ct===re)return fe.avail_out===0&&(et.last_flush=-1),b;if(ct===ie&&(Ve===1?i._tr_align(et):Ve!==5&&(i._tr_stored_block(et,0,0,!1),Ve===3&&(ge(et.head),et.lookahead===0&&(et.strstart=0,et.block_start=0,et.insert=0))),ue(fe),fe.avail_out===0))return et.last_flush=-1,b}return Ve!==g?b:et.wrap<=0?1:(et.wrap===2?(be(et,255&fe.adler),be(et,fe.adler>>8&255),be(et,fe.adler>>16&255),be(et,fe.adler>>24&255),be(et,255&fe.total_in),be(et,fe.total_in>>8&255),be(et,fe.total_in>>16&255),be(et,fe.total_in>>24&255)):(Me(et,fe.adler>>>16),Me(et,65535&fe.adler)),ue(fe),0=at.w_size&&(rt===0&&(ge(at.head),at.strstart=0,at.block_start=0,at.insert=0),Ze=new l.Buf8(at.w_size),l.arraySet(Ze,Ve,Qe-at.w_size,at.w_size,0),Ve=Ze,Qe=at.w_size),Ge=fe.avail_in,ct=fe.next_in,qe=fe.input,fe.avail_in=Qe,fe.next_in=0,fe.input=Ve,Pe(at);at.lookahead>=B;){for(et=at.strstart,Ce=at.lookahead-(B-1);at.ins_h=(at.ins_h<>>=B=U>>>24,M-=B,(B=U>>>16&255)===0)ie[p++]=65535&U;else{if(!(16&B)){if(!(64&B)){U=L[(65535&U)+(S&(1<>>=B,M-=B),M<15&&(S+=Q[c++]<>>=B=U>>>24,M-=B,!(16&(B=U>>>16&255))){if(!(64&B)){U=I[(65535&U)+(S&(1<>>=B,M-=B,(B=p-f)>3,S&=(1<<(M-=V<<3))-1,o.next_in=c,o.next_out=p,o.avail_in=c>>24&255)+(X>>>8&65280)+((65280&X)<<8)+((255&X)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function M(X){var ee;return X&&X.state?(ee=X.state,X.total_in=X.total_out=ee.total=0,X.msg="",ee.wrap&&(X.adler=1&ee.wrap),ee.mode=_,ee.last=0,ee.havedict=0,ee.dmax=32768,ee.head=null,ee.hold=0,ee.bits=0,ee.lencode=ee.lendyn=new o.Buf32(j),ee.distcode=ee.distdyn=new o.Buf32(w),ee.sane=1,ee.back=-1,g):b}function L(X){var ee;return X&&X.state?((ee=X.state).wsize=0,ee.whave=0,ee.wnext=0,M(X)):b}function I(X,ee){var Q,ie;return X&&X.state?(ie=X.state,ee<0?(Q=0,ee=-ee):(Q=1+(ee>>4),ee<48&&(ee&=15)),ee&&(ee<8||15=oe.wsize?(o.arraySet(oe.window,ee,Q-oe.wsize,oe.wsize,0),oe.wnext=0,oe.whave=oe.wsize):(ie<(re=oe.wsize-oe.wnext)&&(re=ie),o.arraySet(oe.window,ee,Q-ie,re,oe.wnext),(ie-=re)?(o.arraySet(oe.window,ee,Q-ie,ie,0),oe.wnext=ie,oe.whave=oe.wsize):(oe.wnext+=re,oe.wnext===oe.wsize&&(oe.wnext=0),oe.whave>>8&255,Q.check=i(Q.check,rt,2,0),pe=ue=0,Q.mode=2;break}if(Q.flags=0,Q.head&&(Q.head.done=!1),!(1&Q.wrap)||(((255&ue)<<8)+(ue>>8))%31){X.msg="incorrect header check",Q.mode=30;break}if((15&ue)!=8){X.msg="unknown compression method",Q.mode=30;break}if(pe-=4,fe=8+(15&(ue>>>=4)),Q.wbits===0)Q.wbits=fe;else if(fe>Q.wbits){X.msg="invalid window size",Q.mode=30;break}Q.dmax=1<>8&1),512&Q.flags&&(rt[0]=255&ue,rt[1]=ue>>>8&255,Q.check=i(Q.check,rt,2,0)),pe=ue=0,Q.mode=3;case 3:for(;pe<32;){if(xe===0)break e;xe--,ue+=ie[oe++]<>>8&255,rt[2]=ue>>>16&255,rt[3]=ue>>>24&255,Q.check=i(Q.check,rt,4,0)),pe=ue=0,Q.mode=4;case 4:for(;pe<16;){if(xe===0)break e;xe--,ue+=ie[oe++]<>8),512&Q.flags&&(rt[0]=255&ue,rt[1]=ue>>>8&255,Q.check=i(Q.check,rt,2,0)),pe=ue=0,Q.mode=5;case 5:if(1024&Q.flags){for(;pe<16;){if(xe===0)break e;xe--,ue+=ie[oe++]<>>8&255,Q.check=i(Q.check,rt,2,0)),pe=ue=0}else Q.head&&(Q.head.extra=null);Q.mode=6;case 6:if(1024&Q.flags&&(xe<(Ne=Q.length)&&(Ne=xe),Ne&&(Q.head&&(fe=Q.head.extra_len-Q.length,Q.head.extra||(Q.head.extra=new Array(Q.head.extra_len)),o.arraySet(Q.head.extra,ie,oe,Ne,fe)),512&Q.flags&&(Q.check=i(Q.check,ie,Ne,oe)),xe-=Ne,oe+=Ne,Q.length-=Ne),Q.length))break e;Q.length=0,Q.mode=7;case 7:if(2048&Q.flags){if(xe===0)break e;for(Ne=0;fe=ie[oe+Ne++],Q.head&&fe&&Q.length<65536&&(Q.head.name+=String.fromCharCode(fe)),fe&&Ne>9&1,Q.head.done=!0),X.adler=Q.check=0,Q.mode=12;break;case 10:for(;pe<32;){if(xe===0)break e;xe--,ue+=ie[oe++]<>>=7&pe,pe-=7&pe,Q.mode=27;break}for(;pe<3;){if(xe===0)break e;xe--,ue+=ie[oe++]<>>=1)){case 0:Q.mode=14;break;case 1:if(V(Q),Q.mode=20,ee!==6)break;ue>>>=2,pe-=2;break e;case 2:Q.mode=17;break;case 3:X.msg="invalid block type",Q.mode=30}ue>>>=2,pe-=2;break;case 14:for(ue>>>=7&pe,pe-=7&pe;pe<32;){if(xe===0)break e;xe--,ue+=ie[oe++]<>>16^65535)){X.msg="invalid stored block lengths",Q.mode=30;break}if(Q.length=65535&ue,pe=ue=0,Q.mode=15,ee===6)break e;case 15:Q.mode=16;case 16:if(Ne=Q.length){if(xe>>=5,pe-=5,Q.ndist=1+(31&ue),ue>>>=5,pe-=5,Q.ncode=4+(15&ue),ue>>>=4,pe-=4,286>>=3,pe-=3}for(;Q.have<19;)Q.lens[Ge[Q.have++]]=0;if(Q.lencode=Q.lendyn,Q.lenbits=7,at={bits:Q.lenbits},Ve=u(0,Q.lens,0,19,Q.lencode,0,Q.work,at),Q.lenbits=at.bits,Ve){X.msg="invalid code lengths set",Q.mode=30;break}Q.have=0,Q.mode=19;case 19:for(;Q.have>>16&255,Be=65535&Ce,!((Te=Ce>>>24)<=pe);){if(xe===0)break e;xe--,ue+=ie[oe++]<>>=Te,pe-=Te,Q.lens[Q.have++]=Be;else{if(Be===16){for(et=Te+2;pe>>=Te,pe-=Te,Q.have===0){X.msg="invalid bit length repeat",Q.mode=30;break}fe=Q.lens[Q.have-1],Ne=3+(3&ue),ue>>>=2,pe-=2}else if(Be===17){for(et=Te+3;pe>>=Te)),ue>>>=3,pe-=3}else{for(et=Te+7;pe>>=Te)),ue>>>=7,pe-=7}if(Q.have+Ne>Q.nlen+Q.ndist){X.msg="invalid bit length repeat",Q.mode=30;break}for(;Ne--;)Q.lens[Q.have++]=fe}}if(Q.mode===30)break;if(Q.lens[256]===0){X.msg="invalid code -- missing end-of-block",Q.mode=30;break}if(Q.lenbits=9,at={bits:Q.lenbits},Ve=u(p,Q.lens,0,Q.nlen,Q.lencode,0,Q.work,at),Q.lenbits=at.bits,Ve){X.msg="invalid literal/lengths set",Q.mode=30;break}if(Q.distbits=6,Q.distcode=Q.distdyn,at={bits:Q.distbits},Ve=u(f,Q.lens,Q.nlen,Q.ndist,Q.distcode,0,Q.work,at),Q.distbits=at.bits,Ve){X.msg="invalid distances set",Q.mode=30;break}if(Q.mode=20,ee===6)break e;case 20:Q.mode=21;case 21:if(6<=xe&&258<=ge){X.next_out=ce,X.avail_out=ge,X.next_in=oe,X.avail_in=xe,Q.hold=ue,Q.bits=pe,c(X,Me),ce=X.next_out,re=X.output,ge=X.avail_out,oe=X.next_in,ie=X.input,xe=X.avail_in,ue=Q.hold,pe=Q.bits,Q.mode===12&&(Q.back=-1);break}for(Q.back=0;ke=(Ce=Q.lencode[ue&(1<>>16&255,Be=65535&Ce,!((Te=Ce>>>24)<=pe);){if(xe===0)break e;xe--,ue+=ie[oe++]<>nt)])>>>16&255,Be=65535&Ce,!(nt+(Te=Ce>>>24)<=pe);){if(xe===0)break e;xe--,ue+=ie[oe++]<>>=nt,pe-=nt,Q.back+=nt}if(ue>>>=Te,pe-=Te,Q.back+=Te,Q.length=Be,ke===0){Q.mode=26;break}if(32&ke){Q.back=-1,Q.mode=12;break}if(64&ke){X.msg="invalid literal/length code",Q.mode=30;break}Q.extra=15&ke,Q.mode=22;case 22:if(Q.extra){for(et=Q.extra;pe>>=Q.extra,pe-=Q.extra,Q.back+=Q.extra}Q.was=Q.length,Q.mode=23;case 23:for(;ke=(Ce=Q.distcode[ue&(1<>>16&255,Be=65535&Ce,!((Te=Ce>>>24)<=pe);){if(xe===0)break e;xe--,ue+=ie[oe++]<>nt)])>>>16&255,Be=65535&Ce,!(nt+(Te=Ce>>>24)<=pe);){if(xe===0)break e;xe--,ue+=ie[oe++]<>>=nt,pe-=nt,Q.back+=nt}if(ue>>>=Te,pe-=Te,Q.back+=Te,64&ke){X.msg="invalid distance code",Q.mode=30;break}Q.offset=Be,Q.extra=15&ke,Q.mode=24;case 24:if(Q.extra){for(et=Q.extra;pe>>=Q.extra,pe-=Q.extra,Q.back+=Q.extra}if(Q.offset>Q.dmax){X.msg="invalid distance too far back",Q.mode=30;break}Q.mode=25;case 25:if(ge===0)break e;if(Ne=Me-ge,Q.offset>Ne){if((Ne=Q.offset-Ne)>Q.whave&&Q.sane){X.msg="invalid distance too far back",Q.mode=30;break}Pe=Ne>Q.wnext?(Ne-=Q.wnext,Q.wsize-Ne):Q.wnext-Ne,Ne>Q.length&&(Ne=Q.length),Oe=Q.window}else Oe=re,Pe=ce-Q.offset,Ne=Q.length;for(geq?(B=Pe[Oe+w[ee]],pe[be+w[ee]]):(B=96,0),S=1<>ce)+(M-=S)]=U<<24|B<<16|V|0,M!==0;);for(S=1<>=1;if(S!==0?(ue&=S-1,ue+=S):ue=0,ee++,--Me[X]==0){if(X===ie)break;X=f[g+w[ee]]}if(re>>7)]}function be(Ce,rt){Ce.pending_buf[Ce.pending++]=255&rt,Ce.pending_buf[Ce.pending++]=rt>>>8&255}function Me(Ce,rt,Ge){Ce.bi_valid>k-Ge?(Ce.bi_buf|=rt<>k-Ce.bi_valid,Ce.bi_valid+=Ge-k):(Ce.bi_buf|=rt<>>=1,Ge<<=1,0<--rt;);return Ge>>>1}function Oe(Ce,rt,Ge){var ct,qe,Ze=new Array(w+1),Qe=0;for(ct=1;ct<=w;ct++)Ze[ct]=Qe=Qe+Ge[ct-1]<<1;for(qe=0;qe<=rt;qe++){var He=Ce[2*qe+1];He!==0&&(Ce[2*qe]=Pe(Ze[He]++,He))}}function Te(Ce){var rt;for(rt=0;rt>1;1<=Ge;Ge--)nt(Ce,Ze,Ge);for(qe=Je;Ge=Ce.heap[1],Ce.heap[1]=Ce.heap[Ce.heap_len--],nt(Ce,Ze,1),ct=Ce.heap[1],Ce.heap[--Ce.heap_max]=Ge,Ce.heap[--Ce.heap_max]=ct,Ze[2*qe]=Ze[2*Ge]+Ze[2*ct],Ce.depth[qe]=(Ce.depth[Ge]>=Ce.depth[ct]?Ce.depth[Ge]:Ce.depth[ct])+1,Ze[2*Ge+1]=Ze[2*ct+1]=qe,Ce.heap[1]=qe++,nt(Ce,Ze,1),2<=Ce.heap_len;);Ce.heap[--Ce.heap_max]=Ce.heap[1],function(Lt,Vt){var hs,Ts,Cs,cs,er,xt,Es=Vt.dyn_tree,ur=Vt.max_code,Mr=Vt.stat_desc.static_tree,Lr=Vt.stat_desc.has_stree,fn=Vt.stat_desc.extra_bits,ki=Vt.stat_desc.extra_base,Ea=Vt.stat_desc.max_length,dr=0;for(cs=0;cs<=w;cs++)Lt.bl_count[cs]=0;for(Es[2*Lt.heap[Lt.heap_max]+1]=0,hs=Lt.heap_max+1;hs>=7;qe>>=1)if(1&it&&He.dyn_ltree[2*Je]!==0)return l;if(He.dyn_ltree[18]!==0||He.dyn_ltree[20]!==0||He.dyn_ltree[26]!==0)return i;for(Je=32;Je>>3,(Ze=Ce.static_len+3+7>>>3)<=qe&&(qe=Ze)):qe=Ze=Ge+5,Ge+4<=qe&&rt!==-1?et(Ce,rt,Ge,ct):Ce.strategy===4||Ze===qe?(Me(Ce,2+(ct?1:0),3),Ae(Ce,Z,X)):(Me(Ce,4+(ct?1:0),3),function(He,Je,it,Lt){var Vt;for(Me(He,Je-257,5),Me(He,it-1,5),Me(He,Lt-4,4),Vt=0;Vt>>8&255,Ce.pending_buf[Ce.d_buf+2*Ce.last_lit+1]=255&rt,Ce.pending_buf[Ce.l_buf+Ce.last_lit]=255&Ge,Ce.last_lit++,rt===0?Ce.dyn_ltree[2*Ge]++:(Ce.matches++,rt--,Ce.dyn_ltree[2*(Q[Ge]+f+1)]++,Ce.dyn_dtree[2*pe(rt)]++),Ce.last_lit===Ce.lit_bufsize-1},a._tr_align=function(Ce){Me(Ce,2,3),Ne(Ce,M,Z),function(rt){rt.bi_valid===16?(be(rt,rt.bi_buf),rt.bi_buf=0,rt.bi_valid=0):8<=rt.bi_valid&&(rt.pending_buf[rt.pending++]=255&rt.bi_buf,rt.bi_buf>>=8,rt.bi_valid-=8)}(Ce)}},{"../utils/common":41}],53:[function(r,n,a){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(r,n,a){(function(o){(function(l,i){if(!l.setImmediate){var c,u,p,f,g=1,b={},_=!1,j=l.document,w=Object.getPrototypeOf&&Object.getPrototypeOf(l);w=w&&w.setTimeout?w:l,c={}.toString.call(l.process)==="[object process]"?function(L){process.nextTick(function(){S(L)})}:function(){if(l.postMessage&&!l.importScripts){var L=!0,I=l.onmessage;return l.onmessage=function(){L=!1},l.postMessage("","*"),l.onmessage=I,L}}()?(f="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",M,!1):l.attachEvent("onmessage",M),function(L){l.postMessage(f+L,"*")}):l.MessageChannel?((p=new MessageChannel).port1.onmessage=function(L){S(L.data)},function(L){p.port2.postMessage(L)}):j&&"onreadystatechange"in j.createElement("script")?(u=j.documentElement,function(L){var I=j.createElement("script");I.onreadystatechange=function(){S(L),I.onreadystatechange=null,u.removeChild(I),I=null},u.appendChild(I)}):function(L){setTimeout(S,0,L)},w.setImmediate=function(L){typeof L!="function"&&(L=new Function(""+L));for(var I=new Array(arguments.length-1),O=0;O"u"?o===void 0?this:o:self)}).call(this,typeof Hv<"u"?Hv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Wet);var hUt=Wet.exports;const mUt=Po(hUt);function Age(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 pUt=()=>{const{isAdmin:t}=Ds(),[s,r]=N.useState(null),[n,a]=N.useState(null),[o,l]=N.useState("all"),[i,c]=N.useState(new Set),[u,p]=N.useState(!1),[f,g]=N.useState(!1),[b,_]=N.useState("images"),[j,w]=N.useState(null),{data:k=[],isLoading:S}=mt({queryKey:["social-swag-2"],queryFn:async()=>{const{data:xe,error:ge}=await H.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(ge)throw ge;return xe}}),{data:M=[]}=mt({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:xe,error:ge}=await H.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(ge)throw ge;return xe}}),{data:L=[]}=mt({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:xe,error:ge}=await H.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(ge)throw ge;return xe}}),{data:I=[]}=mt({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:xe,error:ge}=await H.from("social_accounts").select("id, platform").eq("is_active",!0);if(ge)throw ge;return xe||[]}}),O=I.length>0,q=N.useMemo(()=>o==="all"?null:L.find(xe=>xe.month===o)||null,[o,L]),U=N.useMemo(()=>[...new Set(k.map(ge=>ge.month))].sort((ge,ue)=>ue.localeCompare(ge)),[k]);N.useEffect(()=>{U.length>0&&o==="all"&&l(U[0])},[U,o]);const B=xe=>{try{const ge=vje(xe,"yyyy-MM",new Date);return ms(ge,"MMMM yyyy")}catch{return xe}},V=N.useMemo(()=>o==="all"?k:k.filter(xe=>xe.month===o),[o,k]),Z=N.useMemo(()=>{var xe;return o==="all"?null:((xe=M.find(ge=>ge.month===o))==null?void 0:xe.canva_link)||null},[o,M]),X=async xe=>{try{await navigator.clipboard.writeText(xe),me.success("Caption copied to clipboard!")}catch{me.error("Failed to copy caption")}},ee=async(xe,ge)=>{try{const pe=await(await fetch(xe)).blob(),be=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),Me=navigator.canShare&&navigator.canShare({files:[new File([pe],"test.jpg",{type:"image/jpeg"})]});if(be&&Me){const Ne=new File([pe],`social-swag-${ge}.jpg`,{type:"image/jpeg"});await navigator.share({files:[Ne],title:"Social Swag Image"}),me.success("Image ready to save!")}else{const Ne=window.URL.createObjectURL(pe),Pe=document.createElement("a");Pe.href=Ne,Pe.download=`social-swag-${ge}.jpg`,document.body.appendChild(Pe),Pe.click(),document.body.removeChild(Pe),window.URL.revokeObjectURL(Ne),me.success("Image downloaded!")}}catch(ue){ue.name!=="AbortError"&&me.error("Failed to download image")}},Q=xe=>{c(ge=>{const ue=new Set(ge);return ue.has(xe)?ue.delete(xe):ue.add(xe),ue})},ie=()=>{c(new Set(V.map(xe=>xe.id)))},re=()=>{c(new Set),p(!1)},oe=async()=>{const xe=V.filter(ge=>i.has(ge.id));if(xe.length===0){me.error("No images selected");return}g(!0),me.info(`Preparing ${xe.length} images for download...`);try{const ge=new mUt,ue=[...xe].sort((Pe,Oe)=>Pe.sort_order-Oe.sort_order);for(let Pe=0;Pe{u?Q(xe.id):r(xe)};return e.jsx(Ms,{title:"Social Swag 2.0",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary via-primary/80 to-info p-8 text-primary-foreground",children:[e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzMiAyIDIgNC0yIDQtMiA0LTItMi0yLTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsxs(tt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(pn,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),e.jsxs(tt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(gl,{className:"h-3 w-3 mr-1"}),k.length," images"]})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-3",children:"Social Swag 📸"}),e.jsx("p",{className:"text-lg text-primary-foreground/90 max-w-2xl",children:"Ready-to-post social media images delivered to you monthly. Just download, copy the caption, and share with your audience!"})]})]}),t?e.jsxs(ba,{defaultValue:"gallery",className:"space-y-6",children:[e.jsxs(pa,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(ns,{value:"gallery",className:"gap-2",children:[e.jsx(gl,{className:"h-4 w-4"}),"Gallery"]}),e.jsxs(ns,{value:"scheduled",className:"gap-2",children:[e.jsx(Dd,{className:"h-4 w-4"}),"Scheduled"]})]}),e.jsxs(bs,{value:"gallery",className:"space-y-6",children:[t?O?e.jsx(Ee,{className:"border rounded-xl",children:e.jsx(De,{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(Pi,{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(De,{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(Su,{className:"h-5 w-5 text-blue-600"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Mu,{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(Pi,{to:"/social-connections",children:[e.jsx(dl,{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(De,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(un,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Su,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Mu,{className:"h-5 w-5 text-pink-400"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Post directly to social media"}),e.jsx(tt,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Soon you'll be able to connect your Facebook & Instagram accounts to post images with one click!"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:U.map(xe=>e.jsx("button",{onClick:()=>l(xe),className:It("px-4 py-2 rounded-full text-sm font-medium transition-all",o===xe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:B(xe)},xe))}),o!=="all"&&(Z?e.jsxs("a",{href:Z,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground/50",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-full",children:[e.jsxs("button",{onClick:()=>{_("images"),re()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",b==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(gl,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{_("reels"),re()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",b==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(gu,{className:"h-4 w-4"}),"Reels"]})]}),b==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,className:"gap-2",children:["Select All (",V.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:re,className:"gap-2",children:[e.jsx(Rr,{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:oe,disabled:f,className:"gap-2",children:[e.jsx(yi,{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(va,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&b==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(xe=>{const ge=i.has(xe.id);return e.jsx(Ee,{className:It("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&ge&&"ring-2 ring-primary ring-offset-2"),onClick:()=>ce(xe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:Age(xe.image_url,400,75),alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110",loading:"lazy",decoding:"async"}),xe.post_date&&!u&&e.jsx("div",{className:"absolute top-0 left-0 w-24 h-24 overflow-hidden pointer-events-none",children:e.jsx("div",{className:"absolute flex items-center justify-center text-white font-bold text-[10px] tracking-wider uppercase",style:{top:"20px",left:"-34px",width:"136px",transform:"rotate(-45deg)",backgroundColor:"#2d5052",padding:"5px 0",boxShadow:"0 2px 4px rgba(0,0,0,0.25)"},children:ms(new Date(xe.post_date+"T00:00:00"),"MMM d")})}),u&&e.jsx("div",{className:It("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",ge?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:ge&&e.jsx(va,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},xe.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(gl,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!S&&b==="reels"&&e.jsx(e.Fragment,{children:q?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(Ee,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a(q),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:Age(q.image_url,400,75),alt:"Reel preview",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105",loading:"lazy",decoding:"async"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs(tt,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(gu,{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(gu,{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(fs,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(ps,{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:Age(s.image_url,900,85),alt:"Social swag",className:"w-full h-full object-cover",decoding:"async"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-muted-foreground mb-4",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(hn,{className:"h-4 w-4"}),ms(new Date(s.created_at),"MMMM d, yyyy")]}),s.post_date&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium rounded-full px-3 py-1 text-xs text-white",style:{background:"#406E71"},children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),"Post on ",ms(new Date(s.post_date+"T00:00:00"),"MMMM d, yyyy")]})]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col gap-3 mt-6",children:[t&&e.jsxs(K,{onClick:()=>{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(Bn,{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:()=>X(s.caption),className:"flex-1 gap-2",children:[e.jsx(gi,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{variant:"outline",onClick:()=>ee(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),"Download"]})]})]})]})]})})})}),e.jsx(fs,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(ps,{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(gu,{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:()=>X(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(gi,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(K,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(tn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),e.jsx(dUt,{open:!!j,onOpenChange:xe=>!xe&&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(bs,{value:"scheduled",children:e.jsx(uUt,{})})]}):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(De,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(un,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Su,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Mu,{className:"h-5 w-5 text-pink-400"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Post directly to social media"}),e.jsx(tt,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Soon you'll be able to connect your Facebook & Instagram accounts to post images with one click!"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:U.map(xe=>e.jsx("button",{onClick:()=>l(xe),className:It("px-4 py-2 rounded-full text-sm font-medium transition-all",o===xe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:B(xe)},xe))}),o!=="all"&&(Z?e.jsxs("a",{href:Z,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground/50",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-full",children:[e.jsxs("button",{onClick:()=>{_("images"),re()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",b==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(gl,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{_("reels"),re()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",b==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(gu,{className:"h-4 w-4"}),"Reels"]})]}),b==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,className:"gap-2",children:["Select All (",V.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:re,className:"gap-2",children:[e.jsx(Rr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(K,{size:"sm",onClick:oe,disabled:f,className:"gap-2",children:[e.jsx(yi,{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(va,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&b==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(xe=>{const ge=i.has(xe.id);return e.jsx(Ee,{className:It("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&ge&&"ring-2 ring-primary ring-offset-2"),onClick:()=>ce(xe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:xe.image_url,alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"}),u&&e.jsx("div",{className:It("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",ge?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:ge&&e.jsx(va,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},xe.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(gl,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!S&&b==="reels"&&e.jsx(e.Fragment,{children:q?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(Ee,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a(q),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:q.image_url,alt:"Reel preview",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs(tt,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(gu,{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(gu,{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(fs,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(ps,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:s&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-muted",children:e.jsx("div",{className:"aspect-[4/5]",children:e.jsx("img",{src:s.image_url,alt:"Social swag",className:"w-full h-full object-cover"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[e.jsx(hn,{className:"h-4 w-4"}),ms(new Date(s.created_at),"MMMM d, yyyy")]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[e.jsxs(K,{variant:"outline",onClick:()=>X(s.caption),className:"flex-1 gap-2",children:[e.jsx(gi,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{variant:"outline",onClick:()=>ee(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),"Download"]})]})]})]})})})}),e.jsx(fs,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(ps,{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(gu,{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:()=>X(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(gi,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(K,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(tn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},fUt=()=>{const{swagId:t}=yo(),{user:s}=Ds(),{toast:r}=Ua(),n=Qt(),{trackEngagement:a}=HO(),[o,l]=N.useState(""),{data:i,isLoading:c}=mt({queryKey:["social-swag-detail",t],queryFn:async()=>{const{data:k,error:S}=await H.from("social_swag").select("*").eq("id",t).single();if(S)throw S;const{data:M}=await H.from("social_swag_links").select("*").eq("swag_id",t).order("sort_order");return{...k,links:M||[]}},enabled:!!t});N.useEffect(()=>{i&&a("social_swag",i.id,i.title,"view")},[i==null?void 0:i.id]);const{data:u=[]}=mt({queryKey:["social-swag-likes",t],queryFn:async()=>{const{data:k,error:S}=await H.from("social_swag_likes").select("*").eq("swag_id",t);if(S)throw S;return k},enabled:!!t}),{data:p=[]}=mt({queryKey:["social-swag-comments",t],queryFn:async()=>{const{data:k,error:S}=await H.from("social_swag_comments").select("*").eq("swag_id",t).order("created_at",{ascending:!1});if(S)throw S;const M=[...new Set(k.map(O=>O.user_id))],{data:L}=await H.from("profiles").select("id, name").in("id",M),I=new Map((L==null?void 0:L.map(O=>[O.id,O.name]))||[]);return k.map(O=>({...O,user_name:I.get(O.user_id)||"Unknown User"}))},enabled:!!t}),f=Dt({mutationFn:async k=>{const{error:S}=await H.from("social_swag_comments").insert({swag_id:t,user_id:s.id,content:k});if(S)throw S},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),l(""),r({title:"Comment added!"})},onError:k=>{r({title:"Error adding comment",description:k.message,variant:"destructive"})}}),g=Dt({mutationFn:async k=>{const{error:S}=await H.from("social_swag_comments").delete().eq("id",k);if(S)throw S},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),r({title:"Comment deleted"})}}),b=Dt({mutationFn:async()=>{const k=u.find(S=>S.user_id===(s==null?void 0:s.id));if(k){const{error:S}=await H.from("social_swag_likes").delete().eq("id",k.id);if(S)throw S}else{const{error:S}=await H.from("social_swag_likes").insert({swag_id:t,user_id:s.id});if(S)throw S}},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-likes",t]})}}),_=u.some(k=>k.user_id===(s==null?void 0:s.id)),j=k=>k.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),w=k=>{k.preventDefault(),!(!o.trim()||!s)&&f.mutate(o.trim())};return c?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(Pi,{to:"/social-swag",children:[e.jsx(Ja,{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(iE,{resourceType:"social_swag",resourceId:i.id,resourceTitle:i.title}),e.jsxs(K,{variant:_?"default":"outline",className:"gap-2 w-fit",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(sh,{className:`h-4 w-4 ${_?"fill-current":""}`}),u.length," ",u.length===1?"Like":"Likes"]})]})]}),i.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:i.description}})]}),i.links.length>0&&e.jsx(Ee,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Bo,{className:"h-4 w-4"}),i.links.length===1?"Canva Link":"Canva Links"]}),e.jsx("div",{className:"grid gap-2",children:i.links.map(k=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{a("social_swag",i.id,i.title,"click_canva"),window.open(k.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:k.title}),e.jsx(tn,{className:"h-4 w-4 text-muted-foreground"})]},k.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($c,{className:"h-5 w-5"}),"Comments (",p.length,")"]}),s?e.jsxs("form",{onSubmit:w,className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Add a comment...",value:o,onChange:k=>l(k.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!o.trim()||f.isPending,children:e.jsx(Bn,{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(De,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):p.map(k=>e.jsx(Ee,{children:e.jsx(De,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(kn,{className:"text-sm",children:j(k.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:k.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Uc(new Date(k.created_at),{addSuffix:!0})}),k.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>g.mutate(k.id),children:e.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:k.content})]})]})})},k.id))})]})]})}):e.jsx(Ms,{title:"Social Swag",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Bo,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Item not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This item may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(Pi,{to:"/social-swag",children:"Back to Social Swag"})})]})})},xUt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=N.useState(!0),[i,c]=N.useState(!0),[u,p]=N.useState(!0),f=g=>g.split(" ").map(b=>b[0]).join("").toUpperCase().slice(0,2);return e.jsx("aside",{className:"w-64 shrink-0 hidden lg:block relative z-0",children:e.jsx("div",{className:"sticky top-4 space-y-4 max-h-[calc(100vh-8rem)] overflow-y-auto overscroll-contain",children:e.jsxs("div",{className:"space-y-2 pr-4",children:[e.jsxs(K,{variant:r==="all"?"secondary":"ghost",className:"w-full justify-start",onClick:()=>n("all"),children:[e.jsx(B_,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsxs(gf,{open:o,onOpenChange:l,children:[e.jsx(yf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",children:"Categories"}),o?e.jsx(Eo,{className:"h-4 w-4"}):e.jsx(da,{className:"h-4 w-4"})]})}),e.jsx(vf,{className:"space-y-1 pl-2",children:t.map(g=>e.jsxs(K,{variant:r===g.id?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(g.id),children:[e.jsx("span",{className:"mr-2",children:g.icon||"📂"}),e.jsx("span",{className:"truncate",children:g.name})]},g.id))})]}),s.length>0&&e.jsxs(gf,{open:i,onOpenChange:c,children:[e.jsx(yf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[e.jsx(Th,{className:"h-3 w-3"}),"Your Groups"]}),i?e.jsx(Eo,{className:"h-4 w-4"}):e.jsx(da,{className:"h-4 w-4"})]})}),e.jsx(vf,{className:"space-y-1 pl-2",children:s.map(g=>e.jsxs(K,{variant:r===`group:${g.id}`?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(`group:${g.id}`),children:[e.jsx("span",{className:"mr-2",children:g.icon||"🔒"}),e.jsx("span",{className:"truncate",children:g.name})]},g.id))})]}),e.jsxs(gf,{open:u,onOpenChange:p,children:[e.jsx(yf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[e.jsx(pr,{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(Eo,{className:"h-4 w-4"}):e.jsx(da,{className:"h-4 w-4"})]})}),e.jsx(vf,{className:"pl-2 space-y-1",children:a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-2 px-2",children:"No one else online right now"}):a.map(g=>e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-2 rounded-md hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(Nn,{className:"h-7 w-7",children:[e.jsx($a,{src:g.avatarUrl}),e.jsx(kn,{className:"text-xs",children:f(g.name)})]}),e.jsx(bd,{className:"h-2.5 w-2.5 fill-green-500 text-green-500 absolute -bottom-0.5 -right-0.5"})]}),e.jsx("span",{className:"text-sm truncate",children:g.name})]},g.id))})]})]})})})},gUt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=N.useState(!1),i=u=>u.split(" ").map(p=>p[0]).join("").toUpperCase().slice(0,2),c=()=>{if(r==="all")return"All Posts";if(r.startsWith("group:")){const p=r.replace("group:",""),f=s.find(g=>g.id===p);return f?`🔒 ${f.name}`:"Private Group"}const u=t.find(p=>p.id===r);return u?`${u.icon||"📂"} ${u.name}`:"Category"};return e.jsxs("div",{className:"lg:hidden flex items-center gap-2 mb-4",children:[e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"flex-1 justify-between",children:[e.jsx("span",{className:"truncate",children:c()}),e.jsx(Eo,{className:"h-4 w-4 ml-2 shrink-0"})]})}),e.jsxs(Bd,{className:"w-56 bg-background border",children:[e.jsxs(Ma,{onClick:()=>n("all"),children:[e.jsx(B_,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsx(dw,{}),e.jsx(kve,{className:"text-xs text-muted-foreground",children:"Categories"}),t.map(u=>e.jsxs(Ma,{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(dw,{}),e.jsxs(kve,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Th,{className:"h-3 w-3"}),"Your Groups"]}),s.map(u=>e.jsxs(Ma,{onClick:()=>n(`group:${u.id}`),children:[e.jsx("span",{className:"mr-2",children:u.icon||"🔒"}),u.name]},u.id))]})]})]}),e.jsxs(JA,{open:o,onOpenChange:l,children:[e.jsx(sNe,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(pr,{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(yC,{children:[e.jsx(eE,{children:e.jsxs(tE,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(Gi,{className:"h-[calc(100vh-8rem)] mt-4",children:a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No one else online right now"}):e.jsx("div",{className:"space-y-2",children:a.map(u=>e.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:u.avatarUrl}),e.jsx(kn,{children:i(u.name)})]}),e.jsx(bd,{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 Ege,Vue="HoverCard",[Get]=ad(Vue,[O0]),Hue=O0(),[yUt,Ike]=Get(Vue),Ket=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,c=Hue(s),u=N.useRef(0),p=N.useRef(0),f=N.useRef(!1),g=N.useRef(!1),[b,_]=ah({prop:n,defaultProp:a??!1,onChange:o,caller:Vue}),j=N.useCallback(()=>{clearTimeout(p.current),u.current=window.setTimeout(()=>_(!0),l)},[l,_]),w=N.useCallback(()=>{clearTimeout(u.current),!f.current&&!g.current&&(p.current=window.setTimeout(()=>_(!1),i))},[i,_]),k=N.useCallback(()=>_(!1),[_]);return N.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(p.current)},[]),e.jsx(yUt,{scope:s,open:b,onOpenChange:_,onOpen:j,onClose:w,onDismiss:k,hasSelectionRef:f,isPointerDownOnContentRef:g,children:e.jsx(vO,{...c,children:r})})};Ket.displayName=Vue;var Zet="HoverCardTrigger",Yet=N.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Ike(Zet,r),o=Hue(r);return e.jsx($A,{asChild:!0,...o,children:e.jsx(nn.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:Ir(t.onPointerEnter,Fle(a.onOpen)),onPointerLeave:Ir(t.onPointerLeave,Fle(a.onClose)),onFocus:Ir(t.onFocus,a.onOpen),onBlur:Ir(t.onBlur,a.onClose),onTouchStart:Ir(t.onTouchStart,l=>l.preventDefault())})})});Yet.displayName=Zet;var vUt="HoverCardPortal",[qMs,bUt]=Get(vUt,{forceMount:void 0}),Rle="HoverCardContent",Xet=N.forwardRef((t,s)=>{const r=bUt(Rle,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=Ike(Rle,t.__scopeHoverCard);return e.jsx(Fd,{present:n||o.open,children:e.jsx(_Ut,{"data-state":o.open?"open":"closed",...a,onPointerEnter:Ir(t.onPointerEnter,Fle(o.onOpen)),onPointerLeave:Ir(t.onPointerLeave,Fle(o.onClose)),ref:s})})});Xet.displayName=Rle;var _Ut=N.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,c=Ike(Rle,r),u=Hue(r),p=N.useRef(null),f=qa(s,p),[g,b]=N.useState(!1);return N.useEffect(()=>{if(g){const _=document.body;return Ege=_.style.userSelect||_.style.webkitUserSelect,_.style.userSelect="none",_.style.webkitUserSelect="none",()=>{_.style.userSelect=Ege,_.style.webkitUserSelect=Ege}}},[g]),N.useEffect(()=>{if(p.current){const _=()=>{b(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var w;((w=document.getSelection())==null?void 0:w.toString())!==""&&(c.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",_),()=>{document.removeEventListener("pointerup",_),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),N.useEffect(()=>{p.current&&NUt(p.current).forEach(j=>j.setAttribute("tabindex","-1"))}),e.jsx(Nw,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:Ir(o,_=>{_.preventDefault()}),onDismiss:c.onDismiss,children:e.jsx(bO,{...u,...i,onPointerDown:Ir(i.onPointerDown,_=>{_.currentTarget.contains(_.target)&&b(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:f,style:{...i.style,userSelect:g?"text":void 0,WebkitUserSelect:g?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),wUt="HoverCardArrow",jUt=N.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Hue(r);return e.jsx(_O,{...a,...n,ref:s})});jUt.displayName=wUt;function Fle(t){return s=>s.pointerType==="touch"?void 0:t()}function NUt(t){const s=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;r.nextNode();)s.push(r.currentNode);return s}var kUt=Ket,SUt=Yet,Qet=Xet;const CUt=kUt,MUt=SUt,Jet=N.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(Qet,{ref:a,align:s,sideOffset:r,className:It("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));Jet.displayName=Qet.displayName;const TUt=[{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"}],AUt=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2),ett=({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(CUt,{openDelay:200,closeDelay:100,children:[e.jsx(MUt,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:s})}),e.jsx(Jet,{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=TUt.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(Nn,{className:"h-6 w-6",children:[e.jsx($a,{src:l.user_avatar||void 0}),e.jsx(kn,{className:"text-[10px]",children:AUt(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 EUt({images:t,initialIndex:s=0,open:r,onOpenChange:n}){const[a,o]=N.useState(s),[l,i]=N.useState(!1);N.useEffect(()=>{r&&(o(s),i(!1))},[r,s]);const c=()=>{o(g=>g>0?g-1:t.length-1),i(!1)},u=()=>{o(g=>g{r&&(g.key==="ArrowLeft"&&c(),g.key==="ArrowRight"&&u(),g.key==="Escape"&&n(!1))},[r,t.length]);N.useEffect(()=>(window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)),[p]);const f=t[a];return e.jsx(fs,{open:r,onOpenChange:n,children:e.jsxs(ps,{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(Rr,{className:"h-6 w-6"})}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:c,children:e.jsx(cl,{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(da,{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(VM,{className:"h-5 w-5"}):e.jsx(G_,{className:"h-5 w-5"})}),e.jsx("div",{className:It("flex items-center justify-center w-full h-full min-h-[50vh] p-4",l?"cursor-zoom-out overflow-auto":"cursor-zoom-in"),onClick:()=>(f==null?void 0:f.type)==="image"&&i(!l),children:(f==null?void 0:f.type)==="video"?e.jsx("video",{src:f.url,controls:!0,autoPlay:!0,className:"max-w-full max-h-[85vh] object-contain",onClick:g=>g.stopPropagation()}):e.jsx("img",{src:f==null?void 0:f.url,alt:"",className:It("object-contain transition-transform duration-200",l?"max-w-none max-h-none scale-150":"max-w-full max-h-[85vh]")})}),t.length>1&&e.jsx("div",{className:"absolute bottom-12 left-1/2 -translate-x-1/2 z-50 flex gap-2 bg-black/50 p-2 rounded-lg max-w-[90vw] overflow-x-auto",children:t.map((g,b)=>e.jsx("button",{onClick:()=>{o(b),i(!1)},className:It("w-12 h-12 rounded overflow-hidden flex-shrink-0 border-2 transition-all",a===b?"border-white":"border-transparent opacity-60 hover:opacity-100"),children:g.type==="video"?e.jsx("video",{src:g.url,className:"w-full h-full object-cover"}):e.jsx("img",{src:g.url,alt:"",className:"w-full h-full object-cover"})},b))})]})})}const jz=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],PUt=({commentId:t,reactions:s,currentUserId:r})=>{var u,p;const n=Qt(),[a,o]=N.useState(!1),l=s.find(f=>f.user_id===r),i=Dt({mutationFn:async f=>{l?l.reaction_type===f?await H.from("community_comment_reactions").delete().eq("id",l.id):await H.from("community_comment_reactions").update({reaction_type:f}).eq("id",l.id):await H.from("community_comment_reactions").insert({comment_id:t,user_id:r,reaction_type:f})},onSuccess:()=>{n.invalidateQueries({queryKey:["community-posts"]}),o(!1)}}),c={};return s.forEach(f=>{c[f.reaction_type]=(c[f.reaction_type]||0)+1}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.length>0&&e.jsx(ett,{reactions:s,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("div",{className:"flex -space-x-0.5",children:Object.keys(c).slice(0,2).map(f=>{var g;return e.jsx("span",{className:"text-sm",children:(g=jz.find(b=>b.type===f))==null?void 0:g.emoji},f)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs($o,{open:a,onOpenChange:o,children:[e.jsx(qo,{asChild:!0,children:e.jsx("button",{className:`text-xs hover:text-primary transition-colors ${l?"text-primary font-medium":"text-muted-foreground"}`,children:l?e.jsxs("span",{children:[(u=jz.find(f=>f.type===l.reaction_type))==null?void 0:u.emoji," ",(p=jz.find(f=>f.type===l.reaction_type))==null?void 0:p.label]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ni,{className:"h-3 w-3"}),"Like"]})})}),e.jsx(Ro,{className:"w-auto p-1.5 bg-popover border shadow-lg z-50",side:"top",children:e.jsx("div",{className:"flex gap-0.5",children:jz.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 Lke({content:t,className:s}){const r=/([@#])\[([^\]]+)\]\(([^)]+)\)|(https?:\/\/[^\s<>]+)/g,n=[];let a=0,o,l=0;for(;(o=r.exec(t))!==null;){if(o.index>a&&n.push(t.substring(a,o.index)),o[1]){const i=o[1],c=o[2],u=o[3],p=i==="#";n.push(e.jsx(Pi,{to:p?`/templates/${u}`:`/profile?user=${u}`,className:It("font-medium hover:underline",p?"text-white bg-[#2a4c64] px-1.5 py-0.5 rounded":"text-primary"),onClick:f=>f.stopPropagation(),children:p?c:`@${c}`},`mention-${l++}`))}else if(o[4]){const i=o[4],c=i.replace(/[.,;:!?)]+$/,""),u=i.slice(c.length);let p;try{const f=new URL(c);p=f.hostname+(f.pathname!=="/"?f.pathname.slice(0,20)+(f.pathname.length>20?"...":""):"")}catch{p=c.length>40?c.slice(0,40)+"...":c}n.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline break-all",onClick:f=>f.stopPropagation(),children:p},`url-${l++}`)),u&&n.push(u)}a=o.index+o[0].length}return ae.jsx(N.Fragment,{children:i},c))})}function zle({value:t,onChange:s,placeholder:r="What's on your mind? Use @ to mention someone",className:n,minHeight:a="80px",onMentionsChange:o,onTemplatesChange:l,onKeyDown:i,mentionFormat:c="encoded",enableTemplateMentions:u=!1}){const p=N.useRef(null),f=N.useRef(null),[g,b]=N.useState(!1),[_,j]=N.useState("user"),[w,k]=N.useState(""),[S,M]=N.useState(null),[L,I]=N.useState(0),[O,q]=N.useState({top:0,left:0,width:0}),U=N.useRef(new Map),B=N.useRef(new Map),V=pe=>{if(c==="plain"){const Pe=[];return U.current.forEach((Te,ke)=>{pe.includes(`@${ke}`)&&Pe.push(Te)}),[...new Set(Pe)]}const be=/@\[([^\]]+)\]\(([^)]+)\)/g,Me=[];let Ne;for(;(Ne=be.exec(pe))!==null;)Me.push(Ne[2]);return[...new Set(Me)]},Z=pe=>{if(c==="plain"){const Pe=[];return B.current.forEach((Te,ke)=>{pe.includes(`#${ke}`)&&Pe.push(Te)}),[...new Set(Pe)]}const be=/#\[([^\]]+)\]\(([^)]+)\)/g,Me=[];let Ne;for(;(Ne=be.exec(pe))!==null;)Me.push(Ne[2]);return[...new Set(Me)]};N.useEffect(()=>{if(o){const pe=V(t);o(pe)}if(l){const pe=Z(t);l(pe)}},[t,o,l,c]);const{data:X=[],isLoading:ee}=mt({queryKey:["mention-users",w],queryFn:async()=>{const pe=H.from("profiles").select("id, name").limit(8),be=w.length>=1?pe.ilike("name",`%${w}%`):pe.order("name"),{data:Me,error:Ne}=await be;if(Ne)throw Ne;const Pe=Me.map(Te=>Te.id),Oe=await FZe(Pe);return Me.map(Te=>({id:Te.id,name:Te.name||"Unknown",avatar_url:Oe.get(Te.id)}))},enabled:g&&_==="user",staleTime:3e4}),{data:Q=[],isLoading:ie}=mt({queryKey:["mention-templates",w],queryFn:async()=>{let pe=H.from("canva_templates").select("id, name, preview_image_url").lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(8);w.length>=1&&(pe=pe.ilike("name",`%${w}%`));const{data:be,error:Me}=await pe;if(Me)throw Me;return be||[]},enabled:g&&_==="template"&&u,staleTime:3e4}),re=_==="user"?ee:ie,oe=_==="user"?X:Q,ce=pe=>pe.split(" ").map(be=>be[0]).join("").toUpperCase().slice(0,2),xe=pe=>{const be=pe.target.value,Me=pe.target.selectionStart;s(be);const Ne=be.substring(0,Me),Pe=Ne.lastIndexOf("@"),Oe=u?Ne.lastIndexOf("#"):-1;let Te=-1,ke="user";if(Pe>Oe?(Te=Pe,ke="user"):Oe>Pe&&u&&(Te=Oe,ke="template"),Te!==-1){const Be=Ne.substring(Te+1),nt=Be.includes(" "),Ae=Be.includes(` `);if(!nt&&!Ae&&Be.length<=30){M(Te),k(Be),j(ke),b(!0),I(0);return}}b(!1),M(null)},ge=pe=>{if(S===null)return;const be=t.substring(0,S),Me=t.substring(S+w.length+1),Ne=_==="user"?"@":"#",Pe=c==="plain"?`${Ne}${pe.name} `:`${Ne}[${pe.name}](${pe.id}) `;c==="plain"&&(_==="user"?U.current.set(pe.name,pe.id):B.current.set(pe.name,pe.id));const Oe=be+Pe+Me;s(Oe),b(!1),M(null),k(""),setTimeout(()=>{if(p.current){const Te=be.length+Pe.length;p.current.focus(),p.current.setSelectionRange(Te,Te)}},0)},ue=pe=>{if(!(!g||oe.length===0))switch(pe.key){case"ArrowDown":pe.preventDefault(),I(be=>(be+1)%oe.length);break;case"ArrowUp":pe.preventDefault(),I(be=>(be-1+oe.length)%oe.length);break;case"Enter":oe[L]&&(pe.preventDefault(),ge(oe[L]));break;case"Escape":pe.preventDefault(),b(!1);break;case"Tab":oe[L]&&(pe.preventDefault(),ge(oe[L]));break}};return N.useEffect(()=>{const pe=be=>{f.current&&!f.current.contains(be.target)&&p.current&&!p.current.contains(be.target)&&b(!1)};return document.addEventListener("mousedown",pe),()=>document.removeEventListener("mousedown",pe)},[]),N.useEffect(()=>{if(!g)return;const pe=()=>{const be=p.current;if(!be)return;const Me=be.getBoundingClientRect();q({top:Me.bottom+4,left:Me.left,width:Me.width})};return pe(),window.addEventListener("resize",pe),window.addEventListener("scroll",pe,!0),()=>{window.removeEventListener("resize",pe),window.removeEventListener("scroll",pe,!0)}},[g,t]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Er,{ref:p,value:t,onChange:xe,onKeyDown:pe=>{ue(pe),pe.defaultPrevented||i==null||i(pe)},placeholder:r,className:It("resize-none",n),style:{minHeight:a}}),g&&yp.createPortal(e.jsxs("div",{ref:f,className:"fixed z-[1000] max-h-[220px] overflow-hidden rounded-lg border bg-popover shadow-lg",style:{top:O.top,left:O.left,width:O.width,maxWidth:"320px"},children:[e.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground border-b bg-muted/30",children:_==="user"?"👤 Mention a person":"📋 Link a template"}),re?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Searching..."}):oe.length===0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:w.length<1?`Type to search ${_==="user"?"people":"templates"}...`:`No ${_==="user"?"users":"templates"} found`}):e.jsx("ul",{className:"py-1 max-h-[180px] overflow-y-auto",children:oe.map((pe,be)=>e.jsx("li",{className:It("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",be===L?"bg-accent":"hover:bg-accent/50"),onClick:()=>ge(pe),onMouseEnter:()=>I(be),children:_==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx($a,{src:pe.avatar_url}),e.jsx(kn,{className:"text-xs",children:ce(pe.name)})]}),e.jsx("span",{className:"text-sm font-medium truncate",children:pe.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:pe.preview_image_url?e.jsx("img",{src:pe.preview_image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(ac,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate",children:pe.name})]})},pe.id))})]}),document.body)]})}function IUt(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const u8e=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);function ttt({comment:t,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=Qt(),[c,u]=N.useState(!1),[p,f]=N.useState(""),[g,b]=N.useState([]),_=Dt({mutationFn:async({content:S,parentCommentId:M})=>{const{data:L,error:I}=await H.from("community_comments").insert({post_id:s,user_id:r,content:S,parent_comment_id:M}).select("id").single();if(I)throw I;const O=g;if(O.length>0&&L){const q=O.filter(U=>U!==r).map(U=>({comment_id:L.id,mentioned_user_id:U,mentioned_by_user_id:r}));q.length>0&&await H.from("community_comment_mentions").insert(q)}},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),f(""),b([]),u(!1)}}),j=Dt({mutationFn:async S=>{const{error:M}=await H.from("community_comments").delete().eq("id",S);if(M)throw M},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),w=()=>{p.trim()&&_.mutate({content:p,parentCommentId:t.id})};return e.jsxs("div",{className:l>0?"ml-8 border-l-2 border-muted pl-3":"",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Nn,{className:"h-8 w-8 shrink-0",children:[e.jsx($a,{src:t.user_avatar||void 0}),e.jsx(kn,{className:"text-xs",children:u8e(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(Lke,{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:Uc(new Date(t.created_at),{addSuffix:!0})}),e.jsx(PUt,{commentId:t.id,reactions:t.reactions,currentUserId:r}),r&&l<2&&e.jsxs("button",{onClick:()=>u(!c),className:"hover:text-primary flex items-center gap-1",children:[e.jsx(_L,{className:"h-3 w-3"}),"Reply"]}),(t.user_id===r||o)&&e.jsx("button",{onClick:()=>j.mutate(t.id),className:"hover:text-destructive",children:t.user_id!==r?"Remove":"Delete"})]}),c&&r&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(Nn,{className:"h-6 w-6 shrink-0 mt-1",children:[e.jsx($a,{src:n||void 0}),e.jsx(kn,{className:"text-xs",children:u8e((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(zle,{placeholder:`Reply to ${t.user_name}...`,value:p,onChange:f,onMentionsChange:b,mentionFormat:"plain",className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:w,disabled:!p.trim()||_.isPending,className:"h-8 px-2 mt-0.5",children:e.jsx(Bn,{className:"h-3 w-3"})})]})]})]})]}),t.replies&&t.replies.length>0&&e.jsx("div",{className:"mt-2 space-y-2",children:t.replies.map(S=>e.jsx(ttt,{comment:S,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},S.id))})]})}const Nz=[{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"}],LUt=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=Ds(),{avatarUrl:a}=RZe(t==null?void 0:t.id),{onlineUsers:o}=zYe(),{toast:l}=Ua(),i=Qt(),c=N.useRef(null),[u,p]=N.useState("all"),[f,g]=N.useState(""),[b,_]=N.useState(""),[j,w]=N.useState(""),[k,S]=N.useState([]),[M,L]=N.useState([]),[I,O]=N.useState(""),[q,U]=N.useState(!1),[B,V]=N.useState(null),[Z,X]=N.useState(""),[ee,Q]=N.useState(new Set),[ie,re]=N.useState({}),[oe,ce]=N.useState({}),[xe,ge]=N.useState([]),[ue,pe]=N.useState([]),[be,Me]=N.useState({open:!1,images:[],index:0});N.useEffect(()=>{if(u.startsWith("group:")){const it=u.replace("group:","");w(it),_("")}else u!=="all"?(_(u),w("")):(_(""),w(""))},[u]);const{data:Ne=[]}=mt({queryKey:["community-categories"],queryFn:async()=>{const{data:it,error:Lt}=await H.from("community_categories").select("*").order("sort_order");if(Lt)throw Lt;return it}}),{data:Pe=[]}=mt({queryKey:["community-private-groups"],queryFn:async()=>{const{data:it,error:Lt}=await H.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(Lt)throw Lt;return it}}),Oe=20,{data:Te,isLoading:ke,hasNextPage:Be,fetchNextPage:nt,isFetchingNextPage:Ae}=oUe({queryKey:["community-posts",u],initialPageParam:0,queryFn:async({pageParam:it})=>{var $e;const Lt=it*Oe,Vt=Lt+Oe;let hs=H.from("community_posts").select("*").order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(Lt,Vt);if(u.startsWith("group:")){const Ye=u.replace("group:","");hs=hs.eq("private_group_id",Ye)}else u==="all"||(hs=hs.eq("category_id",u).is("private_group_id",null));const{data:Ts,error:Cs}=await hs;if(Cs)throw Cs;const cs=((Ts==null?void 0:Ts.length)||0)>Oe,er=(Ts||[]).slice(0,Oe);if(er.length===0)return{posts:[],hasMore:!1,nextPage:it+1};const xt=er.map(Ye=>Ye.id),Es=[...new Set(er.filter(Ye=>Ye.category_id).map(Ye=>Ye.category_id))].filter(Boolean),[ur,Mr,Lr,fn,ki]=await Promise.all([Es.length?H.from("community_categories").select("*").in("id",Es):Promise.resolve({data:[]}),H.from("community_post_media").select("*").in("post_id",xt).order("sort_order"),H.from("community_reactions").select("*").in("post_id",xt),H.from("community_comments").select("*").in("post_id",xt).order("created_at",{ascending:!0}),H.from("community_post_resources").select("*").in("post_id",xt)]),Ea=ur==null?void 0:ur.data,dr=Mr==null?void 0:Mr.data,Jr=Lr==null?void 0:Lr.data,Wr=fn==null?void 0:fn.data,dn=ki==null?void 0:ki.data,Yr=(Wr||[]).map(Ye=>Ye.id),[vi,pt]=await Promise.all([Yr.length?H.from("community_comment_reactions").select("*").in("comment_id",Yr):Promise.resolve({data:[]}),(()=>{const Ye=(dn||[]).filter(bt=>bt.resource_type==="template").map(bt=>bt.resource_id);return Ye.length===0?Promise.resolve({data:[]}):H.from("canva_templates").select("id, name, preview_image_url").in("id",Ye)})()]),ir=(vi==null?void 0:vi.data)||[],Vn=(pt==null?void 0:pt.data)||[],Sr=new Map(Vn.map(Ye=>[Ye.id,{name:Ye.name,preview_image_url:Ye.preview_image_url}])),jr=Array.from(new Set([...er.map(Ye=>Ye.user_id),...(Jr||[]).map(Ye=>Ye.user_id),...(Wr||[]).map(Ye=>Ye.user_id),...ir.map(Ye=>Ye.user_id)])),[ea,Pa]=await Promise.all([jr.length?H.from("profiles").select("id, name").in("id",jr):Promise.resolve({data:[]}),FZe(jr)]),Ii=new Map((($e=ea==null?void 0:ea.data)==null?void 0:$e.map(Ye=>[Ye.id,Ye.name]))||[]),Fo=new Map((Ea||[]).map(Ye=>[Ye.id,Ye])),$t=Ye=>{const bt=new Map,gt=[];return Ye.forEach(Ft=>{bt.set(Ft.id,{...Ft,user_name:Ii.get(Ft.user_id)||"Unknown User",user_avatar:Pa.get(Ft.user_id),reactions:ir.filter(Zt=>Zt.comment_id===Ft.id).map(Zt=>({...Zt,user_name:Ii.get(Zt.user_id)||"Unknown User",user_avatar:Pa.get(Zt.user_id)})),replies:[]})}),Ye.forEach(Ft=>{const Zt=bt.get(Ft.id);if(Ft.parent_comment_id&&bt.has(Ft.parent_comment_id)){const Ut=bt.get(Ft.parent_comment_id);Ut.replies=Ut.replies||[],Ut.replies.push(Zt)}else gt.push(Zt)}),gt};return{posts:er.map(Ye=>{const bt=(dn||[]).filter(gt=>gt.post_id===Ye.id).map(gt=>{let Ft="",Zt=null;if(gt.resource_type==="template"){const Ut=Sr.get(gt.resource_id);Ft=(Ut==null?void 0:Ut.name)||"Unknown Template",Zt=(Ut==null?void 0:Ut.preview_image_url)||null}return{id:gt.id,resource_type:gt.resource_type,resource_id:gt.resource_id,resource_name:Ft,resource_preview_url:Zt}});return{...Ye,user_name:Ii.get(Ye.user_id)||"Unknown User",user_avatar:Pa.get(Ye.user_id),category:Ye.category_id?Fo.get(Ye.category_id):null,media:(dr||[]).filter(gt=>gt.post_id===Ye.id),reactions:((Jr||[]).filter(gt=>gt.post_id===Ye.id)||[]).map(gt=>({...gt,user_name:Ii.get(gt.user_id)||"Unknown User",user_avatar:Pa.get(gt.user_id)})),comments:$t((Wr||[]).filter(gt=>gt.post_id===Ye.id)),resources:bt}}),hasMore:cs,nextPage:it+1}},getNextPageParam:it=>it.hasMore?it.nextPage:void 0}),ft=N.useMemo(()=>(Te==null?void 0:Te.pages.flatMap(it=>it.posts))??[],[Te]),fe=Dt({mutationFn:async()=>{U(!0);const{data:it,error:Lt}=await H.from("community_posts").insert({user_id:t.id,category_id:j?null:b||null,private_group_id:j||null,content:f,link_url:I||null}).select().single();if(Lt)throw Lt;for(let hs=0;hs0){const hs=xe.filter(Ts=>Ts!==t.id).map(Ts=>({post_id:it.id,mentioned_user_id:Ts,mentioned_by_user_id:t.id}));hs.length>0&&await H.from("community_post_mentions").insert(hs)}const Vt=IUt(f);if(Vt.length>0){const hs=Vt.map(Ts=>({post_id:it.id,resource_type:"template",resource_id:Ts}));await H.from("community_post_resources").insert(hs)}return it},onSuccess:async it=>{var Lt;i.invalidateQueries({queryKey:["community-posts"]}),g(""),ge([]),pe([]),_(""),w(""),S([]),L([]),O(""),l({title:"Post created!"});try{const Vt=((Lt=t==null?void 0:t.user_metadata)==null?void 0:Lt.name)||"Someone",hs=f.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),Ts=hs.length>50?hs.substring(0,50)+"...":hs;await H.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${Vt}: ${Ts}`,url:"/community"}})}catch(Vt){console.error("Failed to send push notification:",Vt)}},onError:it=>{l({title:"Error creating post",description:it.message,variant:"destructive"})},onSettled:()=>U(!1)}),Ve=Dt({mutationFn:async({postId:it,content:Lt})=>{const{error:Vt}=await H.from("community_posts").update({content:Lt}).eq("id",it);if(Vt)throw Vt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),V(null),X(""),l({title:"Post updated!"})}}),at=Dt({mutationFn:async it=>{const{error:Lt}=await H.from("community_posts").delete().eq("id",it);if(Lt)throw Lt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),et=Dt({mutationFn:async({postId:it,isPinned:Lt})=>{const{error:Vt}=await H.from("community_posts").update({is_pinned:!Lt,pinned_at:Lt?null:new Date().toISOString(),pinned_by:Lt?null:t==null?void 0:t.id}).eq("id",it);if(Vt)throw Vt},onSuccess:(it,{isPinned:Lt})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:Lt?"Post unpinned":"Post pinned to top"})}}),Ce=Dt({mutationFn:async({postId:it,reactionType:Lt})=>{var hs;const Vt=(hs=ft.find(Ts=>Ts.id===it))==null?void 0:hs.reactions.find(Ts=>Ts.user_id===(t==null?void 0:t.id));Vt?Vt.reaction_type===Lt?await H.from("community_reactions").delete().eq("id",Vt.id):await H.from("community_reactions").update({reaction_type:Lt}).eq("id",Vt.id):await H.from("community_reactions").insert({post_id:it,user_id:t.id,reaction_type:Lt})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),rt=Dt({mutationFn:async({postId:it,content:Lt})=>{const{data:Vt,error:hs}=await H.from("community_comments").insert({post_id:it,user_id:t.id,content:Lt}).select("id").single();if(hs)throw hs;const Ts=oe[it]||[];if(Ts.length>0&&Vt){const Cs=Ts.filter(cs=>cs!==t.id).map(cs=>({comment_id:Vt.id,mentioned_user_id:cs,mentioned_by_user_id:t.id}));Cs.length>0&&await H.from("community_comment_mentions").insert(Cs)}},onSuccess:(it,{postId:Lt})=>{i.invalidateQueries({queryKey:["community-posts"]}),re(Vt=>({...Vt,[Lt]:""})),ce(Vt=>({...Vt,[Lt]:[]}))}});Dt({mutationFn:async it=>{const{error:Lt}=await H.from("community_comments").delete().eq("id",it);if(Lt)throw Lt},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const Ge=it=>{const Lt=Array.from(it.target.files||[]);if(Lt.length+k.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}S(Vt=>[...Vt,...Lt]),Lt.forEach(Vt=>{const hs=new FileReader;hs.onloadend=()=>{L(Ts=>[...Ts,hs.result])},hs.readAsDataURL(Vt)})},ct=it=>{S(Lt=>Lt.filter((Vt,hs)=>hs!==it)),L(Lt=>Lt.filter((Vt,hs)=>hs!==it))},qe=it=>it.split(" ").map(Lt=>Lt[0]).join("").toUpperCase().slice(0,2),Ze=it=>{const Lt={};return it.forEach(Vt=>{Lt[Vt.reaction_type]=(Lt[Vt.reaction_type]||0)+1}),Lt},Qe=it=>{var Lt;return(Lt=it.find(Vt=>Vt.user_id===(t==null?void 0:t.id)))==null?void 0:Lt.reaction_type},He=it=>it.reduce((Lt,Vt)=>Lt+1+(Vt.replies?He(Vt.replies):0),0),Je=it=>{if(n)return!0;if(!s||!it.private_group_id)return!1;const Lt=Pe.find(Vt=>Vt.id===it.private_group_id);return Lt!=null&&Lt.brokerage_id?r.some(Vt=>Vt.id===Lt.brokerage_id):!1};return e.jsx(Ms,{title:"Community",children:e.jsxs("div",{className:"flex gap-6 w-full isolate z-0",children:[e.jsx(xUt,{categories:Ne,privateGroups:Pe,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(gUt,{categories:Ne,privateGroups:Pe,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsx(Ee,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:a||void 0}),e.jsx(kn,{children:t!=null&&t.email?qe(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(zle,{placeholder:n?"What's on your mind? Use @ to mention someone, # to link a template":"What's on your mind? Use @ to mention someone",value:f,onChange:g,onMentionsChange:ge,onTemplatesChange:pe,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),M.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:M.map((it,Lt)=>{var Vt;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[(Vt=k[Lt])!=null&&Vt.type.startsWith("video/")?e.jsx("video",{src:it,className:"w-full h-full object-cover"}):e.jsx("img",{src:it,alt:"",className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>ct(Lt),children:e.jsx(Rr,{className:"h-3 w-3"})})]},Lt)})}),I&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:I,onChange:it=>O(it.target.value),placeholder:"https://...",className:"flex-1"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>O(""),children:e.jsx(Rr,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx("input",{type:"file",ref:c,onChange:Ge,accept:"image/*,video/*",multiple:!0,className:"hidden"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var it;return(it=c.current)==null?void 0:it.click()},children:[e.jsx(gl,{className:"h-4 w-4 mr-1"}),"Photo"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var it;return(it=c.current)==null?void 0:it.click()},children:[e.jsx(An,{className:"h-4 w-4 mr-1"}),"Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>O("https://"),children:[e.jsx(Bo,{className:"h-4 w-4 mr-1"}),"Link"]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end",children:[Pe.length>0?e.jsxs(Zs,{value:j||b||"none",onValueChange:it=>{it==="none"?(_(""),w("")):it.startsWith("group:")?(w(it.replace("group:","")),_("")):(_(it),w(""))},children:[e.jsx(Ws,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx(Xs,{placeholder:"Select..."})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:"No category"}),Ne.map(it=>e.jsxs(Mt,{value:it.id,children:[it.icon," ",it.name]},it.id)),Pe.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"}),Pe.map(it=>e.jsxs(Mt,{value:`group:${it.id}`,children:[it.icon||"🔒"," ",it.name]},it.id))]})]})]}):e.jsxs(Zs,{value:b,onValueChange:_,children:[e.jsx(Ws,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:e.jsx(Xs,{placeholder:"Category"})}),e.jsx(Gs,{children:Ne.map(it=>e.jsxs(Mt,{value:it.id,children:[it.icon," ",it.name]},it.id))})]}),e.jsxs(K,{size:"sm",onClick:()=>fe.mutate(),disabled:!f.trim()||q,children:[e.jsx(Bn,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),ke?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((it,Lt)=>e.jsx(Ee,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(ys,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ys,{className:"h-4 w-32"}),e.jsx(ys,{className:"h-4 w-full"}),e.jsx(ys,{className:"h-4 w-3/4"})]})]})})},Lt))}):ft.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx($c,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No posts yet"}),e.jsx("p",{className:"text-muted-foreground",children:"Be the first to start a conversation!"})]})}):e.jsxs("div",{className:"space-y-4",children:[ft.map(it=>{var Lt,Vt,hs,Ts;return e.jsx(Ee,{children:e.jsxs(De,{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(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:it.user_avatar||void 0}),e.jsx(kn,{children:qe(it.user_name||"U")})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold break-words",children:it.user_name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{children:Uc(new Date(it.created_at),{addSuffix:!0})}),it.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs(tt,{variant:"secondary",className:"text-xs",children:[it.category.icon," ",it.category.name]})]})]})]})]}),(it.user_id===(t==null?void 0:t.id)||Je(it))&&e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(px,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[Je(it)&&it.private_group_id&&e.jsx(Ma,{onClick:()=>et.mutate({postId:it.id,isPinned:it.is_pinned}),children:it.is_pinned?e.jsxs(e.Fragment,{children:[e.jsx(xL,{className:"h-4 w-4 mr-2"}),"Unpin Post"]}):e.jsxs(e.Fragment,{children:[e.jsx(U_,{className:"h-4 w-4 mr-2"}),"Pin to Top"]})}),it.user_id===(t==null?void 0:t.id)&&e.jsxs(Ma,{onClick:()=>{V(it),X(it.content)},children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ma,{className:"text-destructive",onClick:()=>at.mutate(it.id),children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),it.user_id!==(t==null?void 0:t.id)?"Remove (Moderate)":"Delete"]})]})]})]}),it.is_pinned&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-primary",children:[e.jsx(U_,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Pinned"})]}),e.jsx("div",{className:"mb-3",children:e.jsx(Lke,{content:it.content})}),it.media.length>0&&e.jsx("div",{className:`grid gap-2 mb-3 ${it.media.length===1?"grid-cols-1":it.media.length===2?"grid-cols-2":it.media.length===3?"grid-cols-3":"grid-cols-2"}`,children:it.media.slice(0,4).map((Cs,cs)=>{const er=cs===3&&it.media.length>4,xt=it.media.length-4;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden bg-muted cursor-pointer group ${it.media.length===1?"max-h-[500px]":it.media.length===2?"aspect-[4/3]":"aspect-square"}`,onClick:()=>Me({open:!0,images:it.media.map(Es=>({url:Es.media_url,type:Es.media_type==="video"?"video":"image"})),index:cs}),children:[Cs.media_type==="video"?e.jsx("video",{src:Cs.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:Cs.media_url,alt:"",className:"w-full h-full object-cover transition-transform group-hover:scale-105"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors flex items-center justify-center",children:e.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity text-white",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})})})}),er&&e.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center",children:e.jsxs("span",{className:"text-white text-2xl font-bold",children:["+",xt]})})]},Cs.id)})}),it.link_url&&e.jsxs("a",{href:it.link_url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg border hover:bg-muted transition-colors mb-3 overflow-hidden",children:[it.link_image&&e.jsx("div",{className:"aspect-video bg-muted",children:e.jsx("img",{src:it.link_image,alt:it.link_title||"Link preview",className:"w-full h-full object-cover",onError:Cs=>{Cs.currentTarget.style.display="none"}})}),e.jsx("div",{className:"p-3",children:it.link_title?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-foreground line-clamp-2",children:it.link_title}),it.link_description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:it.link_description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 truncate",children:new URL(it.link_url).hostname})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary",children:[e.jsx(Bo,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:it.link_url})]})})]}),it.reactions.length>0&&e.jsx(ett,{reactions:it.reactions,children:e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:[e.jsx("div",{className:"flex -space-x-1",children:Object.entries(Ze(it.reactions)).slice(0,3).map(([Cs])=>{var cs;return e.jsx("span",{className:"text-base",children:(cs=Nz.find(er=>er.type===Cs))==null?void 0:cs.emoji},Cs)})}),e.jsx("span",{children:it.reactions.length})]})}),e.jsxs("div",{className:"flex items-center gap-1 border-t border-b py-1 my-2",children:[e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",children:[Qe(it.reactions)?e.jsx("span",{className:"mr-1",children:(Lt=Nz.find(Cs=>Cs.type===Qe(it.reactions)))==null?void 0:Lt.emoji}):e.jsx(sh,{className:"h-4 w-4 mr-1"}),Qe(it.reactions)?(Vt=Nz.find(Cs=>Cs.type===Qe(it.reactions)))==null?void 0:Vt.label:"Like"]})}),e.jsx(Ro,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:Nz.map(Cs=>e.jsx("button",{onClick:()=>Ce.mutate({postId:it.id,reactionType:Cs.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:Cs.label,children:Cs.emoji},Cs.type))})})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>Q(Cs=>{const cs=new Set(Cs);return cs.has(it.id)?cs.delete(it.id):cs.add(it.id),cs}),children:[e.jsx($c,{className:"h-4 w-4 mr-1"}),(()=>{const Cs=He(it.comments);return Cs>0?`Comment (${Cs})`:"Comment"})()]})]}),ee.has(it.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[it.comments.map(Cs=>e.jsx(ttt,{comment:Cs,postId:it.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:Je(it)},Cs.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:a||void 0}),e.jsx(kn,{className:"text-xs",children:qe(((hs=t.email)==null?void 0:hs.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(zle,{placeholder:"Write a comment... (use @ to mention)",value:ie[it.id]||"",onChange:Cs=>re(cs=>({...cs,[it.id]:Cs})),onMentionsChange:Cs=>ce(cs=>({...cs,[it.id]:Cs})),mentionFormat:"plain",onKeyDown:Cs=>{var cs;Cs.defaultPrevented||Cs.key==="Enter"&&!Cs.shiftKey&&((cs=ie[it.id])!=null&&cs.trim())&&(Cs.preventDefault(),rt.mutate({postId:it.id,content:ie[it.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{var Cs;(Cs=ie[it.id])!=null&&Cs.trim()&&rt.mutate({postId:it.id,content:ie[it.id]})},disabled:!((Ts=ie[it.id])!=null&&Ts.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx(Bn,{className:"h-4 w-4"})})]})]})]})]})},it.id)}),Be&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(K,{variant:"outline",onClick:()=>nt(),disabled:Ae,children:Ae?"Loading…":"Load more posts"})})]}),e.jsx(fs,{open:!!B,onOpenChange:()=>V(null),children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Edit Post"})}),e.jsx(Er,{value:Z,onChange:it=>X(it.target.value),className:"min-h-[120px]"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>V(null),children:"Cancel"}),e.jsx(K,{onClick:()=>{B&&Ve.mutate({postId:B.id,content:Z})},disabled:!Z.trim(),children:"Save Changes"})]})]})}),e.jsx(EUt,{images:be.images,initialIndex:be.index,open:be.open,onOpenChange:it=>Me(Lt=>({...Lt,open:it}))})]})]})})},C5={open:{label:"Open",icon:un,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:$c,color:"bg-blue-500"},resolved:{label:"Resolved",icon:xi,color:"bg-green-500"},closed:{label:"Closed",icon:vc,color:"bg-muted-foreground"}},h8e={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function DUt(){const{user:t}=Ds(),s=Qt(),[r,n]=N.useState(null),[a,o]=N.useState(""),{data:l=[],isLoading:i}=mt({queryKey:["support-tickets"],queryFn:async()=>{const{data:f,error:g}=await H.from("support_tickets").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(g)throw g;return f},enabled:!!t}),{data:c=[]}=mt({queryKey:["ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:f,error:g}=await H.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(g)throw g;return f},enabled:!!r}),u=Dt({mutationFn:async f=>{if(!r||!t)throw new Error("Missing data");const{error:g}=await H.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:f,is_admin_reply:!1});if(g)throw g},onSuccess:()=>{s.invalidateQueries({queryKey:["ticket-replies",r==null?void 0:r.id]}),o(""),me.success("Reply sent!")},onError:()=>{me.error("Failed to send reply")}}),p=()=>{a.trim()&&u.mutate(a)};if(r){const f=C5[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(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(tt,{variant:"secondary",children:h8e[r.category]}),e.jsxs(tt,{className:C5[r.status].color,children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),C5[r.status].label]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(gr,{children:["Created on ",ms(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(De,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Conversation"})}),e.jsxs(De,{children:[e.jsx(Gi,{className:"h-[300px] pr-4",children:c.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:c.map(g=>{var b;return e.jsxs("div",{className:`p-4 rounded-lg ${g.is_admin_reply?"bg-primary/10 ml-4":"bg-muted mr-4"}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("span",{className:"font-medium text-sm",children:g.is_admin_reply?"Support Team":((b=g.profiles)==null?void 0:b.name)||"You"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(g.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:g.content})]},g.id)})})}),r.status!=="closed"&&e.jsxs(e.Fragment,{children:[e.jsx(rl,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Type your reply...",value:a,onChange:g=>o(g.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:p,disabled:!a.trim()||u.isPending,className:"self-end",children:e.jsx(Bn,{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(De,{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(Dv,{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(p1e,{trigger:e.jsxs(K,{size:"lg",className:"gap-2",children:[e.jsx($s,{className:"h-5 w-5"}),"Submit a Ticket"]})}),e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-muted rounded-lg",children:[e.jsx(Un,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Or text us: ",e.jsx("span",{className:"font-semibold text-foreground",children:"1-866-527-8668"})]})]})]})]})]})})}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Your Tickets"}),e.jsx(p1e,{trigger:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx($s,{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(De,{className:"text-center py-12",children:[e.jsx($c,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No tickets yet"}),e.jsx("p",{className:"text-muted-foreground",children:"You haven't submitted any support tickets. Use the button above to get started!"})]})}):e.jsx("div",{className:"space-y-3",children:l.map(f=>{const g=C5[f.status].icon;return e.jsx(Ee,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(f),children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:f.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(tt,{variant:"outline",className:"text-xs",children:h8e[f.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(f.created_at),"MMM d, yyyy")})]})]}),e.jsxs(tt,{className:C5[f.status].color,children:[e.jsx(g,{className:"h-3 w-3 mr-1"}),C5[f.status].label]})]})})},f.id)})})]})})}function OUt({open:t,onOpenChange:s}){return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(_s,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(hn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(vs,{children:"Schedule Agent Onboarding"}),e.jsx(Gr,{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 RUt({open:t,onOpenChange:s}){const{brokerageId:r}=Ds(),[n,a]=N.useState(""),[o,l]=N.useState([]),[i,c]=N.useState(!1),{data:u,isLoading:p}=mt({queryKey:["brokerage-agents-for-onboarding",r],queryFn:async()=>{if(!r)return[];const{data:j,error:w}=await H.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name",{ascending:!0});if(w)throw w;return j},enabled:t&&!!r}),f=u==null?void 0:u.filter(j=>j.name.toLowerCase().includes(n.toLowerCase())||j.email.toLowerCase().includes(n.toLowerCase())),g=j=>{l(w=>w.includes(j)?w.filter(k=>k!==j):[...w,j])},b=async()=>{if(o.length===0){me.error("Please select at least one agent");return}c(!0);try{const{data:j,error:w}=await H.functions.invoke("send-onboarding-link",{body:{agentIds:o}});if(w)throw w;me.success(`Onboarding link sent to ${o.length} agent${o.length>1?"s":""}`),l([]),s(!1)}catch(j){console.error("Error sending onboarding link:",j),me.error(j.message||"Failed to send onboarding link")}finally{c(!1)}},_=j=>{j||(l([]),a("")),s(j)};return e.jsx(fs,{open:t,onOpenChange:_,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Bn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(vs,{children:"Send Onboarding Link"}),e.jsx(Gr,{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(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:n,onChange:j=>a(j.target.value),className:"pl-10"})]}),p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):(f==null?void 0:f.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(pr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No agents found"})]}):e.jsx(Gi,{className:"h-[300px] border rounded-lg",children:e.jsx("div",{className:"p-2 space-y-1",children:f==null?void 0:f.map(j=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",onClick:()=>g(j.id),children:[e.jsx(Oo,{checked:o.includes(j.id),onCheckedChange:()=>g(j.id)}),e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{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(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{onClick:b,disabled:o.length===0||i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function FUt(){const[t,s]=N.useState(!1),[r,n]=N.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"mb-8",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(pr,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Agent Onboarding"}),e.jsx(gr,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),e.jsx(De,{children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"Schedule Agent Onboarding"]}),e.jsxs(K,{variant:"outline",onClick:()=>n(!0),className:"flex items-center gap-2",children:[e.jsx(Bn,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(OUt,{open:t,onOpenChange:s}),e.jsx(RUt,{open:r,onOpenChange:n})]})}function zUt({open:t,onOpenChange:s}){return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(_s,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(f0,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(vs,{children:"Schedule Launch Meeting"}),e.jsx(Gr,{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 BUt(){const[t,s]=N.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"mb-8",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(f0,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Launch or ReLaunch Meeting"}),e.jsx(gr,{children:"Schedule a private LevelUp information session for your brokerage. Have one of our staff host a meeting to help your team get the most out of all our trainings, tools, and resources."})]})]})}),e.jsx(De,{children:e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(f0,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx(zUt,{open:t,onOpenChange:s})]})}function $Ut(){const t=fr(),[s,r]=N.useState(""),[n,a]=N.useState(null),{data:o,isLoading:l}=mt({queryKey:["brokerage-resources-published"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resources").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(w)throw w;return j}}),{data:i}=mt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(w)throw w;return j}}),{data:c}=mt({queryKey:["brokerage-resource-pdfs-all"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resource_pdfs").select("resource_id");if(w)throw w;return j}}),{data:u}=mt({queryKey:["brokerage-resource-videos-all"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resource_videos").select("resource_id");if(w)throw w;return j}}),{data:p}=mt({queryKey:["brokerage-resource-links-all"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resource_links").select("resource_id");if(w)throw w;return j}}),f=o==null?void 0:o.filter(j=>{var S;const w=j.title.toLowerCase().includes(s.toLowerCase())||((S=j.description)==null?void 0:S.toLowerCase().includes(s.toLowerCase())),k=!n||j.category_id===n;return w&&k}),g=i==null?void 0:i.filter(j=>o==null?void 0:o.some(w=>w.category_id===j.id)),b=j=>{const w=(c==null?void 0:c.filter(M=>M.resource_id===j).length)||0,k=(u==null?void 0:u.filter(M=>M.resource_id===j).length)||0,S=(p==null?void 0:p.filter(M=>M.resource_id===j).length)||0;return{pdfCount:w,videoCount:k,linkCount:S}},_=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(FUt,{}),e.jsx(BUt,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search resources...",value:s,onChange:j=>r(j.target.value),className:"pl-10"})]}),g&&g.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(tt,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),g.map(j=>e.jsx(tt,{variant:n===j.id?"default":"outline",className:"cursor-pointer",onClick:()=>a(j.id),children:j.name},j.id))]}),!l&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(f==null?void 0:f.length)||0," resource",(f==null?void 0:f.length)!==1?"s":""," available"]}),l?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[...Array(6)].map((j,w)=>e.jsxs(Ee,{children:[e.jsx(ys,{className:"h-40 w-full"}),e.jsx(Pt,{children:e.jsx(ys,{className:"h-5 w-3/4"})}),e.jsxs(De,{children:[e.jsx(ys,{className:"h-4 w-full mb-2"}),e.jsx(ys,{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(Gh,{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:k,linkCount:S}=b(j.id),M=i==null?void 0:i.find(L=>L.id===j.category_id);return e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>_(j.id),children:[j.preview_image_url?e.jsx("img",{src:j.preview_image_url,alt:j.title,className:"w-full h-40 object-cover"}):e.jsx("div",{className:"w-full h-40 bg-muted flex items-center justify-center",children:e.jsx(Gh,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(Rt,{className:"text-lg line-clamp-1",children:j.title}),M&&e.jsx(tt,{variant:"secondary",className:"shrink-0 text-xs",children:M.name})]})}),e.jsxs(De,{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(Sn,{className:"h-4 w-4"}),w]}),k>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(An,{className:"h-4 w-4"}),k]}),S>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Bo,{className:"h-4 w-4"}),S]})]})]})]},j.id)})})]})})}const qUt=()=>{const{resourceId:t}=yo(),{data:s,isLoading:r}=mt({queryKey:["brokerage-resource-detail",t],queryFn:async()=>{const{data:a,error:o}=await H.from("brokerage_resources").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;const{data:l}=await H.from("brokerage_resource_pdfs").select("*").eq("resource_id",t).order("sort_order"),{data:i}=await H.from("brokerage_resource_videos").select("*").eq("resource_id",t).order("sort_order"),{data:c}=await H.from("brokerage_resource_links").select("*").eq("resource_id",t).order("sort_order");return{...a,pdfs:l||[],videos:i||[],links:c||[]}},enabled:!!t}),n=a=>a?a<1024?a+" B":a<1024*1024?(a/1024).toFixed(1)+" KB":(a/(1024*1024)).toFixed(1)+" MB":"";return r?e.jsx(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(Pi,{to:"/brokerage-resources",children:[e.jsx(Ja,{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(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(An,{className:"h-4 w-4"}),"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(De,{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"}),"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(Sn,{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(yi,{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(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(tn,{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(tn,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"font-medium text-sm",children:a.title})]}),e.jsx(tn,{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(Gh,{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(Pi,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function UUt(){const{onlineUsers:t,totalOnline:s}=zYe();return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),"Online Now"]}),e.jsxs(tt,{variant:"secondary",className:"bg-green-100 text-green-700",children:[e.jsx(bd,{className:"h-2 w-2 fill-green-500 text-green-500 mr-1"}),s," online"]})]})}),e.jsx(De,{children:t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No other users online right now"}):e.jsx(Gi,{className:"h-[300px] pr-4",children:e.jsx("div",{className:"space-y-3",children:t.map(r=>{var n;return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(Nn,{className:"h-9 w-9",children:[e.jsx($a,{src:r.avatarUrl,alt:r.name}),e.jsx(kn,{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 ",Uc(new Date(r.onlineSince),{addSuffix:!1})]})]})]},r.id)})})})})]})}const m8e={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:pr,path:"/admin/members",color:"bg-blue-500/10 text-blue-600"},{title:"Invite Codes",description:"Create and manage signup invite codes",icon:EL,path:"/admin/invite-codes",color:"bg-amber-500/10 text-amber-600"},{title:"Subscriptions",description:"Track and manage user subscriptions",icon:Cx,path:"/admin/subscriptions",color:"bg-gradient-to-br from-green-500/20 to-green-500/10 text-green-600"},{title:"Credit Management",description:"View and manage ReelFlow, Postcard, Letter & Check credits for all agents",icon:eL,path:"/admin/credits",color:"bg-gradient-to-br from-emerald-500/20 to-teal-500/10 text-emerald-600"},{title:"Subscription Discounts",description:"Create and manage coupon codes",icon:Fm,path:"/admin/discounts",color:"bg-red-500/10 text-red-600"},{title:"Referral Program",description:"Track brokerage referrals and discounts",icon:_d,path:"/admin/referrals",color:"bg-teal-500/10 text-teal-600"},{title:"Teams",description:"Manage agent teams across all brokerages",icon:pr,path:"/admin/members?tab=teams",color:"bg-violet-500/10 text-violet-600"},{title:"Prospector",description:"Send free trial invites and track conversions",icon:zm,path:"/admin/prospector",color:"bg-gradient-to-br from-orange-500/20 to-amber-500/10 text-orange-600"},{title:"Recruiting",description:"Manage agent recruit pipeline and outreach",icon:Tl,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:ac,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:Kh,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:ey,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:pn,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:pn,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:l1,path:"/admin/newsletters",color:"bg-violet-500/10 text-violet-600"},{title:"Manage Events",description:"Create and publish events with Zoom integration",icon:Dd,path:"/admin/events",color:"bg-green-500/10 text-green-600"},{title:"Additional Services",description:"Manage additional service offerings",icon:Gh,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:Gh,path:"/admin/brokerage-resources",color:"bg-slate-500/10 text-slate-600"},{title:"Agent Email Templates",description:"Manage curated email templates for agents",icon:cr,path:"/admin/agent-email-templates",color:"bg-rose-500/10 text-rose-600"},{title:"Mass Email Templates",description:"Create and manage shared campaign templates",icon:Ah,path:"/admin/email-campaigns/templates",color:"bg-teal-500/10 text-teal-600"}]},platform:{label:"Platform",sections:[{title:"Dashboard Management",description:"Configure banners and dashboard modules",icon:rS,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:nx,path:"/admin/apps",color:"bg-purple-500/10 text-purple-600"},{title:"Email Templates",description:"Customize system email templates",icon:cr,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:Ah,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:CM,path:"/admin/onboarding-checklist",color:"bg-emerald-500/10 text-emerald-600"},{title:"Marketplace",description:"Manage store categories, products, and orders",icon:g0,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:ko,path:"/admin/reward-store",color:"bg-purple-500/10 text-purple-600"},{title:"Agent Points",description:"View agent points, leaderboard, and award bonus points",icon:xo,path:"/admin/agent-points",color:"bg-amber-500/10 text-amber-600"},{title:"Integrations",description:"Connect Canva, Facebook & Instagram for platform-level features",icon:dl,path:"/admin/integrations",color:"bg-blue-500/10 text-blue-600"},{title:"Agent Cards",description:"Manage digital business cards for agents",icon:pr,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:Ah,path:"/admin/notification-settings",color:"bg-rose-500/10 text-rose-600"}]},community:{label:"Community & Support",sections:[{title:"Community Management",description:"Manage categories and private groups",icon:so,path:"/admin/community",color:"bg-cyan-500/10 text-cyan-600"},{title:"Support Tickets",description:"View and respond to agent support requests",icon:DM,path:"/admin/support-tickets",color:"bg-rose-500/10 text-rose-600"},{title:"Wishlist",description:"Review and manage community feature requests",icon:$_,path:"/admin/wishlist",color:"bg-yellow-500/10 text-yellow-600"},{title:"Membership Reviews",description:"View member feedback and ratings",icon:Jn,path:"/admin/membership-reviews",color:"bg-amber-500/10 text-amber-600"},{title:"Weekly Digest",description:"Configure automated weekly email digests",icon:cr,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:No,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:Sh,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:Kh,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:ni,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:bn,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:Jg,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:Sh,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:gl,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:cr,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:z_,path:"/admin/beta/homereel",color:"bg-gradient-to-br from-violet-500/20 to-indigo-500/10 text-violet-600"}]},"lead-sites":{label:"Lead Sites",sections:[{title:"All Sites",description:"Overview of all agent websites with status and quick actions",icon:su,path:"/admin/lead-sites",color:"bg-gradient-to-br from-sky-500/20 to-blue-500/10 text-sky-600"},{title:"MLS Feeds",description:"Manage MLS data feed connections, API keys, and coverage areas",icon:tL,path:"/admin/mls-feeds",color:"bg-gradient-to-br from-emerald-500/20 to-green-500/10 text-emerald-600"},{title:"Lead Analytics",description:"Cross-site lead capture stats, conversions, and top-performing sites",icon:ul,path:"/admin/lead-site-analytics",color:"bg-gradient-to-br from-amber-500/20 to-orange-500/10 text-amber-600"}]}};function VUt(){const t=fr();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(UUt,{})})]}),e.jsxs(ba,{defaultValue:"users",className:"w-full",children:[e.jsx(pa,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1 overflow-x-auto",children:Object.entries(m8e).map(([s,r])=>e.jsx(ns,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(m8e).map(([s,r])=>e.jsx(bs,{value:s,className:"mt-6",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:r.sections.map(n=>e.jsxs(Ee,{className:"cursor-pointer hover:shadow-md transition-all hover:border-primary/50 group",onClick:()=>t(n.path),children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${n.color} mb-2 group-hover:scale-110 transition-transform`,children:e.jsx(n.icon,{className:"h-5 w-5"})}),e.jsx(Rt,{className:"text-base",children:n.title})]}),e.jsx(De,{className:"pt-0",children:e.jsx(gr,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const Rn=N.forwardRef(({className:t,...s},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:It("w-full caption-bottom text-sm",t),...s})}));Rn.displayName="Table";const Fn=N.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:It("[&_tr]:border-b",t),...s}));Fn.displayName="TableHeader";const zn=N.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:It("[&_tr:last-child]:border-0",t),...s}));zn.displayName="TableBody";const HUt=N.forwardRef(({className:t,...s},r)=>e.jsx("tfoot",{ref:r,className:It("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));HUt.displayName="TableFooter";const Ss=N.forwardRef(({className:t,...s},r)=>e.jsx("tr",{ref:r,className:It("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...s}));Ss.displayName="TableRow";const St=N.forwardRef(({className:t,...s},r)=>e.jsx("th",{ref:r,className:It("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));St.displayName="TableHead";const dt=N.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:It("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));dt.displayName="TableCell";const WUt=N.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:It("mt-4 text-sm text-muted-foreground",t),...s}));WUt.displayName="TableCaption";const GUt=()=>{const{isAdmin:t}=Ds(),s=fr(),[r,n]=N.useState([]),[a,o]=N.useState(!0),[l,i]=N.useState(!1),[c,u]=N.useState(null);N.useEffect(()=>{if(!t){s("/dashboard");return}p()},[t]);const p=async()=>{try{const{data:j,error:w}=await H.from("app_tiles").select("*").order("name");if(w)throw w;n(j||[])}catch(j){console.error("Error loading apps:",j),me.error("Failed to load apps")}finally{o(!1)}},f=async j=>{j.preventDefault();const w=new FormData(j.currentTarget),k={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(S=>S.trim()).filter(Boolean)};try{if(c){const{error:S}=await H.from("app_tiles").update(k).eq("id",c.id);if(S)throw S;me.success("App updated successfully")}else{const{error:S}=await H.from("app_tiles").insert([k]);if(S)throw S;me.success("App created successfully")}i(!1),u(null),p()}catch(S){console.error("Error saving app:",S),me.error("Failed to save app")}},g=async j=>{if(confirm("Are you sure you want to delete this app?"))try{const{error:w}=await H.from("app_tiles").delete().eq("id",j);if(w)throw w;me.success("App deleted successfully"),p()}catch(w){console.error("Error deleting app:",w),me.error("Failed to delete app")}},b=j=>{u(j),i(!0)},_=()=>{u(null),i(!0)};return a?e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/dashboard"),children:[e.jsx(Ja,{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(fs,{open:l,onOpenChange:i,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:_,children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Add App"]})}),e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:c?"Edit App":"Create New App"}),e.jsx(Gr,{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(ze,{id:"name",name:"name",defaultValue:c==null?void 0:c.name,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"app_id",children:"App ID"}),e.jsx(ze,{id:"app_id",name:"app_id",defaultValue:c==null?void 0:c.app_id,placeholder:"agent_connect",required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",name:"description",defaultValue:c==null?void 0:c.description})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"icon",children:"Icon (emoji)"}),e.jsx(ze,{id:"icon",name:"icon",defaultValue:c==null?void 0:c.icon,placeholder:"🚀",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"target_url",children:"Target URL"}),e.jsx(ze,{id:"target_url",name:"target_url",type:"url",defaultValue:c==null?void 0:c.target_url,required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"required_tags",children:"Required Tags (comma-separated)"}),e.jsx(ze,{id:"required_tags",name:"required_tags",defaultValue:c==null?void 0:c.required_tags.join(", "),placeholder:"levelup-member, agent-connect"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{type:"submit",children:c?"Update":"Create"})]})]})]})]})]})})}),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Application Tiles"}),e.jsx(gr,{children:"Manage the apps that appear on the member dashboard"})]}),e.jsx(De,{children:r.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsxs(K,{onClick:_,children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Create First App"]})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Icon"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"App ID"}),e.jsx(St,{children:"Target URL"}),e.jsx(St,{children:"Tags"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:r.map(j=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"text-2xl",children:j.icon}),e.jsx(dt,{className:"font-medium",children:j.name}),e.jsx(dt,{className:"font-mono text-sm",children:j.app_id}),e.jsx(dt,{className:"text-sm text-muted-foreground max-w-xs truncate",children:j.target_url}),e.jsx(dt,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:j.required_tags.map(w=>e.jsx("span",{className:"text-xs bg-secondary text-secondary-foreground px-2 py-1 rounded",children:w},w))})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>b(j),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>g(j.id),children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},j.id))})]})})]})})]})};function oh({title:t,description:s,children:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Pi,{to:"/admin",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(Ja,{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 p8e=({expiresAt:t,className:s})=>{const r=new Date().getTime(),n=new Date(t).getTime(),a=Math.ceil((n-r)/(1e3*60*60*24));return a<=0?e.jsxs(tt,{variant:"destructive",className:It("gap-1",s),children:[e.jsx(Ku,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(tt,{variant:"destructive",className:It("gap-1",s),children:[e.jsx(un,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(tt,{className:It("gap-1 bg-amber-500 hover:bg-amber-600",s),children:[e.jsx(un,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):e.jsxs(tt,{variant:"secondary",className:It("gap-1",s),children:[e.jsx(un,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},stt=({open:t,onOpenChange:s,brokerages:r,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=Ua(),l=N.useRef(null),[i,c]=N.useState([]),[u,p]=N.useState(""),[f,g]=N.useState(!1),[b,_]=N.useState("upload"),[j,w]=N.useState(null),k=()=>{c([]),p(""),_("upload"),w(null),l.current&&(l.current.value="")},S=()=>{k(),s(!1)},M=U=>{const B=U.split(` `).map(Q=>Q.trim()).filter(Q=>Q);if(B.length===0)return[];const V=B[0].toLowerCase(),X=V.includes("first")||V.includes("last")||V.includes("email")||V.includes("name")||V.includes("phone")||V.includes("sms")||V.includes("consent")?B.slice(1):B,ee=[];for(const Q of X){const re=(Q.includes(" ")?Q.split(" "):Q.split(",")).map(oe=>oe.trim().replace(/^["']|["']$/g,""));if(re.length>=2){let oe="",ce="",xe="",ge="",ue;if(re.length===2){const Me=re[0].split(" ");oe=Me[0]||"",ce=Me.slice(1).join(" ")||"",xe=re[1]}else if(re.length===3)oe=re[0],ce=re[1],xe=re[2];else if(re.length===4)oe=re[0],ce=re[1],xe=re[2],ge=re[3];else if(re.length>=5){oe=re[0],ce=re[1],xe=re[2],ge=re[3];const Me=re[4].toLowerCase();ue=Me==="true"||Me==="yes"||Me==="1"||Me==="y"}const be=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(xe);ee.push({firstName:oe.trim(),lastName:ce.trim(),email:xe.trim().toLowerCase(),phone:ge.trim()||void 0,smsConsent:ue,isValid:be&&oe.trim().length>0,error:be?oe.trim()?void 0:"Missing name":"Invalid email"})}}return ee},L=U=>{var Z;const B=(Z=U.target.files)==null?void 0:Z[0];if(!B)return;const V=new FileReader;V.onload=X=>{var ie;const ee=(ie=X.target)==null?void 0:ie.result,Q=M(ee);if(Q.length===0){o({title:"No data found",description:"The CSV file appears to be empty or in an unsupported format.",variant:"destructive"});return}c(Q),_("preview")},V.readAsText(B)},I=async()=>{const U=i.filter(V=>V.isValid);if(U.length===0){o({title:"No valid users",description:"There are no valid users to import.",variant:"destructive"});return}const B=n||u||null;g(!0);try{const{data:{session:V}}=await H.auth.getSession(),Z=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/bulk-create-users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${V==null?void 0:V.access_token}`},body:JSON.stringify({users:U.map(ee=>({firstName:ee.firstName,lastName:ee.lastName,email:ee.email,phone:ee.phone,smsConsent:ee.smsConsent})),brokerageId:B})}),X=await Z.json();if(!Z.ok)throw new Error(X.error||"Failed to import users");w(X),_("result"),X.created>0&&a(),o({title:"Import Complete",description:`${X.created} user(s) created successfully.${X.failed>0?` ${X.failed} failed.`:""}`})}catch(V){console.error("Import error:",V),o({title:"Import Failed",description:V.message||"Failed to import users",variant:"destructive"})}finally{g(!1)}},O=i.filter(U=>U.isValid).length,q=i.filter(U=>!U.isValid).length;return e.jsx(fs,{open:t,onOpenChange:S,children:e.jsxs(ps,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(r1,{className:"h-5 w-5"}),"Import Agents from CSV"]}),e.jsx(Gr,{children:"Upload a CSV file with agent information. Each row should contain First Name, Last Name, and Email."})]}),b==="upload"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx("input",{type:"file",accept:".csv,.txt",ref:l,onChange:L,className:"hidden"}),e.jsx(li,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click to upload or drag and drop a CSV file"}),e.jsx(K,{onClick:()=>{var U;return(U=l.current)==null?void 0:U.click()},children:"Select CSV File"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm",children:[e.jsx("p",{className:"font-medium mb-2",children:"Expected CSV Format:"}),e.jsxs("code",{className:"text-xs block bg-background p-2 rounded",children:["First Name, Last Name, Email, Phone, SMS Consent",e.jsx("br",{}),"John, Doe, john@example.com, 555-123-4567, yes",e.jsx("br",{}),"Jane, Smith, jane@example.com, 555-987-6543, true"]}),e.jsx("p",{className:"text-muted-foreground mt-2 text-xs",children:"Phone and SMS Consent columns are optional. SMS Consent accepts: yes/no, true/false, 1/0, y/n."})]})]}),b==="preview"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[!n&&r&&r.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Assign to Brokerage (optional)"}),e.jsxs(Zs,{value:u||"none",onValueChange:U=>p(U==="none"?"":U),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select a brokerage..."})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:"No brokerage"}),r.map(U=>e.jsx(Mt,{value:U.id,children:U.name},U.id))]})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4 text-green-500"}),e.jsxs("span",{children:[O," valid"]})]}),q>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(kl,{className:"h-4 w-4"}),e.jsxs("span",{children:[q," invalid"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/30",children:[e.jsx(St,{children:"First Name"}),e.jsx(St,{children:"Last Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Phone"}),e.jsx(St,{children:"SMS"}),e.jsx(St,{children:"Status"})]})}),e.jsx(zn,{children:i.slice(0,100).map((U,B)=>e.jsxs(Ss,{children:[e.jsx(dt,{children:U.firstName}),e.jsx(dt,{children:U.lastName}),e.jsx(dt,{children:U.email}),e.jsx(dt,{className:"text-muted-foreground",children:U.phone||"-"}),e.jsx(dt,{className:"text-muted-foreground",children:U.smsConsent===!0?"✓":U.smsConsent===!1?"✗":"-"}),e.jsx(dt,{children:U.isValid?e.jsx(tt,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(tt,{variant:"destructive",children:U.error||"Invalid"})})]},B))})]}),i.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",i.length," users"]})]})]}),b==="result"&&j&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(sa,{className:"h-12 w-12 mx-auto text-green-500 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:[j.created," agent(s) created and invited"]}),j.failed>0&&e.jsxs("p",{className:"text-destructive mt-1",children:[j.failed," failed to create"]})]}),j.errors.length>0&&e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 max-h-40 overflow-auto",children:[e.jsx("p",{className:"font-medium text-destructive text-sm mb-2",children:"Errors:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[j.errors.slice(0,10).map((U,B)=>e.jsxs("li",{children:["• ",U]},B)),j.errors.length>10&&e.jsxs("li",{children:["...and ",j.errors.length-10," more"]})]})]})]}),e.jsxs(qn,{children:[b==="upload"&&e.jsx(K,{variant:"outline",onClick:S,children:"Cancel"}),b==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:k,children:"Back"}),e.jsx(K,{onClick:I,disabled:f||O===0,children:f?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${O} Agent${O!==1?"s":""}`})]}),b==="result"&&e.jsx(K,{onClick:S,children:"Done"})]})]})})};function yl({sortKey:t,currentSortKey:s,currentDirection:r,onSort:n,children:a,className:o,...l}){const i=s===t;return e.jsx(St,{className:It("cursor-pointer select-none",o),...l,children:e.jsxs("button",{type:"button",className:"flex items-center gap-1 font-semibold hover:text-foreground transition-colors w-full text-left",onClick:()=>n(t),children:[a,i?r==="asc"?e.jsx(ku,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Wh,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(vd,{className:"h-3.5 w-3.5 shrink-0 opacity-40"})]})})}function YO(t=null,s=null){const[r,n]=N.useState(t),[a,o]=N.useState(s),l=N.useCallback(c=>{r===c?a==="asc"?o("desc"):a==="desc"?(n(null),o(null)):o("asc"):(n(c),o("asc"))},[r,a]),i=N.useCallback((c,u)=>{if(!r||!a||!u[r])return c;const p=u[r];return[...c].sort((f,g)=>{const b=p(f),_=p(g);if(b==null&&_==null)return 0;if(b==null)return 1;if(_==null)return-1;let j;return typeof b=="string"&&typeof _=="string"?j=b.localeCompare(_,void 0,{sensitivity:"base"}):j=b-_,a==="asc"?j:-j})},[r,a]);return{sortKey:r,sortDirection:a,handleSort:l,sortData:i}}const KUt=[{type:"custom",title:"Great job!",message:"Keep up the amazing work!",icon:Jn},{type:"custom",title:"You're on fire!",message:"Your dedication is inspiring!",icon:xo},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:ru}];function rtt({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=N.useState("custom"),[l,i]=N.useState(""),[c,u]=N.useState(""),p=rNt(),f=b=>{o(b.type),i(b.title),u(b.message)},g=async b=>{if(b.preventDefault(),!l.trim()){wn({title:"Title required",description:"Please enter a celebration title",variant:"destructive"});return}try{await p.mutateAsync({user_id:r,celebration_type:a,title:l.trim(),message:c.trim()||void 0}),wn({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),u(""),o("custom")}catch{wn({title:"Error",description:"Failed to send celebration",variant:"destructive"})}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(ru,{className:"h-5 w-5 text-primary"}),"Send Celebration to ",n]}),e.jsx(Gr,{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:KUt.map((b,_)=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>f(b),className:"text-xs",children:[e.jsx(b.icon,{className:"h-3 w-3 mr-1"}),b.title]},_))})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"type",children:"Celebration Type"}),e.jsxs(Zs,{value:a,onValueChange:b=>o(b),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"custom",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Jn,{className:"h-4 w-4"})," Custom"]})}),e.jsx(Mt,{value:"points_earned",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-4 w-4"})," Points Earned"]})}),e.jsx(Mt,{value:"listing_created",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bn,{className:"h-4 w-4"})," Listing Created"]})}),e.jsx(Mt,{value:"deal_closed",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nc,{className:"h-4 w-4"})," Deal Closed"]})})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:l,onChange:b=>i(b.target.value),placeholder:"e.g., Congratulations!",maxLength:100})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"message",children:"Message (optional)"}),e.jsx(Er,{id:"message",value:c,onChange:b=>u(b.target.value),placeholder:"Add a personal message...",rows:3,maxLength:500})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:p.isPending,children:[e.jsx(ru,{className:"h-4 w-4 mr-2"}),p.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const Pge={points_earned:{label:"Points Earned",icon:xo,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:bn,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:nc,color:"bg-green-500"},custom:{label:"Custom",icon:pn,color:"bg-purple-500"}};function ZUt(){const[t,s]=N.useState(""),[r,n]=N.useState("all"),[a,o]=N.useState("all"),{data:l=[],isLoading:i}=mt({queryKey:["admin-celebrations"],queryFn:async()=>{const{data:p,error:f}=await H.from("celebration_queue").select("*").order("created_at",{ascending:!1}).limit(500);if(f)throw f;const g=[...new Set([...p.map(j=>j.user_id),...p.map(j=>j.created_by).filter(Boolean)])],{data:b}=await H.from("profiles").select("id, name, email").in("id",g),_=new Map((b==null?void 0:b.map(j=>[j.id,j]))||[]);return p.map(j=>{var w,k,S;return{...j,user_name:((w=_.get(j.user_id))==null?void 0:w.name)||"Unknown",user_email:((k=_.get(j.user_id))==null?void 0:k.email)||"",creator_name:j.created_by?((S=_.get(j.created_by))==null?void 0:S.name)||"System":"Auto-triggered"}})}}),c=l.filter(p=>{var _,j;const f=((_=p.user_name)==null?void 0:_.toLowerCase().includes(t.toLowerCase()))||((j=p.user_email)==null?void 0:j.toLowerCase().includes(t.toLowerCase()))||p.title.toLowerCase().includes(t.toLowerCase()),g=r==="all"||p.celebration_type===r,b=a==="all"||a==="seen"&&p.seen_at||a==="unseen"&&!p.seen_at;return f&&g&&b}),u={total:l.length,seen:l.filter(p=>p.seen_at).length,unseen:l.filter(p=>!p.seen_at).length,byType:Object.keys(Pge).reduce((p,f)=>(p[f]=l.filter(g=>g.celebration_type===f).length,p),{})};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium",children:"Total Celebrations"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:u.total})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-green-600",children:"Seen"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:u.seen})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:u.unseen})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:u.byType.custom||0})})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(ru,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(gr,{children:"View all celebrations awarded to agents"})]}),e.jsxs(De,{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(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by agent name, email, or title...",value:t,onChange:p=>s(p.target.value),className:"pl-9"})]}),e.jsxs(Zs,{value:r,onValueChange:n,children:[e.jsx(Ws,{className:"w-[180px]",children:e.jsx(Xs,{placeholder:"Filter by type"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),Object.entries(Pge).map(([p,f])=>e.jsx(Mt,{value:p,children:f.label},p))]})]}),e.jsxs(Zs,{value:a,onValueChange:o,children:[e.jsx(Ws,{className:"w-[140px]",children:e.jsx(Xs,{placeholder:"Status"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Status"}),e.jsx(Mt,{value:"seen",children:"Seen"}),e.jsx(Mt,{value:"unseen",children:"Pending"})]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Points"}),e.jsx(St,{children:"Created By"}),e.jsx(St,{children:"Created"}),e.jsx(St,{children:"Status"})]})}),e.jsx(zn,{children:c.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):c.map(p=>{const f=Pge[p.celebration_type],g=f.icon;return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(g,{className:"h-3 w-3"}),f.label]})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:p.user_name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:p.user_email})]})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:p.title}),p.message&&e.jsx("div",{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:p.message})]})}),e.jsx(dt,{children:p.points_amount?e.jsxs(tt,{variant:"secondary",children:["+",p.points_amount]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:p.creator_name})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ms(new Date(p.created_at),"MMM d, yyyy h:mm a")})}),e.jsx(dt,{children:p.seen_at?e.jsx(tt,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):e.jsx(tt,{variant:"outline",className:"bg-orange-50 text-orange-700 border-orange-200",children:"Pending"})})]},p.id)})})]})}),c.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-right",children:["Showing ",c.length," of ",l.length," celebrations"]})]})]})]})}const YUt=()=>{const{user:t}=Ds(),{toast:s}=Ua(),[r,n]=N.useState([]),[a,o]=N.useState(!0),[l,i]=N.useState(!1),[c,u]=N.useState("all"),[p,f]=N.useState("all"),[g,b]=N.useState("new"),[_,j]=N.useState(new Set),w=N.useCallback(async()=>{try{o(!0);const{data:ee,error:Q}=await H.from("profiles").select("id, name, email, phone, is_trial, trial_started_at, trial_expires_at, subscription_status, subscription_end_date, converted_from_trial_at, created_at").or("is_trial.eq.true,subscription_status.eq.trialing,converted_from_trial_at.not.is.null");if(Q)throw Q;const{data:ie,error:re}=await H.from("trial_email_exports").select("user_id");if(re)throw re;const oe=new Set((ie||[]).map(xe=>xe.user_id)),ce=(ee||[]).map(xe=>({...xe,converted_from_trial_at:xe.converted_from_trial_at??null,already_exported:oe.has(xe.id)}));ce.sort((xe,ge)=>new Date(ge.created_at).getTime()-new Date(xe.created_at).getTime()),n(ce)}catch(ee){console.error("Error loading trial users:",ee),s({title:"Error",description:"Failed to load trial users",variant:"destructive"})}finally{o(!1)}},[s]);N.useEffect(()=>{w()},[w]);const k=ee=>ee.trial_started_at?"ghl":"stripe",S=ee=>ee.trial_expires_at?ee.trial_expires_at:ee.subscription_end_date?ee.subscription_end_date:null,M=ee=>ee.converted_from_trial_at!==null,L=ee=>{if(M(ee))return!1;const Q=S(ee);return Q?new Date(Q).getTime()<=Date.now():!1},I=r.filter(ee=>!(c!=="all"&&k(ee)!==c||p==="active"&&(L(ee)||M(ee))||p==="expired"&&!L(ee)||p==="converted"&&!M(ee)||g==="new"&&ee.already_exported||g==="exported"&&!ee.already_exported)),O=()=>{_.size===I.length?j(new Set):j(new Set(I.map(ee=>ee.id)))},q=ee=>{const Q=new Set(_);Q.has(ee)?Q.delete(ee):Q.add(ee),j(Q)},U=async()=>{if(_.size===0){s({title:"No users selected",description:"Select users to export",variant:"destructive"});return}i(!0);try{const ee=r.filter(ue=>_.has(ue.id)),Q="First Name,Last Name,Email,Phone,Trial Type,Status,Signup Date,Expiry Date",ie=ee.map(ue=>{const pe=(ue.name||"").split(" "),be=pe[0]||"",Me=pe.slice(1).join(" ")||"",Ne=k(ue)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Pe=M(ue)?"Converted":L(ue)?"Expired":"Active",Oe=ue.created_at?new Date(ue.created_at).toLocaleDateString():"",Te=S(ue)?new Date(S(ue)).toLocaleDateString():"";return`"${be}","${Me}","${ue.email}","${ue.phone||""}","${Ne}","${Pe}","${Oe}","${Te}"`}),re=[Q,...ie].join(` `),oe=new Blob([re],{type:"text/csv"}),ce=URL.createObjectURL(oe),xe=document.createElement("a");xe.href=ce,xe.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,xe.click(),URL.revokeObjectURL(ce);const ge=ee.filter(ue=>!ue.already_exported).map(ue=>({user_id:ue.id,exported_by:t.id}));if(ge.length>0){const{error:ue}=await H.from("trial_email_exports").upsert(ge,{onConflict:"user_id"});ue&&console.error("Error marking exports:",ue)}s({title:"Export complete",description:`Downloaded ${ee.length} trial user(s). ${ge.length} newly marked as exported.`}),j(new Set),w()}catch(ee){console.error("Export error:",ee),s({title:"Error",description:"Failed to export",variant:"destructive"})}finally{i(!1)}},B=r.filter(ee=>!ee.already_exported).length,V=r.filter(ee=>ee.already_exported).length,Z=r.filter(ee=>M(ee)).length,X=r.filter(ee=>!L(ee)&&!M(ee)).length;return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Total"}),e.jsx(Rt,{className:"text-2xl",children:r.length})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"New (Not Exported)"}),e.jsx(Rt,{className:"text-2xl text-green-600",children:B})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Active Trials"}),e.jsx(Rt,{className:"text-2xl",children:X})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Converted 🎉"}),e.jsx(Rt,{className:"text-2xl text-primary",children:Z})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Already Exported"}),e.jsx(Rt,{className:"text-2xl text-muted-foreground",children:V})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(Zs,{value:g,onValueChange:ee=>b(ee),children:[e.jsx(Ws,{className:"w-[160px]",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Users"}),e.jsx(Mt,{value:"new",children:"New Only"}),e.jsx(Mt,{value:"exported",children:"Already Exported"})]})]}),e.jsxs(Zs,{value:c,onValueChange:ee=>u(ee),children:[e.jsx(Ws,{className:"w-[180px]",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Trial Types"}),e.jsx(Mt,{value:"stripe",children:"Credit Card Trial"}),e.jsx(Mt,{value:"ghl",children:"Free Trial (No CC)"})]})]}),e.jsxs(Zs,{value:p,onValueChange:ee=>f(ee),children:[e.jsx(Ws,{className:"w-[160px]",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Statuses"}),e.jsx(Mt,{value:"active",children:"Active Trial"}),e.jsx(Mt,{value:"expired",children:"Expired"}),e.jsx(Mt,{value:"converted",children:"Converted ✓"})]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(K,{onClick:U,disabled:l||_.size===0,children:[l?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Export Selected (",_.size,")"]})})]}),e.jsx("div",{className:"border rounded-lg",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Oo,{checked:I.length>0&&_.size===I.length,onCheckedChange:O})}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Trial Type"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Signup Date"}),e.jsx(St,{children:"Expires / Renews"}),e.jsx(St,{children:"Exported"})]})}),e.jsx(zn,{children:I.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No trial users match the current filters"})}):I.map(ee=>{const Q=k(ee),ie=M(ee),re=L(ee),oe=S(ee);return e.jsxs(Ss,{className:`hover:bg-muted/30 ${ie?"bg-primary/5":""}`,children:[e.jsx(dt,{children:e.jsx(Oo,{checked:_.has(ee.id),onCheckedChange:()=>q(ee.id)})}),e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ee.name,ie&&e.jsx(ul,{className:"h-3.5 w-3.5 text-primary"})]})}),e.jsx(dt,{className:"text-muted-foreground",children:ee.email}),e.jsx(dt,{children:Q==="stripe"?e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(Cx,{className:"h-3 w-3"}),"Credit Card"]}):e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[e.jsx(cr,{className:"h-3 w-3"}),"Free (No CC)"]})}),e.jsx(dt,{children:ie?e.jsxs(tt,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[e.jsx(ul,{className:"h-3 w-3"}),"Converted"]}):re?e.jsx(tt,{variant:"destructive",children:"Expired"}):e.jsx(tt,{className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active Trial"})}),e.jsx(dt,{className:"text-sm",children:ee.created_at?new Date(ee.created_at).toLocaleDateString():"—"}),e.jsx(dt,{className:"text-sm",children:ie&&oe?e.jsxs("span",{className:"text-muted-foreground",children:["Renews ",new Date(oe).toLocaleDateString()]}):oe?new Date(oe).toLocaleDateString():"—"}),e.jsx(dt,{children:ee.already_exported?e.jsx(sa,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(tt,{variant:"outline",className:"text-green-600 border-green-300",children:"New"})})]},ee.id)})})]})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",I.length," of ",r.length," trial users · ",Z," converted to paid"]})]})},XUt=()=>{const[t,s]=N.useState([]),[r,n]=N.useState(!0);return N.useEffect(()=>{(async()=>{const{data:o,error:l}=await H.from("user_deletion_log").select("*").order("created_at",{ascending:!1});!l&&o&&s(o),n(!1)})()},[]),r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(Nr,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{children:"No deletion records yet"})]})}):e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"User Deletion History"})}),e.jsx(De,{children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Date"}),e.jsx(St,{children:"User"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Brokerage"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Deleted By"})]})}),e.jsx(zn,{children:t.map(a=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"whitespace-nowrap text-sm",children:ms(new Date(a.created_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{className:"font-medium",children:a.deleted_user_name||"—"}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:a.deleted_user_email||"—"}),e.jsx(dt,{children:a.brokerage_name||"—"}),e.jsx(dt,{children:e.jsx(tt,{variant:a.deletion_type==="deleted"?"destructive":"secondary",children:a.deletion_type==="deleted"?"Account Deleted":"Removed"})}),e.jsx(dt,{className:"text-sm",children:a.deleted_by_name||a.deleted_by_email||"—"})]},a.id))})]})})]})},bC=t=>{const{user:s}=Ds(),r=Qt(),n=mt({queryKey:["teams",t],queryFn:async()=>{let f=H.from("teams").select("*").order("created_at",{ascending:!1});t&&(f=f.eq("brokerage_id",t));const{data:g,error:b}=await f;if(b)throw b;return g||[]},enabled:!!s}),a=f=>mt({queryKey:["team-members",f],queryFn:async()=>{const{data:g,error:b}=await H.from("team_members").select("*").eq("team_id",f).order("role",{ascending:!0});if(b)throw b;const _=(g||[]).map(k=>k.user_id),{data:j}=await H.from("profiles").select("id, name, email, avatar_url").in("id",_),w=new Map((j||[]).map(k=>[k.id,k]));return(g||[]).map(k=>({...k,profile:w.get(k.user_id)||null}))},enabled:!!f}),o=Dt({mutationFn:async f=>{const g={name:f.name,created_by:s.id,description:f.description,contact_visibility:f.contact_visibility,lead_pond_enabled:f.lead_pond_enabled,shared_assets_enabled:f.shared_assets_enabled};f.brokerage_id&&(g.brokerage_id=f.brokerage_id);const{data:b,error:_}=await H.from("teams").insert(g).select().single();if(_)throw _;return b},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),me.success("Team created!")},onError:f=>{me.error("Failed to create team: "+f.message)}}),l=Dt({mutationFn:async({id:f,...g})=>{const{data:b,error:_}=await H.from("teams").update(g).eq("id",f).select().single();if(_)throw _;return b},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),me.success("Team updated")},onError:f=>{me.error("Failed to update team: "+f.message)}}),i=Dt({mutationFn:async f=>{const{error:g}=await H.from("teams").delete().eq("id",f);if(g)throw g},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),me.success("Team deleted")},onError:f=>{me.error("Failed to delete team: "+f.message)}}),c=Dt({mutationFn:async f=>{const{data:g,error:b}=await H.from("team_members").insert({team_id:f.team_id,user_id:f.user_id,role:f.role||"team_member"}).select().single();if(b)throw b.message.includes("duplicate")||b.message.includes("unique")?new Error("This agent is already on a team. They must be removed from their current team first."):b;return g},onSuccess:(f,g)=>{r.invalidateQueries({queryKey:["team-members",g.team_id]}),me.success("Member added to team")},onError:f=>{me.error(f.message)}}),u=Dt({mutationFn:async f=>{const{error:g}=await H.from("team_members").delete().eq("id",f.member_id);if(g)throw g},onSuccess:(f,g)=>{r.invalidateQueries({queryKey:["team-members",g.team_id]}),me.success("Member removed from team")},onError:f=>{me.error("Failed to remove member: "+f.message)}}),p=Dt({mutationFn:async f=>{const{error:g}=await H.from("team_members").update({role:f.role}).eq("id",f.member_id);if(g)throw g},onSuccess:(f,g)=>{r.invalidateQueries({queryKey:["team-members",g.team_id]}),me.success("Member role updated")},onError:f=>{me.error("Failed to update role: "+f.message)}});return{teams:n.data||[],isLoading:n.isLoading,createTeam:o,updateTeam:l,deleteTeam:i,addMember:c,removeMember:u,updateMemberRole:p,useTeamMembers:a}},QUt=()=>{const{user:t}=Ds();return mt({queryKey:["team-contacts",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.rpc("get_team_contacts",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},ntt=t=>{const{user:s}=Ds(),r=Qt(),n=mt({queryKey:["lead-pond",t],queryFn:async()=>{const{data:i,error:c}=await H.from("team_lead_pond").select("*").eq("team_id",t).order("created_at",{ascending:!1});if(c)throw c;if(!i||i.length===0)return[];const u=i.map(k=>k.contact_id),p=[...new Set(i.map(k=>k.added_by))],f=i.filter(k=>k.claimed_by).map(k=>k.claimed_by),g=[...new Set([...p,...f])],[b,_]=await Promise.all([H.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",u),H.from("profiles").select("id, name, avatar_url").in("id",g)]),j=new Map((b.data||[]).map(k=>[k.id,k])),w=new Map((_.data||[]).map(k=>[k.id,k]));return i.map(k=>({...k,status:k.claimed_by?"claimed":"available",contact:j.get(k.contact_id)||null,contributor:w.get(k.added_by)||null,claimer:k.claimed_by&&w.get(k.claimed_by)||null}))},enabled:!!t&&!!s}),a=Dt({mutationFn:async i=>{const{data:c,error:u}=await H.rpc("add_to_lead_pond",{_contact_id:i.contact_id,_team_id:i.team_id,_notes:i.notes||null});if(u)throw u;return c},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),me.success("Contact added to Lead Pond")},onError:i=>{me.error(i.message)}}),o=Dt({mutationFn:async i=>{const{error:c}=await H.rpc("claim_lead_pond_contact",{_lead_pond_id:i});if(c)throw c},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),me.success("Lead claimed!")},onError:i=>{me.error(i.message)}}),l=Dt({mutationFn:async i=>{const{error:c}=await H.rpc("return_lead_pond_contact",{_lead_pond_id:i});if(c)throw c},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),me.success("Lead returned to pond")},onError:i=>{me.error(i.message)}});return{leadPondItems:n.data||[],isLoading:n.isLoading,addToLeadPond:a,claimLead:o,returnLead:l}},JUt=()=>{const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.rpc("transfer_contact",{_contact_id:s.contactId,_to_user_id:s.toUserId,_notes:s.notes||null});if(n)throw n;const a=r;if(!a.success)throw new Error(a.error);return a},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["team-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),me.success("Contact transferred successfully")},onError:s=>{me.error(s.message||"Failed to transfer contact")}})};function att({open:t,onOpenChange:s,contactIds:r,contactNames:n=[],onComplete:a}){var I;const{user:o}=Ds(),{data:l}=Bx(),{useTeamMembers:i}=bC(),{data:c=[]}=i((l==null?void 0:l.teamId)||""),u=JUt(),[p,f]=N.useState(null),[g,b]=N.useState(""),[_,j]=N.useState(!1),w=c.filter(O=>O.user_id!==(o==null?void 0:o.id)),k=async()=>{if(p){j(!0);try{for(const O of r)await u.mutateAsync({contactId:O,toUserId:p,notes:g||void 0});s(!1),f(null),b(""),a==null||a()}catch{}finally{j(!1)}}},S=w.find(O=>O.user_id===p),M=r.length>1,L=n.length>0?M?`${n.length} contacts`:n[0]:M?`${r.length} contacts`:"this contact";return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(e1,{className:"h-5 w-5"}),"Transfer ",L]}),e.jsxs(Gr,{children:["Select a team member to transfer ",M?"these contacts":"this contact"," to. The contact will be removed from the current owner's CRM and added to the selected member's."]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{children:[e.jsx(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(O=>{var q,U,B;return e.jsxs("button",{onClick:()=>f(O.user_id),className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${p===O.user_id?"bg-primary/10 border border-primary/30":"hover:bg-accent border border-transparent"}`,children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:((q=O.profile)==null?void 0:q.avatar_url)||""}),e.jsx(kn,{className:"text-xs",children:(((U=O.profile)==null?void 0:U.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:((B=O.profile)==null?void 0:B.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:O.role.replace("_"," ")})]})]},O.user_id)})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"transfer-notes",className:"text-sm font-medium",children:"Notes (optional)"}),e.jsx(Er,{id:"transfer-notes",value:g,onChange:O=>b(O.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:k,disabled:!p||_,children:[_?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(e1,{className:"h-4 w-4 mr-2"}),"Transfer",S?` to ${(I=S.profile)==null?void 0:I.name}`:""]})]})]})})}const Dke=()=>{const t=fr(),{data:s,isLoading:r}=QUt(),{data:n}=Bx(),[a,o]=N.useState(""),[l,i]=N.useState("all"),[c,u]=N.useState(null),[p,f]=N.useState(""),g=(n==null?void 0:n.role)==="team_leader",b=N.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]),_=N.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(k=>{var S,M,L;return(k.first_name+" "+(k.last_name||"")).toLowerCase().includes(w)||((S=k.email)==null?void 0:S.toLowerCase().includes(w))||((M=k.phone)==null?void 0:M.includes(w))||((L=k.owner_name)==null?void 0:L.toLowerCase().includes(w))})}return j},[s,a,l]);return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(ys,{className:"h-10 w-full"}),e.jsx(ys,{className:"h-64 w-full"})]}):!s||s.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pr,{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(De,{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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, phone, or agent...",value:a,onChange:j=>o(j.target.value),className:"pl-9"})]}),e.jsxs(Zs,{value:l,onValueChange:i,children:[e.jsx(Ws,{className:"w-[200px]",children:e.jsx(Xs,{placeholder:"Filter by agent"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Team Members"}),b.map(j=>e.jsx(Mt,{value:j.id,children:j.name},j.id))]})]})]})})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[_.length," contact",_.length!==1?"s":""," from ",b.length," teammate",b.length!==1?"s":""]}),e.jsx(Ee,{children:e.jsx(De,{className:"p-0 overflow-x-auto",children:e.jsxs(Rn,{className:"min-w-[800px]",children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Contact Info"}),e.jsx(St,{children:"Address"}),e.jsx(St,{children:"Lead Source"}),e.jsx(St,{children:"Date Added"}),g&&e.jsx(St,{className:"w-[80px]",children:"Actions"})]})}),e.jsx(zn,{children:_.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:g?7:6,className:"text-center py-8 text-muted-foreground",children:a||l!=="all"?"No contacts match your filters":"No team contacts available"})}):_.map(j=>e.jsxs(Ss,{className:`hover:bg-accent/50 ${g?"cursor-pointer":""}`,onClick:g?()=>t(`/mission-control/contacts/${j.id}`):void 0,children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("span",{className:g?"hover:text-primary hover:underline transition-colors":"",children:[j.first_name," ",j.last_name||""]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx($a,{src:j.owner_avatar_url||""}),e.jsx(kn,{className:"text-[10px]",children:(j.owner_name||"?").charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:j.owner_name||"Unknown"})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[j.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(cr,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:j.email})]}),j.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Un,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:j.phone})]}),!j.email&&!j.phone&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No contact info"})]})}),e.jsx(dt,{children:j.address?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(ma,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:j.address})]}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(dt,{children:j.lead_source?e.jsx(tt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:j.lead_source}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ms(new Date(j.created_at),"MMM d, yyyy")})}),g&&e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:w=>{w.stopPropagation(),u(j.id),f(`${j.first_name} ${j.last_name||""}`.trim())},title:"Transfer to team member",children:e.jsx(e1,{className:"h-4 w-4"})})})]},j.id))})]})})}),e.jsx(att,{open:!!c,onOpenChange:j=>{j||u(null)},contactIds:c?[c]:[],contactNames:p?[p]:[],onComplete:()=>u(null)})]})},Oke=({teamId:t})=>{const{user:s}=Ds(),{leadPondItems:r,isLoading:n,claimLead:a,returnLead:o}=ntt(t);if(console.log("[LeadPondView] render — teamId:",t,"itemCount:",r.length,"loading:",n),n)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(c=>e.jsx(ys,{className:"h-20 w-full"},c))});if(r.length===0)return e.jsx(Ee,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Yg,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Lead Pond is Empty"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Team members can contribute contacts here for others to claim and follow up with."})]})});const l=r.filter(c=>c.status==="available"),i=r.filter(c=>c.status==="claimed");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Available (",l.length,")"]}),l.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No leads available right now."}):e.jsx("div",{className:"space-y-2",children:l.map(c=>{var u,p,f,g,b,_,j;return e.jsx(Ee,{children:e.jsxs(De,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=c.contact)==null?void 0:u.first_name," ",((p=c.contact)==null?void 0:p.last_name)||""]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 mt-1",children:[((f=c.contact)==null?void 0:f.email)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(cr,{className:"h-3 w-3"})," ",c.contact.email]}),((g=c.contact)==null?void 0:g.phone)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Un,{className:"h-3 w-3"})," ",c.contact.phone]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs(Nn,{className:"h-4 w-4",children:[e.jsx($a,{src:((b=c.contributor)==null?void 0:b.avatar_url)||""}),e.jsx(kn,{className:"text-[8px]",children:(((_=c.contributor)==null?void 0:_.name)||"?").charAt(0)})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["from ",((j=c.contributor)==null?void 0:j.name)||"Unknown"]})]})]}),e.jsxs(K,{size:"sm",onClick:()=>a.mutate(c.id),disabled:a.isPending,children:[e.jsx(aL,{className:"mr-1 h-3 w-3"}),"Claim"]})]})},c.id)})})]}),i.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Claimed (",i.length,")"]}),e.jsx("div",{className:"space-y-2",children:i.map(c=>{var u,p,f;return e.jsx(Ee,{className:"opacity-75",children:e.jsxs(De,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=c.contact)==null?void 0:u.first_name," ",((p=c.contact)==null?void 0:p.last_name)||""]}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs(tt,{variant:"secondary",className:"text-xs",children:["Claimed by ",((f=c.claimer)==null?void 0:f.name)||"Unknown"]})})]}),c.claimed_by===(s==null?void 0:s.id)&&e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>o.mutate(c.id),disabled:o.isPending,children:[e.jsx(u1,{className:"mr-1 h-3 w-3"}),"Return"]})]})},c.id)})})]})]})},itt=({teamId:t})=>{const{useTeamMembers:s}=bC(),{data:r=[]}=s(t),n=r.map(b=>b.user_id),a=new Map(r.map(b=>[b.user_id,b.profile])),{data:o=[],isLoading:l}=mt({queryKey:["team-shared-presentations",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:b,error:_}=await H.from("smart_presentations").select("id, owner_user_id, title, client_name, status, view_count, cta_clicked_count, share_token, created_at, published_at").in("owner_user_id",n).neq("status","archived").order("created_at",{ascending:!1});if(_)throw _;return b||[]},enabled:n.length>0}),{data:i=[],isLoading:c}=mt({queryKey:["team-shared-open-houses",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:b,error:_}=await H.from("open_houses").select("id, agent_id, property_address, city, state, event_date, is_active, visitor_count, slug, created_at").in("agent_id",n).order("event_date",{ascending:!1});if(_)throw _;return b||[]},enabled:n.length>0}),{data:u=[],isLoading:p}=mt({queryKey:["team-shared-videos",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:b,error:_}=await H.from("agent_videos").select("id, owner_user_id, title, recipient_name, status, view_count, touch_type, share_token, created_at").in("owner_user_id",n).eq("is_deleted",!1).order("created_at",{ascending:!1}).limit(50);if(_)throw _;return b||[]},enabled:n.length>0});if(l||c||p)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(b=>e.jsx(ys,{className:"h-20 w-full"},b))});const g=b=>{const _=a.get(b);return{name:(_==null?void 0:_.name)||"Unknown",avatar:(_==null?void 0:_.avatar_url)||"",initials:((_==null?void 0:_.name)||"?").charAt(0).toUpperCase()}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-3",children:[e.jsx(Ee,{children:e.jsxs(De,{className:"flex items-center gap-3 p-4",children:[e.jsx(Jg,{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(De,{className:"flex items-center gap-3 p-4",children:[e.jsx(bn,{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(De,{className:"flex items-center gap-3 p-4",children:[e.jsx(An,{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(ba,{defaultValue:"presentations",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"presentations",children:["Presentations (",o.length,")"]}),e.jsxs(ns,{value:"guest-books",children:["Guest Books (",i.length,")"]}),e.jsxs(ns,{value:"videos",children:["Videos (",u.length,")"]})]}),e.jsx(bs,{value:"presentations",className:"space-y-2",children:o.length===0?e.jsx(Ige,{icon:e.jsx(Jg,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(b=>{const _=g(b.owner_user_id);return e.jsx(Ee,{children:e.jsxs(De,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(Nn,{className:"h-8 w-8 shrink-0",children:[e.jsx($a,{src:_.avatar}),e.jsx(kn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:b.title||"Untitled"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ms(new Date(b.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(tt,{variant:b.status==="published"?"default":"secondary",className:"text-xs capitalize",children:b.status}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(On,{className:"h-3 w-3"}),b.view_count||0]})]})]})},b.id)})}),e.jsx(bs,{value:"guest-books",className:"space-y-2",children:i.length===0?e.jsx(Ige,{icon:e.jsx(bn,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(b=>{const _=g(b.agent_id);return e.jsx(Ee,{children:e.jsxs(De,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(Nn,{className:"h-8 w-8 shrink-0",children:[e.jsx($a,{src:_.avatar}),e.jsx(kn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:b.property_address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ms(new Date(b.event_date),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[b.is_active?e.jsx(tt,{className:"text-xs",children:"Active"}):e.jsx(tt,{variant:"secondary",className:"text-xs",children:"Inactive"}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(pr,{className:"h-3 w-3"}),b.visitor_count||0]})]})]})},b.id)})}),e.jsx(bs,{value:"videos",className:"space-y-2",children:u.length===0?e.jsx(Ige,{icon:e.jsx(An,{className:"h-10 w-10"}),label:"No videos yet"}):u.map(b=>{const _=g(b.owner_user_id);return e.jsx(Ee,{children:e.jsxs(De,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(Nn,{className:"h-8 w-8 shrink-0",children:[e.jsx($a,{src:_.avatar}),e.jsx(kn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:b.title||b.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ms(new Date(b.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(tt,{variant:"secondary",className:"text-xs capitalize",children:b.touch_type}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(On,{className:"h-3 w-3"}),b.view_count||0]})]})]})},b.id)})})]})]})},Ige=({icon:t,label:s})=>e.jsx(Ee,{children:e.jsxs(De,{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})]})}),ott=({team:t,brokerageAgents:s,onBack:r,onUpdate:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,onDeleteTeam:i,isUpdating:c,isAddingMember:u})=>{var q,U;const{useTeamMembers:p}=bC(),{data:f=[],isLoading:g}=p(t.id),[b,_]=N.useState(!1),[j,w]=N.useState(""),[k,S]=N.useState("team_member"),{data:M}=mt({queryKey:["agents-on-other-teams",t.id],queryFn:async()=>{const{data:B}=await H.from("team_members").select("user_id, team_id, teams:team_id(name)").neq("team_id",t.id),V=new Map;return(B||[]).forEach(Z=>{var X;V.set(Z.user_id,((X=Z.teams)==null?void 0:X.name)||"another team")}),V}}),L=new Set(f.map(B=>B.user_id)),I=s.filter(B=>!L.has(B.id)),O=async()=>{j&&(await a(j,k),w(""),S("team_member"),_(!1))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(K,{variant:"ghost",onClick:r,className:"mb-2",children:"← Back to Teams"}),e.jsxs(ba,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"members",children:"Members"}),e.jsxs(ns,{value:"contacts",children:[e.jsx(J4,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(ns,{value:"lead-pond",children:[e.jsx(Yg,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(ns,{value:"shared-assets",children:[e.jsx(Om,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),e.jsx(ns,{value:"settings",children:"Settings"})]}),e.jsxs(bs,{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(fs,{open:b,onOpenChange:_,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Tl,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Add Team Member"}),e.jsxs(Gr,{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($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[j&&(((q=I.find(B=>B.id===j))==null?void 0:q.name)||((U=I.find(B=>B.id===j))==null?void 0:U.email))||"Select an agent",e.jsx(Sx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search agents..."}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:"No agents found."}),e.jsx(Fx,{children:I.map(B=>{const V=M==null?void 0:M.get(B.id);return e.jsxs(bp,{value:B.name||B.email||B.id,disabled:!!V,onSelect:()=>w(B.id),children:[e.jsx(va,{className:It("mr-2 h-4 w-4",j===B.id?"opacity-100":"opacity-0")}),B.name||B.email,V&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(on ",V,")"]})]},B.id)})})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Role"}),e.jsxs(Zs,{value:k,onValueChange:S,children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"team_leader",children:"Team Leader"}),e.jsx(Mt,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{onClick:O,disabled:!j||u,children:u?"Adding...":"Add to Team"})]})]})]})]}),g?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(B=>e.jsx(ys,{className:"h-16 w-full"},B))}):f.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(pr,{className:"h-10 w-10 text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No members yet. Add agents to this team."})]})}):e.jsx("div",{className:"space-y-2",children:f.map(B=>{var V,Z,X,ee,Q;return e.jsx(Ee,{children:e.jsxs(De,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:((V=B.profile)==null?void 0:V.avatar_url)||""}),e.jsx(kn,{children:(((Z=B.profile)==null?void 0:Z.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((X=B.profile)==null?void 0:X.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(ee=B.profile)==null?void 0:ee.email})]}),B.role==="team_leader"?e.jsxs(tt,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[e.jsx(Dm,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(tt,{variant:"secondary",children:"Member"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Zs,{value:B.role,onValueChange:ie=>l(B.id,ie),children:[e.jsx(Ws,{className:"w-[140px]",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"team_leader",children:"Team Leader"}),e.jsx(Mt,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:e.jsx(DL,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Remove Member?"}),e.jsxs(tc,{children:["Remove ",((Q=B.profile)==null?void 0:Q.name)||"this member"," from ",t.name,"?"]})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:()=>o(B.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})]})]})},B.id)})})]}),e.jsx(bs,{value:"contacts",className:"space-y-4",children:e.jsx(Dke,{})}),t.lead_pond_enabled&&e.jsx(bs,{value:"lead-pond",className:"space-y-4",children:e.jsx(Oke,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx(bs,{value:"shared-assets",className:"space-y-4",children:e.jsx(itt,{teamId:t.id})}),e.jsxs(bs,{value:"settings",className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{className:"text-lg",children:"Team Settings"}),e.jsx(gr,{children:"Configure how this team operates."})]}),e.jsxs(De,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Team Name"}),e.jsx(ze,{defaultValue:t.name,onBlur:B=>{B.target.value!==t.name&&n({name:B.target.value})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Er,{defaultValue:t.description||"",onBlur:B=>{B.target.value!==(t.description||"")&&n({description:B.target.value||null})},rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Contact Visibility"}),e.jsxs(Zs,{defaultValue:t.contact_visibility,onValueChange:B=>n({contact_visibility:B}),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"private",children:"Private — Members keep their contacts private"}),e.jsx(Mt,{value:"leader_only",children:"Leader Only — Only team leaders can see member contacts"}),e.jsx(Mt,{value:"full_team",children:"Full Team — All team members can see shared contacts"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls whether team leaders and members can view each other's contacts."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(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(qr,{checked:t.lead_pond_enabled,onCheckedChange:B=>n({lead_pond_enabled:B})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(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(qr,{checked:t.shared_assets_enabled,onCheckedChange:B=>n({shared_assets_enabled:B})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(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(qr,{checked:t.shared_videos_enabled??!1,onCheckedChange:B=>n({shared_videos_enabled:B})})]})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsxs(K,{variant:"destructive",size:"sm",children:[e.jsx(Nr,{className:"mr-2 h-4 w-4"}),"Delete Team"]})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Delete Team?"}),e.jsxs(tc,{children:['This will permanently delete "',t.name,'" and remove all team members. This cannot be undone.']})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:()=>{i(),r()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},ltt=({open:t,onOpenChange:s,onCreateTeam:r,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[c,u]=N.useState(1),[p,f]=N.useState(""),[g,b]=N.useState(""),[_,j]=N.useState(""),[w,k]=N.useState(""),[S,M]=N.useState([]),L=()=>{u(1),f(""),b(""),j(""),k(""),M([])},I=B=>{B||L(),s(B)},O=async()=>{const B=_&&_!=="none"?_:i||null;await r({name:p.trim(),description:g.trim()||void 0,brokerage_id:B,leaderId:w||void 0,memberIds:S.length>0?S:void 0}),L()},q=B=>{B!==w&&M(V=>V.includes(B)?V.filter(Z=>Z!==B):[...V,B])},U=a.filter(B=>B.id!==w);return e.jsx(fs,{open:t,onOpenChange:I,children:e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:c===1?"Create New Team":"Assign Team Members"}),e.jsx(Gr,{children:c===1?"Name your team and add a description.":"Pick a leader and optionally add initial members."}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("div",{className:It("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),e.jsx("div",{className:It("h-1.5 flex-1 rounded-full transition-colors",c===2?"bg-primary":"bg-muted")})]})]}),e.jsx("div",{className:"overflow-y-auto flex-1 pr-1",children:c===1?e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"team-name",children:"Team Name *"}),e.jsx(ze,{id:"team-name",value:p,onChange:B=>f(B.target.value),placeholder:"e.g., Downtown Squad",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"team-desc",children:"Description"}),e.jsx(Er,{id:"team-desc",value:g,onChange:B=>b(B.target.value),placeholder:"What is this team focused on?",rows:3})]}),o&&l&&l.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Brokerage"}),e.jsxs(Zs,{value:_,onValueChange:j,children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"No brokerage (independent team)"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:"No brokerage (independent)"}),l.map(B=>e.jsx(Mt,{value:B.id,children:B.name},B.id))]})]})]})]}):e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Dm,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),e.jsxs(Zs,{value:w,onValueChange:B=>{k(B),M(V=>V.filter(Z=>Z!==B))},children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select a team leader (optional)"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:"No leader for now"}),a.map(B=>e.jsx(Mt,{value:B.id,children:B.name||B.email||"Unknown"},B.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Tl,{className:"h-3.5 w-3.5"}),"Initial Members",S.length>0&&e.jsxs(tt,{variant:"secondary",className:"ml-1 text-xs",children:[S.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click agents to add them. You can always add more later."}),e.jsx("div",{className:"border rounded-lg max-h-[240px] overflow-y-auto divide-y",children:U.length===0?e.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:[e.jsx(pr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"No agents available"]}):U.map(B=>{const V=S.includes(B.id);return e.jsxs("button",{type:"button",className:It("w-full flex items-center gap-3 p-3 text-left transition-colors hover:bg-accent/50",V&&"bg-primary/5"),onClick:()=>q(B.id),children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:B.avatar_url||""}),e.jsx(kn,{className:"text-xs",children:(B.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:B.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:B.email})]}),e.jsx("div",{className:It("h-5 w-5 rounded-full border-2 flex items-center justify-center transition-colors shrink-0",V?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:V&&e.jsx(va,{className:"h-3 w-3"})})]},B.id)})})]})]})}),e.jsx(qn,{className:"gap-2 sm:gap-0",children:c===1?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>u(2),disabled:!p.trim(),children:["Next",e.jsx(Qa,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>u(1),children:[e.jsx(Ja,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(K,{onClick:O,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},eVt=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=bC(),[c,u]=N.useState(!1),[p,f]=N.useState(null),[g,b]=N.useState(""),{data:_}=mt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:I,error:O}=await H.from("brokerages").select("id, name").order("name");if(O)throw O;return I||[]}}),{data:j}=mt({queryKey:["admin-team-member-info",t.map(I=>I.id).join(",")],queryFn:async()=>{var B;if(t.length===0)return{};const{data:I}=await H.from("team_members").select("team_id, user_id, role").in("team_id",t.map(V=>V.id));if(!I)return{};const O=I.filter(V=>V.role==="team_leader").map(V=>V.user_id);let q={};if(O.length>0){const{data:V}=await H.from("profiles").select("id, name").in("id",O);V&&(q=Object.fromEntries(V.map(Z=>[Z.id,{name:Z.name}])))}const U={};for(const V of t){const Z=I.filter(ee=>ee.team_id===V.id),X=Z.find(ee=>ee.role==="team_leader");U[V.id]={count:Z.length,leaderName:X&&((B=q[X.user_id])==null?void 0:B.name)||null}}return U},enabled:t.length>0}),w=(p==null?void 0:p.brokerage_id)||null,{data:k}=mt({queryKey:["brokerage-agents-for-teams",w],queryFn:async()=>{let I=H.from("profiles").select("id, name, email, avatar_url").order("name");w&&(I=I.eq("brokerage_id",w));const{data:O,error:q}=await I;if(q)throw q;return O||[]},enabled:!!p}),S=Object.fromEntries((_||[]).map(I=>[I.id,I.name])),M=async I=>{const O=await r.mutateAsync({name:I.name,brokerage_id:I.brokerage_id||null,description:I.description});if(I.leaderId&&I.leaderId!=="none"&&await o.mutateAsync({team_id:O.id,user_id:I.leaderId,role:"team_leader"}),I.memberIds)for(const q of I.memberIds)await o.mutateAsync({team_id:O.id,user_id:q,role:"team_member"});u(!1)};if(p)return e.jsx(ott,{team:p,brokerageAgents:k||[],onBack:()=>f(null),onUpdate:I=>n.mutateAsync({id:p.id,...I}).then(O=>f(O)),onAddMember:(I,O)=>o.mutateAsync({team_id:p.id,user_id:I,role:O}),onRemoveMember:I=>l.mutateAsync({team_id:p.id,member_id:I}),onUpdateRole:(I,O)=>i.mutateAsync({team_id:p.id,member_id:I,role:O}),onDeleteTeam:()=>{a.mutate(p.id),f(null)},isUpdating:n.isPending,isAddingMember:o.isPending});const L=t.filter(I=>I.name.toLowerCase().includes(g.toLowerCase())||(I.description||"").toLowerCase().includes(g.toLowerCase()));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search teams...",value:g,onChange:I=>b(I.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[L.length," of ",t.length," teams"]})]}),e.jsxs(K,{size:"sm",onClick:()=>u(!0),children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(ltt,{open:c,onOpenChange:u,onCreateTeam:M,isCreating:r.isPending,brokerageAgents:[],isAdmin:!0,allBrokerages:_,activeBrokerageId:null}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"font-semibold",children:"Team Name"}),e.jsx(St,{className:"font-semibold",children:"Brokerage"}),e.jsx(St,{className:"font-semibold",children:"Leader"}),e.jsx(St,{className:"font-semibold",children:"Members"}),e.jsx(St,{className:"font-semibold",children:"Visibility"}),e.jsx(St,{className:"w-[100px]"})]})}),e.jsx(zn,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(I=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx(ys,{className:"h-4 w-32"})}),e.jsx(dt,{children:e.jsx(ys,{className:"h-4 w-24"})}),e.jsx(dt,{children:e.jsx(ys,{className:"h-4 w-28"})}),e.jsx(dt,{children:e.jsx(ys,{className:"h-4 w-12"})}),e.jsx(dt,{children:e.jsx(ys,{className:"h-4 w-20"})}),e.jsx(dt,{children:e.jsx(ys,{className:"h-4 w-16"})})]},I))}):L.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-12 text-muted-foreground",children:g?"No teams match your search":"No teams found. Create one to get started."})}):L.map(I=>{const O=j==null?void 0:j[I.id];return e.jsxs(Ss,{className:"hover:bg-muted/30",children:[e.jsxs(dt,{children:[e.jsx("button",{onClick:()=>f(I),className:"text-primary hover:underline font-medium",children:I.name}),I.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:I.description})]}),e.jsx(dt,{children:I.brokerage_id?e.jsx("span",{className:"text-sm",children:S[I.brokerage_id]||"—"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),e.jsx(dt,{children:O!=null&&O.leaderName?e.jsxs("span",{className:"text-sm flex items-center gap-1",children:[e.jsx(Dm,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),O.leaderName]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No leader"})}),e.jsx(dt,{children:e.jsxs(tt,{variant:"secondary",className:"text-xs",children:[e.jsx(pr,{className:"h-3 w-3 mr-1"}),(O==null?void 0:O.count)??0]})}),e.jsx(dt,{children:e.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[e.jsx(th,{className:"h-3 w-3"}),I.contact_visibility.replace("_"," ")]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>f(I),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 "${I.name}"? This cannot be undone.`)&&a.mutate(I.id)},title:"Delete team",children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})})]},I.id)})})]})})]})},tVt=()=>{const t=fr(),{user:s,isAdmin:r}=Ds(),{startImpersonation:n,isLoading:a}=Pde(),{toast:o}=Ua(),[l,i]=N.useState([]),[c,u]=N.useState([]),[p,f]=N.useState([]),[g,b]=N.useState({}),[_,j]=N.useState(!0),[w,k]=N.useState({}),[S,M]=N.useState(!1),[L,I]=N.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[O,q]=N.useState(!1),[U,B]=N.useState(""),[V,Z]=N.useState(1),[X,ee]=N.useState(50),[Q,ie]=N.useState("all"),[re,oe]=N.useState("all"),[ce,xe]=N.useState("all"),[ge,ue]=N.useState("all"),[pe,be]=N.useState(!1),[Me,Ne]=N.useState(!1),[Pe,Oe]=N.useState(null),[Te,ke]=N.useState(null),[Be,nt]=N.useState(!1),[Ae,ft]=N.useState({name:"",email:"",brokerage_id:"",phone:""}),[fe,Ve]=N.useState(null),[at,et]=N.useState(!1),[Ce,rt]=N.useState(""),[Ge,ct]=N.useState(!1),[qe,Ze]=N.useState(!1),[Qe,He]=N.useState(null),[Je,it]=N.useState(""),[Lt,Vt]=N.useState(!1),[hs,Ts]=N.useState(!1),[Cs,cs]=N.useState(null),[er,xt]=N.useState(!1),[Es,ur]=N.useState(!1),[Mr,Lr]=N.useState(null),[fn,ki]=N.useState(""),[Ea,dr]=N.useState(!1),[Jr,Wr]=N.useState({email:"",name:"",password:"",phone:""}),[dn,Yr]=N.useState(!1),[vi,pt]=N.useState(!1),[ir,Vn]=N.useState(""),[Sr,jr]=N.useState(!1),[ea,Pa]=N.useState(!1),[Ii,Fo]=N.useState(""),[$t,je]=N.useState(new Set),[$e,Ye]=N.useState(!1),[bt,gt]=N.useState(!1),[Ft,Zt]=N.useState(null),[Ut,Xt]=N.useState(!1),[Ps,gs]=N.useState(null),[vr,Hr]=N.useState([]),[xr,Ln]=N.useState([]),[Dn,En]=N.useState(!1),[_a,vo]=N.useState({});N.useEffect(()=>{!s||!r||(ti(),hl())},[s,r]);const il=async()=>{try{const{data:jt,error:As}=await H.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(As)throw As;const Qs={};for(const xn of jt??[])Qs[xn.brokerage_id]||(Qs[xn.brokerage_id]=[]),Qs[xn.brokerage_id].push(xn.user_id);b(Qs)}catch(jt){console.error("Error loading brokerage manager assignments:",jt)}},ti=async()=>{try{j(!0);const{data:jt,error:As}=await H.functions.invoke("get-user-details");if(As)throw As;const Qs=jt.users||[];i(Qs),f(jt.brokerages||[]),await il();const xn=Qs.filter(gn=>gn.roles.includes("assistant"));if(xn.length>0){const gn=xn.map(Ur=>Ur.id),{data:ca}=await H.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",gn);if(ca&&ca.length>0){const Ur=[...new Set(ca.map(Op=>Op.agent_id))],{data:uo}=await H.from("profiles").select("id, name, email").in("id",Ur),Qx={};for(const Op of ca){const Zr=uo==null?void 0:uo.find(Q0=>Q0.id===Op.agent_id);Zr&&(Qx[Op.assistant_id]={agent_name:Zr.name||"",agent_email:Zr.email||""})}vo(Qx)}}}catch(jt){console.error("Error loading members:",jt),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{j(!1)}},hl=async()=>{try{const{data:jt,error:As}=await H.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(As)throw As;u(jt||[])}catch(jt){console.error("Error loading apps:",jt),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},oo=async jt=>{if(!Ae.name.trim()||!Ae.email.trim()){o({title:"Error",description:"Name and email are required",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(Ae.email)){o({title:"Error",description:"Please enter a valid email address",variant:"destructive"});return}try{const{error:Qs}=await H.from("profiles").update({name:Ae.name.trim(),email:Ae.email.trim(),brokerage_id:Ae.brokerage_id||null,phone:Ae.phone.trim()||null}).eq("id",jt);if(Qs)throw Qs;o({title:"Success",description:"Member details updated successfully"}),Oe(null),ti()}catch(Qs){console.error("Error updating member:",Qs),o({title:"Error",description:Qs.message||"Failed to update member",variant:"destructive"})}},Ia=async jt=>{try{const{data:{session:As}}=await H.auth.getSession(),Qs=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${As==null?void 0:As.access_token}`},body:JSON.stringify({userId:jt})}),xn=await Qs.json();if(!Qs.ok)throw new Error(xn.error||"Failed to resend welcome email");o({title:"Success",description:"Welcome email sent successfully"})}catch(As){console.error("Error resending welcome email:",As),o({title:"Error",description:As.message||"Failed to resend welcome email",variant:"destructive"})}},lo=async(jt,As)=>{try{const{error:Qs}=await H.functions.invoke("send-password-reset",{body:{email:jt,redirectTo:window.location.origin}});if(Qs)throw Qs;o({title:"Password Reset Sent",description:`Password reset email sent to ${As}`})}catch(Qs){console.error("Error sending password reset:",Qs),o({title:"Error",description:Qs.message||"Failed to send password reset email",variant:"destructive"})}},Ti=async(jt,As)=>{if(confirm(`Are you sure you want to delete ${As}? This action cannot be undone.`))try{const{data:{session:Qs}}=await H.auth.getSession(),xn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Qs==null?void 0:Qs.access_token}`},body:JSON.stringify({userId:jt})}),gn=await xn.json();if(!xn.ok)throw new Error(gn.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),ti()}catch(Qs){console.error("Error deleting user:",Qs),o({title:"Error",description:Qs.message||"Failed to delete user",variant:"destructive"})}},ua=async()=>{if(!L.email||!L.name||!L.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}if(L.role==="brokerage_manager"&&!L.brokerage_id){o({title:"Error",description:"Please select a brokerage for this manager",variant:"destructive"});return}M(!0);try{const{data:{session:jt}}=await H.auth.getSession(),As=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${jt==null?void 0:jt.access_token}`},body:JSON.stringify(L)}),Qs=await As.json();if(!As.ok)throw new Error(Qs.error||"Failed to create user");if(L.role&&L.role!=="user"&&Qs.userId){const xn=L.role==="brokerage_manager"?L.brokerage_id:void 0;await co(Qs.userId,L.role,"add",xn)}o({title:"Success",description:`User ${L.email} created successfully`}),I({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),q(!1),ti()}catch(jt){console.error("Error creating user:",jt),o({title:"Error",description:jt.message||"Failed to create user",variant:"destructive"})}finally{M(!1)}},co=async(jt,As,Qs,xn)=>{try{const{data:{session:gn}}=await H.auth.getSession(),ca={userId:jt,role:As,action:Qs};if(As==="brokerage_manager"){if(!xn){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}ca.brokerageId=xn}const Ur=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${gn==null?void 0:gn.access_token}`},body:JSON.stringify(ca)}),uo=await Ur.json();if(!Ur.ok)throw new Error(uo.error||"Failed to manage user role");o({title:"Success",description:`Role ${Qs==="add"?"added":"removed"} successfully`}),ti()}catch(gn){console.error("Error managing user role:",gn),o({title:"Error",description:gn.message||"Failed to manage user role",variant:"destructive"})}},Mc=(jt,As)=>As.length===0?!0:As.some(Qs=>jt.includes(Qs)),Wc=async(jt,As,Qs)=>{const xn=`${jt}-${As.id}`;Ve(xn);try{if(Qs){const gn=l.find(Ur=>Ur.id===jt),ca=As.required_tags.filter(Ur=>gn==null?void 0:gn.tags.includes(Ur));for(const Ur of ca){const{error:uo}=await H.from("user_tags").delete().eq("user_id",jt).eq("tag",Ur);if(uo)throw uo}o({title:"Access Removed",description:`Removed access to ${As.name}`})}else if(As.required_tags.length>0){const{error:gn}=await H.from("user_tags").insert({user_id:jt,tag:As.required_tags[0]});if(gn)throw gn;o({title:"Access Granted",description:`Granted access to ${As.name}`})}await ti()}catch(gn){console.error("Error toggling access:",gn),o({title:"Error",description:gn.message||"Failed to update access",variant:"destructive"})}finally{Ve(null)}},lu=async()=>{const jt=Ce.trim();if(!jt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(jt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}if(p.find(Qs=>Qs.name.toLowerCase()===jt.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}ct(!0);try{const{error:Qs}=await H.from("brokerages").insert({name:jt});if(Qs)throw Qs;o({title:"Success",description:`Brokerage "${jt}" created successfully`}),rt(""),et(!1),ti()}catch(Qs){console.error("Error creating brokerage:",Qs),o({title:"Error",description:Qs.message||"Failed to create brokerage",variant:"destructive"})}finally{ct(!1)}},Df=jt=>{He(jt),it(jt.name),Ze(!0)},Fl=()=>{He(null),it(""),Ze(!1)},ch=async()=>{if(!Qe)return;const jt=Je.trim();if(!jt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(jt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}Vt(!0);try{const{error:As}=await H.from("brokerages").update({name:jt}).eq("id",Qe.id);if(As)throw As;o({title:"Success",description:"Brokerage updated successfully"}),Fl(),ti()}catch(As){console.error("Error updating brokerage:",As),o({title:"Error",description:As.message||"Failed to update brokerage",variant:"destructive"})}finally{Vt(!1)}},kd=async(jt,As)=>{var Qs;if(!As||typeof As!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const xn={userId:jt,role:"brokerage_manager",action:"add",brokerageId:As};console.debug("[assignManagerToBrokerage] payload",xn);const{data:{session:gn}}=await H.auth.getSession(),ca=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${gn==null?void 0:gn.access_token}`},body:JSON.stringify(xn)}),Ur=await ca.json();if(!ca.ok&&!((Qs=Ur.error)!=null&&Qs.includes("duplicate")))throw new Error(Ur.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await ti()}catch(xn){console.error("Error assigning manager:",xn),o({title:"Error",description:xn.message||"Failed to assign manager",variant:"destructive"})}},Km=jt=>{cs(jt),Ts(!0)},zl=async()=>{if(Cs){xt(!0);try{const jt=l.filter(xn=>xn.brokerage_id===Cs.id),{data:{session:As}}=await H.auth.getSession();for(const xn of jt){const gn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${As==null?void 0:As.access_token}`},body:JSON.stringify({userId:xn.id})});if(!gn.ok){const ca=await gn.json();console.error(`Failed to delete user ${xn.email}:`,ca.error)}}const{error:Qs}=await H.from("brokerages").delete().eq("id",Cs.id);if(Qs)throw Qs;o({title:"Success",description:`Brokerage "${Cs.name}" and ${jt.length} member(s) deleted`}),Ts(!1),cs(null),ti()}catch(jt){console.error("Error deleting brokerage:",jt),o({title:"Error",description:jt.message||"Failed to delete brokerage",variant:"destructive"})}finally{xt(!1)}}},Zx=jt=>{Lr(jt),ki(""),ur(!0)},yy=()=>{Lr(null),ki(""),ur(!1)},V1=async jt=>{try{const{error:As}=await H.from("profiles").update({brokerage_id:null}).eq("id",jt);if(As)throw As;o({title:"Success",description:"User removed from brokerage"}),ti()}catch(As){console.error("Error removing user from brokerage:",As),o({title:"Error",description:As.message||"Failed to remove user",variant:"destructive"})}},H1=async(jt,As)=>{try{const{error:Qs}=await H.from("profiles").update({brokerage_id:As}).eq("id",jt);if(Qs)throw Qs;o({title:"Success",description:"User added to brokerage"}),ti()}catch(Qs){console.error("Error adding user to brokerage:",Qs),o({title:"Error",description:Qs.message||"Failed to add user",variant:"destructive"})}},W1=async()=>{if(!Mr||!Jr.email||!Jr.name||!Jr.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}Yr(!0);try{const{data:{session:jt}}=await H.auth.getSession(),As=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${jt==null?void 0:jt.access_token}`},body:JSON.stringify({...Jr,brokerage_id:Mr.id,role:"user"})}),Qs=await As.json();if(!As.ok)throw new Error(Qs.error||"Failed to create agent");o({title:"Success",description:`Agent ${Jr.email} created successfully`}),Wr({email:"",name:"",password:"",phone:""}),dr(!1),ti()}catch(jt){console.error("Error creating agent:",jt),o({title:"Error",description:jt.message||"Failed to create agent",variant:"destructive"})}finally{Yr(!1)}},Dp=jt=>l.filter(As=>As.brokerage_id===jt),am=jt=>{const As=Dp(jt);if(!fn)return As;const Qs=fn.toLowerCase();return As.filter(xn=>xn.name.toLowerCase().includes(Qs)||xn.email.toLowerCase().includes(Qs))},cu=jt=>l.filter(As=>As.brokerage_id!==jt),im=l.filter(jt=>{var Qs;if(U){const xn=U.toLowerCase();if(!(jt.name.toLowerCase().includes(xn)||jt.email.toLowerCase().includes(xn)||((Qs=jt.brokerage_name)==null?void 0:Qs.toLowerCase().includes(xn))))return!1}if(Q==="claimed"&&!jt.claimed||Q==="unclaimed"&&jt.claimed||re!=="all"&&!jt.roles.includes(re))return!1;const As=jt.is_trial||jt.subscription_status==="trialing";return!(ce==="trial"&&!As||ce==="non-trial"&&As||ge==="none"&&jt.brokerage_id||ge!=="all"&&ge!=="none"&&jt.brokerage_id!==ge)}),{sortKey:$d,sortDirection:Sd,handleSort:du,sortData:Of}=YO("created_at","desc"),Rf=Of(im,{name:jt=>{var As;return((As=jt.name)==null?void 0:As.toLowerCase())||""},brokerage:jt=>{var As;return((As=jt.brokerage_name)==null?void 0:As.toLowerCase())||""},status:jt=>jt.claimed?"active":"pending",role:jt=>jt.roles[0]||"",last_login:jt=>jt.last_sign_in_at?new Date(jt.last_sign_in_at).getTime():null,created_at:jt=>jt.created_at?new Date(jt.created_at).getTime():null}),Zm=Rf.length,Ym=X===0,Cd=Ym?1:Math.ceil(Zm/X),K0=Ym?0:(V-1)*X,Yx=Ym?Zm:K0+X,Al=Rf.slice(K0,Yx),G1=jt=>{B(jt),Z(1)},Xx=jt=>{ee(jt),Z(1)},Lh=(jt,As)=>{jt(As),Z(1)},Hw=async(jt,As)=>{be(!0);try{const Qs=l.find(Ur=>Ur.id===jt);if(!Qs)return;const xn=Qs.trial_expires_at?new Date(Qs.trial_expires_at):new Date,gn=new Date(xn.getTime()+As*24*60*60*1e3),{error:ca}=await H.from("profiles").update({trial_expires_at:gn.toISOString()}).eq("id",jt);if(ca)throw ca;o({title:"Trial Extended",description:`Trial extended by ${As} days`}),ti()}catch(Qs){console.error("Error extending trial:",Qs),o({title:"Error",description:Qs.message||"Failed to extend trial",variant:"destructive"})}finally{be(!1)}},AC=async jt=>{Ne(!0);try{const{error:As}=await H.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",jt);if(As)throw As;o({title:"Account Converted",description:"User has been converted to a full account"}),ti(),vy()}catch(As){console.error("Error converting trial:",As),o({title:"Error",description:As.message||"Failed to convert account",variant:"destructive"})}finally{Ne(!1)}},Z0=async jt=>{En(!0);try{const{data:As}=await H.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",jt);if(As&&As.length>0){const xn=As.map(ca=>ca.assistant_id),{data:gn}=await H.from("profiles").select("id, name, email").in("id",xn);Hr(As.map(ca=>{const Ur=gn==null?void 0:gn.find(uo=>uo.id===ca.assistant_id);return{id:ca.id,assistant_id:ca.assistant_id,assistant_name:(Ur==null?void 0:Ur.name)||"Unknown",assistant_email:(Ur==null?void 0:Ur.email)||"",permissions:ca.permissions||{}}}))}else Hr([]);const{data:Qs}=await H.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",jt);if(Qs&&Qs.length>0){const xn=Qs.map(ca=>ca.agent_id),{data:gn}=await H.from("profiles").select("id, name, email").in("id",xn);Ln(Qs.map(ca=>{const Ur=gn==null?void 0:gn.find(uo=>uo.id===ca.agent_id);return{id:ca.id,agent_id:ca.agent_id,agent_name:(Ur==null?void 0:Ur.name)||"Unknown",agent_email:(Ur==null?void 0:Ur.email)||"",permissions:ca.permissions||{}}}))}else Ln([])}catch(As){console.error("Error loading assistant data:",As)}finally{En(!1)}},La=jt=>{ke(jt),ft({name:jt.name,email:jt.email,brokerage_id:jt.brokerage_id||"",phone:jt.phone||""}),nt(!0),Z0(jt.id)},vy=()=>{ke(null),nt(!1),ft({name:"",email:"",brokerage_id:"",phone:""})},Ww=async()=>{Te&&(await oo(Te.id),vy())},EC=jt=>{je(As=>{const Qs=new Set(As);return Qs.has(jt)?Qs.delete(jt):Qs.add(jt),Qs})},PC=()=>{if($t.size===Al.length&&Al.every(jt=>$t.has(jt.id))){const jt=new Set($t);Al.forEach(As=>jt.delete(As.id)),je(jt)}else{const jt=new Set($t);Al.forEach(As=>jt.add(As.id)),je(jt)}},om=()=>{je(new Set)},Y0=async()=>{if($t.size===0)return;Ye(!0);let jt=0,As=0;try{const{data:{session:Qs}}=await H.auth.getSession();for(const xn of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Qs==null?void 0:Qs.access_token}`},body:JSON.stringify({userId:xn})})).ok?jt++:As++}catch{As++}o({title:"Bulk Email Complete",description:`Sent ${jt} emails${As>0?`, ${As} failed`:""}`}),om()}catch(Qs){o({title:"Error",description:Qs.message||"Failed to send emails",variant:"destructive"})}finally{Ye(!1)}},X0=async()=>{if($t.size===0)return;Ye(!0);let jt=0,As=0;try{const{data:{session:Qs}}=await H.auth.getSession();for(const xn of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-password-reset",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Qs==null?void 0:Qs.access_token}`},body:JSON.stringify({userId:xn})})).ok?jt++:As++}catch{As++}o({title:"Bulk Password Reset Complete",description:`Sent ${jt} reset emails${As>0?`, ${As} failed`:""}`}),om()}catch(Qs){o({title:"Error",description:Qs.message||"Failed to send password reset emails",variant:"destructive"})}finally{Ye(!1)}},Gw=async()=>{if($t.size===0)return;const jt=l.filter(gn=>$t.has(gn.id)).map(gn=>gn.name).slice(0,5).join(", "),As=$t.size>5?` and ${$t.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${$t.size} users (${jt}${As})? This action cannot be undone.`))return;Ye(!0);let Qs=0,xn=0;try{const{data:{session:gn}}=await H.auth.getSession();for(const ca of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${gn==null?void 0:gn.access_token}`},body:JSON.stringify({userId:ca})})).ok?Qs++:xn++}catch{xn++}o({title:"Bulk Delete Complete",description:`Deleted ${Qs} users${xn>0?`, ${xn} failed`:""}`}),om(),ti()}catch(gn){o({title:"Error",description:gn.message||"Failed to delete users",variant:"destructive"})}finally{Ye(!1)}},K1=async()=>{gt(!0);try{const{data:{session:jt}}=await H.auth.getSession(),As=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-phone-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${jt==null?void 0:jt.access_token}`}});if(!As.ok){const xn=await As.json();throw new Error(xn.error||"Failed to sync phones")}const Qs=await As.json();o({title:"Phone Sync Complete",description:`Pulled ${Qs.summary.pulledFromGHL} from GHL, pushed ${Qs.summary.pushedToGHL} to GHL, ${Qs.summary.alreadySynced} already synced`}),ti()}catch(jt){o({title:"Error",description:jt.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{gt(!1)}},Xm=async(jt,As)=>{Zt(jt);try{const{data:{session:Qs}}=await H.auth.getSession(),{data:xn}=await H.from("profiles").select("phone").eq("id",jt).single(),gn=(xn==null?void 0:xn.phone)||"",ca=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-tag-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Qs==null?void 0:Qs.access_token}`},body:JSON.stringify({email:As,action:"update",phone:gn||void 0})});if(!ca.ok){const uo=await ca.json();throw new Error(uo.error||"Failed to sync with GHL")}const Ur=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(As)}`,{method:"GET",headers:{"Content-Type":"application/json"}});o({title:"Phone Synced",description:gn?`Phone ${gn} synced to GHL`:"Sync attempted - run bulk sync to pull phone from GHL"}),ti()}catch(Qs){o({title:"Error",description:Qs.message||"Failed to sync phone",variant:"destructive"})}finally{Zt(null)}},by=async jt=>{await n(jt)},Kw=()=>{if($t.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const jt=l.filter(uo=>$t.has(uo.id)),As=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],Qs=jt.map(uo=>[uo.name,uo.email,uo.phone||"",uo.brokerage_name||"",uo.roles.join("; "),uo.claimed?"Claimed":"Unclaimed",new Date(uo.created_at).toLocaleDateString()]),xn=[As.join(","),...Qs.map(uo=>uo.map(Qx=>`"${(Qx||"").replace(/"/g,'""')}"`).join(","))].join(` `),gn=new Blob([xn],{type:"text/csv"}),ca=URL.createObjectURL(gn),Ur=document.createElement("a");Ur.href=ca,Ur.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,Ur.click(),URL.revokeObjectURL(ca),o({title:"Export complete",description:`Exported ${jt.length} member(s)`})};return _?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(oh,{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:K1,disabled:bt,children:[bt?e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Un,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:bt?"Syncing...":"Sync Phones with GHL"}),e.jsx("span",{className:"sm:hidden",children:bt?"Syncing...":"Sync GHL"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>pt(!0),children:[e.jsx(r1,{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(fs,{open:O,onOpenChange:q,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Tl,{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(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create New User"}),e.jsx(Gr,{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(ze,{id:"name",placeholder:"John Doe",value:L.name,onChange:jt=>I({...L,name:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",placeholder:"john@example.com",value:L.email,onChange:jt=>I({...L,email:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"password",children:"Password"}),e.jsx(ze,{id:"password",type:"password",placeholder:"Min 6 characters",value:L.password,onChange:jt=>I({...L,password:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"555-123-4567",value:L.phone,onChange:jt=>I({...L,phone:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"brokerage",children:["Brokerage",L.role==="brokerage_manager"?" (required)":""]}),e.jsxs(Zs,{value:L.brokerage_id||"none",onValueChange:jt=>I({...L,brokerage_id:jt==="none"?"":jt}),children:[e.jsx(Ws,{id:"brokerage",children:e.jsx(Xs,{placeholder:L.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:"None"}),p.map(jt=>e.jsx(Mt,{value:jt.id,children:jt.name},jt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"role",children:"Role"}),e.jsxs(Zs,{value:L.role,onValueChange:jt=>I({...L,role:jt}),children:[e.jsx(Ws,{id:"role",children:e.jsx(Xs,{placeholder:"Select role"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"user",children:"User"}),e.jsx(Mt,{value:"moderator",children:"Moderator"}),e.jsx(Mt,{value:"brokerage_manager",children:"Brokerage Manager"}),e.jsx(Mt,{value:"admin",children:"Admin"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"trial_days",children:"Trial Period (optional)"}),e.jsxs(Zs,{value:L.trial_days||"none",onValueChange:jt=>I({...L,trial_days:jt==="none"?"":jt}),children:[e.jsx(Ws,{id:"trial_days",children:e.jsx(Xs,{placeholder:"No trial (full access)"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:"No trial (full access)"}),e.jsx(Mt,{value:"7",children:"7-day trial"}),e.jsx(Mt,{value:"30",children:"30-day trial"}),e.jsx(Mt,{value:"60",children:"60-day trial"}),e.jsx(Mt,{value:"90",children:"90-day trial"}),e.jsx(Mt,{value:"365",children:"1-year trial"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Trial accounts don't require a credit card. Access expires after the trial period."})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>q(!1),children:"Cancel"}),e.jsx(K,{onClick:ua,disabled:S,children:S?"Creating...":"Create User"})]})]})]})]})]}),e.jsxs(ba,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"members",children:"Members"}),e.jsx(ns,{value:"brokerages",children:"Brokerages"}),e.jsx(ns,{value:"teams",children:"Teams"}),e.jsx(ns,{value:"trials",children:"Trial Users"}),e.jsx(ns,{value:"access",children:"Access Matrix"}),e.jsx(ns,{value:"celebrations",children:"Celebrations"}),e.jsx(ns,{value:"deletions",children:"Deletion Log"})]}),e.jsxs(bs,{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(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search members...",value:U,onChange:jt=>G1(jt.target.value),className:"pl-10 h-9"})]}),e.jsxs(Zs,{value:Q,onValueChange:jt=>Lh(ie,jt),children:[e.jsx(Ws,{className:"w-[130px] h-9",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Status"}),e.jsx(Mt,{value:"claimed",children:"Active"}),e.jsx(Mt,{value:"unclaimed",children:"Pending"})]})]}),e.jsxs(Zs,{value:re,onValueChange:jt=>Lh(oe,jt),children:[e.jsx(Ws,{className:"w-[130px] h-9",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Roles"}),e.jsx(Mt,{value:"admin",children:"Admin"}),e.jsx(Mt,{value:"brokerage_manager",children:"Manager"}),e.jsx(Mt,{value:"assistant",children:"Assistant"}),e.jsx(Mt,{value:"user",children:"User"})]})]}),e.jsxs(Zs,{value:ce,onValueChange:jt=>Lh(xe,jt),children:[e.jsx(Ws,{className:"w-[130px] h-9",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Users"}),e.jsx(Mt,{value:"trial",children:"Trial Only"}),e.jsx(Mt,{value:"non-trial",children:"Full Only"})]})]}),e.jsxs(Zs,{value:ge,onValueChange:jt=>Lh(ue,jt),children:[e.jsx(Ws,{className:"w-[150px] h-9",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Brokerages"}),e.jsx(Mt,{value:"none",children:"No Brokerage"}),p.map(jt=>e.jsx(Mt,{value:jt.id,children:jt.name},jt.id))]})]}),(U||Q!=="all"||re!=="all"||ce!=="all"||ge!=="all")&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{B(""),ie("all"),oe("all"),xe("all"),ue("all"),Z(1)},children:[e.jsx(Rr,{className:"h-4 w-4 mr-1"}),"Clear"]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:Ym?`Showing all ${Zm} members`:`Showing ${K0+1}-${Math.min(Yx,Zm)} of ${Zm} members`}),e.jsxs(Zs,{value:X.toString(),onValueChange:jt=>Xx(Number(jt)),children:[e.jsx(Ws,{className:"h-9 w-[110px]",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"50",children:"50 / page"}),e.jsx(Mt,{value:"100",children:"100 / page"}),e.jsx(Mt,{value:"250",children:"250 / page"}),e.jsx(Mt,{value:"0",children:"All"})]})]})]})]}),$t.size>0&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/10 border border-primary/20 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zv,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm font-medium",children:[$t.size," selected"]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:Y0,disabled:$e,children:[$e?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(cr,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Resend Invite"}),e.jsx("span",{className:"sm:hidden",children:"Invite"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:X0,disabled:$e,children:[$e?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Sp,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Password Reset"}),e.jsx("span",{className:"sm:hidden",children:"Reset"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:Kw,children:[e.jsx(yi,{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:Gw,disabled:$e,children:[$e?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Nr,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"}),e.jsx("span",{className:"sm:hidden",children:"Del"})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:om,disabled:$e,children:e.jsx(Rr,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"w-[50px]",children:e.jsx(Oo,{checked:Al.length>0&&Al.every(jt=>$t.has(jt.id)),onCheckedChange:PC,"aria-label":"Select all on page"})}),e.jsx(yl,{sortKey:"name",currentSortKey:$d,currentDirection:Sd,onSort:du,children:"Name"}),e.jsx(yl,{sortKey:"brokerage",currentSortKey:$d,currentDirection:Sd,onSort:du,children:"Brokerage"}),e.jsx(yl,{sortKey:"status",currentSortKey:$d,currentDirection:Sd,onSort:du,children:"Status"}),e.jsx(yl,{sortKey:"role",currentSortKey:$d,currentDirection:Sd,onSort:du,children:"Role"}),e.jsx(yl,{sortKey:"last_login",currentSortKey:$d,currentDirection:Sd,onSort:du,children:"Last Login"}),e.jsx(yl,{sortKey:"created_at",currentSortKey:$d,currentDirection:Sd,onSort:du,children:"Member Since"}),e.jsx(St,{className:"w-[100px]"})]})}),e.jsx(zn,{children:Al.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):Al.map(jt=>e.jsxs(Ss,{className:`hover:bg-muted/30 ${$t.has(jt.id)?"bg-primary/5":""}`,children:[e.jsx(dt,{children:e.jsx(Oo,{checked:$t.has(jt.id),onCheckedChange:()=>EC(jt.id),"aria-label":`Select ${jt.name}`})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>La(jt),className:"text-primary hover:underline font-medium text-left",children:jt.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:jt.email})]})}),e.jsx(dt,{className:"text-muted-foreground",children:jt.brokerage_name||"—"}),e.jsx(dt,{children:e.jsx("div",{className:"flex flex-col",children:(()=>{const As=jt.is_trial&&jt.trial_expires_at||!jt.is_trial&&jt.subscription_status==="trialing"&&jt.subscription_end_date,Qs=jt.trial_expires_at||jt.subscription_end_date;if(As&&Qs){const xn=Math.ceil((new Date(Qs).getTime()-Date.now())/864e5),gn=xn<=0,ca=xn<=3;return e.jsx(tt,{variant:"outline",className:It("w-fit",gn?"border-destructive text-destructive":ca?"border-amber-500 text-amber-600":"border-violet-300 text-violet-700 bg-violet-50"),children:gn?"Trial Expired":`Trial · ${xn}d left`})}return e.jsx(tt,{variant:jt.claimed?"default":"secondary",className:jt.claimed?"bg-primary text-primary-foreground w-fit":"w-fit",children:jt.claimed?"Active":"Pending"})})()})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col",children:[jt.roles.length>0?e.jsx("span",{className:"text-sm capitalize",children:jt.roles[0]}):e.jsx("span",{className:"text-muted-foreground",children:"—"}),jt.roles.includes("assistant")&&_a[jt.id]&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",_a[jt.id].agent_name||_a[jt.id].agent_email]})]})}),e.jsx(dt,{className:"text-muted-foreground",children:jt.last_sign_in_at?new Date(jt.last_sign_in_at).toLocaleDateString():"—"}),e.jsx(dt,{className:"text-muted-foreground",children:jt.created_at?new Date(jt.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",onClick:()=>{gs(jt),Xt(!0)},title:"Send celebration",children:e.jsx(ru,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>La(jt),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:()=>Xm(jt.id,jt.email),disabled:Ft===jt.id,title:"Sync phone with GHL",children:Ft===jt.id?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Un,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Ia(jt.id),title:"Resend welcome email",children:e.jsx(cr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>lo(jt.email,jt.name),title:"Send password reset",children:e.jsx(sS,{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:()=>by(jt.id),disabled:a||jt.id===(s==null?void 0:s.id),title:jt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${jt.name}`,children:a?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(aS,{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:()=>Ti(jt.id,jt.name),title:"Delete user",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},jt.id))})]})}),Cd>1&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Page ",V," of ",Cd]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>Z(1),disabled:V===1,children:"First"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Z(jt=>Math.max(1,jt-1)),disabled:V===1,children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,Cd)},(jt,As)=>{let Qs;return Cd<=5||V<=3?Qs=As+1:V>=Cd-2?Qs=Cd-4+As:Qs=V-2+As,e.jsx(K,{variant:V===Qs?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>Z(Qs),children:Qs},Qs)})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Z(jt=>Math.min(Cd,jt+1)),disabled:V===Cd,children:e.jsx(da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>Z(Cd),disabled:V===Cd,children:"Last"})]})]})]}),e.jsx(fs,{open:Be,onOpenChange:nt,children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Edit Member"}),e.jsx(Gr,{children:"Update member details, roles, and app access"})]}),Te&&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(ze,{id:"edit-name",value:Ae.name,onChange:jt=>ft({...Ae,name:jt.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"edit-email",children:"Email"}),e.jsx(ze,{id:"edit-email",type:"email",value:Ae.email,onChange:jt=>ft({...Ae,email:jt.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(ze,{id:"edit-phone",type:"tel",value:Ae.phone,onChange:jt=>ft({...Ae,phone:jt.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs(Zs,{value:Ae.brokerage_id||"none",onValueChange:jt=>ft({...Ae,brokerage_id:jt==="none"?"":jt}),children:[e.jsx(Ws,{id:"edit-brokerage",children:e.jsx(Xs,{placeholder:"Select brokerage"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:"None"}),p.map(jt=>e.jsx(Mt,{value:jt.id,children:jt.name},jt.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:[Te.roles.map(jt=>e.jsxs(tt,{variant:"default",className:"gap-1",children:[e.jsx(th,{className:"h-3 w-3"}),jt,jt==="brokerage_manager"?e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(manage in Brokerages tab)"}):e.jsx("button",{onClick:()=>co(Te.id,jt,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(Rr,{className:"h-3 w-3"})})]},jt)),Te.roles.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),e.jsxs(Zs,{onValueChange:jt=>co(Te.id,jt,"add"),children:[e.jsx(Ws,{className:"w-[200px]",children:e.jsx(Xs,{placeholder:"Add role..."})}),e.jsxs(Gs,{children:[!Te.roles.includes("admin")&&e.jsx(Mt,{value:"admin",children:"Admin"}),!Te.roles.includes("user")&&e.jsx(Mt,{value:"user",children:"User"})]})]}),!Te.roles.includes("brokerage_manager")&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"To add as brokerage manager, use Brokerages tab → Manage"})]}),(vr.length>0||xr.length>0||Te.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(pr,{className:"h-4 w-4"}),"Assistant Relationships"]}),Dn?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs("div",{className:"space-y-3",children:[vr.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Has assistants:"}),vr.map(jt=>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:jt.assistant_name}),e.jsx(tt,{variant:"outline",className:"text-xs",children:"Assistant"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:jt.assistant_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(jt.permissions).filter(([,As])=>As).map(([As])=>e.jsx(tt,{variant:"secondary",className:"text-[10px] capitalize",children:As},As))})]},jt.id))]}),xr.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Assists agents:"}),xr.map(jt=>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:jt.agent_name}),e.jsx(tt,{variant:"outline",className:"text-xs",children:"Agent"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:jt.agent_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(jt.permissions).filter(([,As])=>As).map(([As])=>e.jsx(tt,{variant:"secondary",className:"text-[10px] capitalize",children:As},As))})]},jt.id))]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"App Access"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Toggle which apps this member can access"}),e.jsx("div",{className:"grid gap-3",children:c.map(jt=>{const As=Mc(Te.tags,jt.required_tags),Qs=`${Te.id}-${jt.id}`,xn=fe===Qs,gn=jt.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:jt.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:jt.name}),gn&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Available to all members"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:xn?e.jsx(ws,{className:"h-4 w-4 animate-spin text-muted-foreground"}):gn?e.jsx(tt,{variant:"secondary",className:"text-xs",children:"Always On"}):e.jsx(qr,{checked:As,onCheckedChange:()=>Wc(Te.id,jt,As)})})]},jt.id)})})]}),(Te.is_trial||Te.subscription_status==="trialing")&&e.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(un,{className:"h-4 w-4"}),"Trial Status"]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-amber-50 dark:bg-amber-950/20 border-amber-200 dark:border-amber-800",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[Te.trial_expires_at&&e.jsx(p8e,{expiresAt:Te.trial_expires_at}),!Te.trial_expires_at&&Te.subscription_status==="trialing"&&Te.subscription_end_date&&e.jsx(p8e,{expiresAt:Te.subscription_end_date})]}),(Te.trial_expires_at||Te.subscription_end_date)&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Expires: ",new Date(Te.trial_expires_at||Te.subscription_end_date).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Hw(Te.id,7),disabled:pe,children:[e.jsx(O_,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Hw(Te.id,14),disabled:pe,children:[e.jsx(O_,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Hw(Te.id,30),disabled:pe,children:[e.jsx(O_,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(K,{size:"sm",variant:"default",onClick:()=>AC(Te.id),disabled:Me,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(W_,{className:"h-4 w-4 mr-1"}),"Convert to Full Account"]})]}),Te.trial_started_at&&e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:["Trial started: ",new Date(Te.trial_started_at).toLocaleDateString(),Te.trial_claimed_at&&e.jsxs("span",{children:[" • Claimed: ",new Date(Te.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:[Te.email_confirmed_at&&e.jsxs("div",{children:["Claimed: ",new Date(Te.email_confirmed_at).toLocaleString()]}),Te.last_sign_in_at&&e.jsxs("div",{children:["Last login: ",new Date(Te.last_sign_in_at).toLocaleString()]}),e.jsxs("div",{children:["Created: ",new Date(Te.created_at).toLocaleString()]})]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:vy,children:"Cancel"}),e.jsx(K,{onClick:Ww,children:"Save Changes"})]})]})}),e.jsxs(bs,{value:"access",children:[c.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsx(K,{onClick:()=>t("/admin/apps"),children:"Configure Apps"})]})}):e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Member Access Matrix"}),e.jsx(gr,{children:"Toggle switches to grant or revoke app access for each member"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left p-4 font-semibold sticky left-0 bg-card z-10",children:"Member"}),c.map(jt=>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:jt.icon}),e.jsx("span",{className:"text-sm",children:jt.name})]})},jt.id))]})}),e.jsxs("tbody",{children:[Al.map(jt=>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:jt.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:jt.email})]})}),c.map(As=>{const Qs=Mc(jt.tags,As.required_tags),xn=`${jt.id}-${As.id}`,gn=fe===xn;return e.jsx("td",{className:"p-4 text-center",children:e.jsx("div",{className:"flex items-center justify-center",children:gn?e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"}):e.jsx(qr,{checked:Qs,onCheckedChange:()=>Wc(jt.id,As,Qs),disabled:As.required_tags.length===0})})},As.id)})]},jt.id)),Al.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:c.length+1,className:"p-8 text-center text-muted-foreground",children:"No members found"})})]})]})}),Cd>1&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",K0+1,"-",Math.min(Yx,Zm)," of ",Zm," • Page ",V," of ",Cd]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Z(jt=>Math.max(1,jt-1)),disabled:V===1,children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Z(jt=>Math.min(Cd,jt+1)),disabled:V===Cd,children:e.jsx(da,{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(bs,{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(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search brokerages...",value:ir,onChange:jt=>Vn(jt.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[p.filter(jt=>jt.name.toLowerCase().includes(ir.toLowerCase())).length," of ",p.length," brokerages"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{const jt=[];for(const Ur of p){const uo=g[Ur.id]??[];for(const Qx of uo){const Op=l.find(Zr=>Zr.id===Qx);if(Op){const Zr=(Op.name||"").trim().split(/\s+/),Q0=Zr[0]||"",J0=Zr.slice(1).join(" ")||"";jt.push({firstName:Q0,lastName:J0,email:Op.email,brokerageName:Ur.name})}}}if(jt.length===0){o({title:"No managers found to export"});return}const Qs=[["First Name","Last Name","Email","Brokerage Name"].join(","),...jt.map(Ur=>[Ur.firstName,Ur.lastName,Ur.email,Ur.brokerageName].map(uo=>`"${(uo||"").replace(/"/g,'""')}"`).join(","))].join(` `),xn=new Blob([Qs],{type:"text/csv"}),gn=URL.createObjectURL(xn),ca=document.createElement("a");ca.href=gn,ca.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,ca.click(),URL.revokeObjectURL(gn),o({title:`Exported ${jt.length} managers`})},children:[e.jsx(yi,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(fs,{open:at,onOpenChange:et,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(ka,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create New Brokerage"}),e.jsx(Gr,{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(ze,{id:"brokerage-name",placeholder:"Enter brokerage name",value:Ce,onChange:jt=>rt(jt.target.value),maxLength:100})]})}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>et(!1),children:"Cancel"}),e.jsx(K,{onClick:lu,disabled:Ge,children:Ge?"Creating...":"Create Brokerage"})]})]})]})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"font-semibold",children:"Brokerage Name"}),e.jsx(St,{className:"font-semibold",children:"Manager(s)"}),e.jsx(St,{className:"font-semibold",children:"Agents"}),e.jsx(St,{className:"w-[150px]"})]})}),e.jsx(zn,{children:(()=>{const jt=p.filter(As=>As.name.toLowerCase().includes(ir.toLowerCase()));return jt.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:ir?"No brokerages match your search":"No brokerages found"})}):jt.map(As=>{const Qs=l.filter(Ur=>Ur.brokerage_id===As.id),gn=(g[As.id]??[]).map(Ur=>l.find(uo=>uo.id===Ur)).filter(Boolean),ca=Qs.length;return e.jsxs(Ss,{className:"hover:bg-muted/30",children:[e.jsx(dt,{children:e.jsx("button",{onClick:()=>Df(As),className:"text-primary hover:underline font-medium",children:As.name})}),e.jsx(dt,{children:gn.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:gn.map(Ur=>e.jsx(tt,{variant:"secondary",className:"text-xs",children:Ur.name},Ur.id))}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"No manager"})}),e.jsxs(dt,{children:[ca," member",ca!==1?"s":""]}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"h-8",onClick:()=>Zx(As),children:[e.jsx(pr,{className:"h-4 w-4 mr-1"}),"Manage"]}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Df(As),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:()=>Km(As),title:"Delete brokerage",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},As.id)})})()})]})}),e.jsx(fs,{open:qe,onOpenChange:Ze,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Edit Brokerage"}),e.jsx(Gr,{children:"Update brokerage details and manage managers"})]}),Qe&&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(ze,{id:"edit-brokerage-name",value:Je,onChange:jt=>it(jt.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 As=(g[Qe.id]??[]).map(Qs=>l.find(xn=>xn.id===Qs)).filter(Boolean);return As.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):As.map(Qs=>e.jsxs(tt,{variant:"default",className:"gap-1",children:[e.jsx(th,{className:"h-3 w-3"}),Qs.name,e.jsx("button",{onClick:()=>co(Qs.id,"brokerage_manager","remove",Qe.id),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove manager from this brokerage",children:e.jsx(Rr,{className:"h-3 w-3"})})]},Qs.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($o,{open:Sr,onOpenChange:jr,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":Sr,className:"w-full justify-between",children:["Search for a member...",e.jsx(cn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-full p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search by name or email..."}),e.jsxs(Ox,{className:"max-h-[200px]",children:[e.jsx(Rx,{children:"No members found."}),e.jsx(Fx,{children:(()=>{const jt=new Set(g[Qe.id]??[]);return l.filter(As=>!jt.has(As.id)&&(r||As.brokerage_id===Qe.id)).map(As=>e.jsxs(bp,{value:`${As.name} ${As.email}`,onSelect:()=>{kd(As.id,Qe.id),jr(!1)},children:[As.name," (",As.email,")"]},As.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(jt=>jt.brokerage_id===Qe.id).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(jt=>jt.brokerage_id===Qe.id).map(jt=>e.jsxs("div",{className:"text-sm py-1 flex items-center justify-between",children:[e.jsx("span",{children:jt.name}),jt.roles.includes("brokerage_manager")&&e.jsx(tt,{variant:"outline",className:"text-xs",children:"Manager"})]},jt.id))})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:Fl,children:"Cancel"}),e.jsx(K,{onClick:ch,disabled:Lt,children:Lt?"Saving...":"Save Changes"})]})]})}),e.jsx(fs,{open:hs,onOpenChange:Ts,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(Gr,{children:['Are you sure you want to delete "',Cs==null?void 0:Cs.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 "',Cs==null?void 0:Cs.name,'"']}),e.jsxs("li",{children:["All ",l.filter(jt=>jt.brokerage_id===(Cs==null?void 0:Cs.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Ts(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:zl,disabled:er,children:er?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(fs,{open:Es,onOpenChange:ur,children:e.jsxs(ps,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-5 w-5"}),"Manage ",Mr==null?void 0:Mr.name]}),e.jsx(Gr,{children:"Add, remove, or manage users in this brokerage"})]}),Mr&&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(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search members...",value:fn,onChange:jt=>ki(jt.target.value),className:"pl-10 h-9"})]}),e.jsxs(fs,{open:Ea,onOpenChange:dr,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Tl,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Add New Agent"}),e.jsxs(Gr,{children:["Create a new agent for ",Mr.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(ze,{id:"agent-name",placeholder:"John Doe",value:Jr.name,onChange:jt=>Wr({...Jr,name:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"agent-email",children:"Email"}),e.jsx(ze,{id:"agent-email",type:"email",placeholder:"john@example.com",value:Jr.email,onChange:jt=>Wr({...Jr,email:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"agent-password",children:"Password"}),e.jsx(ze,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:Jr.password,onChange:jt=>Wr({...Jr,password:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"agent-phone",children:"Phone (optional)"}),e.jsx(ze,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:Jr.phone,onChange:jt=>Wr({...Jr,phone:jt.target.value})})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>dr(!1),children:"Cancel"}),e.jsx(K,{onClick:W1,disabled:dn,children:dn?"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($o,{open:ea,onOpenChange:Pa,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":ea,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(cn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search users...",value:Ii,onValueChange:Fo}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:"No users found."}),e.jsx(Fx,{children:cu(Mr.id).filter(jt=>Ii===""||jt.name.toLowerCase().includes(Ii.toLowerCase())||jt.email.toLowerCase().includes(Ii.toLowerCase())).map(jt=>e.jsxs(bp,{value:`${jt.name} ${jt.email}`,onSelect:()=>{H1(jt.id,Mr.id),Pa(!1),Fo("")},children:[jt.name," (",jt.email,")"]},jt.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"font-semibold",children:"Name"}),e.jsx(St,{className:"font-semibold",children:"Email"}),e.jsx(St,{className:"font-semibold",children:"Status"}),e.jsx(St,{className:"font-semibold",children:"Role"}),e.jsx(St,{className:"w-[120px]"})]})}),e.jsx(zn,{children:am(Mr.id).length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:fn?"No matching members found":"No members in this brokerage"})}):am(Mr.id).map(jt=>e.jsxs(Ss,{className:"hover:bg-muted/30",children:[e.jsx(dt,{className:"font-medium",children:jt.name}),e.jsx(dt,{className:"text-muted-foreground",children:jt.email}),e.jsx(dt,{children:jt.claimed?e.jsx(tt,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):e.jsx(tt,{variant:"secondary",children:"Pending"})}),e.jsx(dt,{children:jt.roles.includes("brokerage_manager")?e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(th,{className:"h-3 w-3"}),"Manager"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Agent"})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[!jt.claimed&&e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Ia(jt.id),title:"Resend welcome email",children:e.jsx(cr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>V1(jt.id),title:"Remove from brokerage",children:e.jsx(Rr,{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:()=>by(jt.id),disabled:a||jt.id===(s==null?void 0:s.id),title:jt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${jt.name}`,children:a?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(aS,{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:()=>Ti(jt.id,jt.name),title:"Delete user",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},jt.id))})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Dp(Mr.id).length," total member",Dp(Mr.id).length!==1?"s":""," •",Dp(Mr.id).filter(jt=>jt.roles.includes("brokerage_manager")).length," manager",Dp(Mr.id).filter(jt=>jt.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(qn,{children:e.jsx(K,{variant:"outline",onClick:yy,children:"Close"})})]})})]}),e.jsx(bs,{value:"teams",children:e.jsx(eVt,{})}),e.jsx(bs,{value:"trials",children:e.jsx(YUt,{})}),e.jsx(bs,{value:"celebrations",children:e.jsx(ZUt,{})}),e.jsx(bs,{value:"deletions",children:e.jsx(XUt,{})})]})]}),e.jsx(stt,{open:vi,onOpenChange:pt,brokerages:p,onSuccess:ti}),Ps&&e.jsx(rtt,{open:Ut,onOpenChange:jt=>{Xt(jt),jt||gs(null)},userId:Ps.id,userName:Ps.name})]})},sVt=()=>{const[t,s]=N.useState([]),[r,n]=N.useState(!0),[a,o]=N.useState(!1),[l,i]=N.useState(""),[c,u]=N.useState(""),[p,f]=N.useState(""),[g,b]=N.useState("");N.useEffect(()=>{_()},[]);const _=async()=>{const{data:I,error:O}=await H.from("invite_codes").select("*").order("created_at",{ascending:!1});O?(me.error("Failed to load invite codes"),console.error(O)):s(I||[]),n(!1)},j=async I=>{if(I.preventDefault(),!l.trim()){me.error("Please enter a code");return}o(!0);const{error:O}=await H.from("invite_codes").insert({code:l.trim().toUpperCase(),description:c.trim()||null,max_uses:p?parseInt(p):null,trial_days:g?parseInt(g):null});O?O.code==="23505"?me.error("This code already exists"):(me.error("Failed to create invite code"),console.error(O)):(me.success("Invite code created"),i(""),u(""),f(""),b(""),_()),o(!1)},w=async(I,O)=>{const{error:q}=await H.from("invite_codes").update({is_active:!O}).eq("id",I);q?me.error("Failed to update code"):s(t.map(U=>U.id===I?{...U,is_active:!O}:U))},k=async I=>{const{error:O}=await H.from("invite_codes").delete().eq("id",I);O?me.error("Failed to delete code"):(me.success("Code deleted"),s(t.filter(q=>q.id!==I)))},S="https://dashboard.relevelup.com",M=I=>{const O=`${S}/join?code=${I}`;navigator.clipboard.writeText(O),me.success("Link copied to clipboard")},L=`${S}/join`;return e.jsx(Ms,{title:"Invite Codes",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Invite Codes",description:"Manage signup invite codes"}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Create New Code"}),e.jsxs(gr,{children:["Share link: ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:L})]})]}),e.jsx(De,{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(ze,{id:"code",placeholder:"WELCOME2024",value:l,onChange:I=>i(I.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(ze,{id:"description",placeholder:"For marketing campaign",value:c,onChange:I=>u(I.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"maxUses",children:"Max Uses"}),e.jsx(ze,{id:"maxUses",type:"number",placeholder:"Unlimited",value:p,onChange:I=>f(I.target.value),className:"w-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"trialDays",children:"Trial Days"}),e.jsx(ze,{id:"trialDays",type:"number",placeholder:"None",value:g,onChange:I=>b(I.target.value),className:"w-28"})]}),e.jsxs(K,{type:"submit",disabled:a,children:[a?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Active Codes"})}),e.jsx(De,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx("p",{className:"text-center py-8 text-muted-foreground",children:"No invite codes yet"}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Code"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Uses"}),e.jsx(St,{children:"Trial"}),e.jsx(St,{children:"Created"}),e.jsx(St,{children:"Active"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(zn,{children:t.map(I=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-mono font-medium",children:I.code}),e.jsx(dt,{className:"text-muted-foreground",children:I.description||"—"}),e.jsxs(dt,{children:[I.uses_count,I.max_uses&&` / ${I.max_uses}`]}),e.jsx(dt,{children:I.trial_days?e.jsxs("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:[I.trial_days," days"]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"text-muted-foreground",children:ms(new Date(I.created_at),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx(qr,{checked:I.is_active,onCheckedChange:()=>w(I.id,I.is_active)})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>M(I.code),title:"Copy invite link",children:e.jsx(gi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>k(I.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},I.id))})]})})]})]})})},XO=async t=>{try{const{data:s,error:r}=await H.from("push_notification_settings").select("is_enabled").eq("setting_key",t).maybeSingle();return r?(console.error("Error checking notification setting:",r),!0):(s==null?void 0:s.is_enabled)??!0}catch(s){return console.error("Error checking notification setting:",s),!0}},oE=async t=>{try{const{data:s,error:r}=await H.functions.invoke("send-push-notification",{body:t});return r?(console.error("Error sending notification:",r),{success:!1,error:r}):(console.log("Notification sent:",s),{success:!0,data:s})}catch(s){return console.error("Error sending notification:",s),{success:!1,error:s}}},rVt=async(t,s)=>await XO("new_templates")?oE({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}),nVt=async(t,s)=>oE({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),aVt=async(t,s)=>await XO("new_events")?oE({title:"New Event",body:`New event: ${t}`,url:`/events/${s}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),iVt=async(t,s)=>await XO("new_toolbox")?oE({title:"New Resource Kit",body:`New resource kit available: ${t}`,url:`/toolbox/${s}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),abe=async(t,s)=>await XO("new_social_swag")?oE({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}),oVt=async(t,s)=>await XO("new_newsletters")?oE({title:"New Newsletter",body:`New newsletter available: ${t}`,url:`/newsletters/${s}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),kz={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 lVt(){const t=fr(),s=Qt(),[r,n]=N.useState(!1),[a,o]=N.useState(null),[l,i]=N.useState(kz),[c,u]=N.useState(null),[p,f]=N.useState(null),[g,b]=N.useState(!1),_=N.useRef(null),[j,w]=N.useState(!1),[k,S]=N.useState(null),[M,L]=N.useState(!1),[I,O]=N.useState(null),[q,U]=N.useState(null),[B,V]=N.useState(!0),[Z,X]=N.useState(""),{data:ee,isLoading:Q}=mt({queryKey:["admin-events"],queryFn:async()=>{const{data:Ce,error:rt}=await H.from("events").select("*").order("event_date",{ascending:!0});if(rt)throw rt;return Ce}}),{data:ie}=mt({queryKey:["event-registrations-count"],queryFn:async()=>{let Ce=[],rt=0;const Ge=1e3;for(;;){const{data:qe,error:Ze}=await H.from("event_registrations").select("event_id").range(rt,rt+Ge-1);if(Ze)throw Ze;if(!qe||qe.length===0||(Ce=Ce.concat(qe),qe.length{ct[qe.event_id]=(ct[qe.event_id]||0)+1}),ct}}),{data:re,isLoading:oe}=mt({queryKey:["event-registrations-details",k==null?void 0:k.id],queryFn:async()=>{if(!k)return[];const{data:Ce,error:rt}=await H.from("event_registrations").select("id, user_id, registered_at, zoom_join_url, zoom_name, zoom_email").eq("event_id",k.id).order("registered_at",{ascending:!1});if(rt)throw rt;if(!Ce||Ce.length===0)return[];const Ge=Ce.map(Ze=>Ze.user_id).filter(Boolean);let ct=[];if(Ge.length>0){const{data:Ze,error:Qe}=await H.from("profiles").select("id, name, email").in("id",Ge);if(Qe)throw Qe;ct=Ze||[]}const qe=new Map((ct==null?void 0:ct.map(Ze=>[Ze.id,Ze]))||[]);return Ce.map(Ze=>({...Ze,profiles:Ze.user_id&&qe.get(Ze.user_id)||null}))},enabled:!!k}),{data:ce,isLoading:xe}=mt({queryKey:["event-attendees-details",k==null?void 0:k.id],queryFn:async()=>{if(!k)return[];const{data:Ce,error:rt}=await H.from("event_attendees").select("id, user_id, zoom_email, zoom_name, join_time, leave_time, duration_minutes, manually_added, created_at").eq("event_id",k.id).order("created_at",{ascending:!1});if(rt)throw rt;if(!Ce||Ce.length===0)return[];const Ge=Ce.map(He=>He.user_id).filter(Boolean);let ct=[];if(Ge.length>0){const{data:He,error:Je}=await H.from("profiles").select("id, name, email").in("id",Ge);if(Je)throw Je;ct=He||[]}const{data:qe}=await H.from("agent_points").select("user_id").eq("event_id",k.id),Ze=new Set((qe==null?void 0:qe.map(He=>He.user_id))||[]),Qe=new Map((ct==null?void 0:ct.map(He=>[He.id,He]))||[]);return Ce.map(He=>({...He,profiles:He.user_id&&Qe.get(He.user_id)||null,points_awarded:He.user_id?Ze.has(He.user_id):!1}))},enabled:!!k}),ge=Ce=>{S(Ce),w(!0)},ue=Dt({mutationFn:async Ce=>{const{data:{session:rt}}=await H.auth.getSession();if(!rt)throw new Error("Not authenticated");const Ge=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${rt.access_token}`},body:JSON.stringify({event_id:Ce})}),ct=await Ge.json();if(!Ge.ok)throw new Error(ct.error||"Failed to sync");return ct},onSuccess:Ce=>{s.invalidateQueries({queryKey:["event-registrations-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),me.success(Ce.message)},onError:Ce=>{me.error("Failed to sync: "+Ce.message)}}),pe=Dt({mutationFn:async Ce=>{const{data:{session:rt}}=await H.auth.getSession();if(!rt)throw new Error("Not authenticated");const Ge=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${rt.access_token}`},body:JSON.stringify({event_id:Ce})}),ct=await Ge.json();if(!Ge.ok)throw new Error(ct.error||"Failed to sync attendees");return ct},onSuccess:Ce=>{s.invalidateQueries({queryKey:["event-attendees-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),Ce!=null&&Ce.message?me.success(Ce.message):me.success(`Synced ${Ce.synced||0} attendees. ${Ce.points_awarded||0} points awarded!`)},onError:Ce=>{me.error("Failed to sync attendees: "+Ce.message)}}),be=Dt({mutationFn:async({eventId:Ce,testMode:rt})=>{const{data:{session:Ge}}=await H.auth.getSession();if(!Ge)throw new Error("Not authenticated");const ct=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-event-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ge.access_token}`},body:JSON.stringify({event_id:Ce,test_mode:rt})}),qe=await ct.json();if(!ct.ok)throw new Error(qe.error||"Failed to send reminders");return qe},onSuccess:Ce=>{Ce.test?me.success(Ce.message||"Test email sent!"):me.success(Ce.message||`Reminder emails sent to ${Ce.sent} registrants!`)},onError:Ce=>{me.error("Failed to send reminders: "+Ce.message)}}),{data:Me}=mt({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let Ce=[],rt=0;const Ge=1e3;for(;;){const{data:ct,error:qe}=await H.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(rt,rt+Ge-1);if(qe)throw qe;if(!ct||ct.length===0||(Ce=[...Ce,...ct],ct.length{const{error:qe}=await H.from("event_attendees").update({user_id:rt}).eq("id",Ce);if(qe)throw qe;if(ct&&Ge){const{error:Qe}=await H.from("zoom_email_aliases").upsert({user_id:rt,zoom_email:Ge.toLowerCase()},{onConflict:"zoom_email"});Qe&&console.error("Failed to save alias:",Qe)}const Ze=k==null?void 0:k.id;if(Ze){const{data:Qe}=await H.from("user_roles").select("id").eq("user_id",rt).eq("role","admin").single();if(!Qe){const{data:He}=await H.from("agent_points").select("id").eq("user_id",rt).eq("event_id",Ze).single();He||(await H.rpc("award_attendance_points",{p_user_id:rt,p_event_id:Ze,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await H.rpc("check_and_award_badges",{p_user_id:rt}))}}return{userId:rt,zoomEmail:Ge,shouldSaveAlias:ct}},onSuccess:Ce=>{s.invalidateQueries({queryKey:["event-attendees-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let rt="Attendee linked and points awarded!";Ce.shouldSaveAlias&&Ce.zoomEmail&&(rt+=` Email "${Ce.zoomEmail}" will be auto-matched in the future.`),me.success(rt),L(!1),O(null),U(null),X("")},onError:Ce=>{me.error("Failed to link attendee: "+Ce.message)}}),Pe=Ce=>{O(Ce),U(null),V(!0),X(""),L(!0)},Oe=()=>{!I||!q||Ne.mutate({attendeeId:I.id,userId:q,zoomEmail:I.zoom_email,shouldSaveAlias:B})},Te=(Me==null?void 0:Me.filter(Ce=>{var Ge,ct;if(!Z)return!0;const rt=Z.toLowerCase();return((Ge=Ce.name)==null?void 0:Ge.toLowerCase().includes(rt))||((ct=Ce.email)==null?void 0:ct.toLowerCase().includes(rt))}))||[],ke=async Ce=>{const rt=Ce.name.split(".").pop(),ct=`${`${crypto.randomUUID()}.${rt}`}`,{error:qe}=await H.storage.from("event-images").upload(ct,Ce);if(qe)throw qe;const{data:{publicUrl:Ze}}=H.storage.from("event-images").getPublicUrl(ct);return Ze},Be=Ce=>{var Ge;const rt=(Ge=Ce.target.files)==null?void 0:Ge[0];if(rt){if(rt.size>5*1024*1024){me.error("Image must be less than 5MB");return}u(rt),f(URL.createObjectURL(rt))}},nt=()=>{u(null),f(null),i({...l,image_url:""}),_.current&&(_.current.value="")},Ae=Dt({mutationFn:async Ce=>{b(!0);let rt=Ce.image_url;c&&(rt=await ke(c)||"");const Ge=new Date(Ce.event_date),[ct,qe]=Ce.event_time.split(":");Ge.setHours(parseInt(ct),parseInt(qe));const Ze=[new Date(Ge)];if(Ce.is_recurring&&Ce.recurrence_end_date){let it=new Date(Ge);for(;Ce.recurrence_pattern==="weekly"?it=g4(it,1):Ce.recurrence_pattern==="biweekly"?it=g4(it,2):it=Bm(it,1),!(it>Ce.recurrence_end_date);)Ze.push(new Date(it))}const Qe=Ze.map(it=>({title:Ce.title,description:Ce.description||null,image_url:rt||null,video_url:Ce.video_url||null,event_date:it.toISOString(),zoom_link:Ce.zoom_link,zoom_meeting_id:Ce.zoom_meeting_id||null,capacity:Ce.capacity?parseInt(Ce.capacity):null,is_published:Ce.is_published})),{data:He,error:Je}=await H.from("events").insert(Qe).select();if(Je)throw Je;return He&&He.length>0&&aVt(Ce.title,He[0].id),Ze.length},onSuccess:Ce=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success(Ce>1?`${Ce} recurring events created successfully`:"Event created successfully"),n(!1),i(kz),u(null),f(null),b(!1)},onError:Ce=>{me.error("Failed to create event: "+Ce.message),b(!1)}}),ft=Dt({mutationFn:async({id:Ce,data:rt})=>{b(!0);let Ge=rt.image_url;c&&(Ge=await ke(c)||"");const ct=new Date(rt.event_date),[qe,Ze]=rt.event_time.split(":");ct.setHours(parseInt(qe),parseInt(Ze));const{error:Qe}=await H.from("events").update({title:rt.title,description:rt.description||null,image_url:Ge||null,video_url:rt.video_url||null,event_date:ct.toISOString(),zoom_link:rt.zoom_link,zoom_meeting_id:rt.zoom_meeting_id||null,capacity:rt.capacity?parseInt(rt.capacity):null,is_published:rt.is_published}).eq("id",Ce);if(Qe)throw Qe},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success("Event updated successfully"),n(!1),o(null),i(kz),u(null),f(null),b(!1)},onError:Ce=>{me.error("Failed to update event: "+Ce.message),b(!1)}}),fe=Dt({mutationFn:async Ce=>{const{error:rt}=await H.from("events").delete().eq("id",Ce);if(rt)throw rt},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success("Event deleted successfully")},onError:Ce=>{me.error("Failed to delete event: "+Ce.message)}}),Ve=Ce=>{var Ge;const rt=new Date(Ce.event_date);o(Ce),i({title:Ce.title,description:Ce.description||"",image_url:Ce.image_url||"",video_url:Ce.video_url||"",event_date:rt,event_time:ms(rt,"HH:mm"),zoom_link:Ce.zoom_link,zoom_meeting_id:Ce.zoom_meeting_id||"",capacity:((Ge=Ce.capacity)==null?void 0:Ge.toString())||"",is_published:Ce.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),f(Ce.image_url||null),u(null),n(!0)},at=Ce=>{if(Ce.preventDefault(),!l.event_date){me.error("Please select a date");return}if(l.is_recurring&&!l.recurrence_end_date){me.error("Please select an end date for recurring events");return}a?ft.mutate({id:a.id,data:l}):Ae.mutate(l)},et=()=>{n(!1),o(null),i(kz),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(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Event Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Create and manage upcoming events"})]})]}),e.jsxs(Ee,{className:"mb-6",children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{children:"All Events"}),e.jsxs(fs,{open:r,onOpenChange:Ce=>!Ce&&et(),children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Event"]})}),e.jsxs(ps,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:a?"Edit Event":"Create New Event"})}),e.jsxs("form",{onSubmit:at,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:l.title,onChange:Ce=>i({...l,title:Ce.target.value}),placeholder:"Event title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(my,{content:l.description,onChange:Ce=>i({...l,description:Ce}),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:_,accept:"image/*",onChange:Be,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:nt,children:e.jsx(Rr,{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 Ce;return(Ce=_.current)==null?void 0:Ce.click()},children:[e.jsx(li,{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($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!l.event_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),l.event_date?ms(l.event_date,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:l.event_date,onSelect:Ce=>i({...l,event_date:Ce}),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(ze,{id:"time",type:"time",value:l.event_time,onChange:Ce=>i({...l,event_time:Ce.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"zoom_link",children:"Zoom Link *"}),e.jsx(ze,{id:"zoom_link",value:l.zoom_link,onChange:Ce=>i({...l,zoom_link:Ce.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(ze,{id:"zoom_meeting_id",value:l.zoom_meeting_id,onChange:Ce=>i({...l,zoom_meeting_id:Ce.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(ze,{id:"video_url",value:l.video_url,onChange:Ce=>i({...l,video_url:Ce.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(ze,{id:"capacity",type:"number",value:l.capacity,onChange:Ce=>i({...l,capacity:Ce.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(bL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{htmlFor:"is_recurring",children:"Recurring Event"})]}),e.jsx(qr,{id:"is_recurring",checked:l.is_recurring,onCheckedChange:Ce=>i({...l,is_recurring:Ce})})]}),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(Zs,{value:l.recurrence_pattern,onValueChange:Ce=>i({...l,recurrence_pattern:Ce}),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"weekly",children:"Weekly"}),e.jsx(Mt,{value:"biweekly",children:"Every 2 Weeks"}),e.jsx(Mt,{value:"monthly",children:"Monthly"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Repeat Until"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!l.recurrence_end_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?ms(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:l.recurrence_end_date,onSelect:Ce=>i({...l,recurrence_end_date:Ce}),disabled:Ce=>Ce<(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 Ce=1,rt=new Date(l.event_date);for(;rt=l.recurrence_pattern==="weekly"?g4(rt,1):l.recurrence_pattern==="biweekly"?g4(rt,2):Bm(rt,1),!(rt>l.recurrence_end_date);)Ce++;return Ce})()," 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(qr,{id:"is_published",checked:l.is_published,onCheckedChange:Ce=>i({...l,is_published:Ce})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:et,className:"flex-1",children:"Cancel"}),e.jsx(K,{type:"submit",className:"flex-1",disabled:Ae.isPending||ft.isPending||g,children:g?"Uploading...":a?"Update Event":l.is_recurring&&l.event_date&&l.recurrence_end_date?"Create Recurring Events":"Create Event"})]})]})]})]})]}),e.jsx(De,{children:Q?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading events..."}):(ee==null?void 0:ee.length)===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No events yet. Create your first event!"}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Date & Time"}),e.jsx(St,{children:"Registrations"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:ee==null?void 0:ee.map(Ce=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:Ce.title}),e.jsx(dt,{children:ms(new Date(Ce.event_date),"PPP p")}),e.jsx(dt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>ge(Ce),children:[e.jsx(pr,{className:"h-4 w-4"}),(ie==null?void 0:ie[Ce.id])||0,Ce.capacity&&` / ${Ce.capacity}`]})}),e.jsx(dt,{children:e.jsx("span",{className:It("px-2 py-1 rounded-full text-xs font-medium",Ce.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:Ce.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(Ce.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(tn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ve(Ce),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?")&&fe.mutate(Ce.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Ce.id))})]})})]}),e.jsx(fs,{open:j,onOpenChange:w,children:e.jsxs(ps,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),k==null?void 0:k.title]}),e.jsx(Gr,{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:()=>be.mutate({eventId:k.id,testMode:!0}),disabled:be.isPending,children:[e.jsx(cr,{className:It("h-4 w-4 mr-2",be.isPending&&"animate-spin")}),"Send Test to Me"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>be.mutate({eventId:k.id}),disabled:be.isPending||!(re!=null&&re.length),children:[e.jsx(cr,{className:It("h-4 w-4 mr-2",be.isPending&&"animate-spin")}),be.isPending?"Sending...":"Send Reminder to All"]}),(k==null?void 0:k.zoom_meeting_id)&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ue.mutate(k.id),disabled:ue.isPending,children:[e.jsx(Go,{className:It("h-4 w-4 mr-2",ue.isPending&&"animate-spin")}),ue.isPending?"Syncing...":"Sync Registrations"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>pe.mutate(k.id),disabled:pe.isPending,children:[e.jsx(xo,{className:It("h-4 w-4 mr-2",pe.isPending&&"animate-spin")}),pe.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),e.jsxs(ba,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2",children:[e.jsxs(ns,{value:"registrations",className:"gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),"Registrations (",(re==null?void 0:re.length)||0,")"]}),e.jsxs(ns,{value:"attendees",className:"gap-2",children:[e.jsx(sa,{className:"h-4 w-4"}),"Attendees (",(ce==null?void 0:ce.length)||0,")"]})]}),e.jsx(bs,{value:"registrations",className:"mt-4",children:oe?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading registrations..."}):(re==null?void 0:re.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No registrations yet for this event."}),(k==null?void 0:k.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Registrations" to import from Zoom.'})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Registered"}),e.jsx(St,{children:"Status"})]})}),e.jsx(zn,{children:re==null?void 0:re.map(Ce=>{var qe,Ze;const rt=((qe=Ce.profiles)==null?void 0:qe.name)||Ce.zoom_name||"Unknown",Ge=((Ze=Ce.profiles)==null?void 0:Ze.email)||Ce.zoom_email||null,ct=!Ce.user_id;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[rt,ct&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),e.jsx(dt,{children:Ge?e.jsxs("a",{href:`mailto:${Ge}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(cr,{className:"h-3 w-3"}),Ge]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(dt,{className:"text-muted-foreground text-sm",children:ms(new Date(Ce.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{children:Ce.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"})})]},Ce.id)})})]})}),e.jsx(bs,{value:"attendees",className:"mt-4",children:xe?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading attendees..."}):(ce==null?void 0:ce.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No attendees recorded yet."}),(k==null?void 0:k.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Attendees & Award Points" after the event ends to import actual participants from Zoom.'})]}):e.jsxs(e.Fragment,{children:[(ce==null?void 0:ce.filter(Ce=>!Ce.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(kl,{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 (",ce==null?void 0:ce.filter(Ce=>!Ce.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:ce==null?void 0:ce.filter(Ce=>!Ce.user_id).map(Ce=>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:Ce.zoom_name||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Ce.zoom_email||"No email"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Pe(Ce),className:"gap-1",children:[e.jsx(dl,{className:"h-3 w-3"}),"Link to Profile"]})]},Ce.id))})]}),e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Duration"}),e.jsx(St,{children:"Points"})]})}),e.jsx(zn,{children:ce==null?void 0:ce.filter(Ce=>Ce.user_id).map(Ce=>{var ct,qe;const rt=((ct=Ce.profiles)==null?void 0:ct.name)||Ce.zoom_name||"Unknown",Ge=((qe=Ce.profiles)==null?void 0:qe.email)||Ce.zoom_email||null;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[rt,Ce.manually_added&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",children:"Manual"})]})}),e.jsx(dt,{children:Ge?e.jsxs("a",{href:`mailto:${Ge}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(cr,{className:"h-3 w-3"}),Ge]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(dt,{children:Ce.duration_minutes?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[e.jsx(un,{className:"h-3 w-3"}),Ce.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:Ce.points_awarded?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:[e.jsx(xo,{className:"h-3 w-3"}),"+10 pts"]}):e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-muted text-muted-foreground",children:"Pending"})})]},Ce.id)})})]})]})})]})]})}),e.jsx(fs,{open:M,onOpenChange:L,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(dl,{className:"h-5 w-5"}),"Link Attendee to Profile"]}),e.jsx(Gr,{children:"Link this Zoom attendee to an existing member profile to award them points."})]}),I&&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:I.zoom_name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:I.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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:Z,onChange:Ce=>X(Ce.target.value),className:"pl-9"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-md",children:Te.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:Te.slice(0,20).map(Ce=>e.jsxs("button",{type:"button",onClick:()=>U(Ce.id),className:It("w-full p-3 text-left hover:bg-muted/50 transition-colors",q===Ce.id&&"bg-primary/10 border-l-2 border-primary"),children:[e.jsx("p",{className:"text-sm font-medium",children:Ce.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Ce.email})]},Ce.id))})}),I.zoom_email&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Oo,{id:"save-alias",checked:B,onCheckedChange:Ce=>V(Ce)}),e.jsx("label",{htmlFor:"save-alias",className:"text-sm text-muted-foreground cursor-pointer",children:"Remember this email for future auto-matching"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsx(K,{onClick:Oe,disabled:!q||Ne.isPending,children:Ne.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}function cVt({selectedKitIds:t,onChange:s}){const[r,n]=N.useState(""),[a,o]=N.useState(!1),{data:l=[]}=mt({queryKey:["all-resource-kits-picker"],queryFn:async()=>{const{data:f,error:g}=await H.from("resource_kits").select("id, name, featured_image_url").eq("is_published",!0).order("name");if(g)throw g;return f}}),i=l.filter(f=>t.includes(f.id)),c=l.filter(f=>!t.includes(f.id)&&f.name.toLowerCase().includes(r.toLowerCase())),u=f=>{s([...t,f])},p=f=>{s(t.filter(g=>g!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(Ml,{className:"h-4 w-4"}),"Linked Toolkits"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(f=>e.jsxs(tt,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>p(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Rr,{className:"h-3 w-3"})})]},f.id))}),e.jsxs($o,{open:a,onOpenChange:o,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(Ml,{className:"h-3.5 w-3.5"}),"Add Toolkit"]})}),e.jsxs(Ro,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(cn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search toolkits...",value:r,onChange:f=>n(f.target.value),className:"pl-7 h-8 text-sm"})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children:c.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:r?"No toolkits found":"All toolkits selected"}):c.map(f=>e.jsxs("button",{type:"button",onClick:()=>{u(f.id),n("")},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[f.featured_image_url?e.jsx("img",{src:f.featured_image_url,alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(Ml,{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 dVt=()=>{const{user:t}=Ds(),{toast:s}=Ua(),r=Qt(),[n,a]=Cc(),[o,l]=N.useState(!1),[i,c]=N.useState(null),[u,p]=N.useState({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),[f,g]=N.useState(null),[b,_]=N.useState(0),[j,w]=N.useState(!1),[k,S]=N.useState(null),[M,L]=N.useState(""),[I,O]=N.useState([]),[q,U]=N.useState(""),[B,V]=N.useState(""),[Z,X]=N.useState(!1),[ee,Q]=N.useState(!1),{data:ie=[]}=mt({queryKey:["template-categories"],queryFn:async()=>{const{data:Ve,error:at}=await H.from("template_categories").select("*").order("name");if(at)throw at;return Ve}}),{data:re=[]}=mt({queryKey:["template-types"],queryFn:async()=>{const{data:Ve,error:at}=await H.from("template_types").select("*").order("name");if(at)throw at;return Ve}}),{data:oe=[],isLoading:ce}=mt({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:Ve,error:at}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(at)throw at;const{data:et,error:Ce}=await H.from("template_links").select("*").order("sort_order");if(Ce)throw Ce;const{data:rt,error:Ge}=await H.from("template_guides").select("*").order("sort_order");if(Ge)throw Ge;return Ve.map(qe=>({...qe,links:(et==null?void 0:et.filter(Ze=>Ze.template_id===qe.id))||[],guides:(rt==null?void 0:rt.filter(Ze=>Ze.template_id===qe.id))||[]}))}});N.useEffect(()=>{const Ve=n.get("edit");if(Ve&&oe.length>0){const at=oe.find(et=>et.id===Ve);at&&(Me(at),a({},{replace:!0}))}},[oe,n]);const xe=Dt({mutationFn:async Ve=>{const{data:at,error:et}=await H.from("template_categories").insert({name:Ve}).select().single();if(et)throw et;return at},onSuccess:Ve=>{r.invalidateQueries({queryKey:["template-categories"]}),p({...u,category_id:Ve.id}),U(""),X(!1),s({title:"Category added"})},onError:Ve=>{s({title:"Error adding category",description:Ve.message,variant:"destructive"})}}),ge=Dt({mutationFn:async Ve=>{const{data:at,error:et}=await H.from("template_types").insert({name:Ve}).select().single();if(et)throw et;return at},onSuccess:Ve=>{r.invalidateQueries({queryKey:["template-types"]}),p({...u,type_id:Ve.id}),V(""),Q(!1),s({title:"Type added"})},onError:Ve=>{s({title:"Error adding type",description:Ve.message,variant:"destructive"})}}),ue=Dt({mutationFn:async Ve=>{var Ge;let at=Ve.existingImageUrl;if(Ve.image){const ct=Ve.image.name.split(".").pop(),qe=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ct}`,{error:Ze}=await H.storage.from("template-previews").upload(qe,Ve.image);if(Ze)throw Ze;const{data:Qe}=H.storage.from("template-previews").getPublicUrl(qe);at=Qe.publicUrl}const et={name:Ve.template.name,description:Ve.template.description||null,category_id:Ve.template.category_id||null,type_id:Ve.template.type_id||null,preview_image_url:at,video_url:Ve.videoUrl||null,publish_date:Ve.template.publish_date?new Date(Ve.template.publish_date).toISOString():new Date().toISOString(),created_by:t==null?void 0:t.id};let Ce=Ve.templateId;if(Ce){const{error:ct}=await H.from("canva_templates").update(et).eq("id",Ce);if(ct)throw ct;const{error:qe}=await H.from("template_links").delete().eq("template_id",Ce);if(qe)throw qe;const Ze=((Ge=Ve.existingGuides)==null?void 0:Ge.map(Je=>Je.id).filter(Boolean))||[],Qe=Ve.template.guides.map(Je=>Je.id).filter(Boolean),He=Ze.filter(Je=>!Qe.includes(Je));He.length>0&&await H.from("template_guides").delete().in("id",He)}else{const{data:ct,error:qe}=await H.from("canva_templates").insert(et).select().single();if(qe)throw qe;Ce=ct.id,rVt(Ve.template.name,ct.id)}const rt=Ve.template.links.filter(ct=>ct.title.trim()&&ct.canva_share_link.trim());if(rt.length>0){const ct=rt.map((Ze,Qe)=>({template_id:Ce,title:Ze.title.trim(),canva_share_link:Ze.canva_share_link.trim(),sort_order:Qe})),{error:qe}=await H.from("template_links").insert(ct);if(qe)throw qe}for(let ct=0;ct0)){const{error:ct}=await H.from("resource_kit_templates").insert(Ve.linkedKitIds.map(qe=>({template_id:Ce,kit_id:qe})));if(ct)throw ct}},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),be(),l(!1),s({title:i?"Template updated":"Template created"})},onError:Ve=>{s({title:"Error saving template",description:Ve.message,variant:"destructive"})}}),pe=Dt({mutationFn:async Ve=>{const{error:at}=await H.from("canva_templates").delete().eq("id",Ve);if(at)throw at},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),s({title:"Template deleted"})},onError:Ve=>{s({title:"Error deleting template",description:Ve.message,variant:"destructive"})}}),be=()=>{p({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),S(null),L(""),c(null),X(!1),Q(!1),U(""),V(""),g(null),_(0),w(!1),O([])},Me=async Ve=>{var et;c(Ve),p({name:Ve.name,description:Ve.description||"",category_id:Ve.category_id||"",type_id:Ve.type_id||"",publish_date:Ve.publish_date?new Date(Ve.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:Ve.links&&Ve.links.length>0?Ve.links.map(Ce=>({id:Ce.id,title:Ce.title,canva_share_link:Ce.canva_share_link,sort_order:Ce.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((et=Ve.guides)==null?void 0:et.map(Ce=>({id:Ce.id,name:Ce.name,file_url:Ce.file_url,file_type:Ce.file_type,file_size:Ce.file_size,sort_order:Ce.sort_order})))||[],video_url:Ve.video_url||""}),L(Ve.preview_image_url||""),g(null);const{data:at}=await H.from("resource_kit_templates").select("kit_id").eq("template_id",Ve.id);O((at||[]).map(Ce=>Ce.kit_id)),l(!0)},Ne=Ve=>{var et;const at=(et=Ve.target.files)==null?void 0:et[0];at&&(S(at),L(URL.createObjectURL(at)))},Pe=()=>{p({...u,links:[...u.links,{title:"",canva_share_link:"",sort_order:u.links.length}]})},Oe=Ve=>{if(u.links.length<=1)return;const at=u.links.filter((et,Ce)=>Ce!==Ve);p({...u,links:at})},Te=(Ve,at,et)=>{const Ce=[...u.links];Ce[Ve]={...Ce[Ve],[at]:et},p({...u,links:Ce})},ke=Ve=>{const at=Ve.target.files;if(!at)return;const et=Array.from(at).map((Ce,rt)=>({name:Ce.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:Ce.type,file_size:Ce.size,sort_order:u.guides.length+rt,file:Ce}));p({...u,guides:[...u.guides,...et]}),Ve.target.value=""},Be=Ve=>{const at=u.guides.filter((et,Ce)=>Ce!==Ve);p({...u,guides:at})},nt=(Ve,at)=>{const et=[...u.guides];et[Ve]={...et[Ve],name:at},p({...u,guides:et})},Ae=async()=>{if(!f)return null;w(!0),_(0);try{const{data:Ve,error:at}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:u.name||f.name}});if(at)throw new Error(at.message);const{videoId:et,libraryId:Ce}=Ve,{data:rt,error:Ge}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:et}});if(Ge)throw new Error(Ge.message);const ct=new XMLHttpRequest;return await new Promise((Ze,Qe)=>{ct.upload.addEventListener("progress",He=>{if(He.lengthComputable){const Je=Math.round(He.loaded/He.total*100);_(Je)}}),ct.addEventListener("load",()=>{ct.status>=200&&ct.status<300?Ze():Qe(new Error(`Upload failed with status ${ct.status}`))}),ct.addEventListener("error",()=>Qe(new Error("Upload failed"))),ct.open("PUT",rt.uploadUrl),ct.setRequestHeader("AccessKey",rt.apiKey),ct.send(f)}),`https://player.mediadelivery.net/embed/${Ce}/${et}`}catch(Ve){return console.error("Bunny upload error:",Ve),s({title:"Video upload failed",description:Ve instanceof Error?Ve.message:"Unknown error",variant:"destructive"}),null}finally{w(!1)}},ft=Ve=>{var et;const at=(et=Ve.target.files)==null?void 0:et[0];at&&g(at),Ve.target.value=""},fe=async Ve=>{if(Ve.preventDefault(),!u.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(u.links.filter(Ce=>Ce.title.trim()&&Ce.canva_share_link.trim()).length===0){s({title:"Please add at least one Canva link",variant:"destructive"});return}let et=u.video_url;if(f){const Ce=await Ae();if(!Ce)return;et=Ce}ue.mutate({template:u,image:k,existingImageUrl:(i==null?void 0:i.preview_image_url)||null,templateId:i==null?void 0:i.id,existingGuides:i==null?void 0:i.guides,videoUrl:et,linkedKitIds:I})};return e.jsx(Ms,{title:"Manage Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Manage Templates",description:"Create and manage Canva templates"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:oe.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:ie.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:re.length})})]})]}),e.jsxs(fs,{open:o,onOpenChange:Ve=>{l(Ve),Ve||be()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Add Template"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:i?"Edit Template":"Add New Template"})}),e.jsxs("form",{onSubmit:fe,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Name *"}),e.jsx(ze,{id:"name",value:u.name,onChange:Ve=>p({...u,name:Ve.target.value}),placeholder:"Template name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(my,{content:u.description,onChange:Ve=>p({...u,description:Ve}),placeholder:"Brief description of the template",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Canva Links *"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Pe,className:"gap-1",children:[e.jsx($s,{className:"h-3 w-3"}),"Add Link"]})]}),e.jsx("div",{className:"space-y-3",children:u.links.map((Ve,at)=>e.jsxs("div",{className:"flex gap-2 items-start p-3 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ze,{value:Ve.title,onChange:et=>Te(at,"title",et.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(ze,{value:Ve.canva_share_link,onChange:et=>Te(at,"canva_share_link",et.target.value),placeholder:"https://www.canva.com/design/..."})]}),u.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>Oe(at),children:e.jsx(Rr,{className:"h-4 w-4"})})]},at))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Category"}),Z?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:q,onChange:Ve=>U(Ve.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>q.trim()&&xe.mutate(q.trim()),disabled:xe.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{X(!1),U("")},children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Zs,{value:u.category_id,onValueChange:Ve=>p({...u,category_id:Ve}),children:[e.jsx(Ws,{className:"flex-1",children:e.jsx(Xs,{placeholder:"Select category"})}),e.jsx(Gs,{children:ie.map(Ve=>e.jsx(Mt,{value:Ve.id,children:Ve.name},Ve.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>X(!0),children:e.jsx($s,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Template Type"}),ee?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:B,onChange:Ve=>V(Ve.target.value),placeholder:"New type name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>B.trim()&&ge.mutate(B.trim()),disabled:ge.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Q(!1),V("")},children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Zs,{value:u.type_id,onValueChange:Ve=>p({...u,type_id:Ve}),children:[e.jsx(Ws,{className:"flex-1",children:e.jsx(Xs,{placeholder:"Select type"})}),e.jsx(Gs,{children:re.map(Ve=>e.jsx(Mt,{value:Ve.id,children:Ve.name},Ve.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>Q(!0),children:e.jsx($s,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:u.publish_date,onChange:Ve=>p({...u,publish_date:Ve.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Templates are sorted by publish date (newest first) on the member page"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[M?e.jsxs("div",{className:"relative w-32 h-24 rounded-lg overflow-hidden border bg-muted",children:[e.jsx("img",{src:M,alt:"Preview",className:"w-full h-full object-cover"}),e.jsx(K,{type:"button",size:"icon",variant:"destructive",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>{S(null),L("")},children:e.jsx(Rr,{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(gl,{className:"h-8 w-8 text-muted-foreground/50"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:Ne,className:"cursor-pointer"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Upload a preview image for this template"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(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(An,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:"Video uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>p({...u,video_url:""}),className:"text-destructive hover:text-destructive",children:"Remove"})]}),e.jsx("div",{className:"aspect-video max-w-md rounded-lg overflow-hidden border",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]}):j?e.jsxs("div",{className:"space-y-2 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm",children:["Uploading video... ",b,"%"]})]}),e.jsx(Bi,{value:b,className:"h-2"})]}):f?e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/30",children:[e.jsx(An,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:f.name}),e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(f.size/1024/1024).toFixed(1)," MB"]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>g(null),children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(ze,{type:"file",accept:"video/*",onChange:ft,className:"hidden"}),e.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 border-2 border-dashed rounded-lg hover:border-primary/50 transition-colors",children:[e.jsx(An,{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(ze,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:ke,className:"hidden"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",asChild:!0,children:e.jsxs("span",{children:[e.jsx(li,{className:"h-3 w-3"}),"Add Files"]})})]})]}),u.guides.length>0?e.jsx("div",{className:"space-y-2",children:u.guides.map((Ve,at)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(Sn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(ze,{value:Ve.name,onChange:et=>nt(at,et.target.value),placeholder:"Guide name",className:"flex-1"}),Ve.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(Ve.file_size/1024).toFixed(0)," KB"]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>Be(at),children:e.jsx(Rr,{className:"h-4 w-4"})})]},Ve.id||at))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No guide files added. Upload PDFs to help agents understand how to use this template."})]}),e.jsx(cVt,{selectedKitIds:I,onChange:O}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{l(!1),be()},children:"Cancel"}),e.jsx(K,{type:"submit",disabled:ue.isPending,children:ue.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(De,{className:"p-0",children:ce?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):oe.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No templates yet. Add your first template!"}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Preview"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Links"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:oe.map(Ve=>{var at,et,Ce,rt,Ge;return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:Ve.preview_image_url?e.jsx("img",{src:Ve.preview_image_url,alt:Ve.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(gl,{className:"h-4 w-4 text-muted-foreground"})})})}),e.jsx(dt,{className:"font-medium",children:Ve.name}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs(tt,{variant:"secondary",children:[((at=Ve.links)==null?void 0:at.length)||0," link",(((et=Ve.links)==null?void 0:et.length)||0)!==1?"s":""]}),(((Ce=Ve.guides)==null?void 0:Ce.length)||0)>0&&e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"}),(rt=Ve.guides)==null?void 0:rt.length," guide",(((Ge=Ve.guides)==null?void 0:Ge.length)||0)!==1?"s":""]})]})}),e.jsx(dt,{children:Ve.category?e.jsx(tt,{variant:"secondary",children:Ve.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{children:Ve.type?e.jsx(tt,{variant:"outline",children:Ve.type.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{className:"text-muted-foreground",children:new Date(Ve.publish_date).toLocaleDateString()}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"icon",variant:"ghost",onClick:()=>Me(Ve),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?")&&pe.mutate(Ve.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},Ve.id)})})]})})})]})})};function ctt({selectedTemplateIds:t,onChange:s}){const[r,n]=N.useState(""),[a,o]=N.useState(!1),{data:l=[]}=mt({queryKey:["all-canva-templates-picker"],queryFn:async()=>{const{data:f,error:g}=await H.from("canva_templates").select("id, name, preview_image_url").order("name");if(g)throw g;return f}}),i=l.filter(f=>t.includes(f.id)),c=l.filter(f=>!t.includes(f.id)&&f.name.toLowerCase().includes(r.toLowerCase())),u=f=>{s([...t,f])},p=f=>{s(t.filter(g=>g!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(nS,{className:"h-4 w-4"}),"Linked Templates"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(f=>e.jsxs(tt,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>p(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Rr,{className:"h-3 w-3"})})]},f.id))}),e.jsxs($o,{open:a,onOpenChange:o,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(nS,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs(Ro,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(cn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search templates...",value:r,onChange:f=>n(f.target.value),className:"pl-7 h-8 text-sm"})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children:c.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:r?"No templates found":"All templates selected"}):c.map(f=>e.jsxs("button",{type:"button",onClick:()=>{u(f.id),n("")},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[f.preview_image_url?e.jsx("img",{src:f.preview_image_url,alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(nS,{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 uVt=[{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"}],hVt=()=>{const{user:t}=Ds(),[s,r]=Cc(),{toast:n}=Ua(),a=Qt(),[o,l]=N.useState(!1),[i,c]=N.useState(null),[u,p]=N.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[f,g]=N.useState(null),[b,_]=N.useState(""),[j,w]=N.useState([]),[k,S]=N.useState([]),[M,L]=N.useState([]),[I,O]=N.useState([]),[q,U]=N.useState(""),[B,V]=N.useState(!1),[Z,X]=N.useState(null),[ee,Q]=N.useState(0),[ie,re]=N.useState(!1),[oe,ce]=N.useState(null),{data:xe=[]}=mt({queryKey:["academy-categories"],queryFn:async()=>{const{data:fe,error:Ve}=await H.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(Ve)throw Ve;return fe}}),{data:ge=[],isLoading:ue}=mt({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:fe,error:Ve}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if(Ve)throw Ve;const{data:at,error:et}=await H.from("academy_resources").select("*").order("sort_order");if(et)throw et;return fe.map(rt=>({...rt,resources:(at==null?void 0:at.filter(Ge=>Ge.video_id===rt.id))||[]}))}});N.useEffect(()=>{const fe=s.get("edit");if(fe&&ge.length>0){const Ve=ge.find(at=>at.id===fe);Ve&&(Oe(Ve),r({},{replace:!0}))}},[ge,s]);const pe=Dt({mutationFn:async fe=>{const{data:Ve,error:at}=await H.from("academy_categories").insert({name:fe,sort_order:xe.length}).select().single();if(at)throw at;return Ve},onSuccess:fe=>{a.invalidateQueries({queryKey:["academy-categories"]}),p({...u,category_id:fe.id}),U(""),V(!1),n({title:"Category added"})},onError:fe=>{n({title:"Error adding category",description:fe.message,variant:"destructive"})}}),be=Dt({mutationFn:async fe=>{let Ve=fe.existingThumbnailUrl;if(fe.thumbnail){const Ce=fe.thumbnail.name.split(".").pop(),rt=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${Ce}`,{error:Ge}=await H.storage.from("academy-resources").upload(rt,fe.thumbnail);if(Ge)throw Ge;const{data:ct}=H.storage.from("academy-resources").getPublicUrl(rt);Ve=ct.publicUrl}const at={title:fe.video.title,description:fe.video.description||null,video_url:fe.video.video_url,video_type:fe.video.video_type,duration:fe.video.duration||null,thumbnail_url:Ve,category_id:fe.video.category_id||null,publish_date:fe.video.publish_date?new Date(fe.video.publish_date).toISOString():new Date().toISOString(),is_published:fe.video.is_published,created_by:t==null?void 0:t.id};let et=fe.videoId;if(et){const{error:Ce}=await H.from("academy_videos").update(at).eq("id",et);if(Ce)throw Ce}else{const{data:Ce,error:rt}=await H.from("academy_videos").insert(at).select().single();if(rt)throw rt;et=Ce.id,nVt(fe.video.title,Ce.id)}if(fe.resourcesToDelete.length>0){const{error:Ce}=await H.from("academy_resources").delete().in("id",fe.resourcesToDelete);if(Ce)throw Ce}for(let Ce=0;Ce0){const{error:Ce}=await H.from("academy_video_templates").insert(I.map(rt=>({video_id:et,template_id:rt})));if(Ce)throw Ce}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Pe(),l(!1),n({title:i?"Video updated":"Video created"})},onError:fe=>{n({title:"Error saving video",description:fe.message,variant:"destructive"})}}),Me=Dt({mutationFn:async fe=>{const{error:Ve}=await H.from("academy_videos").delete().eq("id",fe);if(Ve)throw Ve},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),n({title:"Video deleted"})},onError:fe=>{n({title:"Error deleting video",description:fe.message,variant:"destructive"})}}),Ne=Dt({mutationFn:async({id:fe,is_published:Ve})=>{const{error:at}=await H.from("academy_videos").update({is_published:Ve}).eq("id",fe);if(at)throw at},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:fe=>{n({title:"Error updating video",description:fe.message,variant:"destructive"})}}),Pe=()=>{p({title:"",description:"",video_url:"",video_type:"bunny_stream",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),g(null),_(""),w([]),S([]),L([]),c(null),O([]),U(""),X(null),Q(0),re(!1),ce(null)},Oe=async fe=>{c(fe),p({title:fe.title,description:fe.description||"",video_url:fe.video_url,video_type:fe.video_type,duration:fe.duration||"",category_id:fe.category_id||"",publish_date:fe.publish_date?new Date(fe.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:fe.is_published}),_(fe.thumbnail_url||""),S(fe.resources||[]),w([]),L([]);const{data:Ve}=await H.from("academy_video_templates").select("template_id").eq("video_id",fe.id);O((Ve||[]).map(at=>at.template_id)),l(!0)},Te=fe=>{var at;const Ve=(at=fe.target.files)==null?void 0:at[0];Ve&&(g(Ve),_(URL.createObjectURL(Ve)))},ke=fe=>{const Ve=fe.target.files;if(Ve){const at=Array.from(Ve).map(et=>({file:et,title:et.name.replace(/\.[^/.]+$/,"")}));w([...j,...at])}fe.target.value=""},Be=fe=>{w(j.filter((Ve,at)=>at!==fe))},nt=fe=>{L([...M,fe]),S(k.filter(Ve=>Ve.id!==fe))},Ae=async()=>{if(!Z)return null;re(!0),Q(0);try{const{data:fe,error:Ve}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:u.title||Z.name}});if(Ve)throw new Error(Ve.message);const{videoId:at,libraryId:et}=fe;ce(at);const{data:Ce,error:rt}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:at}});if(rt)throw new Error(rt.message);const Ge=new XMLHttpRequest;return await new Promise((qe,Ze)=>{Ge.upload.addEventListener("progress",Qe=>{if(Qe.lengthComputable){const He=Math.round(Qe.loaded/Qe.total*100);Q(He)}}),Ge.addEventListener("load",()=>{Ge.status>=200&&Ge.status<300?qe():Ze(new Error(`Upload failed with status ${Ge.status}`))}),Ge.addEventListener("error",()=>Ze(new Error("Upload failed"))),Ge.open("PUT",Ce.uploadUrl),Ge.setRequestHeader("AccessKey",Ce.apiKey),Ge.send(Z)}),`https://player.mediadelivery.net/embed/${et}/${at}`}catch(fe){return console.error("Bunny upload error:",fe),n({title:"Video upload failed",description:fe instanceof Error?fe.message:"Unknown error",variant:"destructive"}),null}finally{re(!1)}},ft=async fe=>{if(fe.preventDefault(),!u.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let Ve=u.video_url;if(u.video_type==="bunny_stream"&&Z&&!i){const at=await Ae();if(!at)return;Ve=at}else if(!u.video_url.trim()&&u.video_type!=="bunny_stream"){n({title:"Please enter a video URL",variant:"destructive"});return}else if(u.video_type==="bunny_stream"&&!Z&&!u.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}be.mutate({video:{...u,video_url:Ve},thumbnail:f,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:j,resourcesToDelete:M})};return e.jsx(Ms,{title:"Manage Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Manage Academy",description:"Create and manage training videos and resources"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:ge.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:ge.filter(fe=>fe.is_published).length})})]})]}),e.jsxs(fs,{open:o,onOpenChange:fe=>{l(fe),fe||Pe()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Add Video"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:i?"Edit Video":"Add New Video"})}),e.jsxs("form",{onSubmit:ft,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:u.title,onChange:fe=>p({...u,title:fe.target.value}),placeholder:"Video title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(my,{content:u.description,onChange:fe=>p({...u,description:fe}),placeholder:"Brief description of the video",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Video Type"}),e.jsxs(Zs,{value:u.video_type,onValueChange:fe=>{p({...u,video_type:fe,video_url:""}),X(null)},disabled:ie,children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:uVt.map(fe=>e.jsx(Mt,{value:fe.value,children:fe.label},fe.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(ze,{type:"file",accept:"video/*",onChange:fe=>{var at;const Ve=(at=fe.target.files)==null?void 0:at[0];Ve&&X(Ve)},disabled:ie}),Z&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(An,{className:"h-4 w-4"}),Z.name," (",(Z.size/(1024*1024)).toFixed(1)," MB)"]}),ie&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),e.jsx(Bi,{value:ee,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[ee,"%"]})]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"video_url",children:"Video URL *"}),e.jsx(ze,{id:"video_url",value:u.video_url,onChange:fe=>p({...u,video_url:fe.target.value}),placeholder:"https://...",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"duration",children:"Duration"}),e.jsx(ze,{id:"duration",value:u.duration,onChange:fe=>p({...u,duration:fe.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(ze,{id:"publish_date",type:"date",value:u.publish_date,onChange:fe=>p({...u,publish_date:fe.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Category"}),B?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:q,onChange:fe=>U(fe.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>q.trim()&&pe.mutate(q.trim()),disabled:pe.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{V(!1),U("")},children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Zs,{value:u.category_id,onValueChange:fe=>p({...u,category_id:fe}),children:[e.jsx(Ws,{className:"flex-1",children:e.jsx(Xs,{placeholder:"Select category"})}),e.jsx(Gs,{children:xe.map(fe=>e.jsx(Mt,{value:fe.id,children:fe.name},fe.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>V(!0),children:e.jsx($s,{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:[b&&e.jsx("img",{src:b,alt:"Thumbnail preview",className:"w-32 h-20 object-cover rounded-md border"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:Te,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(li,{className:"h-3 w-3"}),"Add Files",e.jsx("input",{type:"file",multiple:!0,accept:".pdf,.pptx,.ppt,.xlsx,.xls,.docx,.doc,.zip",onChange:ke,className:"hidden"})]})})]}),(k.length>0||j.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[k.map(fe=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:fe.title}),e.jsx(tt,{variant:"outline",className:"text-xs",children:fe.file_type}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>nt(fe.id),className:"text-destructive hover:text-destructive",children:e.jsx(Rr,{className:"h-4 w-4"})})]},fe.id)),j.map((fe,Ve)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:fe.title,onChange:at=>{const et=[...j];et[Ve].title=at.target.value,w(et)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(tt,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>Be(Ve),className:"text-destructive hover:text-destructive",children:e.jsx(Rr,{className:"h-4 w-4"})})]},Ve))]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: PDF, PowerPoint, Excel, Word, ZIP"})]}),e.jsx(ctt,{selectedTemplateIds:I,onChange:O}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_published",checked:u.is_published,onCheckedChange:fe=>p({...u,is_published:fe})}),e.jsx(ve,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(qn,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:ie,children:"Cancel"}),e.jsx(K,{type:"submit",disabled:be.isPending||ie,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):be.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(De,{className:"p-0",children:ue?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):ge.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(An,{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(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Duration"}),e.jsx(St,{children:"Resources"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-[120px]",children:"Actions"})]})}),e.jsx(zn,{children:ge.map(fe=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[fe.thumbnail_url?e.jsx("img",{src:fe.thumbnail_url,alt:"",className:"w-16 h-10 object-cover rounded"}):e.jsx("div",{className:"w-16 h-10 bg-muted rounded flex items-center justify-center",children:e.jsx(An,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:fe.title}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:fe.video_type.replace("_"," ")})]})]})}),e.jsx(dt,{children:fe.category?e.jsx(tt,{variant:"outline",children:fe.category.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(dt,{children:fe.duration||"-"}),e.jsx(dt,{children:fe.resources&&fe.resources.length>0?e.jsxs(tt,{variant:"secondary",children:[fe.resources.length," file(s)"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(dt,{children:new Date(fe.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(qr,{checked:fe.is_published,onCheckedChange:Ve=>Ne.mutate({id:fe.id,is_published:Ve})})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Oe(fe),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Me.mutate(fe.id),className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},fe.id))})]})})})]})})};function mVt(){var be,Me,Ne;const t=Qt(),[s,r]=Cc(),[n,a]=N.useState(!1),[o,l]=N.useState(null),[i,c]=N.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=N.useState(null),[f,g]=N.useState(""),[b,_]=N.useState([]),[j,w]=N.useState([]),[k,S]=N.useState([]),[M,L]=N.useState(null),{data:I,isLoading:O}=mt({queryKey:["resource-kits"],queryFn:async()=>{const{data:Pe,error:Oe}=await H.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(Oe)throw Oe;return Pe}}),{data:q}=mt({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:Pe,error:Oe}=await H.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(Oe)throw Oe;return Pe}}),{data:U}=mt({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:Pe,error:Oe}=await H.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(Oe)throw Oe;return Pe}});N.useEffect(()=>{const Pe=s.get("edit");if(Pe&&I&&I.length>0&&q&&U){const Oe=I.find(Te=>Te.id===Pe);Oe&&(V(Oe),r({},{replace:!0}))}},[I,q,U,s]);const B=()=>{c({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),g(""),_([]),w([]),S([]),l(null)},V=async Pe=>{l(Pe),c({name:Pe.name,description:Pe.description||"",publish_date:Pe.publish_date.split("T")[0],is_published:Pe.is_published}),g(Pe.featured_image_url||"");const Oe=(q==null?void 0:q.filter(Be=>Be.kit_id===Pe.id))||[];_(Oe.map(Be=>({id:Be.id,name:Be.name,file_url:Be.file_url,file_type:Be.file_type,file_size:Be.file_size,sort_order:Be.sort_order})));const Te=(U==null?void 0:U.filter(Be=>Be.kit_id===Pe.id))||[];w(Te.map(Be=>({id:Be.id,title:Be.title,canva_share_link:Be.canva_share_link,sort_order:Be.sort_order})));const{data:ke}=await H.from("resource_kit_templates").select("template_id").eq("kit_id",Pe.id);S((ke||[]).map(Be=>Be.template_id)),a(!0)},Z=Pe=>{var Te;const Oe=(Te=Pe.target.files)==null?void 0:Te[0];Oe&&(p(Oe),g(URL.createObjectURL(Oe)))},X=()=>{_([...b,{name:"",file_url:"",sort_order:b.length}])},ee=Pe=>{_(b.filter((Oe,Te)=>Te!==Pe))},Q=(Pe,Oe,Te)=>{const ke=[...b];ke[Pe]={...ke[Pe],[Oe]:Te},_(ke)},ie=()=>{w([...j,{title:"",canva_share_link:"",sort_order:j.length}])},re=Pe=>{w(j.filter((Oe,Te)=>Te!==Pe))},oe=(Pe,Oe,Te)=>{const ke=[...j];ke[Pe]={...ke[Pe],[Oe]:Te},w(ke)},ce=(Pe,Oe)=>{var ke;const Te=(ke=Oe.target.files)==null?void 0:ke[0];if(Te){const Be=[...b],nt=Te.name.replace(/\.[^/.]+$/,"");Be[Pe]={...Be[Pe],file:Te,file_type:Te.type,file_size:Te.size,name:Be[Pe].name||nt},_(Be)}},xe=Dt({mutationFn:async()=>{let Pe=(o==null?void 0:o.featured_image_url)||null;if(u){const nt=u.name.split(".").pop(),Ae=`${Date.now()}.${nt}`,{error:ft}=await H.storage.from("resource-kits").upload(`featured/${Ae}`,u);if(ft)throw ft;const{data:fe}=H.storage.from("resource-kits").getPublicUrl(`featured/${Ae}`);Pe=fe.publicUrl}const Oe={name:i.name,description:i.description||null,featured_image_url:Pe,publish_date:i.publish_date,is_published:i.is_published};let Te;const ke=!o,Be=(o==null?void 0:o.is_published)||!1;if(o){const{error:nt}=await H.from("resource_kits").update(Oe).eq("id",o.id);if(nt)throw nt;Te=o.id;const Ae=(q==null?void 0:q.filter(Ce=>Ce.kit_id===o.id).map(Ce=>Ce.id))||[],ft=b.filter(Ce=>Ce.id).map(Ce=>Ce.id),fe=Ae.filter(Ce=>!ft.includes(Ce));fe.length>0&&await H.from("resource_kit_files").delete().in("id",fe);const Ve=(U==null?void 0:U.filter(Ce=>Ce.kit_id===o.id).map(Ce=>Ce.id))||[],at=j.filter(Ce=>Ce.id).map(Ce=>Ce.id),et=Ve.filter(Ce=>!at.includes(Ce));et.length>0&&await H.from("resource_kit_links").delete().in("id",et)}else{const{data:nt,error:Ae}=await H.from("resource_kits").insert(Oe).select().single();if(Ae)throw Ae;Te=nt.id}for(let nt=0;nt0){const{error:nt}=await H.from("resource_kit_templates").insert(k.map(Ae=>({kit_id:Te,template_id:Ae})));if(nt)throw nt}return{kitId:Te,kitName:i.name,isNewKit:ke,wasPublished:Be,isPublished:i.is_published}},onSuccess:Pe=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),t.invalidateQueries({queryKey:["resource-kit-links"]}),me.success(o?"Resource kit updated":"Resource kit created"),Pe.isPublished&&(Pe.isNewKit||!Pe.wasPublished)&&iVt(Pe.kitName,Pe.kitId),a(!1),B()},onError:Pe=>{me.error("Failed to save resource kit: "+Pe.message)}}),ge=Dt({mutationFn:async Pe=>{const{error:Oe}=await H.from("resource_kits").delete().eq("id",Pe);if(Oe)throw Oe},onSuccess:()=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),me.success("Resource kit deleted")},onError:Pe=>{me.error("Failed to delete: "+Pe.message)}}),ue=Pe=>{if(Pe.preventDefault(),!i.name){me.error("Please enter a name");return}xe.mutate()},pe=Pe=>(q==null?void 0:q.filter(Oe=>Oe.kit_id===Pe).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(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Kits"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:(I==null?void 0:I.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:(I==null?void 0:I.filter(Pe=>Pe.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{B(),a(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Resource Kit"]})]}),e.jsx(Ee,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Files"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:O?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(I==null?void 0:I.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No resource kits yet. Create your first one!"})}):I==null?void 0:I.map(Pe=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Pe.featured_image_url?e.jsx("img",{src:Pe.featured_image_url,alt:Pe.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(Ml,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Pe.name}),Pe.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Pe.description})]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),pe(Pe.id)]})}),e.jsx(dt,{children:ms(new Date(Pe.publish_date),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Pe.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Pe.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const Oe=(q==null?void 0:q.filter(ke=>ke.kit_id===Pe.id))||[],Te=(U==null?void 0:U.filter(ke=>ke.kit_id===Pe.id))||[];L({...Pe,files:Oe,links:Te})},children:e.jsx(On,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>V(Pe),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&ge.mutate(Pe.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Pe.id))})]})})}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:o?"Edit Resource Kit":"Add Resource Kit"})}),e.jsxs("form",{onSubmit:ue,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(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(Ml,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(ze,{type:"file",accept:"image/*",onChange:Z})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Name *"}),e.jsx(ze,{id:"name",value:i.name,onChange:Pe=>c({...i,name:Pe.target.value}),placeholder:"Resource Kit Name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(my,{content:i.description,onChange:Pe=>c({...i,description:Pe}),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(ze,{id:"publish_date",type:"date",value:i.publish_date,onChange:Pe=>c({...i,publish_date:Pe.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(qr,{checked:i.is_published,onCheckedChange:Pe=>c({...i,is_published:Pe})}),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:X,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add File"]})]}),b.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No files added yet. Click "Add File" to include resources.'}):e.jsx("div",{className:"space-y-3",children:b.map((Pe,Oe)=>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 ",Oe+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ee(Oe),children:e.jsx(Rr,{className:"h-4 w-4"})})]}),e.jsx(ze,{placeholder:"File name (e.g., Getting Started Guide)",value:Pe.name,onChange:Te=>Q(Oe,"name",Te.target.value)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"file",onChange:Te=>ce(Oe,Te),className:"flex-1"}),Pe.file_url&&!Pe.file&&e.jsx("a",{href:Pe.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline whitespace-nowrap",children:"Current file"}),Pe.file&&e.jsx("span",{className:"text-sm text-green-600 whitespace-nowrap",children:"New file selected"})]})]},Oe))})]}),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:ie,children:[e.jsx($s,{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((Pe,Oe)=>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 ",Oe+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>re(Oe),children:e.jsx(Rr,{className:"h-4 w-4"})})]}),e.jsx(ze,{placeholder:"Link title (e.g., Social Media Post Template)",value:Pe.title,onChange:Te=>oe(Oe,"title",Te.target.value)}),e.jsx(ze,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:Pe.canva_share_link,onChange:Te=>oe(Oe,"canva_share_link",Te.target.value)})]},Oe))})]}),e.jsx(ctt,{selectedTemplateIds:k,onChange:S}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:xe.isPending,children:xe.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(fs,{open:!!M,onOpenChange:()=>L(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(_s,{children:e.jsx(vs,{children:M==null?void 0:M.name})}),e.jsxs("div",{className:"space-y-4",children:[(M==null?void 0:M.featured_image_url)&&e.jsx("img",{src:M.featured_image_url,alt:M.name,className:"w-full h-48 object-cover rounded-lg"}),(M==null?void 0:M.description)&&e.jsx("p",{className:"text-muted-foreground",children:M.description}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Resource Files (",((be=M==null?void 0:M.files)==null?void 0:be.length)||0,")"]}),((Me=M==null?void 0:M.files)==null?void 0:Me.length)===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No files in this kit"}):e.jsx("div",{className:"space-y-2",children:(Ne=M==null?void 0:M.files)==null?void 0:Ne.map(Pe=>e.jsxs("a",{href:Pe.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(Sn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Pe.name})]},Pe.id))})]}),(M==null?void 0:M.links)&&M.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Canva Links (",M.links.length,")"]}),e.jsx("div",{className:"space-y-2",children:M.links.map(Pe=>e.jsxs("a",{href:Pe.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(Bo,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Pe.title})]},Pe.id))})]})]})]})})]})})}const pVt=()=>{const{user:t}=Ds(),{toast:s}=Ua(),r=Qt(),[n,a]=N.useState(!1),[o,l]=N.useState(null),[i,c]=N.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[u,p]=N.useState(null),[f,g]=N.useState(""),{data:b=[],isLoading:_}=mt({queryKey:["social-swag-admin"],queryFn:async()=>{const{data:U,error:B}=await H.from("social_swag").select("*").order("publish_date",{ascending:!1});if(B)throw B;const{data:V,error:Z}=await H.from("social_swag_links").select("*").order("sort_order");if(Z)throw Z;return U.map(ee=>({...ee,links:(V==null?void 0:V.filter(Q=>Q.swag_id===ee.id))||[]}))}}),j=Dt({mutationFn:async U=>{let B=U.existingImageUrl;if(U.image){const ie=U.image.name.split(".").pop(),re=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ie}`,{error:oe}=await H.storage.from("template-previews").upload(re,U.image);if(oe)throw oe;const{data:ce}=H.storage.from("template-previews").getPublicUrl(re);B=ce.publicUrl}const V={title:U.item.title,description:U.item.description||null,preview_image_url:B,publish_date:U.item.publish_date?new Date(U.item.publish_date).toISOString():new Date().toISOString(),is_published:U.item.is_published,created_by:t==null?void 0:t.id};let Z=U.itemId;const X=!Z,ee=(o==null?void 0:o.is_published)||!1;if(Z){const{error:ie}=await H.from("social_swag").update(V).eq("id",Z);if(ie)throw ie;await H.from("social_swag_links").delete().eq("swag_id",Z)}else{const{data:ie,error:re}=await H.from("social_swag").insert(V).select().single();if(re)throw re;Z=ie.id}const Q=U.item.links.filter(ie=>ie.title.trim()&&ie.canva_share_link.trim());if(Q.length>0){const ie=Q.map((oe,ce)=>({swag_id:Z,title:oe.title.trim(),canva_share_link:oe.canva_share_link.trim(),sort_order:ce})),{error:re}=await H.from("social_swag_links").insert(ie);if(re)throw re}return{itemId:Z,itemTitle:U.item.title,isNewItem:X,wasPublished:ee,isPublished:U.item.is_published}},onSuccess:U=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:o?"Item updated":"Item created"}),U.isPublished&&(U.isNewItem||!U.wasPublished)&&abe(U.itemTitle,U.itemId),a(!1),k()},onError:U=>{s({title:"Error saving item",description:U.message,variant:"destructive"})}}),w=Dt({mutationFn:async U=>{const{error:B}=await H.from("social_swag").delete().eq("id",U);if(B)throw B},onSuccess:()=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:"Item deleted"})},onError:U=>{s({title:"Error deleting item",description:U.message,variant:"destructive"})}}),k=()=>{c({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),p(null),g(""),l(null)},S=U=>{l(U),c({title:U.title,description:U.description||"",publish_date:U.publish_date?new Date(U.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:U.is_published,links:U.links&&U.links.length>0?U.links.map(B=>({id:B.id,title:B.title,canva_share_link:B.canva_share_link,sort_order:B.sort_order})):[{title:"",canva_share_link:"",sort_order:0}]}),g(U.preview_image_url||""),a(!0)},M=U=>{var V;const B=(V=U.target.files)==null?void 0:V[0];B&&(p(B),g(URL.createObjectURL(B)))},L=()=>{c({...i,links:[...i.links,{title:"",canva_share_link:"",sort_order:i.links.length}]})},I=U=>{if(i.links.length<=1)return;const B=i.links.filter((V,Z)=>Z!==U);c({...i,links:B})},O=(U,B,V)=>{const Z=[...i.links];Z[U]={...Z[U],[B]:V},c({...i,links:Z})},q=U=>{if(U.preventDefault(),!i.title.trim()){s({title:"Title is required",variant:"destructive"});return}j.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Ms,{title:"Manage Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Manage Social Swag",description:"Create and manage social media content"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Items"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:b.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:b.filter(U=>U.is_published).length})})]})]}),e.jsxs(fs,{open:n,onOpenChange:U=>{a(U),U||k()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Add Item"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:o?"Edit Item":"Add New Item"})}),e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:i.title,onChange:U=>c({...i,title:U.target.value}),placeholder:"Enter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(my,{content:i.description,onChange:U=>c({...i,description:U}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:i.publish_date,onChange:U=>c({...i,publish_date:U.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qr,{id:"is_published",checked:i.is_published,onCheckedChange:U=>c({...i,is_published:U})}),e.jsx(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),g("")},children:e.jsx(Rr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(gl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(ze,{type:"file",accept:"image/*",onChange:M,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:L,children:[e.jsx($s,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map((U,B)=>e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["Link ",B+1]}),i.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>I(B),children:e.jsx(Rr,{className:"h-3 w-3"})})]}),e.jsx(ze,{placeholder:"Link title (e.g., Instagram Post)",value:U.title,onChange:V=>O(B,"title",V.target.value)}),e.jsx(ze,{placeholder:"Canva share link",value:U.canva_share_link,onChange:V=>O(B,"canva_share_link",V.target.value)})]})},B))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:j.isPending,children:j.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(De,{className:"p-0",children:_?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):b.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'No items yet. Click "Add Item" to create your first one.'}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-16",children:"Preview"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Links"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:b.map(U=>{var B;return e.jsxs(Ss,{children:[e.jsx(dt,{children:U.preview_image_url?e.jsx("img",{src:U.preview_image_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(gl,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(dt,{className:"font-medium",children:U.title}),e.jsxs(dt,{children:[((B=U.links)==null?void 0:B.length)||0," links"]}),e.jsx(dt,{children:new Date(U.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(tt,{variant:U.is_published?"default":"secondary",children:U.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/social-swag/${U.id}`,"_blank"),children:e.jsx(On,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(U),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(U.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},U.id)})})]})})})]})})};function fVt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const Wue=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function lE(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function Rke(t){return"nodeType"in t}function Pp(t){var s,r;return t?lE(t)?t:Rke(t)&&(s=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Fke(t){const{Document:s}=Pp(t);return t instanceof s}function QO(t){return lE(t)?!1:t instanceof Pp(t).HTMLElement}function dtt(t){return t instanceof Pp(t).SVGElement}function cE(t){return t?lE(t)?t.document:Rke(t)?Fke(t)?t:QO(t)||dtt(t)?t.ownerDocument:document:document:document}const E0=Wue?N.useLayoutEffect:N.useEffect;function zke(t){const s=N.useRef(t);return E0(()=>{s.current=t}),N.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a{t.current=setInterval(n,a)},[]),r=N.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,r]}function yD(t,s){s===void 0&&(s=[t]);const r=N.useRef(t);return E0(()=>{r.current!==t&&(r.current=t)},s),r}function JO(t,s){const r=N.useRef();return N.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function Ble(t){const s=zke(t),r=N.useRef(null),n=N.useCallback(a=>{a!==r.current&&(s==null||s(a,r.current)),r.current=a},[]);return[r,n]}function ibe(t){const s=N.useRef();return N.useEffect(()=>{s.current=t},[t]),s.current}let Lge={};function eR(t,s){return N.useMemo(()=>{if(s)return s;const r=Lge[t]==null?0:Lge[t]+1;return Lge[t]=r,t+"-"+r},[t,s])}function utt(t){return function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a{const i=Object.entries(l);for(const[c,u]of i){const p=o[c];p!=null&&(o[c]=p+t*u)}return o},{...s})}}const sT=utt(1),vD=utt(-1);function gVt(t){return"clientX"in t&&"clientY"in t}function Bke(t){if(!t)return!1;const{KeyboardEvent:s}=Pp(t.target);return s&&t instanceof s}function yVt(t){if(!t)return!1;const{TouchEvent:s}=Pp(t.target);return s&&t instanceof s}function obe(t){if(yVt(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 gVt(t)?{x:t.clientX,y:t.clientY}:null}const QS=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[QS.Translate.toString(t),QS.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:r,easing:n}=t;return s+" "+r+"ms "+n}}}),f8e="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function vVt(t){return t.matches(f8e)?t:t.querySelector(f8e)}const bVt={display:"none"};function _Vt(t){let{id:s,value:r}=t;return ht.createElement("div",{id:s,style:bVt},r)}function wVt(t){let{id:s,announcement:r,ariaLiveType:n="assertive"}=t;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ht.createElement("div",{id:s,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function jVt(){const[t,s]=N.useState("");return{announce:N.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const htt=N.createContext(null);function NVt(t){const s=N.useContext(htt);N.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function kVt(){const[t]=N.useState(()=>new Set),s=N.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[N.useCallback(n=>{let{type:a,event:o}=n;t.forEach(l=>{var i;return(i=l[a])==null?void 0:i.call(l,o)})},[t]),s]}const SVt={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. `},CVt={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 MVt(t){let{announcements:s=CVt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=SVt}=t;const{announce:o,announcement:l}=jVt(),i=eR("DndLiveRegion"),[c,u]=N.useState(!1);if(N.useEffect(()=>{u(!0)},[]),NVt(N.useMemo(()=>({onDragStart(f){let{active:g}=f;o(s.onDragStart({active:g}))},onDragMove(f){let{active:g,over:b}=f;s.onDragMove&&o(s.onDragMove({active:g,over:b}))},onDragOver(f){let{active:g,over:b}=f;o(s.onDragOver({active:g,over:b}))},onDragEnd(f){let{active:g,over:b}=f;o(s.onDragEnd({active:g,over:b}))},onDragCancel(f){let{active:g,over:b}=f;o(s.onDragCancel({active:g,over:b}))}}),[o,s])),!c)return null;const p=ht.createElement(ht.Fragment,null,ht.createElement(_Vt,{id:n,value:a.draggable}),ht.createElement(wVt,{id:i,announcement:l}));return r?yp.createPortal(p,r):p}var yu;(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"})(yu||(yu={}));function $le(){}function qle(t,s){return N.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function $ke(){for(var t=arguments.length,s=new Array(t),r=0;r[...s].filter(n=>n!=null),[...s])}const dy=Object.freeze({x:0,y:0});function mtt(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function ptt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return r-n}function TVt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function x8e(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 ftt(t,s){if(!t||t.length===0)return null;const[r]=t;return r[s]}function g8e(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 qke=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=g8e(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,c=r.get(i);if(c){const u=mtt(g8e(c),a);o.push({id:i,data:{droppableContainer:l,value:u}})}}return o.sort(ptt)},AVt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=x8e(s),o=[];for(const l of n){const{id:i}=l,c=r.get(i);if(c){const u=x8e(c),p=a.reduce((g,b,_)=>g+mtt(u[_],b),0),f=Number((p/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:f}})}}return o.sort(ptt)};function EVt(t,s){const r=Math.max(s.top,t.top),n=Math.max(s.left,t.left),a=Math.min(s.left+s.width,t.left+t.width),o=Math.min(s.top+s.height,t.top+t.height),l=a-n,i=o-r;if(n{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=[];for(const o of n){const{id:l}=o,i=r.get(l);if(i){const c=EVt(i,s);c>0&&a.push({id:l,data:{droppableContainer:o,value:c}})}}return a.sort(TVt)};function IVt(t,s,r){return{...t,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function xtt(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:dy}function LVt(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 DVt=LVt(1);function OVt(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 RVt(t,s,r){const n=OVt(s);if(!n)return t;const{scaleX:a,scaleY:o,x:l,y:i}=n,c=t.left-l-(1-a)*parseFloat(r),u=t.top-i-(1-o)*parseFloat(r.slice(r.indexOf(" ")+1)),p=a?t.width/a:t.width,f=o?t.height/o:t.height;return{width:p,height:f,top:u,right:c+p,bottom:u+f,left:c}}const FVt={ignoreTransform:!1};function dE(t,s){s===void 0&&(s=FVt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:p}=Pp(t).getComputedStyle(t);u&&(r=RVt(r,u,p))}const{top:n,left:a,width:o,height:l,bottom:i,right:c}=r;return{top:n,left:a,width:o,height:l,bottom:i,right:c}}function y8e(t){return dE(t,{ignoreTransform:!0})}function zVt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function BVt(t,s){return s===void 0&&(s=Pp(t).getComputedStyle(t)),s.position==="fixed"}function $Vt(t,s){s===void 0&&(s=Pp(t).getComputedStyle(t));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const o=s[a];return typeof o=="string"?r.test(o):!1})}function Gue(t,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(Fke(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!QO(a)||dtt(a)||r.includes(a))return r;const o=Pp(t).getComputedStyle(a);return a!==t&&$Vt(a,o)&&r.push(a),BVt(a,o)?r:n(a.parentNode)}return t?n(t):r}function gtt(t){const[s]=Gue(t,1);return s??null}function Dge(t){return!Wue||!t?null:lE(t)?t:Rke(t)?Fke(t)||t===cE(t).scrollingElement?window:QO(t)?t:null:null}function ytt(t){return lE(t)?t.scrollX:t.scrollLeft}function vtt(t){return lE(t)?t.scrollY:t.scrollTop}function lbe(t){return{x:ytt(t),y:vtt(t)}}var Wu;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Wu||(Wu={}));function btt(t){return!Wue||!t?!1:t===document.scrollingElement}function _tt(t){const s={x:0,y:0},r=btt(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 qVt={x:.2,y:.2};function UVt(t,s,r,n,a){let{top:o,left:l,right:i,bottom:c}=r;n===void 0&&(n=10),a===void 0&&(a=qVt);const{isTop:u,isBottom:p,isLeft:f,isRight:g}=_tt(t),b={x:0,y:0},_={x:0,y:0},j={height:s.height*a.y,width:s.width*a.x};return!u&&o<=s.top+j.height?(b.y=Wu.Backward,_.y=n*Math.abs((s.top+j.height-o)/j.height)):!p&&c>=s.bottom-j.height&&(b.y=Wu.Forward,_.y=n*Math.abs((s.bottom-j.height-c)/j.height)),!g&&i>=s.right-j.width?(b.x=Wu.Forward,_.x=n*Math.abs((s.right-j.width-i)/j.width)):!f&&l<=s.left+j.width&&(b.x=Wu.Backward,_.x=n*Math.abs((s.left+j.width-l)/j.width)),{direction:b,speed:_}}function VVt(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 wtt(t){return t.reduce((s,r)=>sT(s,lbe(r)),dy)}function HVt(t){return t.reduce((s,r)=>s+ytt(r),0)}function WVt(t){return t.reduce((s,r)=>s+vtt(r),0)}function GVt(t,s){if(s===void 0&&(s=dE),!t)return;const{top:r,left:n,bottom:a,right:o}=s(t);gtt(t)&&(a<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const KVt=[["x",["left","right"],HVt],["y",["top","bottom"],WVt]];class Uke{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=Gue(r),a=wtt(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of KVt)for(const c of l)Object.defineProperty(this,c,{get:()=>{const u=i(n),p=a[o]-u;return this.rect[c]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class l8{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 ZVt(t){const{EventTarget:s}=Pp(t);return t instanceof s?t:cE(t)}function Oge(t,s){const r=Math.abs(t.x),n=Math.abs(t.y);return typeof s=="number"?Math.sqrt(r**2+n**2)>s:"x"in s&&"y"in s?r>s.x&&n>s.y:"x"in s?r>s.x:"y"in s?n>s.y:!1}var dx;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(dx||(dx={}));function v8e(t){t.preventDefault()}function YVt(t){t.stopPropagation()}var To;(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"})(To||(To={}));const jtt={start:[To.Space,To.Enter],cancel:[To.Esc],end:[To.Space,To.Enter,To.Tab]},XVt=(t,s)=>{let{currentCoordinates:r}=s;switch(t.code){case To.Right:return{...r,x:r.x+25};case To.Left:return{...r,x:r.x-25};case To.Down:return{...r,y:r.y+25};case To.Up:return{...r,y:r.y-25}}};class Vke{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 l8(cE(r)),this.windowListeners=new l8(Pp(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(dx.Resize,this.handleCancel),this.windowListeners.add(dx.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(dx.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&GVt(n),r(dy)}handleKeyDown(s){if(Bke(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=jtt,coordinateGetter:l=XVt,scrollBehavior:i="smooth"}=a,{code:c}=s;if(o.end.includes(c)){this.handleEnd(s);return}if(o.cancel.includes(c)){this.handleCancel(s);return}const{collisionRect:u}=n.current,p=u?{x:u.left,y:u.top}:dy;this.referenceCoordinates||(this.referenceCoordinates=p);const f=l(s,{active:r,context:n.current,currentCoordinates:p});if(f){const g=vD(f,p),b={x:0,y:0},{scrollableAncestors:_}=n.current;for(const j of _){const w=s.code,{isTop:k,isRight:S,isLeft:M,isBottom:L,maxScroll:I,minScroll:O}=_tt(j),q=VVt(j),U={x:Math.min(w===To.Right?q.right-q.width/2:q.right,Math.max(w===To.Right?q.left:q.left+q.width/2,f.x)),y:Math.min(w===To.Down?q.bottom-q.height/2:q.bottom,Math.max(w===To.Down?q.top:q.top+q.height/2,f.y))},B=w===To.Right&&!S||w===To.Left&&!M,V=w===To.Down&&!L||w===To.Up&&!k;if(B&&U.x!==f.x){const Z=j.scrollLeft+g.x,X=w===To.Right&&Z<=I.x||w===To.Left&&Z>=O.x;if(X&&!g.y){j.scrollTo({left:Z,behavior:i});return}X?b.x=j.scrollLeft-Z:b.x=w===To.Right?j.scrollLeft-I.x:j.scrollLeft-O.x,b.x&&j.scrollBy({left:-b.x,behavior:i});break}else if(V&&U.y!==f.y){const Z=j.scrollTop+g.y,X=w===To.Down&&Z<=I.y||w===To.Up&&Z>=O.y;if(X&&!g.x){j.scrollTo({top:Z,behavior:i});return}X?b.y=j.scrollTop-Z:b.y=w===To.Down?j.scrollTop-I.y:j.scrollTop-O.y,b.y&&j.scrollBy({top:-b.y,behavior:i});break}}this.handleMove(s,sT(vD(f,this.referenceCoordinates),b))}}}handleMove(s,r){const{onMove:n}=this.props;s.preventDefault(),n(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Vke.activators=[{eventName:"onKeyDown",handler:(t,s,r)=>{let{keyboardCodes:n=jtt,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 b8e(t){return!!(t&&"distance"in t)}function _8e(t){return!!(t&&"delay"in t)}class Hke{constructor(s,r,n){var a;n===void 0&&(n=ZVt(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=cE(l),this.documentListeners=new l8(this.document),this.listeners=new l8(n),this.windowListeners=new l8(Pp(l)),this.initialCoordinates=(a=obe(o))!=null?a:dy,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(dx.Resize,this.handleCancel),this.windowListeners.add(dx.DragStart,v8e),this.windowListeners.add(dx.VisibilityChange,this.handleCancel),this.windowListeners.add(dx.ContextMenu,v8e),this.documentListeners.add(dx.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(_8e(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(b8e(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:n,onPending:a}=this.props;a(n,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(dx.Click,YVt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(dx.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:n,initialCoordinates:a,props:o}=this,{onMove:l,options:{activationConstraint:i}}=o;if(!a)return;const c=(r=obe(s))!=null?r:dy,u=vD(a,c);if(!n&&i){if(b8e(i)){if(i.tolerance!=null&&Oge(u,i.tolerance))return this.handleCancel();if(Oge(u,i.distance))return this.handleStart()}if(_8e(i)&&Oge(u,i.tolerance))return this.handleCancel();this.handlePending(i,u);return}s.cancelable&&s.preventDefault(),l(c)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===To.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const QVt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class tR extends Hke{constructor(s){const{event:r}=s,n=cE(r.target);super(s,QVt,n)}}tR.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 JVt={move:{name:"mousemove"},end:{name:"mouseup"}};var cbe;(function(t){t[t.RightClick=2]="RightClick"})(cbe||(cbe={}));class eHt extends Hke{constructor(s){super(s,JVt,cE(s.event.target))}}eHt.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return r.button===cbe.RightClick?!1:(n==null||n({event:r}),!0)}}];const Rge={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class tHt extends Hke{constructor(s){super(s,Rge)}static setup(){return window.addEventListener(Rge.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Rge.move.name,s)};function s(){}}}tHt.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 c8;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(c8||(c8={}));var Ule;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ule||(Ule={}));function sHt(t){let{acceleration:s,activator:r=c8.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=Ule.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:p,delta:f,threshold:g}=t;const b=nHt({delta:f,disabled:!o}),[_,j]=xVt(),w=N.useRef({x:0,y:0}),k=N.useRef({x:0,y:0}),S=N.useMemo(()=>{switch(r){case c8.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case c8.DraggableRect:return a}},[r,a,c]),M=N.useRef(null),L=N.useCallback(()=>{const O=M.current;if(!O)return;const q=w.current.x*k.current.x,U=w.current.y*k.current.y;O.scrollBy(q,U)},[]),I=N.useMemo(()=>i===Ule.TreeOrder?[...u].reverse():u,[i,u]);N.useEffect(()=>{if(!o||!u.length||!S){j();return}for(const O of I){if((n==null?void 0:n(O))===!1)continue;const q=u.indexOf(O),U=p[q];if(!U)continue;const{direction:B,speed:V}=UVt(O,U,S,s,g);for(const Z of["x","y"])b[Z][B[Z]]||(V[Z]=0,B[Z]=0);if(V.x>0||V.y>0){j(),M.current=O,_(L,l),w.current=V,k.current=B;return}}w.current={x:0,y:0},k.current={x:0,y:0},j()},[s,L,n,j,o,l,JSON.stringify(S),JSON.stringify(b),_,u,I,p,JSON.stringify(g)])}const rHt={x:{[Wu.Backward]:!1,[Wu.Forward]:!1},y:{[Wu.Backward]:!1,[Wu.Forward]:!1}};function nHt(t){let{delta:s,disabled:r}=t;const n=ibe(s);return JO(a=>{if(r||!n||!a)return rHt;const o={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[Wu.Backward]:a.x[Wu.Backward]||o.x===-1,[Wu.Forward]:a.x[Wu.Forward]||o.x===1},y:{[Wu.Backward]:a.y[Wu.Backward]||o.y===-1,[Wu.Forward]:a.y[Wu.Forward]||o.y===1}}},[r,s,n])}function aHt(t,s){const r=s!=null?t.get(s):void 0,n=r?r.node.current:null;return JO(a=>{var o;return s==null?null:(o=n??a)!=null?o:null},[n,s])}function iHt(t,s){return N.useMemo(()=>t.reduce((r,n)=>{const{sensor:a}=n,o=a.activators.map(l=>({eventName:l.eventName,handler:s(l.handler,n)}));return[...r,...o]},[]),[t,s])}var bD;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(bD||(bD={}));var dbe;(function(t){t.Optimized="optimized"})(dbe||(dbe={}));const w8e=new Map;function oHt(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=N.useState(null),{frequency:i,measure:c,strategy:u}=a,p=N.useRef(t),f=w(),g=yD(f),b=N.useCallback(function(k){k===void 0&&(k=[]),!g.current&&l(S=>S===null?k:S.concat(k.filter(M=>!S.includes(M))))},[g]),_=N.useRef(null),j=JO(k=>{if(f&&!r)return w8e;if(!k||k===w8e||p.current!==t||o!=null){const S=new Map;for(let M of t){if(!M)continue;if(o&&o.length>0&&!o.includes(M.id)&&M.rect.current){S.set(M.id,M.rect.current);continue}const L=M.node.current,I=L?new Uke(c(L),L):null;M.rect.current=I,I&&S.set(M.id,I)}return S}return k},[t,o,r,f,c]);return N.useEffect(()=>{p.current=t},[t]),N.useEffect(()=>{f||b()},[r,f]),N.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),N.useEffect(()=>{f||typeof i!="number"||_.current!==null||(_.current=setTimeout(()=>{b(),_.current=null},i))},[i,f,b,...n]),{droppableRects:j,measureDroppableContainers:b,measuringScheduled:o!=null};function w(){switch(u){case bD.Always:return!1;case bD.BeforeDragging:return r;default:return!r}}}function Ntt(t,s){return JO(r=>t?r||(typeof s=="function"?s(t):t):null,[s,t])}function lHt(t,s){return Ntt(t,s)}function cHt(t){let{callback:s,disabled:r}=t;const n=zke(s),a=N.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,r]);return N.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function Kue(t){let{callback:s,disabled:r}=t;const n=zke(s),a=N.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[r]);return N.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function dHt(t){return new Uke(dE(t),t)}function j8e(t,s,r){s===void 0&&(s=dHt);const[n,a]=N.useState(null);function o(){a(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??r)!=null?u:null}const p=s(t);return JSON.stringify(c)===JSON.stringify(p)?c:p})}const l=cHt({callback(c){if(t)for(const u of c){const{type:p,target:f}=u;if(p==="childList"&&f instanceof HTMLElement&&f.contains(t)){o();break}}}}),i=Kue({callback:o});return E0(()=>{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 uHt(t){const s=Ntt(t);return xtt(t,s)}const N8e=[];function hHt(t){const s=N.useRef(t),r=JO(n=>t?n&&n!==N8e&&t&&s.current&&t.parentNode===s.current.parentNode?n:Gue(t):N8e,[t]);return N.useEffect(()=>{s.current=t},[t]),r}function mHt(t){const[s,r]=N.useState(null),n=N.useRef(t),a=N.useCallback(o=>{const l=Dge(o.target);l&&r(i=>i?(i.set(l,lbe(l)),new Map(i)):null)},[]);return N.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(c=>{const u=Dge(c);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,lbe(u)]):null}).filter(c=>c!=null);r(i.length?new Map(i):null),n.current=t}return()=>{l(t),l(o)};function l(i){i.forEach(c=>{const u=Dge(c);u==null||u.removeEventListener("scroll",a)})}},[a,t]),N.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>sT(o,l),dy):wtt(t):dy,[t,s])}function k8e(t,s){s===void 0&&(s=[]);const r=N.useRef(null);return N.useEffect(()=>{r.current=null},s),N.useEffect(()=>{const n=t!==dy;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?vD(t,r.current):dy}function pHt(t){N.useEffect(()=>{if(!Wue)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 fHt(t,s){return N.useMemo(()=>t.reduce((r,n)=>{let{eventName:a,handler:o}=n;return r[a]=l=>{o(l,s)},r},{}),[t,s])}function ktt(t){return N.useMemo(()=>t?zVt(t):null,[t])}const S8e=[];function xHt(t,s){s===void 0&&(s=dE);const[r]=t,n=ktt(r?Pp(r):null),[a,o]=N.useState(S8e);function l(){o(()=>t.length?t.map(c=>btt(c)?n:new Uke(s(c),c)):S8e)}const i=Kue({callback:l});return E0(()=>{i==null||i.disconnect(),l(),t.forEach(c=>i==null?void 0:i.observe(c))},[t]),a}function gHt(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return QO(s)?s:t}function yHt(t){let{measure:s}=t;const[r,n]=N.useState(null),a=N.useCallback(u=>{for(const{target:p}of u)if(QO(p)){n(f=>{const g=s(p);return f?{...f,width:g.width,height:g.height}:g});break}},[s]),o=Kue({callback:a}),l=N.useCallback(u=>{const p=gHt(u);o==null||o.disconnect(),p&&(o==null||o.observe(p)),n(p?s(p):null)},[s,o]),[i,c]=Ble(l);return N.useMemo(()=>({nodeRef:i,rect:r,setRef:c}),[r,i,c])}const vHt=[{sensor:tR,options:{}},{sensor:Vke,options:{}}],bHt={current:{}},Eie={draggable:{measure:y8e},droppable:{measure:y8e,strategy:bD.WhileDragging,frequency:dbe.Optimized},dragOverlay:{measure:dE}};class d8 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 _Ht={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new d8,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:$le},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Eie,measureDroppableContainers:$le,windowRect:null,measuringScheduled:!1},wHt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:$le,draggableNodes:new Map,over:null,measureDroppableContainers:$le},Zue=N.createContext(wHt),Stt=N.createContext(_Ht);function jHt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new d8}}}function NHt(t,s){switch(s.type){case yu.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case yu.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 yu.DragEnd:case yu.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case yu.RegisterDroppable:{const{element:r}=s,{id:n}=r,a=new d8(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case yu.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 d8(t.droppable.containers);return l.set(r,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:l}}}case yu.UnregisterDroppable:{const{id:r,key:n}=s,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const o=new d8(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function kHt(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=N.useContext(Zue),o=ibe(n),l=ibe(r==null?void 0:r.id);return N.useEffect(()=>{if(!s&&!n&&o&&l!=null){if(!Bke(o)||document.activeElement===o.target)return;const i=a.get(l);if(!i)return;const{activatorNode:c,node:u}=i;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const p of[c.current,u.current]){if(!p)continue;const f=vVt(p);if(f){f.focus();break}}})}},[n,s,a,l,o]),null}function SHt(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function CHt(t){return N.useMemo(()=>({draggable:{...Eie.draggable,...t==null?void 0:t.draggable},droppable:{...Eie.droppable,...t==null?void 0:t.droppable},dragOverlay:{...Eie.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 MHt(t){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=t;const o=N.useRef(!1),{x:l,y:i}=typeof a=="boolean"?{x:a,y:a}:a;E0(()=>{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=xtt(p,n);if(l||(f.x=0),i||(f.y=0),o.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const g=gtt(u);g&&g.scrollBy({top:f.y,left:f.x})}},[s,l,i,n,r])}const Ctt=N.createContext({...dy,scaleX:1,scaleY:1});var Qb;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Qb||(Qb={}));const Wke=N.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:c=!0,children:u,sensors:p=vHt,collisionDetection:f=PVt,measuring:g,modifiers:b,..._}=s;const j=N.useReducer(NHt,void 0,jHt),[w,k]=j,[S,M]=kVt(),[L,I]=N.useState(Qb.Uninitialized),O=L===Qb.Initialized,{draggable:{active:q,nodes:U,translate:B},droppable:{containers:V}}=w,Z=q!=null?U.get(q):null,X=N.useRef({initial:null,translated:null}),ee=N.useMemo(()=>{var Ea;return q!=null?{id:q,data:(Ea=Z==null?void 0:Z.data)!=null?Ea:bHt,rect:X}:null},[q,Z]),Q=N.useRef(null),[ie,re]=N.useState(null),[oe,ce]=N.useState(null),xe=yD(_,Object.values(_)),ge=eR("DndDescribedBy",l),ue=N.useMemo(()=>V.getEnabled(),[V]),pe=CHt(g),{droppableRects:be,measureDroppableContainers:Me,measuringScheduled:Ne}=oHt(ue,{dragging:O,dependencies:[B.x,B.y],config:pe.droppable}),Pe=aHt(U,q),Oe=N.useMemo(()=>oe?obe(oe):null,[oe]),Te=ki(),ke=lHt(Pe,pe.draggable.measure);MHt({activeNode:q!=null?U.get(q):null,config:Te.layoutShiftCompensation,initialRect:ke,measure:pe.draggable.measure});const Be=j8e(Pe,pe.draggable.measure,ke),nt=j8e(Pe?Pe.parentElement:null),Ae=N.useRef({activatorEvent:null,active:null,activeNode:Pe,collisionRect:null,collisions:null,droppableRects:be,draggableNodes:U,draggingNode:null,draggingNodeRect:null,droppableContainers:V,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ft=V.getNodeFor((r=Ae.current.over)==null?void 0:r.id),fe=yHt({measure:pe.dragOverlay.measure}),Ve=(n=fe.nodeRef.current)!=null?n:Pe,at=O?(a=fe.rect)!=null?a:Be:null,et=!!(fe.nodeRef.current&&fe.rect),Ce=uHt(et?null:Be),rt=ktt(Ve?Pp(Ve):null),Ge=hHt(O?ft??Pe:null),ct=xHt(Ge),qe=SHt(b,{transform:{x:B.x-Ce.x,y:B.y-Ce.y,scaleX:1,scaleY:1},activatorEvent:oe,active:ee,activeNodeRect:Be,containerNodeRect:nt,draggingNodeRect:at,over:Ae.current.over,overlayNodeRect:fe.rect,scrollableAncestors:Ge,scrollableAncestorRects:ct,windowRect:rt}),Ze=Oe?sT(Oe,B):null,Qe=mHt(Ge),He=k8e(Qe),Je=k8e(Qe,[Be]),it=sT(qe,He),Lt=at?DVt(at,qe):null,Vt=ee&&Lt?f({active:ee,collisionRect:Lt,droppableRects:be,droppableContainers:ue,pointerCoordinates:Ze}):null,hs=ftt(Vt,"id"),[Ts,Cs]=N.useState(null),cs=et?qe:sT(qe,Je),er=IVt(cs,(o=Ts==null?void 0:Ts.rect)!=null?o:null,Be),xt=N.useRef(null),Es=N.useCallback((Ea,dr)=>{let{sensor:Jr,options:Wr}=dr;if(Q.current==null)return;const dn=U.get(Q.current);if(!dn)return;const Yr=Ea.nativeEvent,vi=new Jr({active:Q.current,activeNode:dn,event:Yr,options:Wr,context:Ae,onAbort(ir){if(!U.get(ir))return;const{onDragAbort:Sr}=xe.current,jr={id:ir};Sr==null||Sr(jr),S({type:"onDragAbort",event:jr})},onPending(ir,Vn,Sr,jr){if(!U.get(ir))return;const{onDragPending:Pa}=xe.current,Ii={id:ir,constraint:Vn,initialCoordinates:Sr,offset:jr};Pa==null||Pa(Ii),S({type:"onDragPending",event:Ii})},onStart(ir){const Vn=Q.current;if(Vn==null)return;const Sr=U.get(Vn);if(!Sr)return;const{onDragStart:jr}=xe.current,ea={activatorEvent:Yr,active:{id:Vn,data:Sr.data,rect:X}};yp.unstable_batchedUpdates(()=>{jr==null||jr(ea),I(Qb.Initializing),k({type:yu.DragStart,initialCoordinates:ir,active:Vn}),S({type:"onDragStart",event:ea}),re(xt.current),ce(Yr)})},onMove(ir){k({type:yu.DragMove,coordinates:ir})},onEnd:pt(yu.DragEnd),onCancel:pt(yu.DragCancel)});xt.current=vi;function pt(ir){return async function(){const{active:Sr,collisions:jr,over:ea,scrollAdjustedTranslate:Pa}=Ae.current;let Ii=null;if(Sr&&Pa){const{cancelDrop:Fo}=xe.current;Ii={activatorEvent:Yr,active:Sr,collisions:jr,delta:Pa,over:ea},ir===yu.DragEnd&&typeof Fo=="function"&&await Promise.resolve(Fo(Ii))&&(ir=yu.DragCancel)}Q.current=null,yp.unstable_batchedUpdates(()=>{k({type:ir}),I(Qb.Uninitialized),Cs(null),re(null),ce(null),xt.current=null;const Fo=ir===yu.DragEnd?"onDragEnd":"onDragCancel";if(Ii){const $t=xe.current[Fo];$t==null||$t(Ii),S({type:Fo,event:Ii})}})}}},[U]),ur=N.useCallback((Ea,dr)=>(Jr,Wr)=>{const dn=Jr.nativeEvent,Yr=U.get(Wr);if(Q.current!==null||!Yr||dn.dndKit||dn.defaultPrevented)return;const vi={active:Yr};Ea(Jr,dr.options,vi)===!0&&(dn.dndKit={capturedBy:dr.sensor},Q.current=Wr,Es(Jr,dr))},[U,Es]),Mr=iHt(p,ur);pHt(p),E0(()=>{Be&&L===Qb.Initializing&&I(Qb.Initialized)},[Be,L]),N.useEffect(()=>{const{onDragMove:Ea}=xe.current,{active:dr,activatorEvent:Jr,collisions:Wr,over:dn}=Ae.current;if(!dr||!Jr)return;const Yr={active:dr,activatorEvent:Jr,collisions:Wr,delta:{x:it.x,y:it.y},over:dn};yp.unstable_batchedUpdates(()=>{Ea==null||Ea(Yr),S({type:"onDragMove",event:Yr})})},[it.x,it.y]),N.useEffect(()=>{const{active:Ea,activatorEvent:dr,collisions:Jr,droppableContainers:Wr,scrollAdjustedTranslate:dn}=Ae.current;if(!Ea||Q.current==null||!dr||!dn)return;const{onDragOver:Yr}=xe.current,vi=Wr.get(hs),pt=vi&&vi.rect.current?{id:vi.id,rect:vi.rect.current,data:vi.data,disabled:vi.disabled}:null,ir={active:Ea,activatorEvent:dr,collisions:Jr,delta:{x:dn.x,y:dn.y},over:pt};yp.unstable_batchedUpdates(()=>{Cs(pt),Yr==null||Yr(ir),S({type:"onDragOver",event:ir})})},[hs]),E0(()=>{Ae.current={activatorEvent:oe,active:ee,activeNode:Pe,collisionRect:Lt,collisions:Vt,droppableRects:be,draggableNodes:U,draggingNode:Ve,draggingNodeRect:at,droppableContainers:V,over:Ts,scrollableAncestors:Ge,scrollAdjustedTranslate:it},X.current={initial:at,translated:Lt}},[ee,Pe,Vt,Lt,U,Ve,at,be,V,Ts,Ge,it]),sHt({...Te,delta:B,draggingRect:Lt,pointerCoordinates:Ze,scrollableAncestors:Ge,scrollableAncestorRects:ct});const Lr=N.useMemo(()=>({active:ee,activeNode:Pe,activeNodeRect:Be,activatorEvent:oe,collisions:Vt,containerNodeRect:nt,dragOverlay:fe,draggableNodes:U,droppableContainers:V,droppableRects:be,over:Ts,measureDroppableContainers:Me,scrollableAncestors:Ge,scrollableAncestorRects:ct,measuringConfiguration:pe,measuringScheduled:Ne,windowRect:rt}),[ee,Pe,Be,oe,Vt,nt,fe,U,V,be,Ts,Me,Ge,ct,pe,Ne,rt]),fn=N.useMemo(()=>({activatorEvent:oe,activators:Mr,active:ee,activeNodeRect:Be,ariaDescribedById:{draggable:ge},dispatch:k,draggableNodes:U,over:Ts,measureDroppableContainers:Me}),[oe,Mr,ee,Be,k,ge,U,Ts,Me]);return ht.createElement(htt.Provider,{value:M},ht.createElement(Zue.Provider,{value:fn},ht.createElement(Stt.Provider,{value:Lr},ht.createElement(Ctt.Provider,{value:er},u)),ht.createElement(kHt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),ht.createElement(MVt,{...i,hiddenTextDescribedById:ge}));function ki(){const Ea=(ie==null?void 0:ie.autoScrollEnabled)===!1,dr=typeof c=="object"?c.enabled===!1:c===!1,Jr=O&&!Ea&&!dr;return typeof c=="object"?{...c,enabled:Jr}:{enabled:Jr}}}),THt=N.createContext(null),C8e="button",AHt="Draggable";function EHt(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=eR(AHt),{activators:l,activatorEvent:i,active:c,activeNodeRect:u,ariaDescribedById:p,draggableNodes:f,over:g}=N.useContext(Zue),{role:b=C8e,roleDescription:_="draggable",tabIndex:j=0}=a??{},w=(c==null?void 0:c.id)===s,k=N.useContext(w?Ctt:THt),[S,M]=Ble(),[L,I]=Ble(),O=fHt(l,s),q=yD(r);E0(()=>(f.set(s,{id:s,key:o,node:S,activatorNode:L,data:q}),()=>{const B=f.get(s);B&&B.key===o&&f.delete(s)}),[f,s]);const U=N.useMemo(()=>({role:b,tabIndex:j,"aria-disabled":n,"aria-pressed":w&&b===C8e?!0:void 0,"aria-roledescription":_,"aria-describedby":p.draggable}),[n,b,j,w,_,p.draggable]);return{active:c,activatorEvent:i,activeNodeRect:u,attributes:U,isDragging:w,listeners:n?void 0:O,node:S,over:g,setNodeRef:M,setActivatorNodeRef:I,transform:k}}function PHt(){return N.useContext(Stt)}const IHt="Droppable",LHt={timeout:25};function DHt(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=eR(IHt),{active:l,dispatch:i,over:c,measureDroppableContainers:u}=N.useContext(Zue),p=N.useRef({disabled:r}),f=N.useRef(!1),g=N.useRef(null),b=N.useRef(null),{disabled:_,updateMeasurementsFor:j,timeout:w}={...LHt,...a},k=yD(j??n),S=N.useCallback(()=>{if(!f.current){f.current=!0;return}b.current!=null&&clearTimeout(b.current),b.current=setTimeout(()=>{u(Array.isArray(k.current)?k.current:[k.current]),b.current=null},w)},[w]),M=Kue({callback:S,disabled:_||!l}),L=N.useCallback((U,B)=>{M&&(B&&(M.unobserve(B),f.current=!1),U&&M.observe(U))},[M]),[I,O]=Ble(L),q=yD(s);return N.useEffect(()=>{!M||!I.current||(M.disconnect(),f.current=!1,M.observe(I.current))},[I,M]),N.useEffect(()=>(i({type:yu.RegisterDroppable,element:{id:n,key:o,disabled:r,node:I,rect:g,data:q}}),()=>i({type:yu.UnregisterDroppable,key:o,id:n})),[n]),N.useEffect(()=>{r!==p.current.disabled&&(i({type:yu.SetDroppableDisabled,id:n,key:o,disabled:r}),p.current.disabled=r)},[n,o,r,i]),{active:l,rect:g,isOver:(c==null?void 0:c.id)===n,node:I,over:c,setNodeRef:O}}function Gke(t,s,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function OHt(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function Sz(t){return t!==null&&t>=0}function RHt(t,s){if(t===s)return!0;if(t.length!==s.length)return!1;for(let r=0;r{var s;let{rects:r,activeNodeRect:n,activeIndex:a,overIndex:o,index:l}=t;const i=(s=r[a])!=null?s:n;if(!i)return null;const c=zHt(r,l,a);if(l===a){const u=r[o];return u?{x:aa&&l<=o?{x:-i.width-c,y:0,...Cz}:l=o?{x:i.width+c,y:0,...Cz}:{x:0,y:0,...Cz}};function zHt(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=Gke(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}},Mtt="Sortable",Ttt=ht.createContext({activeIndex:-1,containerId:Mtt,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:sR,disabled:{draggable:!1,droppable:!1}});function Kke(t){let{children:s,id:r,items:n,strategy:a=sR,disabled:o=!1}=t;const{active:l,dragOverlay:i,droppableRects:c,over:u,measureDroppableContainers:p}=PHt(),f=eR(Mtt,r),g=i.rect!==null,b=N.useMemo(()=>n.map(O=>typeof O=="object"&&"id"in O?O.id:O),[n]),_=l!=null,j=l?b.indexOf(l.id):-1,w=u?b.indexOf(u.id):-1,k=N.useRef(b),S=!RHt(b,k.current),M=w!==-1&&j===-1||S,L=FHt(o);E0(()=>{S&&_&&p(b)},[S,b,_,p]),N.useEffect(()=>{k.current=b},[b]);const I=N.useMemo(()=>({activeIndex:j,containerId:f,disabled:L,disableTransforms:M,items:b,overIndex:w,useDragOverlay:g,sortedRects:OHt(b,c),strategy:a}),[j,f,L.draggable,L.droppable,M,b,w,c,g,a]);return ht.createElement(Ttt.Provider,{value:I},s)}const BHt=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return Gke(r,n,a).indexOf(s)},$Ht=t=>{let{containerId:s,isSorting:r,wasDragging:n,index:a,items:o,newIndex:l,previousItems:i,previousContainerId:c,transition:u}=t;return!u||!n||i!==o&&a===l?!1:r?!0:l!==a&&s===c},qHt={duration:200,easing:"ease"},Att="transform",UHt=QS.Transition.toString({property:Att,duration:0,easing:"linear"}),VHt={roleDescription:"sortable"};function HHt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=N.useState(null),i=N.useRef(r);return E0(()=>{if(!s&&r!==i.current&&n.current){const c=a.current;if(c){const u=dE(n.current,{ignoreTransform:!0}),p={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(p.x||p.y)&&l(p)}}r!==i.current&&(i.current=r)},[s,r,n,a]),N.useEffect(()=>{o&&l(null)},[o]),o}function Zke(t){let{animateLayoutChanges:s=$Ht,attributes:r,disabled:n,data:a,getNewIndex:o=BHt,id:l,strategy:i,resizeObserverConfig:c,transition:u=qHt}=t;const{items:p,containerId:f,activeIndex:g,disabled:b,disableTransforms:_,sortedRects:j,overIndex:w,useDragOverlay:k,strategy:S}=N.useContext(Ttt),M=WHt(n,b),L=p.indexOf(l),I=N.useMemo(()=>({sortable:{containerId:f,index:L,items:p},...a}),[f,a,L,p]),O=N.useMemo(()=>p.slice(p.indexOf(l)),[p,l]),{rect:q,node:U,isOver:B,setNodeRef:V}=DHt({id:l,data:I,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:O,...c}}),{active:Z,activatorEvent:X,activeNodeRect:ee,attributes:Q,setNodeRef:ie,listeners:re,isDragging:oe,over:ce,setActivatorNodeRef:xe,transform:ge}=EHt({id:l,data:I,attributes:{...VHt,...r},disabled:M.draggable}),ue=fVt(V,ie),pe=!!Z,be=pe&&!_&&Sz(g)&&Sz(w),Me=!k&&oe,Ne=Me&&be?ge:null,Oe=be?Ne??(i??S)({rects:j,activeNodeRect:ee,activeIndex:g,overIndex:w,index:L}):null,Te=Sz(g)&&Sz(w)?o({id:l,items:p,activeIndex:g,overIndex:w}):L,ke=Z==null?void 0:Z.id,Be=N.useRef({activeId:ke,items:p,newIndex:Te,containerId:f}),nt=p!==Be.current.items,Ae=s({active:Z,containerId:f,isDragging:oe,isSorting:pe,id:l,index:L,items:p,newIndex:Be.current.newIndex,previousItems:Be.current.items,previousContainerId:Be.current.containerId,transition:u,wasDragging:Be.current.activeId!=null}),ft=HHt({disabled:!Ae,index:L,node:U,rect:q});return N.useEffect(()=>{pe&&Be.current.newIndex!==Te&&(Be.current.newIndex=Te),f!==Be.current.containerId&&(Be.current.containerId=f),p!==Be.current.items&&(Be.current.items=p)},[pe,Te,f,p]),N.useEffect(()=>{if(ke===Be.current.activeId)return;if(ke!=null&&Be.current.activeId==null){Be.current.activeId=ke;return}const Ve=setTimeout(()=>{Be.current.activeId=ke},50);return()=>clearTimeout(Ve)},[ke]),{active:Z,activeIndex:g,attributes:Q,data:I,rect:q,index:L,newIndex:Te,items:p,isOver:B,isSorting:pe,isDragging:oe,listeners:re,node:U,overIndex:w,over:ce,setNodeRef:ue,setActivatorNodeRef:xe,setDroppableNodeRef:V,setDraggableNodeRef:ie,transform:ft??Oe,transition:fe()};function fe(){if(ft||nt&&Be.current.newIndex===L)return UHt;if(!(Me&&!Bke(X)||!u)&&(pe||Ae))return QS.Transition.toString({...u,property:Att})}}function WHt(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 Vle(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 GHt=[To.Down,To.Right,To.Up,To.Left],KHt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(GHt.includes(t.code)){if(t.preventDefault(),!r||!n)return;const c=[];o.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const g=a.get(f.id);if(g)switch(t.code){case To.Down:n.topg.top&&c.push(f);break;case To.Left:n.left>g.left&&c.push(f);break;case To.Right:n.left1&&(p=u[1].id),p!=null){const f=o.get(r.id),g=o.get(p),b=g?a.get(g.id):null,_=g==null?void 0:g.node.current;if(_&&b&&f&&g){const w=Gue(_).some((O,q)=>i[q]!==O),k=Ett(f,g),S=ZHt(f,g),M=w||!k?{x:0,y:0}:{x:S?n.width-b.width:0,y:S?n.height-b.height:0},L={x:b.left,y:b.top};return M.x&&M.y?L:vD(L,M)}}}};function Ett(t,s){return!Vle(t)||!Vle(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function ZHt(t,s){return!Vle(t)||!Vle(s)||!Ett(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(Nr,{className:"h-3.5 w-3.5"})})]}),t.post_date&&e.jsx("div",{className:"absolute bottom-2 left-2",children:e.jsxs(tt,{className:"bg-primary/90 text-primary-foreground text-[10px] gap-1 backdrop-blur-sm px-1.5 py-0.5",children:[e.jsx(hn,{className:"h-2.5 w-2.5"}),ms(new Date(t.post_date+"T00:00:00"),"MMM d")]})})]}),e.jsxs(De,{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:t.caption}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:It("w-full h-7 text-[11px] gap-1 justify-start font-normal",!t.post_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"h-3 w-3"}),t.post_date?ms(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs(Ro,{className:"w-auto p-0",align:"start",children:[e.jsx(_f,{mode:"single",selected:t.post_date?new Date(t.post_date+"T00:00:00"):void 0,onSelect:f=>n(t.id,f?ms(f,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"}),t.post_date&&e.jsx("div",{className:"p-2 border-t",children:e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>n(t.id,null),children:"Clear date"})})]})]})]})]})})}const XHt=()=>{const t=Qt(),[s,r]=N.useState("all"),[n,a]=N.useState(!1),[o,l]=N.useState(ms(new Date,"yyyy-MM")),[i,c]=N.useState([]),[u,p]=N.useState(!1),[f,g]=N.useState(null),[b,_]=N.useState(null),[j,w]=N.useState(""),[k,S]=N.useState(null),[M,L]=N.useState(!1),[I,O]=N.useState(!1),[q,U]=N.useState(ms(new Date,"yyyy-MM")),[B,V]=N.useState(null),[Z,X]=N.useState(""),[ee,Q]=N.useState(""),[ie,re]=N.useState(""),[oe,ce]=N.useState(!1),xe=$ke(qle(tR,{activationConstraint:{distance:5}}),qle(Vke,{coordinateGetter:KHt})),{data:ge=[],isLoading:ue}=mt({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:Ze,error:Qe}=await H.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(Qe)throw Qe;return Ze}}),{data:pe=[]}=mt({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:Ze,error:Qe}=await H.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(Qe)throw Qe;return Ze}}),{data:be=[]}=mt({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:Ze,error:Qe}=await H.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(Qe)throw Qe;return Ze}}),Me=[...new Set(ge.map(Ze=>Ze.month))].sort((Ze,Qe)=>Qe.localeCompare(Ze)),Ne=s==="all"?ge:ge.filter(Ze=>Ze.month===s),Pe=Ze=>{const Qe=vje(Ze,"yyyy-MM",new Date);return ms(Qe,"MMMM yyyy")},Oe=Ze=>{_(Ze),w(Ze.caption),S(Ze.post_date)},Te=async()=>{if(b){L(!0);try{const{error:Ze}=await H.from("social_swag_2").update({caption:j,post_date:k}).eq("id",b.id);if(Ze)throw Ze;me.success("Image updated"),_(null),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})}catch{me.error("Failed to update image")}finally{L(!1)}}},ke=async Ze=>{const{active:Qe,over:He}=Ze;if(!He||Qe.id===He.id)return;const Je=Ne,it=Je.findIndex(hs=>hs.id===Qe.id),Lt=Je.findIndex(hs=>hs.id===He.id);if(it===-1||Lt===-1)return;const Vt=Gke(Je,it,Lt);t.setQueryData(["admin-social-swag-2"],hs=>{if(!hs)return hs;const Ts={};return Vt.forEach((Cs,cs)=>{Ts[Cs.id]=cs}),hs.map(Cs=>Ts[Cs.id]!==void 0?{...Cs,sort_order:Ts[Cs.id]}:Cs).sort((Cs,cs)=>Cs.month!==cs.month?cs.month.localeCompare(Cs.month):Cs.sort_order-cs.sort_order)});try{await Promise.all(Vt.map((hs,Ts)=>H.from("social_swag_2").update({sort_order:Ts}).eq("id",hs.id)))}catch{me.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},Be=Ze=>{const He=Array.from(Ze.target.files||[]).sort((Je,it)=>Je.name.localeCompare(it.name,void 0,{numeric:!0,sensitivity:"base"})).slice(0,16-i.length).map(Je=>({file:Je,preview:URL.createObjectURL(Je),caption:""}));c(Je=>[...Je,...He].slice(0,16))},nt=Ze=>{c(Qe=>{const He=[...Qe];return URL.revokeObjectURL(He[Ze].preview),He.splice(Ze,1),He})},Ae=(Ze,Qe)=>{c(He=>{const Je=[...He];return Je[Ze]={...Je[Ze],caption:Qe},Je})},ft=async()=>{var Qe;if(i.length===0){me.error("Please add at least one image");return}if(i.filter(He=>!He.caption.trim()).length>0){me.error("Please add captions to all images");return}p(!0);try{const{data:He}=await H.from("social_swag_2").select("sort_order").eq("month",o).order("sort_order",{ascending:!1}).limit(1),Je=(((Qe=He==null?void 0:He[0])==null?void 0:Qe.sort_order)??-1)+1;for(let it=0;it{const Qe=Ze.image_url.split("/social-swag-2/");Qe[1]&&await H.storage.from("social-swag-2").remove([Qe[1]]);const{error:He}=await H.from("social_swag_2").delete().eq("id",Ze.id);if(He)throw He},onSuccess:()=>{me.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>me.error("Failed to delete image")}),Ve=Dt({mutationFn:async({id:Ze,postDate:Qe})=>{const{error:He}=await H.from("social_swag_2").update({post_date:Qe}).eq("id",Ze);if(He)throw He},onSuccess:()=>{me.success("Post date updated"),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})},onError:()=>me.error("Failed to update post date")}),at=Dt({mutationFn:async({month:Ze,link:Qe})=>{const{error:He}=await H.from("social_swag_2_months").upsert({month:Ze,canva_link:Qe||null},{onConflict:"month"});if(He)throw He},onSuccess:()=>{me.success("Canva link updated"),g(null),t.invalidateQueries({queryKey:["admin-social-swag-2-months"]})},onError:()=>me.error("Failed to update Canva link")}),et=Ze=>{var Qe;return((Qe=pe.find(He=>He.month===Ze))==null?void 0:Qe.canva_link)||""},Ce=Ze=>be.find(Qe=>Qe.month===Ze)||null,rt=Ze=>{var He;const Qe=(He=Ze.target.files)==null?void 0:He[0];Qe&&(V(Qe),X(URL.createObjectURL(Qe)))},Ge=()=>{Z&&URL.revokeObjectURL(Z),V(null),X(""),Q(""),re("")},ct=async()=>{if(!B){me.error("Please select an image");return}ce(!0);try{const Ze=B.name.split(".").pop(),Qe=`reels/${q}-${Date.now()}.${Ze}`,{error:He}=await H.storage.from("social-swag-2").upload(Qe,B);if(He)throw He;const{data:{publicUrl:Je}}=H.storage.from("social-swag-2").getPublicUrl(Qe),{error:it}=await H.from("social_swag_2_reels").upsert({month:q,image_url:Je,canva_link:ie||null,caption:ee||null},{onConflict:"month"});if(it)throw it;me.success("Reel uploaded successfully!"),abe(`${Pe(q)} Reel`,"social-swag-2"),Ge(),O(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(Ze){console.error("Reel upload error:",Ze),me.error("Failed to upload reel")}finally{ce(!1)}},qe=Dt({mutationFn:async Ze=>{const Qe=Ze.image_url.split("/social-swag-2/");Qe[1]&&await H.storage.from("social-swag-2").remove([Qe[1]]);const{error:He}=await H.from("social_swag_2_reels").delete().eq("id",Ze.id);if(He)throw He},onSuccess:()=>{me.success("Reel deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})},onError:()=>me.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(fs,{open:n,onOpenChange:a,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Upload Images"]})}),e.jsxs(ps,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{type:"month",value:o,onChange:Ze=>l(Ze.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:Be,className:"hidden",id:"swag-upload",disabled:i.length>=16}),e.jsxs("label",{htmlFor:"swag-upload",className:"cursor-pointer",children:[e.jsx(li,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select images (max 16)"})]})]})]}),i.length>0&&e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:i.map((Ze,Qe)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative aspect-[4/5] rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:Ze.preview,alt:`Upload ${Qe+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:()=>nt(Qe),children:e.jsx(Rr,{className:"h-3 w-3"})})]}),e.jsx(Er,{placeholder:"Caption...",value:Ze.caption,onChange:He=>Ae(Qe,He.target.value),className:"text-xs h-20"})]},Qe))}),e.jsx(K,{onClick:ft,disabled:u||i.length===0,className:"w-full gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),e.jsxs(fs,{open:I,onOpenChange:Ze=>{O(Ze),Ze||Ge()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(gu,{className:"h-4 w-4"}),"Upload Reel"]})}),e.jsxs(ps,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{type:"month",value:q,onChange:Ze=>U(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Reel Preview Image"}),Z?e.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:Z,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(Z),V(null),X("")},children:e.jsx(Rr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:rt,className:"hidden",id:"reel-upload"}),e.jsxs("label",{htmlFor:"reel-upload",className:"cursor-pointer",children:[e.jsx(gu,{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(ze,{value:ie,onChange:Ze=>re(Ze.target.value),placeholder:"https://www.canva.com/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Caption"}),e.jsx(Er,{value:ee,onChange:Ze=>Q(Ze.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(K,{onClick:ct,disabled:oe||!B,className:"w-full gap-2",children:oe?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(li,{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(De,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ge.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:Me.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Months"})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ba,{value:s,onValueChange:r,children:e.jsxs(pa,{children:[e.jsx(ns,{value:"all",children:"All"}),Me.map(Ze=>e.jsx(ns,{value:Ze,children:Pe(Ze)},Ze))]})}),s!=="all"&&e.jsx(Ee,{children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Bo,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(ve,{className:"text-sm text-muted-foreground",children:["Canva Edit Link for ",Pe(s)]}),(f==null?void 0:f.month)===s?e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(ze,{value:f.link,onChange:Ze=>g({...f,link:Ze.target.value}),placeholder:"https://www.canva.com/..."}),e.jsx(K,{size:"sm",onClick:()=>at.mutate(f),children:"Save"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>g(null),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-sm",children:et(s)||"No link set"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>g({month:s,link:et(s)}),children:"Edit"})]})]})]})})}),s!=="all"&&e.jsx(Ee,{children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(gu,{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 ",Pe(s)]}),(()=>{const Ze=Ce(s);return Ze?e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("img",{src:Ze.image_url,alt:"Reel preview",className:"w-16 h-28 object-cover rounded"}),e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsx("p",{className:"line-clamp-2",children:Ze.caption||"No caption"}),Ze.canva_link&&e.jsx("a",{href:Ze.canva_link,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-xs",children:"View Canva Link"})]}),e.jsx(K,{variant:"destructive",size:"sm",onClick:()=>qe.mutate(Ze),children:e.jsx(Nr,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"No reel uploaded for this month"})})()]})]})})})]}),ue?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}):Ne.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(gl,{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(Wke,{sensors:xe,collisionDetection:qke,onDragEnd:ke,children:e.jsx(Kke,{items:Ne.map(Ze=>Ze.id),strategy:sR,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:Ne.map(Ze=>e.jsx(YHt,{item:Ze,onEdit:Oe,onDelete:Qe=>fe.mutate(Qe),onDateChange:(Qe,He)=>Ve.mutate({id:Qe,postDate:He})},Ze.id))})})})]}),e.jsx(fs,{open:!!b,onOpenChange:Ze=>{Ze||_(null)},children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Edit Image"})}),b&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"aspect-[4/5] max-h-48 w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:b.image_url,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Caption"}),e.jsx(Er,{value:j,onChange:Ze=>w(Ze.target.value),placeholder:"Enter caption...",className:"h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Post Date"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("flex-1 justify-start gap-2 font-normal",!k&&"text-muted-foreground"),children:[e.jsx(hn,{className:"h-4 w-4"}),k?ms(new Date(k+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:k?new Date(k+"T00:00:00"):void 0,onSelect:Ze=>S(Ze?ms(Ze,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),k&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(null),children:e.jsx(Rr,{className:"h-4 w-4"})})]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(null),children:"Cancel"}),e.jsx(K,{onClick:Te,disabled:M,className:"gap-2",children:M?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},QHt=()=>{const{toast:t}=Ua(),s=Qt(),[r,n]=N.useState("categories"),[a,o]=N.useState(!1),[l,i]=N.useState(null),[c,u]=N.useState({name:"",description:"",icon:""}),[p,f]=N.useState(!1),[g,b]=N.useState(null),[_,j]=N.useState({name:"",description:"",icon:""}),[w,k]=N.useState(!1),[S,M]=N.useState(null),[L,I]=N.useState(""),{data:O=[],isLoading:q}=mt({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:ke,error:Be}=await H.from("community_categories").select("*").order("sort_order");if(Be)throw Be;return ke}}),{data:U=[],isLoading:B}=mt({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:ke,error:Be}=await H.from("community_private_groups").select("*").order("sort_order");if(Be)throw Be;return ke}}),{data:V=[]}=mt({queryKey:["admin-group-members",S==null?void 0:S.id],queryFn:async()=>{if(!S)return[];const{data:ke,error:Be}=await H.from("community_private_group_members").select("*").eq("group_id",S.id);if(Be)throw Be;return ke},enabled:!!S}),{data:Z=[]}=mt({queryKey:["admin-all-profiles"],queryFn:async()=>{let Be=[],nt=0,Ae=!0;for(;Ae;){const{data:ft,error:fe}=await H.from("profiles").select("id, name, email, brokerage_id").order("name").range(nt,nt+1e3-1);if(fe)throw fe;ft&&ft.length>0?(Be=[...Be,...ft],nt+=1e3,Ae=ft.length===1e3):Ae=!1}return Be}}),{data:X=[]}=mt({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:ke,error:Be}=await H.from("brokerages").select("*").order("name");if(Be)throw Be;return ke}}),ee=Dt({mutationFn:async ke=>{if(ke.id){const{error:Be}=await H.from("community_categories").update({name:ke.name,description:ke.description||null,icon:ke.icon||null}).eq("id",ke.id);if(Be)throw Be}else{const Be=Math.max(...O.map(Ae=>Ae.sort_order),0),{error:nt}=await H.from("community_categories").insert({name:ke.name,description:ke.description||null,icon:ke.icon||null,sort_order:Be+1});if(nt)throw nt}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),u({name:"",description:"",icon:""}),t({title:l?"Category updated!":"Category created!"})},onError:ke=>{t({title:"Error",description:ke.message,variant:"destructive"})}}),Q=Dt({mutationFn:async ke=>{const{error:Be}=await H.from("community_categories").delete().eq("id",ke);if(Be)throw Be},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),t({title:"Category deleted"})}}),ie=Dt({mutationFn:async({id:ke,direction:Be})=>{const nt=O.findIndex(Ae=>Ae.id===ke);if(Be==="up"&&nt>0){const Ae=O[nt-1],ft=O[nt];await H.from("community_categories").update({sort_order:ft.sort_order}).eq("id",Ae.id),await H.from("community_categories").update({sort_order:Ae.sort_order}).eq("id",ft.id)}else if(Be==="down"&&nts.invalidateQueries({queryKey:["admin-community-categories"]})}),re=Dt({mutationFn:async ke=>{if(ke.id){const{error:Be}=await H.from("community_private_groups").update({name:ke.name,description:ke.description||null,icon:ke.icon||null}).eq("id",ke.id);if(Be)throw Be}else{const Be=Math.max(...U.map(Ae=>Ae.sort_order),0),{error:nt}=await H.from("community_private_groups").insert({name:ke.name,description:ke.description||null,icon:ke.icon||null,sort_order:Be+1});if(nt)throw nt}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),f(!1),b(null),j({name:"",description:"",icon:""}),t({title:g?"Private group updated!":"Private group created!"})},onError:ke=>{t({title:"Error",description:ke.message,variant:"destructive"})}}),oe=Dt({mutationFn:async ke=>{const{error:Be}=await H.from("community_private_groups").delete().eq("id",ke);if(Be)throw Be},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),t({title:"Private group deleted"})}}),ce=Dt({mutationFn:async({id:ke,direction:Be})=>{const nt=U.findIndex(Ae=>Ae.id===ke);if(Be==="up"&&nt>0){const Ae=U[nt-1],ft=U[nt];await H.from("community_private_groups").update({sort_order:ft.sort_order}).eq("id",Ae.id),await H.from("community_private_groups").update({sort_order:Ae.sort_order}).eq("id",ft.id)}else if(Be==="down"&&nts.invalidateQueries({queryKey:["admin-private-groups"]})}),xe=Dt({mutationFn:async({groupId:ke,userId:Be,isMember:nt})=>{if(nt){const{error:Ae}=await H.from("community_private_group_members").delete().eq("group_id",ke).eq("user_id",Be);if(Ae)throw Ae}else{const{error:Ae}=await H.from("community_private_group_members").insert({group_id:ke,user_id:Be});if(Ae)throw Ae}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),ge=Dt({mutationFn:async({groupId:ke,brokerageId:Be,isMember:nt})=>{if(nt){const{error:Ae}=await H.from("community_private_group_members").delete().eq("group_id",ke).eq("brokerage_id",Be);if(Ae)throw Ae}else{const{error:Ae}=await H.from("community_private_group_members").insert({group_id:ke,brokerage_id:Be});if(Ae)throw Ae}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),ue=ke=>{i(ke),u({name:ke.name,description:ke.description||"",icon:ke.icon||""}),o(!0)},pe=()=>{i(null),u({name:"",description:"",icon:""}),o(!0)},be=ke=>{b(ke),j({name:ke.name,description:ke.description||"",icon:ke.icon||""}),f(!0)},Me=()=>{b(null),j({name:"",description:"",icon:""}),f(!0)},Ne=ke=>{M(ke),I(""),k(!0)},Pe=ke=>V.some(Be=>Be.user_id===ke),Oe=ke=>V.some(Be=>Be.brokerage_id===ke),Te=Z.filter(ke=>ke.name.toLowerCase().includes(L.toLowerCase())||ke.email.toLowerCase().includes(L.toLowerCase()));return e.jsx(Ms,{title:"Community Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),e.jsxs(ba,{value:r,onValueChange:n,children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"categories",children:"Public Categories"}),e.jsxs(ns,{value:"private-groups",children:[e.jsx(Th,{className:"h-4 w-4 mr-1"}),"Private Groups"]})]}),e.jsxs(bs,{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:pe,children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Ee,{children:e.jsx(De,{className:"pt-6",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[50px]",children:"Order"}),e.jsx(St,{className:"w-[80px]",children:"Icon"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(zn,{children:q?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):O.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):O.map((ke,Be)=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Be===0,onClick:()=>ie.mutate({id:ke.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Be===O.length-1,onClick:()=>ie.mutate({id:ke.id,direction:"down"}),children:"↓"})]})}),e.jsx(dt,{className:"text-2xl",children:ke.icon||"📁"}),e.jsx(dt,{className:"font-medium",children:ke.name}),e.jsx(dt,{className:"text-muted-foreground",children:ke.description||"—"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ue(ke),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.")&&Q.mutate(ke.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},ke.id))})]})})})]}),e.jsxs(bs,{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(ka,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),e.jsxs(K,{onClick:Me,children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),e.jsx(Ee,{children:e.jsx(De,{className:"pt-6",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[50px]",children:"Order"}),e.jsx(St,{className:"w-[80px]",children:"Icon"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"w-[120px]",children:"Members"}),e.jsx(St,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(zn,{children:B?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):U.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No private groups yet. Create your first one!"})}):U.map((ke,Be)=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Be===0,onClick:()=>ce.mutate({id:ke.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Be===U.length-1,onClick:()=>ce.mutate({id:ke.id,direction:"down"}),children:"↓"})]})}),e.jsx(dt,{className:"text-2xl",children:ke.icon||"🔒"}),e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ke.name,ke.brokerage_id?e.jsxs(tt,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(ka,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):e.jsxs(tt,{variant:"secondary",className:"text-xs",children:[e.jsx(Th,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(dt,{className:"text-muted-foreground",children:ke.description||"—"}),e.jsx(dt,{children:e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Ne(ke),children:[e.jsx(pr,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[!ke.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>be(ke),children:e.jsx(Ra,{className:"h-4 w-4"})}),!ke.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.")&&oe.mutate(ke.id)},children:e.jsx(Nr,{className:"h-4 w-4"})}),ke.brokerage_id&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},ke.id))})]})})})]})]}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:l?"Edit Category":"Create Category"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Icon (emoji)"}),e.jsx(ze,{value:c.icon,onChange:ke=>u(Be=>({...Be,icon:ke.target.value})),placeholder:"💬",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(ze,{value:c.name,onChange:ke=>u(Be=>({...Be,name:ke.target.value})),placeholder:"Category name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Er,{value:c.description,onChange:ke=>u(Be=>({...Be,description:ke.target.value})),placeholder:"Brief description of this category",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>ee.mutate({...c,id:l==null?void 0:l.id}),disabled:!c.name.trim(),children:l?"Save Changes":"Create Category"})]})]})]})}),e.jsx(fs,{open:p,onOpenChange:f,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:g?"Edit Private Group":"Create Private Group"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Icon (emoji)"}),e.jsx(ze,{value:_.icon,onChange:ke=>j(Be=>({...Be,icon:ke.target.value})),placeholder:"🔒",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(ze,{value:_.name,onChange:ke=>j(Be=>({...Be,name:ke.target.value})),placeholder:"e.g., Pioneers",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Er,{value:_.description,onChange:ke=>j(Be=>({...Be,description:ke.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:()=>re.mutate({..._,id:g==null?void 0:g.id}),disabled:!_.name.trim(),children:g?"Save Changes":"Create Private Group"})]})]})]})}),e.jsx(fs,{open:w,onOpenChange:k,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(vs,{children:["Manage Members: ",S==null?void 0:S.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ba,{defaultValue:"brokerages",children:[e.jsxs(pa,{className:"w-full",children:[e.jsx(ns,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),e.jsx(ns,{value:"users",className:"flex-1",children:"Individual Users"})]}),e.jsxs(bs,{value:"brokerages",className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select brokerages to grant all their agents access to this private group."}),e.jsx(Gi,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[X.map(ke=>e.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-muted rounded-md",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oo,{checked:Oe(ke.id),onCheckedChange:()=>{S&&ge.mutate({groupId:S.id,brokerageId:ke.id,isMember:Oe(ke.id)})}}),e.jsx("span",{className:"font-medium",children:ke.name})]}),e.jsxs(tt,{variant:"secondary",children:[Z.filter(Be=>Be.brokerage_id===ke.id).length," agents"]})]},ke.id)),X.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No brokerages found"})]})})]}),e.jsxs(bs,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search users...",value:L,onChange:ke=>I(ke.target.value),className:"pl-9"})]}),e.jsx(Gi,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Te.map(ke=>e.jsx("div",{className:"flex items-center justify-between p-2 hover:bg-muted rounded-md",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oo,{checked:Pe(ke.id),onCheckedChange:()=>{S&&xe.mutate({groupId:S.id,userId:ke.id,isMember:Pe(ke.id)})}}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ke.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ke.email})]})]})},ke.id)),Te.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No users found"})]})})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{onClick:()=>k(!1),children:"Done"})})]})]})})]})})},M8e=t=>{switch(t){case"academy_video":return e.jsx(nl,{className:"h-3 w-3"});case"template":return e.jsx(Sn,{className:"h-3 w-3"});case"toolbox":return e.jsx(Ml,{className:"h-3 w-3"});case"newsletter":return e.jsx(l1,{className:"h-3 w-3"});case"social_swag":return e.jsx(pn,{className:"h-3 w-3"});default:return e.jsx(tn,{className:"h-3 w-3"})}},JHt=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}},eWt=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}},tWt=()=>{const{toast:t}=Ua(),[s,r]=N.useState([]),[n,a]=N.useState([]),[o,l]=N.useState([]),[i,c]=N.useState(!0),[u,p]=N.useState(""),[f,g]=N.useState(null),[b,_]=N.useState([]),[j,w]=N.useState([]);N.useEffect(()=>{k()},[]);const k=async()=>{try{c(!0);const{data:V,error:Z}=await H.from("activity_logs").select(` id, user_id, app_name, launched_at, profiles ( name, email, brokerages ( name ) ) `).order("launched_at",{ascending:!1}).limit(5e3);if(Z)throw Z;const{data:X,error:ee}=await H.from("content_engagement_logs").select(` id, user_id, resource_type, resource_id, resource_title, action_type, created_at `).order("created_at",{ascending:!1}).limit(5e3);if(ee)throw ee;const Q=[...new Set((X==null?void 0:X.map(ue=>ue.user_id))||[])],{data:ie}=await H.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",Q),re=new Map((ie==null?void 0:ie.map(ue=>[ue.id,ue]))||[]),oe=(V==null?void 0:V.map(ue=>{var pe,be,Me,Ne;return{id:ue.id,user_id:ue.user_id,app_name:ue.app_name,launched_at:ue.launched_at,user_name:((pe=ue.profiles)==null?void 0:pe.name)||"Unknown",user_email:((be=ue.profiles)==null?void 0:be.email)||"Unknown",brokerage_name:((Ne=(Me=ue.profiles)==null?void 0:Me.brokerages)==null?void 0:Ne.name)||null}}))||[],ce=(X==null?void 0:X.map(ue=>{var be;const pe=re.get(ue.user_id);return{id:ue.id,user_id:ue.user_id,resource_type:ue.resource_type,resource_id:ue.resource_id,resource_title:ue.resource_title,action_type:ue.action_type,created_at:ue.created_at,user_name:(pe==null?void 0:pe.name)||"Unknown",user_email:(pe==null?void 0:pe.email)||"Unknown",brokerage_name:((be=pe==null?void 0:pe.brokerages)==null?void 0:be.name)||null}}))||[];r(oe),a(ce);const xe=new Map;oe.forEach(ue=>{if(!xe.has(ue.user_id))xe.set(ue.user_id,{user_id:ue.user_id,user_name:ue.user_name,user_email:ue.user_email,brokerage_name:ue.brokerage_name,last_activity_type:"app",last_activity_name:ue.app_name,last_activity_at:ue.launched_at,total_app_launches:1,total_content_views:0});else{const pe=xe.get(ue.user_id);pe.total_app_launches++,new Date(ue.launched_at)>new Date(pe.last_activity_at)&&(pe.last_activity_type="app",pe.last_activity_name=ue.app_name,pe.last_activity_at=ue.launched_at)}}),ce.forEach(ue=>{if(!xe.has(ue.user_id))xe.set(ue.user_id,{user_id:ue.user_id,user_name:ue.user_name,user_email:ue.user_email,brokerage_name:ue.brokerage_name,last_activity_type:ue.resource_type,last_activity_name:ue.resource_title,last_activity_at:ue.created_at,total_app_launches:0,total_content_views:1});else{const pe=xe.get(ue.user_id);pe.total_content_views++,new Date(ue.created_at)>new Date(pe.last_activity_at)&&(pe.last_activity_type=ue.resource_type,pe.last_activity_name=ue.resource_title,pe.last_activity_at=ue.created_at)}});const ge=Array.from(xe.values()).sort((ue,pe)=>new Date(pe.last_activity_at).getTime()-new Date(ue.last_activity_at).getTime());l(ge)}catch(V){console.error("Error loading activity:",V),t({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{c(!1)}},S=V=>{g({id:V.user_id,name:V.user_name,email:V.user_email});const Z=s.filter(ee=>ee.user_id===V.user_id),X=n.filter(ee=>ee.user_id===V.user_id);_(Z),w(X)},M=()=>{g(null),_([]),w([])},{sortKey:L,sortDirection:I,handleSort:O,sortData:q}=YO("last_activity_at","desc"),U=o.filter(V=>{var X;if(!u)return!0;const Z=u.toLowerCase();return V.user_name.toLowerCase().includes(Z)||V.user_email.toLowerCase().includes(Z)||((X=V.brokerage_name)==null?void 0:X.toLowerCase().includes(Z))}),B=q(U,{user:V=>{var Z;return((Z=V.user_name)==null?void 0:Z.toLowerCase())||""},brokerage:V=>{var Z;return((Z=V.brokerage_name)==null?void 0:Z.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(De,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"User Activity"}),e.jsx(gr,{children:"App launches and content engagement - click to see full history"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or brokerage...",value:u,onChange:V=>p(V.target.value),className:"pl-9"})]})}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(yl,{sortKey:"user",currentSortKey:L,currentDirection:I,onSort:O,children:"User"}),e.jsx(yl,{sortKey:"brokerage",currentSortKey:L,currentDirection:I,onSort:O,children:"Brokerage"}),e.jsx(St,{children:"Last Activity"}),e.jsx(yl,{sortKey:"last_activity_at",currentSortKey:L,currentDirection:I,onSort:O,children:"Last Active"}),e.jsx(yl,{sortKey:"apps",currentSortKey:L,currentDirection:I,onSort:O,className:"text-right",children:"Apps"}),e.jsx(yl,{sortKey:"content",currentSortKey:L,currentDirection:I,onSort:O,className:"text-right",children:"Content"})]})}),e.jsx(zn,{children:B.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):B.map(V=>e.jsxs(Ss,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>S(V),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:V.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:V.user_email})]})}),e.jsx(dt,{children:V.brokerage_name?e.jsx(tt,{variant:"outline",children:V.brokerage_name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(dt,{children:e.jsx("div",{className:"flex items-center gap-2",children:V.last_activity_type==="app"?e.jsxs(tt,{variant:"secondary",children:[e.jsx(tn,{className:"h-3 w-3 mr-1"}),V.last_activity_name]}):e.jsxs(tt,{variant:"outline",className:"flex items-center gap-1",children:[M8e(V.last_activity_type),e.jsx("span",{className:"max-w-32 truncate",children:V.last_activity_name})]})})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Uc(new Date(V.last_activity_at),{addSuffix:!0})}),e.jsx(dt,{className:"text-right",children:e.jsx(tt,{variant:"outline",children:V.total_app_launches})}),e.jsx(dt,{className:"text-right",children:e.jsx(tt,{variant:"outline",children:V.total_content_views})})]},V.user_id))})]})})]})]}),e.jsx(fs,{open:!!f,onOpenChange:V=>!V&&M(),children:e.jsxs(ps,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(vs,{children:[f==null?void 0:f.name,"'s Activity"]}),e.jsx(Gr,{children:f==null?void 0:f.email})]}),e.jsxs(ba,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2",children:[e.jsxs(ns,{value:"content",children:["Content (",j.length,")"]}),e.jsxs(ns,{value:"apps",children:["App Launches (",b.length,")"]})]}),e.jsx(bs,{value:"content",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Resource"}),e.jsx(St,{children:"Action"}),e.jsx(St,{children:"Time"})]})}),e.jsx(zn,{children:j.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):j.map(V=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs(tt,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[M8e(V.resource_type),JHt(V.resource_type)]})}),e.jsx(dt,{className:"max-w-48",children:e.jsx("span",{className:"truncate block",children:V.resource_title})}),e.jsx(dt,{children:e.jsx(tt,{variant:"secondary",children:eWt(V.action_type)})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Uc(new Date(V.created_at),{addSuffix:!0})})]},V.id))})]})})}),e.jsx(bs,{value:"apps",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"App"}),e.jsx(St,{children:"Time"})]})}),e.jsx(zn,{children:b.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):b.map(V=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx(tt,{variant:"secondary",children:V.app_name})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Uc(new Date(V.launched_at),{addSuffix:!0})})]},V.id))})]})})})]})]})})]})},sWt=()=>{const{toast:t}=Ua(),[s,r]=N.useState({totalUsers:0,activeUsers:0,pendingUsers:0,totalBrokerages:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0,uniqueActiveThisWeek:0}),[n,a]=N.useState(!0);N.useEffect(()=>{o()},[]);const o=async()=>{try{a(!0);const{count:l}=await H.from("profiles").select("*",{count:"exact",head:!0}),{count:i}=await H.from("profiles").select("*",{count:"exact",head:!0}).not("last_login","is",null),c=(l||0)-(i||0),{count:u}=await H.from("brokerages").select("*",{count:"exact",head:!0}),{count:p}=await H.from("activity_logs").select("*",{count:"exact",head:!0}),f=new Date;f.setDate(f.getDate()-7);const{count:g}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",f.toISOString()),b=new Date;b.setMonth(b.getMonth()-1);const{count:_}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",b.toISOString()),{data:j}=await H.from("activity_logs").select("user_id").gte("launched_at",f.toISOString()),w=new Set(j==null?void 0:j.map(k=>k.user_id)).size;r({totalUsers:l||0,activeUsers:i||0,pendingUsers:c,totalBrokerages:u||0,totalLaunches:p||0,launchesThisWeek:g||0,launchesThisMonth:_||0,uniqueActiveThisWeek: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(De,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(pr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalUsers}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.activeUsers," active, ",s.pendingUsers," pending"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(xi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.activeUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.totalUsers>0?`${Math.round(s.activeUsers/s.totalUsers*100)}% of total`:"0% of total"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(un,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.pendingUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(ka,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalBrokerages}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total brokerages"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(kh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(kh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(kh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisMonth}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(ul,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.uniqueActiveThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique users"})]})]})]})},T8e={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},A8e={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 Ptt({brokerageOnly:t=!1,brokerageId:s}){const[r,n]=N.useState([]),[a,o]=N.useState(!0),[l,i]=N.useState(""),[c,u]=N.useState("all");N.useEffect(()=>{p()},[s]);const p=async()=>{o(!0);try{let O=[];if(t&&s){const{data:Q}=await H.from("profiles").select("id").eq("brokerage_id",s);if(O=(Q==null?void 0:Q.map(ie=>ie.id))||[],O.length===0){n([]),o(!1);return}}let q=H.from("resource_shares").select("*").order("created_at",{ascending:!1});t&&O.length>0&&(q=q.or(`sender_id.in.(${O.join(",")}),recipient_id.in.(${O.join(",")})`));const{data:U,error:B}=await q;if(B)throw B;const V=new Set;U==null||U.forEach(Q=>{V.add(Q.sender_id),V.add(Q.recipient_id)});const{data:Z}=await H.from("profiles").select("id, name, email").in("id",Array.from(V)),X=new Map((Z==null?void 0:Z.map(Q=>[Q.id,Q]))||[]),ee=(U==null?void 0:U.map(Q=>({...Q,sender:X.get(Q.sender_id),recipient:X.get(Q.recipient_id)})))||[];n(ee)}catch(O){console.error("Error loading shares:",O)}finally{o(!1)}},{sortKey:f,sortDirection:g,handleSort:b,sortData:_}=YO("created_at","desc"),j=r.filter(O=>{var B,V;const q=l===""||O.resource_title.toLowerCase().includes(l.toLowerCase())||((B=O.sender)==null?void 0:B.name.toLowerCase().includes(l.toLowerCase()))||((V=O.recipient)==null?void 0:V.name.toLowerCase().includes(l.toLowerCase())),U=c==="all"||O.resource_type===c;return q&&U}),w=_(j,{resource:O=>{var q;return((q=O.resource_title)==null?void 0:q.toLowerCase())||""},type:O=>O.resource_type,sender:O=>{var q,U;return((U=(q=O.sender)==null?void 0:q.name)==null?void 0:U.toLowerCase())||""},recipient:O=>{var q,U;return((U=(q=O.recipient)==null?void 0:q.name)==null?void 0:U.toLowerCase())||""},status:O=>O.is_read?1:0,created_at:O=>new Date(O.created_at).getTime()}),k=r.length,S=new Set(r.map(O=>O.sender_id)).size,M=new Set(r.map(O=>O.recipient_id)).size,L=r.length>0?Math.round(r.filter(O=>O.is_read).length/r.length*100):0,I=r.reduce((O,q)=>(O[q.resource_type]=(O[q.resource_type]||0)+1,O),{});return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((O,q)=>e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(ys,{className:"h-4 w-20"})}),e.jsx(De,{children:e.jsx(ys,{className:"h-8 w-16"})})]},q))}),e.jsx(Ee,{children:e.jsx(De,{className:"p-6",children:e.jsx(ys,{className:"h-[300px]"})})})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Shares"}),e.jsx(_d,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:k})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Active Sharers"}),e.jsx(pr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:S})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(ul,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:M})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(De,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[L,"%"]})})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-sm font-medium",children:"Shares by Resource Type"})}),e.jsx(De,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(I).map(([O,q])=>e.jsxs(tt,{variant:"secondary",className:A8e[O],children:[T8e[O],": ",q]},O)),Object.keys(I).length===0&&e.jsx("span",{className:"text-muted-foreground text-sm",children:"No shares yet"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Share History"}),e.jsxs(gr,{children:["All resource shares ",t?"in your brokerage":"across the platform"]})]}),e.jsxs(De,{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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by resource, sender, or recipient...",value:l,onChange:O=>i(O.target.value),className:"pl-9"})]}),e.jsxs(Zs,{value:c,onValueChange:u,children:[e.jsx(Ws,{className:"w-[180px]",children:e.jsx(Xs,{placeholder:"Resource type"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),e.jsx(Mt,{value:"event",children:"Events"}),e.jsx(Mt,{value:"template",children:"Templates"}),e.jsx(Mt,{value:"academy_video",children:"Academy Videos"}),e.jsx(Mt,{value:"resource_kit",children:"Resource Kits"}),e.jsx(Mt,{value:"newsletter",children:"Newsletters"}),e.jsx(Mt,{value:"social_swag",children:"Social Swag"})]})]})]}),e.jsx(Gi,{className:"h-[400px]",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(yl,{sortKey:"resource",currentSortKey:f,currentDirection:g,onSort:b,children:"Resource"}),e.jsx(yl,{sortKey:"type",currentSortKey:f,currentDirection:g,onSort:b,children:"Type"}),e.jsx(yl,{sortKey:"sender",currentSortKey:f,currentDirection:g,onSort:b,children:"Sender"}),e.jsx(yl,{sortKey:"recipient",currentSortKey:f,currentDirection:g,onSort:b,children:"Recipient"}),e.jsx(yl,{sortKey:"status",currentSortKey:f,currentDirection:g,onSort:b,children:"Status"}),e.jsx(yl,{sortKey:"created_at",currentSortKey:f,currentDirection:g,onSort:b,children:"Date"})]})}),e.jsx(zn,{children:w.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):w.map(O=>{var q,U;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium max-w-[200px] truncate",children:O.resource_title}),e.jsx(dt,{children:e.jsx(tt,{variant:"secondary",className:A8e[O.resource_type],children:T8e[O.resource_type]})}),e.jsx(dt,{children:((q=O.sender)==null?void 0:q.name)||"Unknown"}),e.jsx(dt,{children:((U=O.recipient)==null?void 0:U.name)||"Unknown"}),e.jsx(dt,{children:e.jsx(tt,{variant:O.is_read?"default":"outline",children:O.is_read?"Read":"Unread"})}),e.jsx(dt,{className:"text-muted-foreground",children:ms(new Date(O.created_at),"MMM d, yyyy")})]},O.id)})})]})})]})]})]})}const Fge={academy_video:{label:"Academy Videos",icon:An,color:"bg-purple-100 text-purple-800",actionLabel:"Watched",actionIcon:On},template:{label:"Templates",icon:Rv,color:"bg-blue-100 text-blue-800",actionLabel:"Accessed",actionIcon:wh},toolbox:{label:"Toolkit",icon:ey,color:"bg-amber-100 text-amber-800",actionLabel:"Downloaded",actionIcon:yi},newsletter:{label:"Newsletters",icon:cr,color:"bg-emerald-100 text-emerald-800",actionLabel:"Clicked",actionIcon:wh},social_swag:{label:"Social Swag",icon:ac,color:"bg-pink-100 text-pink-800",actionLabel:"Accessed",actionIcon:wh},event:{label:"Events",icon:hn,color:"bg-cyan-100 text-cyan-800",actionLabel:"Registered",actionIcon:wh}};function E8e(t){return t.resource_type==="toolbox"?t.total_downloads:t.total_clicks}function rWt(t,s){return t==="toolbox"?s.downloads:s.clicks}function nWt(){var O;const[t,s]=N.useState([]),[r,n]=N.useState(!0),[a,o]=N.useState(null),l=N.useRef(null),{sortKey:i,sortDirection:c,handleSort:u,sortData:p}=YO("total_views","desc");N.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:q,error:U}=await H.rpc("get_admin_content_engagement");if(U)throw U;s(q||[])}catch(q){console.error("Error loading content engagement:",q)}finally{n(!1)}},g=q=>{o(U=>{const B=U===q?null:q;return requestAnimationFrame(()=>{var V;(V=l.current)==null||V.scrollIntoView({behavior:"smooth",block:"start"})}),B})};if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-4",children:[...Array(4)].map((q,U)=>e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(ys,{className:"h-4 w-20"})}),e.jsx(De,{children:e.jsx(ys,{className:"h-8 w-16"})})]},U))}),e.jsx(Ee,{children:e.jsx(De,{className:"py-8",children:e.jsx(ys,{className:"h-64 w-full"})})})]});const b=t.reduce((q,U)=>q+U.total_views,0),_=t.reduce((q,U)=>q+U.total_clicks,0),j=t.reduce((q,U)=>q+U.total_downloads,0),w=t.length,k=t.reduce((q,U)=>(q[U.resource_type]||(q[U.resource_type]={views:0,clicks:0,downloads:0,assets:0,uniqueUsers:0}),q[U.resource_type].views+=U.total_views,q[U.resource_type].clicks+=U.total_clicks,q[U.resource_type].downloads+=U.total_downloads,q[U.resource_type].assets+=1,q[U.resource_type].uniqueUsers+=U.unique_users,q),{}),S=a?t.filter(q=>q.resource_type===a):t,M=p(S,{asset:q=>{var U;return((U=q.resource_title)==null?void 0:U.toLowerCase())||""},type:q=>q.resource_type,views:q=>q.total_views,actions:q=>E8e(q),unique_users:q=>q.unique_users,last_activity:q=>q.last_engaged_at?new Date(q.last_engaged_at).getTime():0}),L=a?Fge[a]||{label:a,icon:On,actionLabel:"Actions"}:null,I=L==null?void 0:L.icon;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-5",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Views"}),e.jsx(On,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:b.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Across all content"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(wh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:_.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link & Canva clicks"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Downloads"}),e.jsx(yi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Assets Tracked"}),e.jsx(ul,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(wh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[b>0?Math.round((_+j)/b*100):0,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Of views → actions"})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Engagement by Content Type"}),e.jsx(gr,{children:"Click a category to see individual asset performance"})]}),e.jsx(De,{children:e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-3",children:Object.entries(k).map(([q,U])=>{const B=Fge[q]||{label:q,icon:On,color:"bg-muted text-muted-foreground",actionIcon:wh},V=B.icon,Z=a===q;return e.jsxs("button",{type:"button",onClick:()=>g(q),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors cursor-pointer ${Z?"ring-2 ring-primary border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsx("div",{className:`p-2 rounded-md ${B.color}`,children:e.jsx(V,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:B.label}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(On,{className:"h-3 w-3"})," ",U.views]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B.actionIcon,{className:"h-3 w-3"})," ",rWt(q,U)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pr,{className:"h-3 w-3"})," ",U.uniqueUsers]})]})]}),e.jsxs(tt,{variant:"secondary",className:"text-[10px]",children:[U.assets," items"]})]},q)})})})]}),e.jsx("div",{ref:l,children:e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{className:"text-sm font-medium flex items-center gap-2",children:L&&I?e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"h-4 w-4"}),L.label," — Top Performers"]}):"Top Content by Engagement"}),e.jsx(gr,{children:a?`${S.length} ${((O=L==null?void 0:L.label)==null?void 0:O.toLowerCase())||"items"} ranked by total interactions`:"All tracked assets ranked by total interactions"})]}),a&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>o(null),className:"gap-1",children:[e.jsx(Ja,{className:"h-3.5 w-3.5"}),"Show All"]})]})}),e.jsx(De,{children:S.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No engagement data yet. As users view and click content, stats will appear here."}):e.jsx(Gi,{className:"h-[400px]",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[40px]",children:"#"}),e.jsx(yl,{sortKey:"asset",currentSortKey:i,currentDirection:c,onSort:u,children:"Asset"}),!a&&e.jsx(yl,{sortKey:"type",currentSortKey:i,currentDirection:c,onSort:u,children:"Type"}),e.jsx(yl,{sortKey:"views",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:"Views"}),e.jsx(yl,{sortKey:"actions",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:L?L.actionLabel:"Actions"}),e.jsx(yl,{sortKey:"unique_users",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:"Unique Users"}),e.jsx(yl,{sortKey:"last_activity",currentSortKey:i,currentDirection:c,onSort:u,children:"Last Activity"})]})}),e.jsx(zn,{children:M.map((q,U)=>{const B=Fge[q.resource_type]||{label:q.resource_type,color:"bg-muted text-muted-foreground"};return e.jsxs(Ss,{children:[e.jsx(dt,{className:"text-muted-foreground text-xs",children:U+1}),e.jsx(dt,{children:e.jsx("p",{className:"font-medium text-sm truncate max-w-[250px]",children:q.resource_title})}),!a&&e.jsx(dt,{children:e.jsx(tt,{className:`text-[10px] ${B.color}`,children:B.label})}),e.jsx(dt,{className:"text-right font-medium",children:q.total_views}),e.jsx(dt,{className:"text-right font-medium",children:E8e(q)}),e.jsx(dt,{className:"text-right",children:q.unique_users}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:q.last_engaged_at?Uc(new Date(q.last_engaged_at),{addSuffix:!0}):"—"})]},`${q.resource_type}-${q.resource_id}`)})})]})})})]})})]})}var aWt=Array.isArray,Ip=aWt,iWt=typeof Hv=="object"&&Hv&&Hv.Object===Object&&Hv,Itt=iWt,oWt=Itt,lWt=typeof self=="object"&&self&&self.Object===Object&&self,cWt=oWt||lWt||Function("return this")(),B0=cWt,dWt=B0,uWt=dWt.Symbol,rR=uWt,P8e=rR,Ltt=Object.prototype,hWt=Ltt.hasOwnProperty,mWt=Ltt.toString,XP=P8e?P8e.toStringTag:void 0;function pWt(t){var s=hWt.call(t,XP),r=t[XP];try{t[XP]=void 0;var n=!0}catch{}var a=mWt.call(t);return n&&(s?t[XP]=r:delete t[XP]),a}var fWt=pWt,xWt=Object.prototype,gWt=xWt.toString;function yWt(t){return gWt.call(t)}var vWt=yWt,I8e=rR,bWt=fWt,_Wt=vWt,wWt="[object Null]",jWt="[object Undefined]",L8e=I8e?I8e.toStringTag:void 0;function NWt(t){return t==null?t===void 0?jWt:wWt:L8e&&L8e in Object(t)?bWt(t):_Wt(t)}var $1=NWt;function kWt(t){return t!=null&&typeof t=="object"}var q1=kWt,SWt=$1,CWt=q1,MWt="[object Symbol]";function TWt(t){return typeof t=="symbol"||CWt(t)&&SWt(t)==MWt}var uE=TWt,AWt=Ip,EWt=uE,PWt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,IWt=/^\w*$/;function LWt(t,s){if(AWt(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||EWt(t)?!0:IWt.test(t)||!PWt.test(t)||s!=null&&t in Object(s)}var Yke=LWt;function DWt(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var Fw=DWt;const hE=Po(Fw);var OWt=$1,RWt=Fw,FWt="[object AsyncFunction]",zWt="[object Function]",BWt="[object GeneratorFunction]",$Wt="[object Proxy]";function qWt(t){if(!RWt(t))return!1;var s=OWt(t);return s==zWt||s==BWt||s==FWt||s==$Wt}var Xke=qWt;const Mi=Po(Xke);var UWt=B0,VWt=UWt["__core-js_shared__"],HWt=VWt,zge=HWt,D8e=function(){var t=/[^.]+$/.exec(zge&&zge.keys&&zge.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function WWt(t){return!!D8e&&D8e in t}var GWt=WWt,KWt=Function.prototype,ZWt=KWt.toString;function YWt(t){if(t!=null){try{return ZWt.call(t)}catch{}try{return t+""}catch{}}return""}var Dtt=YWt,XWt=Xke,QWt=GWt,JWt=Fw,eGt=Dtt,tGt=/[\\^$.*+?()[\]{}|]/g,sGt=/^\[object .+?Constructor\]$/,rGt=Function.prototype,nGt=Object.prototype,aGt=rGt.toString,iGt=nGt.hasOwnProperty,oGt=RegExp("^"+aGt.call(iGt).replace(tGt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function lGt(t){if(!JWt(t)||QWt(t))return!1;var s=XWt(t)?oGt:sGt;return s.test(eGt(t))}var cGt=lGt;function dGt(t,s){return t==null?void 0:t[s]}var uGt=dGt,hGt=cGt,mGt=uGt;function pGt(t,s){var r=mGt(t,s);return hGt(r)?r:void 0}var _C=pGt,fGt=_C,xGt=fGt(Object,"create"),Yue=xGt,O8e=Yue;function gGt(){this.__data__=O8e?O8e(null):{},this.size=0}var yGt=gGt;function vGt(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var bGt=vGt,_Gt=Yue,wGt="__lodash_hash_undefined__",jGt=Object.prototype,NGt=jGt.hasOwnProperty;function kGt(t){var s=this.__data__;if(_Gt){var r=s[t];return r===wGt?void 0:r}return NGt.call(s,t)?s[t]:void 0}var SGt=kGt,CGt=Yue,MGt=Object.prototype,TGt=MGt.hasOwnProperty;function AGt(t){var s=this.__data__;return CGt?s[t]!==void 0:TGt.call(s,t)}var EGt=AGt,PGt=Yue,IGt="__lodash_hash_undefined__";function LGt(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=PGt&&s===void 0?IGt:s,this}var DGt=LGt,OGt=yGt,RGt=bGt,FGt=SGt,zGt=EGt,BGt=DGt;function mE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var rKt=sKt,nKt=Xue;function aKt(t,s){var r=this.__data__,n=nKt(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var iKt=aKt,oKt=UGt,lKt=XGt,cKt=eKt,dKt=rKt,uKt=iKt;function pE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s0?1:-1},S4=function(s){return JS(s)&&s.indexOf("%")===s.length-1},ln=function(s){return EZt(s)&&!nR(s)},DZt=function(s){return $i(s)},ju=function(s){return ln(s)||JS(s)},OZt=0,xE=function(s){var r=++OZt;return"".concat(s||"").concat(r)},Am=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(!ln(s)&&!JS(s))return n;var o;if(S4(s)){var l=s.indexOf("%");o=r*parseFloat(s.slice(0,l))/100}else o=+s;return nR(o)&&(o=n),a&&o>r&&(o=r),o},o_=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},RZt=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 VZt(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 hbe(t){"@babel/helpers - typeof";return hbe=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},hbe(t)}var U8e={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"},g1=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},V8e=null,$ge=null,o4e=function t(s){if(s===V8e&&Array.isArray($ge))return $ge;var r=[];return N.Children.forEach(s,function(n){$i(n)||(SZt.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),$ge=r,V8e=s,r};function jf(t,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return g1(a)}):n=[g1(s)],o4e(t).forEach(function(a){var o=wf(a,"type.displayName")||wf(a,"type.name");n.indexOf(o)!==-1&&r.push(a)}),r}function tf(t,s){var r=jf(t,s);return r&&r[0]}var H8e=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!ln(n)||n<=0||!ln(a)||a<=0)},HZt=["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"],WZt=function(s){return s&&s.type&&JS(s.type)&&HZt.indexOf(s.type)>=0},GZt=function(s){return s&&hbe(s)==="object"&&"clipDot"in s},KZt=function(s,r,n,a){var o,l=(o=Bge==null?void 0:Bge[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!Mi(s)&&(a&&l.includes(r)||BZt.includes(r))||n&&i4e.includes(r)},ai=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(N.isValidElement(s)&&(a=s.props),!hE(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;KZt((i=a)===null||i===void 0?void 0:i[l],l,r,n)&&(o[l]=a[l])}),o},mbe=function t(s,r){if(s===r)return!0;var n=N.Children.count(s);if(n!==N.Children.count(r))return!1;if(n===0)return!0;if(n===1)return W8e(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 JZt(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 fbe(t){var s=t.children,r=t.width,n=t.height,a=t.viewBox,o=t.className,l=t.style,i=t.title,c=t.desc,u=QZt(t,XZt),p=a||{width:r,height:n,x:0,y:0},f=Vi("recharts-surface",o);return ht.createElement("svg",pbe({},ai(u,!0,"svg"),{className:f,width:r,height:n,style:l,viewBox:"".concat(p.x," ").concat(p.y," ").concat(p.width," ").concat(p.height)}),ht.createElement("title",null,i),ht.createElement("desc",null,c),s)}var eYt=["children","className"];function xbe(){return xbe=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 sYt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var Zo=ht.forwardRef(function(t,s){var r=t.children,n=t.className,a=tYt(t,eYt),o=Vi("recharts-layer",n);return ht.createElement("g",xbe({className:o},ai(a,!0),{ref:s}),r)}),sy=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:aYt(t,s,r)}var oYt=iYt,lYt="\\ud800-\\udfff",cYt="\\u0300-\\u036f",dYt="\\ufe20-\\ufe2f",uYt="\\u20d0-\\u20ff",hYt=cYt+dYt+uYt,mYt="\\ufe0e\\ufe0f",pYt="\\u200d",fYt=RegExp("["+pYt+lYt+hYt+mYt+"]");function xYt(t){return fYt.test(t)}var Htt=xYt;function gYt(t){return t.split("")}var yYt=gYt,Wtt="\\ud800-\\udfff",vYt="\\u0300-\\u036f",bYt="\\ufe20-\\ufe2f",_Yt="\\u20d0-\\u20ff",wYt=vYt+bYt+_Yt,jYt="\\ufe0e\\ufe0f",NYt="["+Wtt+"]",gbe="["+wYt+"]",ybe="\\ud83c[\\udffb-\\udfff]",kYt="(?:"+gbe+"|"+ybe+")",Gtt="[^"+Wtt+"]",Ktt="(?:\\ud83c[\\udde6-\\uddff]){2}",Ztt="[\\ud800-\\udbff][\\udc00-\\udfff]",SYt="\\u200d",Ytt=kYt+"?",Xtt="["+jYt+"]?",CYt="(?:"+SYt+"(?:"+[Gtt,Ktt,Ztt].join("|")+")"+Xtt+Ytt+")*",MYt=Xtt+Ytt+CYt,TYt="(?:"+[Gtt+gbe+"?",gbe,Ktt,Ztt,NYt].join("|")+")",AYt=RegExp(ybe+"(?="+ybe+")|"+TYt+MYt,"g");function EYt(t){return t.match(AYt)||[]}var PYt=EYt,IYt=yYt,LYt=Htt,DYt=PYt;function OYt(t){return LYt(t)?DYt(t):IYt(t)}var RYt=OYt,FYt=oYt,zYt=Htt,BYt=RYt,$Yt=ztt;function qYt(t){return function(s){s=$Yt(s);var r=zYt(s)?BYt(s):void 0,n=r?r[0]:s.charAt(0),a=r?FYt(r,1).join(""):s.slice(1);return n[t]()+a}}var UYt=qYt,VYt=UYt,HYt=VYt("toUpperCase"),WYt=HYt;const uhe=Po(WYt);function Gl(t){return function(){return t}}const Qtt=Math.cos,Gle=Math.sin,py=Math.sqrt,Kle=Math.PI,hhe=2*Kle,vbe=Math.PI,bbe=2*vbe,a4=1e-6,GYt=bbe-a4;function Jtt(t){this._+=t[0];for(let s=1,r=t.length;s=0))throw new Error(`invalid digits: ${t}`);if(s>15)return Jtt;const r=10**s;return function(n){this._+=n[0];for(let a=1,o=n.length;aa4)if(!(Math.abs(f*c-u*p)>a4)||!o)this._append`L${this._x1=s},${this._y1=r}`;else{let b=n-l,_=a-i,j=c*c+u*u,w=b*b+_*_,k=Math.sqrt(j),S=Math.sqrt(g),M=o*Math.tan((vbe-Math.acos((j+g-w)/(2*k*S)))/2),L=M/S,I=M/k;Math.abs(L-1)>a4&&this._append`L${s+L*p},${r+L*f}`,this._append`A${o},${o},0,0,${+(f*b>p*_)},${this._x1=s+I*c},${this._y1=r+I*u}`}}arc(s,r,n,a,o,l){if(s=+s,r=+r,n=+n,l=!!l,n<0)throw new Error(`negative radius: ${n}`);let i=n*Math.cos(a),c=n*Math.sin(a),u=s+i,p=r+c,f=1^l,g=l?a-o:o-a;this._x1===null?this._append`M${u},${p}`:(Math.abs(this._x1-u)>a4||Math.abs(this._y1-p)>a4)&&this._append`L${u},${p}`,n&&(g<0&&(g=g%bbe+bbe),g>GYt?this._append`A${n},${n},0,1,${f},${s-i},${r-c}A${n},${n},0,1,${f},${this._x1=u},${this._y1=p}`:g>a4&&this._append`A${n},${n},0,${+(g>=vbe)},${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 l4e(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 ZYt(s)}function c4e(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function est(t){this._context=t}est.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 mhe(t){return new est(t)}function tst(t){return t[0]}function sst(t){return t[1]}function rst(t,s){var r=Gl(!0),n=null,a=mhe,o=null,l=l4e(i);t=typeof t=="function"?t:t===void 0?tst:Gl(t),s=typeof s=="function"?s:s===void 0?sst:Gl(s);function i(c){var u,p=(c=c4e(c)).length,f,g=!1,b;for(n==null&&(o=a(b=l())),u=0;u<=p;++u)!(u=b;--_)i.point(M[_],L[_]);i.lineEnd(),i.areaEnd()}k&&(M[g]=+t(w,g,f),L[g]=+s(w,g,f),i.point(n?+n(w,g,f):M[g],r?+r(w,g,f):L[g]))}if(S)return i=null,S+""||null}function p(){return rst().defined(a).curve(l).context(o)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Gl(+f),n=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Gl(+f),u):t},u.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Gl(+f),u):n},u.y=function(f){return arguments.length?(s=typeof f=="function"?f:Gl(+f),r=null,u):s},u.y0=function(f){return arguments.length?(s=typeof f=="function"?f:Gl(+f),u):s},u.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Gl(+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:Gl(!!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 nst{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 YYt(t){return new nst(t,!0)}function XYt(t){return new nst(t,!1)}const d4e={draw(t,s){const r=py(s/Kle);t.moveTo(r,0),t.arc(0,0,r,0,hhe)}},QYt={draw(t,s){const r=py(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()}},ast=py(1/3),JYt=ast*2,eXt={draw(t,s){const r=py(s/JYt),n=r*ast;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},tXt={draw(t,s){const r=py(s),n=-r/2;t.rect(n,n,r,r)}},sXt=.8908130915292852,ist=Gle(Kle/10)/Gle(7*Kle/10),rXt=Gle(hhe/10)*ist,nXt=-Qtt(hhe/10)*ist,aXt={draw(t,s){const r=py(s*sXt),n=rXt*r,a=nXt*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=hhe*o/5,i=Qtt(l),c=Gle(l);t.lineTo(c*r,-i*r),t.lineTo(i*n-c*a,c*n+i*a)}t.closePath()}},qge=py(3),iXt={draw(t,s){const r=-py(s/(qge*3));t.moveTo(0,r*2),t.lineTo(-qge*r,-r),t.lineTo(qge*r,-r),t.closePath()}},Xf=-.5,Qf=py(3)/2,_be=1/py(12),oXt=(_be/2+1)*3,lXt={draw(t,s){const r=py(s/oXt),n=r/2,a=r*_be,o=n,l=r*_be+r,i=-o,c=l;t.moveTo(n,a),t.lineTo(o,l),t.lineTo(i,c),t.lineTo(Xf*n-Qf*a,Qf*n+Xf*a),t.lineTo(Xf*o-Qf*l,Qf*o+Xf*l),t.lineTo(Xf*i-Qf*c,Qf*i+Xf*c),t.lineTo(Xf*n+Qf*a,Xf*a-Qf*n),t.lineTo(Xf*o+Qf*l,Xf*l-Qf*o),t.lineTo(Xf*i+Qf*c,Xf*c-Qf*i),t.closePath()}};function cXt(t,s){let r=null,n=l4e(a);t=typeof t=="function"?t:Gl(t||d4e),s=typeof s=="function"?s:Gl(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:Gl(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:Gl(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function Zle(){}function Yle(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 ost(t){this._context=t}ost.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:Yle(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:Yle(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function dXt(t){return new ost(t)}function lst(t){this._context=t}lst.prototype={areaStart:Zle,areaEnd:Zle,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:Yle(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function uXt(t){return new lst(t)}function cst(t){this._context=t}cst.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:Yle(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function hXt(t){return new cst(t)}function dst(t){this._context=t}dst.prototype={areaStart:Zle,areaEnd:Zle,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 mXt(t){return new dst(t)}function K8e(t){return t<0?-1:1}function Z8e(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(K8e(o)+K8e(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function Y8e(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function Uge(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 Xle(t){this._context=t}Xle.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:Uge(this,this._t0,Y8e(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,Uge(this,Y8e(this,r=Z8e(this,t,s)),r);break;default:Uge(this,this._t0,r=Z8e(this,t,s));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s,this._t0=r}}};function ust(t){this._context=new hst(t)}(ust.prototype=Object.create(Xle.prototype)).point=function(t,s){Xle.prototype.point.call(this,s,t)};function hst(t){this._context=t}hst.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 pXt(t){return new Xle(t)}function fXt(t){return new ust(t)}function mst(t){this._context=t}mst.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=X8e(t),a=X8e(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 gXt(t){return new phe(t,.5)}function yXt(t){return new phe(t,0)}function vXt(t){return new phe(t,1)}function YT(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 bXt(t,s){return t[s]}function _Xt(t){const s=[];return s.key=t,s}function wXt(){var t=Gl([]),s=wbe,r=YT,n=bXt;function a(o){var l=Array.from(t.apply(this,arguments),_Xt),i,c=l.length,u=-1,p;for(const f of o)for(i=0,++u;i0){for(var r,n,a=0,o=t[0].length,l;a0){for(var r=0,n=t[s[0]],a,o=n.length;r0)||!((o=(a=t[s[0]]).length)>0))){for(var r=0,n=1,a,o,l;n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function EXt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var pst={symbolCircle:d4e,symbolCross:QYt,symbolDiamond:eXt,symbolSquare:tXt,symbolStar:aXt,symbolTriangle:iXt,symbolWye:lXt},PXt=Math.PI/180,IXt=function(s){var r="symbol".concat(uhe(s));return pst[r]||d4e},LXt=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*PXt;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}},DXt=function(s,r){pst["symbol".concat(uhe(s))]=r},u4e=function(s){var r=s.type,n=r===void 0?"circle":r,a=s.size,o=a===void 0?64:a,l=s.sizeType,i=l===void 0?"area":l,c=AXt(s,SXt),u=J8e(J8e({},c),{},{type:n,size:o,sizeType:i}),p=function(){var w=IXt(n),k=cXt().type(w).size(LXt(o,i,n));return k()},f=u.className,g=u.cx,b=u.cy,_=ai(u,!0);return g===+g&&b===+b&&o===+o?ht.createElement("path",jbe({},_,{className:Vi("recharts-symbols",f),transform:"translate(".concat(g,", ").concat(b,")"),d:p()})):null};u4e.registerSymbol=DXt;function XT(t){"@babel/helpers - typeof";return XT=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},XT(t)}function Nbe(){return Nbe=Object.assign?Object.assign.bind():function(t){for(var s=1;s`);var S=b.inactive?u:b.color;return ht.createElement("li",Nbe({className:w,style:f,key:"legend-item-".concat(_)},eC(n.props,b,_)),ht.createElement(fbe,{width:l,height:l,viewBox:p,style:g},n.renderIcon(b)),ht.createElement("span",{className:"recharts-legend-item-text",style:{color:S}},j?j(k,b,_):k))})}},{key:"render",value:function(){var n=this.props,a=n.payload,o=n.layout,l=n.align;if(!a||!a.length)return null;var i={padding:0,margin:0,textAlign:o==="horizontal"?l:"left"};return ht.createElement("ul",{className:"recharts-default-legend",style:i},this.renderItems())}}])}(N.PureComponent);wD(h4e,"displayName","Legend");wD(h4e,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var HXt=Que;function WXt(){this.__data__=new HXt,this.size=0}var GXt=WXt;function KXt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var ZXt=KXt;function YXt(t){return this.__data__.get(t)}var XXt=YXt;function QXt(t){return this.__data__.has(t)}var JXt=QXt,eQt=Que,tQt=Jke,sQt=e4e,rQt=200;function nQt(t,s){var r=this.__data__;if(r instanceof eQt){var n=r.__data__;if(!tQt||n.lengthi))return!1;var u=o.get(t),p=o.get(s);if(u&&p)return u==s&&p==t;var f=-1,g=!0,b=r&SQt?new wQt:void 0;for(o.set(t,s),o.set(s,t);++f-1&&t%1==0&&t-1&&t%1==0&&t<=AJt}var x4e=EJt,PJt=$1,IJt=x4e,LJt=q1,DJt="[object Arguments]",OJt="[object Array]",RJt="[object Boolean]",FJt="[object Date]",zJt="[object Error]",BJt="[object Function]",$Jt="[object Map]",qJt="[object Number]",UJt="[object Object]",VJt="[object RegExp]",HJt="[object Set]",WJt="[object String]",GJt="[object WeakMap]",KJt="[object ArrayBuffer]",ZJt="[object DataView]",YJt="[object Float32Array]",XJt="[object Float64Array]",QJt="[object Int8Array]",JJt="[object Int16Array]",ees="[object Int32Array]",tes="[object Uint8Array]",ses="[object Uint8ClampedArray]",res="[object Uint16Array]",nes="[object Uint32Array]",fc={};fc[YJt]=fc[XJt]=fc[QJt]=fc[JJt]=fc[ees]=fc[tes]=fc[ses]=fc[res]=fc[nes]=!0;fc[DJt]=fc[OJt]=fc[KJt]=fc[RJt]=fc[ZJt]=fc[FJt]=fc[zJt]=fc[BJt]=fc[$Jt]=fc[qJt]=fc[UJt]=fc[VJt]=fc[HJt]=fc[WJt]=fc[GJt]=!1;function aes(t){return LJt(t)&&IJt(t.length)&&!!fc[PJt(t)]}var ies=aes;function oes(t){return function(s){return t(s)}}var kst=oes,tce={exports:{}};tce.exports;(function(t,s){var r=Itt,n=s&&!s.nodeType&&s,a=n&&!0&&t&&!t.nodeType&&t,o=a&&a.exports===n,l=o&&r.process,i=function(){try{var c=a&&a.require&&a.require("util").types;return c||l&&l.binding&&l.binding("util")}catch{}}();t.exports=i})(tce,tce.exports);var les=tce.exports,ces=ies,des=kst,iDe=les,oDe=iDe&&iDe.isTypedArray,ues=oDe?des(oDe):ces,Sst=ues,hes=fJt,mes=p4e,pes=Ip,fes=Nst,xes=f4e,ges=Sst,yes=Object.prototype,ves=yes.hasOwnProperty;function bes(t,s){var r=pes(t),n=!r&&mes(t),a=!r&&!n&&fes(t),o=!r&&!n&&!a&&ges(t),l=r||n||a||o,i=l?hes(t.length,String):[],c=i.length;for(var u in t)(s||ves.call(t,u))&&!(l&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||xes(u,c)))&&i.push(u);return i}var _es=bes,wes=Object.prototype;function jes(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||wes;return t===r}var Nes=jes;function kes(t,s){return function(r){return t(s(r))}}var Cst=kes,Ses=Cst,Ces=Ses(Object.keys,Object),Mes=Ces,Tes=Nes,Aes=Mes,Ees=Object.prototype,Pes=Ees.hasOwnProperty;function Ies(t){if(!Tes(t))return Aes(t);var s=[];for(var r in Object(t))Pes.call(t,r)&&r!="constructor"&&s.push(r);return s}var Les=Ies,Des=Xke,Oes=x4e;function Res(t){return t!=null&&Oes(t.length)&&!Des(t)}var aR=Res,Fes=_es,zes=Les,Bes=aR;function $es(t){return Bes(t)?Fes(t):zes(t)}var fhe=$es,qes=rJt,Ues=mJt,Ves=fhe;function Hes(t){return qes(t,Ves,Ues)}var Wes=Hes,lDe=Wes,Ges=1,Kes=Object.prototype,Zes=Kes.hasOwnProperty;function Yes(t,s,r,n,a,o){var l=r&Ges,i=lDe(t),c=i.length,u=lDe(s),p=u.length;if(c!=p&&!l)return!1;for(var f=c;f--;){var g=i[f];if(!(l?g in s:Zes.call(s,g)))return!1}var b=o.get(t),_=o.get(s);if(b&&_)return b==s&&_==t;var j=!0;o.set(t,s),o.set(s,t);for(var w=l;++f-1}var Kss=Gss;function Zss(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=drs){var u=s?null:lrs(t);if(u)return crs(u);l=!1,a=ors,c=new nrs}else c=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Srs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Crs(t){return t.value}function Mrs(t,s){if(ht.isValidElement(t))return ht.cloneElement(t,s);if(typeof t=="function")return ht.createElement(t,s);s.ref;var r=krs(s,grs);return ht.createElement(h4e,r)}var NDe=1,nT=function(t){function s(){var r;yrs(this,s);for(var n=arguments.length,a=new Array(n),o=0;oNDe||Math.abs(a.height-this.lastBoundingBox.height)>NDe)&&(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?kv({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(n){var a=this.props,o=a.layout,l=a.align,i=a.verticalAlign,c=a.margin,u=a.chartWidth,p=a.chartHeight,f,g;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(l==="center"&&o==="vertical"){var b=this.getBBoxSnapshot();f={left:((u||0)-b.width)/2}}else f=l==="right"?{right:c&&c.right||0}:{left:c&&c.left||0};if(!n||(n.top===void 0||n.top===null)&&(n.bottom===void 0||n.bottom===null))if(i==="middle"){var _=this.getBBoxSnapshot();g={top:((p||0)-_.height)/2}}else g=i==="bottom"?{bottom:c&&c.bottom||0}:{top:c&&c.top||0};return kv(kv({},f),g)}},{key:"render",value:function(){var n=this,a=this.props,o=a.content,l=a.width,i=a.height,c=a.wrapperStyle,u=a.payloadUniqBy,p=a.payload,f=kv(kv({position:"absolute",width:l||"auto",height:i||"auto"},this.getDefaultPosition(c)),c);return ht.createElement("div",{className:"recharts-legend-wrapper",style:f,ref:function(b){n.wrapperNode=b}},Mrs(o,kv(kv({},this.props),{},{payload:Lst(p,u,Crs)})))}}],[{key:"getWithHeight",value:function(n,a){var o=kv(kv({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&ln(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(N.PureComponent);xhe(nT,"displayName","Legend");xhe(nT,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var kDe=rR,Trs=p4e,Ars=Ip,SDe=kDe?kDe.isConcatSpreadable:void 0;function Ers(t){return Ars(t)||Trs(t)||!!(SDe&&t&&t[SDe])}var Prs=Ers,Irs=wst,Lrs=Prs;function Rst(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=Lrs),a||(a=[]);++o0&&r(i)?s>1?Rst(i,s-1,r,n,a):Irs(a,i):n||(a[a.length]=i)}return a}var Fst=Rst;function Drs(t){return function(s,r,n){for(var a=-1,o=Object(s),l=n(s),i=l.length;i--;){var c=l[t?i:++a];if(r(o[c],c,o)===!1)break}return s}}var Ors=Drs,Rrs=Ors,Frs=Rrs(),zrs=Frs,Brs=zrs,$rs=fhe;function qrs(t,s){return t&&Brs(t,s,$rs)}var zst=qrs,Urs=aR;function Vrs(t,s){return function(r,n){if(r==null)return r;if(!Urs(r))return t(r,n);for(var a=r.length,o=s?a:-1,l=Object(r);(s?o--:++os||o&&l&&c&&!i&&!u||n&&l&&c||!r&&c||!a)return 1;if(!n&&!o&&!u&&t=i)return c;var u=r[n];return c*(u=="desc"?-1:1)}}return t.index-s.index}var nns=rns,Gge=s4e,ans=r4e,ins=$0,ons=Bst,lns=Jrs,cns=kst,dns=nns,uns=vE,hns=Ip;function mns(t,s,r){s.length?s=Gge(s,function(o){return hns(o)?function(l){return ans(l,o.length===1?o[0]:o)}:o}):s=[uns];var n=-1;s=Gge(s,cns(ins));var a=ons(t,function(o,l,i){var c=Gge(s,function(u){return u(o)});return{criteria:c,index:++n,value:o}});return lns(a,function(o,l){return dns(o,l,r)})}var pns=mns;function fns(t,s,r){switch(r.length){case 0:return t.call(s);case 1:return t.call(s,r[0]);case 2:return t.call(s,r[0],r[1]);case 3:return t.call(s,r[0],r[1],r[2])}return t.apply(s,r)}var xns=fns,gns=xns,MDe=Math.max;function yns(t,s,r){return s=MDe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=MDe(n.length-s,0),l=Array(o);++a0){if(++s>=Mns)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var Pns=Ens,Ins=Cns,Lns=Pns,Dns=Lns(Ins),Ons=Dns,Rns=vE,Fns=vns,zns=Ons;function Bns(t,s){return zns(Fns(t,s,Rns),t+"")}var $ns=Bns,qns=Qke,Uns=aR,Vns=f4e,Hns=Fw;function Wns(t,s,r){if(!Hns(r))return!1;var n=typeof s;return(n=="number"?Uns(r)&&Vns(s,r.length):n=="string"&&s in r)?qns(r[s],t):!1}var ghe=Wns,Gns=Fst,Kns=pns,Zns=$ns,ADe=ghe,Yns=Zns(function(t,s){if(t==null)return[];var r=s.length;return r>1&&ADe(t,s[0],s[1])?s=[]:r>2&&ADe(s[0],s[1],s[2])&&(s=[s[0]]),Kns(t,Gns(s,1),[])}),Xns=Yns;const v4e=Po(Xns);function jD(t){"@babel/helpers - typeof";return jD=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},jD(t)}function Pbe(){return Pbe=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=s.x),"".concat(QP,"-left"),ln(r)&&s&&ln(s.x)&&r=s.y),"".concat(QP,"-top"),ln(n)&&s&&ln(s.y)&&nj?Math.max(p,c[n]):Math.max(f,c[n])}function has(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 mas(t){var s=t.allowEscapeViewBox,r=t.coordinate,n=t.offsetTopLeft,a=t.position,o=t.reverseDirection,l=t.tooltipBox,i=t.useTranslate3d,c=t.viewBox,u,p,f;return l.height>0&&l.width>0&&r?(p=IDe({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:c,viewBoxDimension:c.width}),f=IDe({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:c,viewBoxDimension:c.height}),u=has({translateX:p,translateY:f,useTranslate3d:i})):u=das,{cssProperties:u,cssClasses:uas({translateX:p,translateY:f,coordinate:r})}}function JT(t){"@babel/helpers - typeof";return JT=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},JT(t)}function LDe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function DDe(t){for(var s=1;sODe||Math.abs(n.height-this.state.lastBoundingBox.height)>ODe)&&this.setState({lastBoundingBox:{width:n.width,height:n.height}})}else(this.state.lastBoundingBox.width!==-1||this.state.lastBoundingBox.height!==-1)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var n,a;this.props.active&&this.updateBBox(),this.state.dismissed&&(((n=this.props.coordinate)===null||n===void 0?void 0:n.x)!==this.state.dismissedAtCoordinate.x||((a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var n=this,a=this.props,o=a.active,l=a.allowEscapeViewBox,i=a.animationDuration,c=a.animationEasing,u=a.children,p=a.coordinate,f=a.hasPayload,g=a.isAnimationActive,b=a.offset,_=a.position,j=a.reverseDirection,w=a.useTranslate3d,k=a.viewBox,S=a.wrapperStyle,M=mas({allowEscapeViewBox:l,coordinate:p,offsetTopLeft:b,position:_,reverseDirection:j,tooltipBox:this.state.lastBoundingBox,useTranslate3d:w,viewBox:k}),L=M.cssClasses,I=M.cssProperties,O=DDe(DDe({transition:g&&o?"transform ".concat(i,"ms ").concat(c):void 0},I),{},{pointerEvents:"none",visibility:!this.state.dismissed&&o&&f?"visible":"hidden",position:"absolute",top:0,left:0},S);return ht.createElement("div",{tabIndex:-1,className:L,style:O,ref:function(U){n.wrapperNode=U}},u)}}])}(N.PureComponent),jas=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},wC={isSsr:jas()};function eA(t){"@babel/helpers - typeof";return eA=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},eA(t)}function RDe(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 FDe(t){for(var s=1;s0;return ht.createElement(was,{allowEscapeViewBox:l,animationDuration:i,animationEasing:c,isAnimationActive:g,active:o,coordinate:p,hasPayload:O,offset:b,position:w,reverseDirection:k,useTranslate3d:S,viewBox:M,wrapperStyle:L},Ias(u,FDe(FDe({},this.props),{},{payload:I})))}}])}(N.PureComponent);b4e(hp,"displayName","Tooltip");b4e(hp,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!wC.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 Las=B0,Das=function(){return Las.Date.now()},Oas=Das,Ras=/\s/;function Fas(t){for(var s=t.length;s--&&Ras.test(t.charAt(s)););return s}var zas=Fas,Bas=zas,$as=/^\s+/;function qas(t){return t&&t.slice(0,Bas(t)+1).replace($as,"")}var Uas=qas,Vas=Uas,zDe=Fw,Has=uE,BDe=NaN,Was=/^[-+]0x[0-9a-f]+$/i,Gas=/^0b[01]+$/i,Kas=/^0o[0-7]+$/i,Zas=parseInt;function Yas(t){if(typeof t=="number")return t;if(Has(t))return BDe;if(zDe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=zDe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=Vas(t);var r=Gas.test(t);return r||Kas.test(t)?Zas(t.slice(2),r?2:8):Was.test(t)?BDe:+t}var Wst=Yas,Xas=Fw,Zge=Oas,$De=Wst,Qas="Expected a function",Jas=Math.max,eis=Math.min;function tis(t,s,r){var n,a,o,l,i,c,u=0,p=!1,f=!1,g=!0;if(typeof t!="function")throw new TypeError(Qas);s=$De(s)||0,Xas(r)&&(p=!!r.leading,f="maxWait"in r,o=f?Jas($De(r.maxWait)||0,s):o,g="trailing"in r?!!r.trailing:g);function b(O){var q=n,U=a;return n=a=void 0,u=O,l=t.apply(U,q),l}function _(O){return u=O,i=setTimeout(k,s),p?b(O):l}function j(O){var q=O-c,U=O-u,B=s-q;return f?eis(B,o-U):B}function w(O){var q=O-c,U=O-u;return c===void 0||q>=s||q<0||f&&U>=o}function k(){var O=Zge();if(w(O))return S(O);i=setTimeout(k,j(O))}function S(O){return i=void 0,g&&n?b(O):(n=a=void 0,l)}function M(){i!==void 0&&clearTimeout(i),u=0,n=c=a=i=void 0}function L(){return i===void 0?l:S(Zge())}function I(){var O=Zge(),q=w(O);if(n=arguments,a=this,c=O,q){if(i===void 0)return _(c);if(f)return clearTimeout(i),i=setTimeout(k,s),b(c)}return i===void 0&&(i=setTimeout(k,s)),l}return I.cancel=M,I.flush=L,I}var sis=tis,ris=sis,nis=Fw,ais="Expected a function";function iis(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(ais);return nis(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),ris(t,s,{leading:n,maxWait:s,trailing:a})}var ois=iis;const Gst=Po(ois);function kD(t){"@babel/helpers - typeof";return kD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},kD(t)}function qDe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Ez(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&(ee=Gst(ee,j,{trailing:!0,leading:!1}));var Q=new ResizeObserver(ee),ie=I.current.getBoundingClientRect(),re=ie.width,oe=ie.height;return Z(re,oe),Q.observe(I.current),function(){Q.disconnect()}},[Z,j]);var X=N.useMemo(function(){var ee=B.containerWidth,Q=B.containerHeight;if(ee<0||Q<0)return null;sy(S4(l)||S4(c),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,c),sy(!r||r>0,"The aspect(%s) must be greater than zero.",r);var ie=S4(l)?ee:l,re=S4(c)?Q:c;r&&r>0&&(ie?re=ie/r:re&&(ie=re*r),g&&re>g&&(re=g)),sy(ie>0||re>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.`,ie,re,l,c,p,f,r);var oe=!Array.isArray(b)&&g1(b.type).endsWith("Chart");return ht.Children.map(b,function(ce){return ht.isValidElement(ce)?N.cloneElement(ce,Ez({width:ie,height:re},oe?{style:Ez({height:"100%",width:"100%",maxHeight:re,maxWidth:ie},ce.props.style)}:{})):ce})},[r,b,c,g,f,p,B,l]);return ht.createElement("div",{id:w?"".concat(w):void 0,className:Vi("recharts-responsive-container",k),style:Ez(Ez({},L),{},{width:l,height:c,minWidth:p,minHeight:f,maxHeight:g}),ref:I},X)}),iR=function(s){return null};iR.displayName="Cell";function SD(t){"@babel/helpers - typeof";return SD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},SD(t)}function VDe(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 Obe(t){for(var s=1;s1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||wC.isSsr)return{width:0,height:0};var n=_is(r),a=JSON.stringify({text:s,copyStyle:n});if(M5.widthCache[a])return M5.widthCache[a];try{var o=document.getElementById(HDe);o||(o=document.createElement("span"),o.setAttribute("id",HDe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=Obe(Obe({},bis),n);Object.assign(o.style,l),o.textContent="".concat(s);var i=o.getBoundingClientRect(),c={width:i.width,height:i.height};return M5.widthCache[a]=c,++M5.cacheCount>vis&&(M5.cacheCount=0,M5.widthCache={}),c}catch{return{width:0,height:0}}},wis=function(s){return{top:s.top+window.scrollY-document.documentElement.clientTop,left:s.left+window.scrollX-document.documentElement.clientLeft}};function CD(t){"@babel/helpers - typeof";return CD=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},CD(t)}function ace(t,s){return Sis(t)||kis(t,s)||Nis(t,s)||jis()}function jis(){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 Nis(t,s){if(t){if(typeof t=="string")return WDe(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 WDe(t,s)}}function WDe(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 Bis(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 QDe(t,s){return Vis(t)||Uis(t,s)||qis(t,s)||$is()}function $is(){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 qis(t,s){if(t){if(typeof t=="string")return JDe(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 JDe(t,s)}}function JDe(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 ie.reduce(function(re,oe){var ce=oe.word,xe=oe.width,ge=re[re.length-1];if(ge&&(a==null||o||ge.width+xe+noe.width?re:oe})};if(!p)return b;for(var j="…",w=function(ie){var re=f.slice(0,ie),oe=Xst({breakAll:u,style:c,children:re+j}).wordsWithComputedWidth,ce=g(oe),xe=ce.length>l||_(ce).width>Number(a);return[xe,ce]},k=0,S=f.length-1,M=0,L;k<=S&&M<=f.length-1;){var I=Math.floor((k+S)/2),O=I-1,q=w(O),U=QDe(q,2),B=U[0],V=U[1],Z=w(I),X=QDe(Z,1),ee=X[0];if(!B&&!ee&&(k=I+1),B&&ee&&(S=I-1),!B&&ee){L=V;break}M++}return L||b},eOe=function(s){var r=$i(s)?[]:s.toString().split(Yst);return[{words:r}]},Wis=function(s){var r=s.width,n=s.scaleToFit,a=s.children,o=s.style,l=s.breakAll,i=s.maxLines;if((r||n)&&!wC.isSsr){var c,u,p=Xst({breakAll:l,children:a,style:o});if(p){var f=p.wordsWithComputedWidth,g=p.spaceWidth;c=f,u=g}else return eOe(a);return His({breakAll:l,children:a,maxLines:i,style:o},c,u,r,n)}return eOe(a)},tOe="#808080",tC=function(s){var r=s.x,n=r===void 0?0:r,a=s.y,o=a===void 0?0:a,l=s.lineHeight,i=l===void 0?"1em":l,c=s.capHeight,u=c===void 0?"0.71em":c,p=s.scaleToFit,f=p===void 0?!1:p,g=s.textAnchor,b=g===void 0?"start":g,_=s.verticalAnchor,j=_===void 0?"end":_,w=s.fill,k=w===void 0?tOe:w,S=XDe(s,Fis),M=N.useMemo(function(){return Wis({breakAll:S.breakAll,children:S.children,maxLines:S.maxLines,scaleToFit:f,style:S.style,width:S.width})},[S.breakAll,S.children,S.maxLines,f,S.style,S.width]),L=S.dx,I=S.dy,O=S.angle,q=S.className,U=S.breakAll,B=XDe(S,zis);if(!ju(n)||!ju(o))return null;var V=n+(ln(L)?L:0),Z=o+(ln(I)?I:0),X;switch(j){case"start":X=Yge("calc(".concat(u,")"));break;case"middle":X=Yge("calc(".concat((M.length-1)/2," * -").concat(i," + (").concat(u," / 2))"));break;default:X=Yge("calc(".concat(M.length-1," * -").concat(i,")"));break}var ee=[];if(f){var Q=M[0].width,ie=S.width;ee.push("scale(".concat((ln(ie)?ie/Q:1)/Q,")"))}return O&&ee.push("rotate(".concat(O,", ").concat(V,", ").concat(Z,")")),ee.length&&(B.transform=ee.join(" ")),ht.createElement("text",Rbe({},ai(B,!0),{x:V,y:Z,className:Vi("recharts-text",q),textAnchor:b,fill:k.includes("url")?tOe:k}),M.map(function(re,oe){var ce=re.words.join(U?"":" ");return ht.createElement("tspan",{x:V,dy:oe===0?X:i,key:"".concat(ce,"-").concat(oe)},ce)}))};function sw(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function Gis(t,s){return t==null||s==null?NaN:st?1:s>=t?0:NaN}function _4e(t){let s,r,n;t.length!==2?(s=sw,r=(i,c)=>sw(t(i),c),n=(i,c)=>t(i)-c):(s=t===sw||t===Gis?t:Kis,r=t,n=t);function a(i,c,u=0,p=i.length){if(u>>1;r(i[f],c)<0?u=f+1:p=f}while(u>>1;r(i[f],c)<=0?u=f+1:p=f}while(uu&&n(i[f-1],c)>-n(i[f],c)?f-1:f}return{left:a,center:l,right:o}}function Kis(){return 0}function Qst(t){return t===null?NaN:+t}function*Zis(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const Yis=_4e(sw),oR=Yis.right;_4e(Qst).center;class sOe extends Map{constructor(s,r=Jis){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(rOe(this,s))}has(s){return super.has(rOe(this,s))}set(s,r){return super.set(Xis(this,s),r)}delete(s){return super.delete(Qis(this,s))}}function rOe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function Xis({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function Qis({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function Jis(t){return t!==null&&typeof t=="object"?t.valueOf():t}function eos(t=sw){if(t===sw)return Jst;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 Jst(t,s){return(t==null||!(t>=t))-(s==null||!(s>=s))||(ts?1:0)}const tos=Math.sqrt(50),sos=Math.sqrt(10),ros=Math.sqrt(2);function ice(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>=tos?10:o>=sos?5:o>=ros?2:1;let i,c,u;return a<0?(u=Math.pow(10,-a)/l,i=Math.round(t*u),c=Math.round(s*u),i/us&&--c,u=-u):(u=Math.pow(10,a)*l,i=Math.round(t/u),c=Math.round(s/u),i*us&&--c),c0))return[];if(t===s)return[t];const n=s=a))return[];const i=o-a+1,c=new Array(i);if(n)if(l<0)for(let u=0;u=n)&&(r=n);return r}function aOe(t,s){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function ert(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?Jst:eos(a);n>r;){if(n-r>600){const c=n-r+1,u=s-r+1,p=Math.log(c),f=.5*Math.exp(2*p/3),g=.5*Math.sqrt(p*f*(c-f)/c)*(u-c/2<0?-1:1),b=Math.max(r,Math.floor(s-u*f/c+g)),_=Math.min(n,Math.floor(s+(c-u)*f/c+g));ert(t,s,b,_,a)}const o=t[s];let l=r,i=n;for(JP(t,r,s),a(t[n],o)>0&&JP(t,r,n);l0;)--i}a(t[r],o)===0?JP(t,r,i):(++i,JP(t,i,n)),i<=s&&(r=i+1),s<=i&&(n=i-1)}return t}function JP(t,s,r){const n=t[s];t[s]=t[r],t[r]=n}function nos(t,s,r){if(t=Float64Array.from(Zis(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return aOe(t);if(s>=1)return nOe(t);var n,a=(n-1)*s,o=Math.floor(a),l=nOe(ert(t,o).subarray(0,o+1)),i=aOe(t.subarray(o+1));return l+(i-l)*(a-o)}}function aos(t,s,r=Qst){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 ios(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?Iz(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?Iz(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=los.exec(t))?new _p(s[1],s[2],s[3],1):(s=cos.exec(t))?new _p(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=dos.exec(t))?Iz(s[1],s[2],s[3],s[4]):(s=uos.exec(t))?Iz(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=hos.exec(t))?hOe(s[1],s[2]/100,s[3]/100,1):(s=mos.exec(t))?hOe(s[1],s[2]/100,s[3]/100,s[4]):iOe.hasOwnProperty(t)?cOe(iOe[t]):t==="transparent"?new _p(NaN,NaN,NaN,0):null}function cOe(t){return new _p(t>>16&255,t>>8&255,t&255,1)}function Iz(t,s,r,n){return n<=0&&(t=s=r=NaN),new _p(t,s,r,n)}function xos(t){return t instanceof lR||(t=ED(t)),t?(t=t.rgb(),new _p(t.r,t.g,t.b,t.opacity)):new _p}function qbe(t,s,r,n){return arguments.length===1?xos(t):new _p(t,s,r,n??1)}function _p(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}j4e(_p,qbe,srt(lR,{brighter(t){return t=t==null?oce:Math.pow(oce,t),new _p(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?TD:Math.pow(TD,t),new _p(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new _p(NS(this.r),NS(this.g),NS(this.b),lce(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:dOe,formatHex:dOe,formatHex8:gos,formatRgb:uOe,toString:uOe}));function dOe(){return`#${C4(this.r)}${C4(this.g)}${C4(this.b)}`}function gos(){return`#${C4(this.r)}${C4(this.g)}${C4(this.b)}${C4((isNaN(this.opacity)?1:this.opacity)*255)}`}function uOe(){const t=lce(this.opacity);return`${t===1?"rgb(":"rgba("}${NS(this.r)}, ${NS(this.g)}, ${NS(this.b)}${t===1?")":`, ${t})`}`}function lce(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function NS(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function C4(t){return t=NS(t),(t<16?"0":"")+t.toString(16)}function hOe(t,s,r,n){return n<=0?t=s=r=NaN:r<=0||r>=1?t=s=NaN:s<=0&&(t=NaN),new Vg(t,s,r,n)}function rrt(t){if(t instanceof Vg)return new Vg(t.h,t.s,t.l,t.opacity);if(t instanceof lR||(t=ED(t)),!t)return new Vg;if(t instanceof Vg)return t;t=t.rgb();var s=t.r/255,r=t.g/255,n=t.b/255,a=Math.min(s,r,n),o=Math.max(s,r,n),l=NaN,i=o-a,c=(o+a)/2;return i?(s===o?l=(r-n)/i+(r0&&c<1?0:l,new Vg(l,i,c,t.opacity)}function yos(t,s,r,n){return arguments.length===1?rrt(t):new Vg(t,s,r,n??1)}function Vg(t,s,r,n){this.h=+t,this.s=+s,this.l=+r,this.opacity=+n}j4e(Vg,yos,srt(lR,{brighter(t){return t=t==null?oce:Math.pow(oce,t),new Vg(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?TD:Math.pow(TD,t),new Vg(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,s=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*s,a=2*r-n;return new _p(Xge(t>=240?t-240:t+120,a,n),Xge(t,a,n),Xge(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new Vg(mOe(this.h),Lz(this.s),Lz(this.l),lce(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=lce(this.opacity);return`${t===1?"hsl(":"hsla("}${mOe(this.h)}, ${Lz(this.s)*100}%, ${Lz(this.l)*100}%${t===1?")":`, ${t})`}`}}));function mOe(t){return t=(t||0)%360,t<0?t+360:t}function Lz(t){return Math.max(0,Math.min(1,t||0))}function Xge(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 N4e=t=>()=>t;function vos(t,s){return function(r){return t+r*s}}function bos(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 _os(t){return(t=+t)==1?nrt:function(s,r){return r-s?bos(s,r,t):N4e(isNaN(s)?r:s)}}function nrt(t,s){var r=s-t;return r?vos(t,r):N4e(isNaN(t)?s:t)}const pOe=function t(s){var r=_os(s);function n(a,o){var l=r((a=qbe(a)).r,(o=qbe(o)).r),i=r(a.g,o.g),c=r(a.b,o.b),u=nrt(a.opacity,o.opacity);return function(p){return a.r=l(p),a.g=i(p),a.b=c(p),a.opacity=u(p),a+""}}return n.gamma=t,n}(1);function wos(t,s){s||(s=[]);var r=t?Math.min(s.length,t.length):0,n=s.slice(),a;return function(o){for(a=0;ar&&(o=s.slice(r,o),i[l]?i[l]+=o:i[++l]=o),(n=n[0])===(a=a[0])?i[l]?i[l]+=a:i[++l]=a:(i[++l]=null,c.push({i:l,x:cce(n,a)})),r=Qge.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function Ios(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?Los:Ios,c=u=null,f}function f(g){return g==null||isNaN(g=+g)?o:(c||(c=i(t.map(n),s,r)))(n(l(g)))}return f.invert=function(g){return l(a((u||(u=i(s,t.map(n),cce)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,dce),p()):t.slice()},f.range=function(g){return arguments.length?(s=Array.from(g),p()):s.slice()},f.rangeRound=function(g){return s=Array.from(g),r=k4e,p()},f.clamp=function(g){return arguments.length?(l=g?!0:Em,p()):l!==Em},f.interpolate=function(g){return arguments.length?(r=g,p()):r},f.unknown=function(g){return arguments.length?(o=g,f):o},function(g,b){return n=g,a=b,p()}}function S4e(){return yhe()(Em,Em)}function Dos(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function uce(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 tA(t){return t=uce(Math.abs(t)),t?t[1]:NaN}function Oos(t,s){return function(r,n){for(var a=r.length,o=[],l=0,i=t[0],c=0;a>0&&i>0&&(c+i+1>n&&(i=Math.max(1,n-c)),o.push(r.substring(a-=i,a+i)),!((c+=i+1)>n));)i=t[l=(l+1)%t.length];return o.reverse().join(s)}}function Ros(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var Fos=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function PD(t){if(!(s=Fos.exec(t)))throw new Error("invalid format: "+t);var s;return new C4e({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]})}PD.prototype=C4e.prototype;function C4e(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+""}C4e.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 zos(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 art;function Bos(t,s){var r=uce(t,s);if(!r)return t+"";var n=r[0],a=r[1],o=a-(art=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")+uce(t,Math.max(0,s+o-1))[0]}function xOe(t,s){var r=uce(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 gOe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Dos,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)=>xOe(t*100,s),r:xOe,s:Bos,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function yOe(t){return t}var vOe=Array.prototype.map,bOe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function $os(t){var s=t.grouping===void 0||t.thousands===void 0?yOe:Oos(vOe.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?yOe:Ros(vOe.call(t.numerals,String)),l=t.percent===void 0?"%":t.percent+"",i=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=PD(f);var g=f.fill,b=f.align,_=f.sign,j=f.symbol,w=f.zero,k=f.width,S=f.comma,M=f.precision,L=f.trim,I=f.type;I==="n"?(S=!0,I="g"):gOe[I]||(M===void 0&&(M=12),L=!0,I="g"),(w||g==="0"&&b==="=")&&(w=!0,g="0",b="=");var O=j==="$"?r:j==="#"&&/[boxX]/.test(I)?"0"+I.toLowerCase():"",q=j==="$"?n:/[%p]/.test(I)?l:"",U=gOe[I],B=/[defgprs%]/.test(I);M=M===void 0?6:/[gprs]/.test(I)?Math.max(1,Math.min(21,M)):Math.max(0,Math.min(20,M));function V(Z){var X=O,ee=q,Q,ie,re;if(I==="c")ee=U(Z)+ee,Z="";else{Z=+Z;var oe=Z<0||1/Z<0;if(Z=isNaN(Z)?c:U(Math.abs(Z),M),L&&(Z=zos(Z)),oe&&+Z==0&&_!=="+"&&(oe=!1),X=(oe?_==="("?_:i:_==="-"||_==="("?"":_)+X,ee=(I==="s"?bOe[8+art/3]:"")+ee+(oe&&_==="("?")":""),B){for(Q=-1,ie=Z.length;++Qre||re>57){ee=(re===46?a+Z.slice(Q+1):Z.slice(Q))+ee,Z=Z.slice(0,Q);break}}}S&&!w&&(Z=s(Z,1/0));var ce=X.length+Z.length+ee.length,xe=ce>1)+X+Z+ee+xe.slice(ce);break;default:Z=xe+X+Z+ee;break}return o(Z)}return V.toString=function(){return f+""},V}function p(f,g){var b=u((f=PD(f),f.type="f",f)),_=Math.max(-8,Math.min(8,Math.floor(tA(g)/3)))*3,j=Math.pow(10,-_),w=bOe[8+_/3];return function(k){return b(j*k)+w}}return{format:u,formatPrefix:p}}var Dz,M4e,irt;qos({thousands:",",grouping:[3],currency:["$",""]});function qos(t){return Dz=$os(t),M4e=Dz.format,irt=Dz.formatPrefix,Dz}function Uos(t){return Math.max(0,-tA(Math.abs(t)))}function Vos(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(tA(s)/3)))*3-tA(Math.abs(t)))}function Hos(t,s){return t=Math.abs(t),s=Math.abs(s)-t,Math.max(0,tA(s)-tA(t))+1}function ort(t,s,r,n){var a=Bbe(t,s,r),o;switch(n=PD(n??",f"),n.type){case"s":{var l=Math.max(Math.abs(t),Math.abs(s));return n.precision==null&&!isNaN(o=Vos(a,l))&&(n.precision=o),irt(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=Hos(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=Uos(a))&&(n.precision=o-(n.type==="%")*2);break}}return M4e(n)}function zw(t){var s=t.domain;return t.ticks=function(r){var n=s();return Fbe(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var a=s();return ort(a[0],a[a.length-1],r??10,n)},t.nice=function(r){r==null&&(r=10);var n=s(),a=0,o=n.length-1,l=n[a],i=n[o],c,u,p=10;for(i0;){if(u=zbe(l,i,r),u===c)return n[a]=l,n[o]=i,s(n);if(u>0)l=Math.floor(l/u)*u,i=Math.ceil(i/u)*u;else if(u<0)l=Math.ceil(l*u)/u,i=Math.floor(i*u)/u;else break;c=u}return t},t}function hce(){var t=S4e();return t.copy=function(){return cR(t,hce())},Hx.apply(t,arguments),zw(t)}function lrt(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,dce),r):t.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return lrt(t).unknown(s)},t=arguments.length?Array.from(t,dce):[0,1],zw(r)}function crt(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 Yos(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 jOe(t){return(s,r)=>-t(-s,r)}function T4e(t){const s=t(_Oe,wOe),r=s.domain;let n=10,a,o;function l(){return a=Yos(n),o=Zos(n),r()[0]<0?(a=jOe(a),o=jOe(o),t(Wos,Gos)):t(_Oe,wOe),s}return s.base=function(i){return arguments.length?(n=+i,l()):n},s.domain=function(i){return arguments.length?(r(i),l()):r()},s.ticks=i=>{const c=r();let u=c[0],p=c[c.length-1];const f=p0){for(;g<=b;++g)for(_=1;_p)break;k.push(j)}}else for(;g<=b;++g)for(_=n-1;_>=1;--_)if(j=g>0?_/o(-g):_*o(g),!(jp)break;k.push(j)}k.length*2{if(i==null&&(i=10),c==null&&(c=n===10?"s":","),typeof c!="function"&&(!(n%1)&&(c=PD(c)).precision==null&&(c.trim=!0),c=M4e(c)),i===1/0)return c;const u=Math.max(1,n*i/s.ticks().length);return p=>{let f=p/o(Math.round(a(p)));return f*nr(crt(r(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),s}function drt(){const t=T4e(yhe()).domain([1,10]);return t.copy=()=>cR(t,drt()).base(t.base()),Hx.apply(t,arguments),t}function NOe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function kOe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function A4e(t){var s=1,r=t(NOe(s),kOe(s));return r.constant=function(n){return arguments.length?t(NOe(s=+n),kOe(s)):s},zw(r)}function urt(){var t=A4e(yhe());return t.copy=function(){return cR(t,urt()).constant(t.constant())},Hx.apply(t,arguments)}function SOe(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function Xos(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Qos(t){return t<0?-t*t:t*t}function E4e(t){var s=t(Em,Em),r=1;function n(){return r===1?t(Em,Em):r===.5?t(Xos,Qos):t(SOe(r),SOe(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},zw(s)}function P4e(){var t=E4e(yhe());return t.copy=function(){return cR(t,P4e()).exponent(t.exponent())},Hx.apply(t,arguments),t}function Jos(){return P4e.apply(null,arguments).exponent(.5)}function COe(t){return Math.sign(t)*t*t}function els(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function hrt(){var t=S4e(),s=[0,1],r=!1,n;function a(o){var l=els(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert(COe(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,dce)).map(COe)),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 hrt(t.domain(),s).round(r).clamp(t.clamp()).unknown(n)},Hx.apply(a,arguments),zw(a)}function mrt(){var t=[],s=[],r=[],n;function a(){var l=0,i=Math.max(1,s.length);for(r=new Array(i-1);++l0?r[i-1]:t[0],i=r?[n[r-1],s]:[n[u-1],n[u]]},l.unknown=function(c){return arguments.length&&(o=c),l},l.thresholds=function(){return n.slice()},l.copy=function(){return prt().domain([t,s]).range(a).unknown(o)},Hx.apply(zw(l),arguments)}function frt(){var t=[.5],s=[0,1],r,n=1;function a(o){return o!=null&&o<=o?s[oR(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 frt().domain(t).range(s).unknown(r)},Hx.apply(a,arguments)}const Jge=new Date,eye=new Date;function Lu(t,s,r,n){function a(o){return t(o=arguments.length===0?new Date:new Date(+o)),o}return a.floor=o=>(t(o=new Date(+o)),o),a.ceil=o=>(t(o=new Date(o-1)),s(o,1),t(o),o),a.round=o=>{const l=a(o),i=a.ceil(o);return o-l(s(o=new Date(+o),l==null?1:Math.floor(l)),o),a.range=(o,l,i)=>{const c=[];if(o=a.ceil(o),i=i==null?1:Math.floor(i),!(o0))return c;let u;do c.push(u=new Date(+o)),s(o,i),t(o);while(uLu(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)=>(Jge.setTime(+o),eye.setTime(+l),t(Jge),t(eye),Math.floor(r(Jge,eye))),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 mce=Lu(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);mce.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Lu(s=>{s.setTime(Math.floor(s/t)*t)},(s,r)=>{s.setTime(+s+r*t)},(s,r)=>(r-s)/t):mce);mce.range;const Yv=1e3,_x=Yv*60,Xv=_x*60,A1=Xv*24,I4e=A1*7,MOe=A1*30,tye=A1*365,M4=Lu(t=>{t.setTime(t-t.getMilliseconds())},(t,s)=>{t.setTime(+t+s*Yv)},(t,s)=>(s-t)/Yv,t=>t.getUTCSeconds());M4.range;const L4e=Lu(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Yv)},(t,s)=>{t.setTime(+t+s*_x)},(t,s)=>(s-t)/_x,t=>t.getMinutes());L4e.range;const D4e=Lu(t=>{t.setUTCSeconds(0,0)},(t,s)=>{t.setTime(+t+s*_x)},(t,s)=>(s-t)/_x,t=>t.getUTCMinutes());D4e.range;const O4e=Lu(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Yv-t.getMinutes()*_x)},(t,s)=>{t.setTime(+t+s*Xv)},(t,s)=>(s-t)/Xv,t=>t.getHours());O4e.range;const R4e=Lu(t=>{t.setUTCMinutes(0,0,0)},(t,s)=>{t.setTime(+t+s*Xv)},(t,s)=>(s-t)/Xv,t=>t.getUTCHours());R4e.range;const dR=Lu(t=>t.setHours(0,0,0,0),(t,s)=>t.setDate(t.getDate()+s),(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*_x)/A1,t=>t.getDate()-1);dR.range;const vhe=Lu(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/A1,t=>t.getUTCDate()-1);vhe.range;const xrt=Lu(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/A1,t=>Math.floor(t/A1));xrt.range;function jC(t){return Lu(s=>{s.setDate(s.getDate()-(s.getDay()+7-t)%7),s.setHours(0,0,0,0)},(s,r)=>{s.setDate(s.getDate()+r*7)},(s,r)=>(r-s-(r.getTimezoneOffset()-s.getTimezoneOffset())*_x)/I4e)}const bhe=jC(0),pce=jC(1),tls=jC(2),sls=jC(3),sA=jC(4),rls=jC(5),nls=jC(6);bhe.range;pce.range;tls.range;sls.range;sA.range;rls.range;nls.range;function NC(t){return Lu(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)/I4e)}const _he=NC(0),fce=NC(1),als=NC(2),ils=NC(3),rA=NC(4),ols=NC(5),lls=NC(6);_he.range;fce.range;als.range;ils.range;rA.range;ols.range;lls.range;const F4e=Lu(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());F4e.range;const z4e=Lu(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());z4e.range;const E1=Lu(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());E1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Lu(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)});E1.range;const P1=Lu(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());P1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Lu(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)});P1.range;function grt(t,s,r,n,a,o){const l=[[M4,1,Yv],[M4,5,5*Yv],[M4,15,15*Yv],[M4,30,30*Yv],[o,1,_x],[o,5,5*_x],[o,15,15*_x],[o,30,30*_x],[a,1,Xv],[a,3,3*Xv],[a,6,6*Xv],[a,12,12*Xv],[n,1,A1],[n,2,2*A1],[r,1,I4e],[s,1,MOe],[s,3,3*MOe],[t,1,tye]];function i(u,p,f){const g=pw).right(l,g);if(b===l.length)return t.every(Bbe(u/tye,p/tye,f));if(b===0)return mce.every(Math.max(Bbe(u,p,f),1));const[_,j]=l[g/l[b-1][2]53)return null;"w"in Ae||(Ae.w=1),"Z"in Ae?(fe=rye(eI(Ae.y,0,1)),Ve=fe.getUTCDay(),fe=Ve>4||Ve===0?fce.ceil(fe):fce(fe),fe=vhe.offset(fe,(Ae.V-1)*7),Ae.y=fe.getUTCFullYear(),Ae.m=fe.getUTCMonth(),Ae.d=fe.getUTCDate()+(Ae.w+6)%7):(fe=sye(eI(Ae.y,0,1)),Ve=fe.getDay(),fe=Ve>4||Ve===0?pce.ceil(fe):pce(fe),fe=dR.offset(fe,(Ae.V-1)*7),Ae.y=fe.getFullYear(),Ae.m=fe.getMonth(),Ae.d=fe.getDate()+(Ae.w+6)%7)}else("W"in Ae||"U"in Ae)&&("w"in Ae||(Ae.w="u"in Ae?Ae.u%7:"W"in Ae?1:0),Ve="Z"in Ae?rye(eI(Ae.y,0,1)).getUTCDay():sye(eI(Ae.y,0,1)).getDay(),Ae.m=0,Ae.d="W"in Ae?(Ae.w+6)%7+Ae.W*7-(Ve+5)%7:Ae.w+Ae.U*7-(Ve+6)%7);return"Z"in Ae?(Ae.H+=Ae.Z/100|0,Ae.M+=Ae.Z%100,rye(Ae)):sye(Ae)}}function U(ke,Be,nt,Ae){for(var ft=0,fe=Be.length,Ve=nt.length,at,et;ft=Ve)return-1;if(at=Be.charCodeAt(ft++),at===37){if(at=Be.charAt(ft++),et=I[at in TOe?Be.charAt(ft++):at],!et||(Ae=et(ke,nt,Ae))<0)return-1}else if(at!=nt.charCodeAt(Ae++))return-1}return Ae}function B(ke,Be,nt){var Ae=u.exec(Be.slice(nt));return Ae?(ke.p=p.get(Ae[0].toLowerCase()),nt+Ae[0].length):-1}function V(ke,Be,nt){var Ae=b.exec(Be.slice(nt));return Ae?(ke.w=_.get(Ae[0].toLowerCase()),nt+Ae[0].length):-1}function Z(ke,Be,nt){var Ae=f.exec(Be.slice(nt));return Ae?(ke.w=g.get(Ae[0].toLowerCase()),nt+Ae[0].length):-1}function X(ke,Be,nt){var Ae=k.exec(Be.slice(nt));return Ae?(ke.m=S.get(Ae[0].toLowerCase()),nt+Ae[0].length):-1}function ee(ke,Be,nt){var Ae=j.exec(Be.slice(nt));return Ae?(ke.m=w.get(Ae[0].toLowerCase()),nt+Ae[0].length):-1}function Q(ke,Be,nt){return U(ke,s,Be,nt)}function ie(ke,Be,nt){return U(ke,r,Be,nt)}function re(ke,Be,nt){return U(ke,n,Be,nt)}function oe(ke){return l[ke.getDay()]}function ce(ke){return o[ke.getDay()]}function xe(ke){return c[ke.getMonth()]}function ge(ke){return i[ke.getMonth()]}function ue(ke){return a[+(ke.getHours()>=12)]}function pe(ke){return 1+~~(ke.getMonth()/3)}function be(ke){return l[ke.getUTCDay()]}function Me(ke){return o[ke.getUTCDay()]}function Ne(ke){return c[ke.getUTCMonth()]}function Pe(ke){return i[ke.getUTCMonth()]}function Oe(ke){return a[+(ke.getUTCHours()>=12)]}function Te(ke){return 1+~~(ke.getUTCMonth()/3)}return{format:function(ke){var Be=O(ke+="",M);return Be.toString=function(){return ke},Be},parse:function(ke){var Be=q(ke+="",!1);return Be.toString=function(){return ke},Be},utcFormat:function(ke){var Be=O(ke+="",L);return Be.toString=function(){return ke},Be},utcParse:function(ke){var Be=q(ke+="",!0);return Be.toString=function(){return ke},Be}}}var TOe={"-":"",_:" ",0:"0"},lh=/^\s*\d+/,pls=/^%/,fls=/[\\^$*+?|[\]().{}]/g;function Qo(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function gls(t,s,r){var n=lh.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function yls(t,s,r){var n=lh.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function vls(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function bls(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function _ls(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function AOe(t,s,r){var n=lh.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function EOe(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function wls(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 jls(t,s,r){var n=lh.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function Nls(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function POe(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function kls(t,s,r){var n=lh.exec(s.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function IOe(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function Sls(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function Cls(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function Mls(t,s,r){var n=lh.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function Tls(t,s,r){var n=lh.exec(s.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function Als(t,s,r){var n=pls.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function Els(t,s,r){var n=lh.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function Pls(t,s,r){var n=lh.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function LOe(t,s){return Qo(t.getDate(),s,2)}function Ils(t,s){return Qo(t.getHours(),s,2)}function Lls(t,s){return Qo(t.getHours()%12||12,s,2)}function Dls(t,s){return Qo(1+dR.count(E1(t),t),s,3)}function yrt(t,s){return Qo(t.getMilliseconds(),s,3)}function Ols(t,s){return yrt(t,s)+"000"}function Rls(t,s){return Qo(t.getMonth()+1,s,2)}function Fls(t,s){return Qo(t.getMinutes(),s,2)}function zls(t,s){return Qo(t.getSeconds(),s,2)}function Bls(t){var s=t.getDay();return s===0?7:s}function $ls(t,s){return Qo(bhe.count(E1(t)-1,t),s,2)}function vrt(t){var s=t.getDay();return s>=4||s===0?sA(t):sA.ceil(t)}function qls(t,s){return t=vrt(t),Qo(sA.count(E1(t),t)+(E1(t).getDay()===4),s,2)}function Uls(t){return t.getDay()}function Vls(t,s){return Qo(pce.count(E1(t)-1,t),s,2)}function Hls(t,s){return Qo(t.getFullYear()%100,s,2)}function Wls(t,s){return t=vrt(t),Qo(t.getFullYear()%100,s,2)}function Gls(t,s){return Qo(t.getFullYear()%1e4,s,4)}function Kls(t,s){var r=t.getDay();return t=r>=4||r===0?sA(t):sA.ceil(t),Qo(t.getFullYear()%1e4,s,4)}function Zls(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+Qo(s/60|0,"0",2)+Qo(s%60,"0",2)}function DOe(t,s){return Qo(t.getUTCDate(),s,2)}function Yls(t,s){return Qo(t.getUTCHours(),s,2)}function Xls(t,s){return Qo(t.getUTCHours()%12||12,s,2)}function Qls(t,s){return Qo(1+vhe.count(P1(t),t),s,3)}function brt(t,s){return Qo(t.getUTCMilliseconds(),s,3)}function Jls(t,s){return brt(t,s)+"000"}function ecs(t,s){return Qo(t.getUTCMonth()+1,s,2)}function tcs(t,s){return Qo(t.getUTCMinutes(),s,2)}function scs(t,s){return Qo(t.getUTCSeconds(),s,2)}function rcs(t){var s=t.getUTCDay();return s===0?7:s}function ncs(t,s){return Qo(_he.count(P1(t)-1,t),s,2)}function _rt(t){var s=t.getUTCDay();return s>=4||s===0?rA(t):rA.ceil(t)}function acs(t,s){return t=_rt(t),Qo(rA.count(P1(t),t)+(P1(t).getUTCDay()===4),s,2)}function ics(t){return t.getUTCDay()}function ocs(t,s){return Qo(fce.count(P1(t)-1,t),s,2)}function lcs(t,s){return Qo(t.getUTCFullYear()%100,s,2)}function ccs(t,s){return t=_rt(t),Qo(t.getUTCFullYear()%100,s,2)}function dcs(t,s){return Qo(t.getUTCFullYear()%1e4,s,4)}function ucs(t,s){var r=t.getUTCDay();return t=r>=4||r===0?rA(t):rA.ceil(t),Qo(t.getUTCFullYear()%1e4,s,4)}function hcs(){return"+0000"}function OOe(){return"%"}function ROe(t){return+t}function FOe(t){return Math.floor(+t/1e3)}var T5,wrt,jrt;mcs({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 mcs(t){return T5=mls(t),wrt=T5.format,T5.parse,jrt=T5.utcFormat,T5.utcParse,T5}function pcs(t){return new Date(t)}function fcs(t){return t instanceof Date?+t:+new Date(+t)}function B4e(t,s,r,n,a,o,l,i,c,u){var p=S4e(),f=p.invert,g=p.domain,b=u(".%L"),_=u(":%S"),j=u("%I:%M"),w=u("%I %p"),k=u("%a %d"),S=u("%b %d"),M=u("%B"),L=u("%Y");function I(O){return(c(O)s(a/(t.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,o)=>nos(t,o/n))},r.copy=function(){return Crt(s).domain(t)},U1.apply(r,arguments)}function jhe(){var t=0,s=.5,r=1,n=1,a,o,l,i,c,u=Em,p,f=!1,g;function b(j){return isNaN(j=+j)?g:(j=.5+((j=+p(j))-o)*(n*js}var Ert=wcs,jcs=Nhe,Ncs=Ert,kcs=vE;function Scs(t){return t&&t.length?jcs(t,kcs,Ncs):void 0}var Ccs=Scs;const khe=Po(Ccs);function Mcs(t,s){return tt.e^o.s<0?1:-1;for(n=o.d.length,a=t.d.length,s=0,r=nt.d[s]^o.s<0?1:-1;return n===a?0:n>a^o.s<0?1:-1};aa.decimalPlaces=aa.dp=function(){var t=this,s=t.d.length-1,r=(s-t.e)*yc;if(s=t.d[s],s)for(;s%10==0;s/=10)r--;return r<0?0:r};aa.dividedBy=aa.div=function(t){return y1(this,new this.constructor(t))};aa.dividedToIntegerBy=aa.idiv=function(t){var s=this,r=s.constructor;return Rl(y1(s,new r(t),0,1),r.precision)};aa.equals=aa.eq=function(t){return!this.cmp(t)};aa.exponent=function(){return nu(this)};aa.greaterThan=aa.gt=function(t){return this.cmp(t)>0};aa.greaterThanOrEqualTo=aa.gte=function(t){return this.cmp(t)>=0};aa.isInteger=aa.isint=function(){return this.e>this.d.length-2};aa.isNegative=aa.isneg=function(){return this.s<0};aa.isPositive=aa.ispos=function(){return this.s>0};aa.isZero=function(){return this.s===0};aa.lessThan=aa.lt=function(t){return this.cmp(t)<0};aa.lessThanOrEqualTo=aa.lte=function(t){return this.cmp(t)<1};aa.logarithm=aa.log=function(t){var s,r=this,n=r.constructor,a=n.precision,o=a+5;if(t===void 0)t=new n(10);else if(t=new n(t),t.s<1||t.eq(df))throw Error(zx+"NaN");if(r.s<1)throw Error(zx+(r.s?"NaN":"-Infinity"));return r.eq(df)?new n(0):(Bc=!1,s=y1(ID(r,o),ID(t,o),o),Bc=!0,Rl(s,a))};aa.minus=aa.sub=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?Ort(s,t):Lrt(s,(t.s=-t.s,t))};aa.modulo=aa.mod=function(t){var s,r=this,n=r.constructor,a=n.precision;if(t=new n(t),!t.s)throw Error(zx+"NaN");return r.s?(Bc=!1,s=y1(r,t,0,1).times(t),Bc=!0,r.minus(s)):Rl(new n(r),a)};aa.naturalExponential=aa.exp=function(){return Drt(this)};aa.naturalLogarithm=aa.ln=function(){return ID(this)};aa.negated=aa.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};aa.plus=aa.add=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?Lrt(s,t):Ort(s,(t.s=-t.s,t))};aa.precision=aa.sd=function(t){var s,r,n,a=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(kS+t);if(s=nu(a)+1,n=a.d.length-1,r=n*yc+1,n=a.d[n],n){for(;n%10==0;n/=10)r--;for(n=a.d[0];n>=10;n/=10)r++}return t&&s>r?s:r};aa.squareRoot=aa.sqrt=function(){var t,s,r,n,a,o,l,i=this,c=i.constructor;if(i.s<1){if(!i.s)return new c(0);throw Error(zx+"NaN")}for(t=nu(i),Bc=!1,a=Math.sqrt(+i),a==0||a==1/0?(s=l0(i.d),(s.length+t)%2==0&&(s+="0"),a=Math.sqrt(s),t=wE((t+1)/2)-(t<0||t%2),a==1/0?s="5e"+t:(s=a.toExponential(),s=s.slice(0,s.indexOf("e")+1)+t),n=new c(s)):n=new c(a.toString()),r=c.precision,a=l=r+3;;)if(o=n,n=o.plus(y1(i,o,l+2)).times(.5),l0(o.d).slice(0,l)===(s=l0(n.d)).slice(0,l)){if(s=s.slice(l-3,l+1),a==l&&s=="4999"){if(Rl(o,r+1,0),o.times(o).eq(i)){n=o;break}}else if(s!="9999")break;l+=4}return Bc=!0,Rl(n,r)};aa.times=aa.mul=function(t){var s,r,n,a,o,l,i,c,u,p=this,f=p.constructor,g=p.d,b=(t=new f(t)).d;if(!p.s||!t.s)return new f(0);for(t.s*=p.s,r=p.e+t.e,c=g.length,u=b.length,c=0;){for(s=0,a=c+n;a>n;)i=o[a]+b[n]*g[a-n-1]+s,o[a--]=i%Vu|0,s=i/Vu|0;o[a]=(o[a]+s)%Vu|0}for(;!o[--l];)o.pop();return s?++r:o.shift(),t.d=o,t.e=r,Bc?Rl(t,f.precision):t};aa.toDecimalPlaces=aa.todp=function(t,s){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(P0(t,0,_E),s===void 0?s=n.rounding:P0(s,0,8),Rl(r,t+nu(r)+1,s))};aa.toExponential=function(t,s){var r,n=this,a=n.constructor;return t===void 0?r=sC(n,!0):(P0(t,0,_E),s===void 0?s=a.rounding:P0(s,0,8),n=Rl(new a(n),t+1,s),r=sC(n,!0,t+1)),r};aa.toFixed=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?sC(a):(P0(t,0,_E),s===void 0?s=o.rounding:P0(s,0,8),n=Rl(new o(a),t+nu(a)+1,s),r=sC(n.abs(),!1,t+nu(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};aa.toInteger=aa.toint=function(){var t=this,s=t.constructor;return Rl(new s(t),nu(t)+1,s.rounding)};aa.toNumber=function(){return+this};aa.toPower=aa.pow=function(t){var s,r,n,a,o,l,i=this,c=i.constructor,u=12,p=+(t=new c(t));if(!t.s)return new c(df);if(i=new c(i),!i.s){if(t.s<1)throw Error(zx+"Infinity");return i}if(i.eq(df))return i;if(n=c.precision,t.eq(df))return Rl(i,n);if(s=t.e,r=t.d.length-1,l=s>=r,o=i.s,l){if((r=p<0?-p:p)<=Irt){for(a=new c(df),s=Math.ceil(n/yc+4),Bc=!1;r%2&&(a=a.times(i),$Oe(a.d,s)),r=wE(r/2),r!==0;)i=i.times(i),$Oe(i.d,s);return Bc=!0,t.s<0?new c(df).div(a):Rl(a,n)}}else if(o<0)throw Error(zx+"NaN");return o=o<0&&t.d[Math.max(s,r)]&1?-1:1,i.s=1,Bc=!1,a=t.times(ID(i,n+u)),Bc=!0,a=Drt(a),a.s=o,a};aa.toPrecision=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?(r=nu(a),n=sC(a,r<=o.toExpNeg||r>=o.toExpPos)):(P0(t,1,_E),s===void 0?s=o.rounding:P0(s,0,8),a=Rl(new o(a),t,s),r=nu(a),n=sC(a,t<=r||r<=o.toExpNeg,t)),n};aa.toSignificantDigits=aa.tosd=function(t,s){var r=this,n=r.constructor;return t===void 0?(t=n.precision,s=n.rounding):(P0(t,1,_E),s===void 0?s=n.rounding:P0(s,0,8)),Rl(new n(r),t,s)};aa.toString=aa.valueOf=aa.val=aa.toJSON=aa[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,s=nu(t),r=t.constructor;return sC(t,s<=r.toExpNeg||s>=r.toExpPos)};function Lrt(t,s){var r,n,a,o,l,i,c,u,p=t.constructor,f=p.precision;if(!t.s||!s.s)return s.s||(s=new p(t)),Bc?Rl(s,f):s;if(c=t.d,u=s.d,l=t.e,a=s.e,c=c.slice(),o=l-a,o){for(o<0?(n=c,o=-o,i=u.length):(n=u,a=l,i=c.length),l=Math.ceil(f/yc),i=l>i?l+1:i+1,o>i&&(o=i,n.length=1),n.reverse();o--;)n.push(0);n.reverse()}for(i=c.length,o=u.length,i-o<0&&(o=i,n=u,u=c,c=n),r=0;o;)r=(c[--o]=c[o]+u[o]+r)/Vu|0,c[o]%=Vu;for(r&&(c.unshift(r),++a),i=c.length;c[--i]==0;)c.pop();return s.d=c,s.e=a,Bc?Rl(s,f):s}function P0(t,s,r){if(t!==~~t||tr)throw Error(kS+t)}function l0(t){var s,r,n,a=t.length-1,o="",l=t[0];if(a>0){for(o+=l,s=1;sl?1:-1;else for(i=c=0;ia[i]?1:-1;break}return c}function r(n,a,o){for(var l=0;o--;)n[o]-=l,l=n[o]1;)n.shift()}return function(n,a,o,l){var i,c,u,p,f,g,b,_,j,w,k,S,M,L,I,O,q,U,B=n.constructor,V=n.s==a.s?1:-1,Z=n.d,X=a.d;if(!n.s)return new B(n);if(!a.s)throw Error(zx+"Division by zero");for(c=n.e-a.e,q=X.length,I=Z.length,b=new B(V),_=b.d=[],u=0;X[u]==(Z[u]||0);)++u;if(X[u]>(Z[u]||0)&&--c,o==null?S=o=B.precision:l?S=o+(nu(n)-nu(a))+1:S=o,S<0)return new B(0);if(S=S/yc+2|0,u=0,q==1)for(p=0,X=X[0],S++;(u1&&(X=t(X,p),Z=t(Z,p),q=X.length,I=Z.length),L=q,j=Z.slice(0,q),w=j.length;w=Vu/2&&++O;do p=0,i=s(X,j,q,w),i<0?(k=j[0],q!=w&&(k=k*Vu+(j[1]||0)),p=k/O|0,p>1?(p>=Vu&&(p=Vu-1),f=t(X,p),g=f.length,w=j.length,i=s(f,j,g,w),i==1&&(p--,r(f,q16)throw Error(U4e+nu(t));if(!t.s)return new p(df);for(Bc=!1,i=f,l=new p(.03125);t.abs().gte(.1);)t=t.times(l),u+=5;for(n=Math.log(o4(2,u))/Math.LN10*2+5|0,i+=n,r=a=o=new p(df),p.precision=i;;){if(a=Rl(a.times(t),i),r=r.times(++c),l=o.plus(y1(a,r,i)),l0(l.d).slice(0,i)===l0(o.d).slice(0,i)){for(;u--;)o=Rl(o.times(o),i);return p.precision=f,s==null?(Bc=!0,Rl(o,f)):o}o=l}}function nu(t){for(var s=t.e*yc,r=t.d[0];r>=10;r/=10)s++;return s}function nye(t,s,r){if(s>t.LN10.sd())throw Bc=!0,r&&(t.precision=r),Error(zx+"LN10 precision limit exceeded");return Rl(new t(t.LN10),s)}function Jb(t){for(var s="";t--;)s+="0";return s}function ID(t,s){var r,n,a,o,l,i,c,u,p,f=1,g=10,b=t,_=b.d,j=b.constructor,w=j.precision;if(b.s<1)throw Error(zx+(b.s?"NaN":"-Infinity"));if(b.eq(df))return new j(0);if(s==null?(Bc=!1,u=w):u=s,b.eq(10))return s==null&&(Bc=!0),nye(j,u);if(u+=g,j.precision=u,r=l0(_),n=r.charAt(0),o=nu(b),Math.abs(o)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)b=b.times(t),r=l0(b.d),n=r.charAt(0),f++;o=nu(b),n>1?(b=new j("0."+r),o++):b=new j(n+"."+r.slice(1))}else return c=nye(j,u+2,w).times(o+""),b=ID(new j(n+"."+r.slice(1)),u-g).plus(c),j.precision=w,s==null?(Bc=!0,Rl(b,w)):b;for(i=l=b=y1(b.minus(df),b.plus(df),u),p=Rl(b.times(b),u),a=3;;){if(l=Rl(l.times(p),u),c=i.plus(y1(l,new j(a),u)),l0(c.d).slice(0,u)===l0(i.d).slice(0,u))return i=i.times(2),o!==0&&(i=i.plus(nye(j,u+2,w).times(o+""))),i=y1(i,new j(f),u),j.precision=w,s==null?(Bc=!0,Rl(i,w)):i;i=c,a+=2}}function BOe(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=wE(r/yc),t.d=[],n=(r+1)%yc,r<0&&(n+=yc),nxce||t.e<-xce))throw Error(U4e+r)}else t.s=0,t.e=0,t.d=[0];return t}function Rl(t,s,r){var n,a,o,l,i,c,u,p,f=t.d;for(l=1,o=f[0];o>=10;o/=10)l++;if(n=s-l,n<0)n+=yc,a=s,u=f[p=0];else{if(p=Math.ceil((n+1)/yc),o=f.length,p>=o)return t;for(u=o=f[p],l=1;o>=10;o/=10)l++;n%=yc,a=n-yc+l}if(r!==void 0&&(o=o4(10,l-a-1),i=u/o%10|0,c=s<0||f[p+1]!==void 0||u%o,c=r<4?(i||c)&&(r==0||r==(t.s<0?3:2)):i>5||i==5&&(r==4||c||r==6&&(n>0?a>0?u/o4(10,l-a):0:f[p-1])%10&1||r==(t.s<0?8:7))),s<1||!f[0])return c?(o=nu(t),f.length=1,s=s-o-1,f[0]=o4(10,(yc-s%yc)%yc),t.e=wE(-s/yc)||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=o4(10,yc-n),f[p]=a>0?(u/o4(10,l-a)%o4(10,a)|0)*o:0),c)for(;;)if(p==0){(f[0]+=o)==Vu&&(f[0]=1,++t.e);break}else{if(f[p]+=o,f[p]!=Vu)break;f[p--]=0,o=1}for(n=f.length;f[--n]===0;)f.pop();if(Bc&&(t.e>xce||t.e<-xce))throw Error(U4e+nu(t));return t}function Ort(t,s){var r,n,a,o,l,i,c,u,p,f,g=t.constructor,b=g.precision;if(!t.s||!s.s)return s.s?s.s=-s.s:s=new g(t),Bc?Rl(s,b):s;if(c=t.d,f=s.d,n=s.e,u=t.e,c=c.slice(),l=u-n,l){for(p=l<0,p?(r=c,l=-l,i=f.length):(r=f,n=u,i=c.length),a=Math.max(Math.ceil(b/yc),i)+2,l>a&&(l=a,r.length=1),r.reverse(),a=l;a--;)r.push(0);r.reverse()}else{for(a=c.length,i=f.length,p=a0;--a)c[i++]=0;for(a=f.length;a>l;){if(c[--a]0?o=o.charAt(0)+"."+o.slice(1)+Jb(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+Jb(-a-1)+o,r&&(n=r-l)>0&&(o+=Jb(n))):a>=l?(o+=Jb(a+1-l),r&&(n=r-a-1)>0&&(o=o+"."+Jb(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=Jb(n))),t.s<0?"-"+o:o}function $Oe(t,s){if(t.length>s)return t.length=s,!0}function Rrt(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(kS+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 BOe(l,o.toString())}else if(typeof o!="string")throw Error(kS+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,Zcs.test(o))BOe(l,o);else throw Error(kS+o)}if(a.prototype=aa,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.clone=Rrt,a.config=a.set=Ycs,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(kS+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(kS+r+": "+n);return this}var V4e=Rrt(Kcs);df=new V4e(1);const Nl=V4e;function Xcs(t){return tds(t)||eds(t)||Jcs(t)||Qcs()}function Qcs(){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 Jcs(t,s){if(t){if(typeof t=="string")return Hbe(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 Hbe(t,s)}}function eds(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function tds(t){if(Array.isArray(t))return Hbe(t)}function Hbe(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,qOe(function(){for(var i=arguments.length,c=new Array(i),u=0;ut.length)&&(s=t.length);for(var r=0,n=new Array(s);r"u"||!(Symbol.iterator in Object(t)))){var r=[],n=!0,a=!1,o=void 0;try{for(var l=t[Symbol.iterator](),i;!(n=(i=l.next()).done)&&(r.push(i.value),!(s&&r.length===s));n=!0);}catch(c){a=!0,o=c}finally{try{!n&&l.return!=null&&l.return()}finally{if(a)throw o}}return r}}function xds(t){if(Array.isArray(t))return t}function qrt(t){var s=LD(t,2),r=s[0],n=s[1],a=r,o=n;return r>n&&(a=n,o=r),[a,o]}function Urt(t,s,r){if(t.lte(0))return new Nl(0);var n=Mhe.getDigitCount(t.toNumber()),a=new Nl(10).pow(n),o=t.div(a),l=n!==1?.05:.1,i=new Nl(Math.ceil(o.div(l).toNumber())).add(r).mul(l),c=i.mul(a);return s?c:new Nl(Math.ceil(c))}function gds(t,s,r){var n=1,a=new Nl(t);if(!a.isint()&&r){var o=Math.abs(t);o<1?(n=new Nl(10).pow(Mhe.getDigitCount(t)-1),a=new Nl(Math.floor(a.div(n).toNumber())).mul(n)):o>1&&(a=new Nl(Math.floor(t)))}else t===0?a=new Nl(Math.floor((s-1)/2)):r||(a=new Nl(Math.floor(t)));var l=Math.floor((s-1)/2),i=ads(nds(function(c){return a.add(new Nl(c-l).mul(n)).toNumber()}),Wbe);return i(0,s)}function Vrt(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 Nl(0),tickMin:new Nl(0),tickMax:new Nl(0)};var o=Urt(new Nl(s).sub(t).div(r-1),n,a),l;t<=0&&s>=0?l=new Nl(0):(l=new Nl(t).add(s).div(2),l=l.sub(new Nl(l).mod(o)));var i=Math.ceil(l.sub(t).div(o).toNumber()),c=Math.ceil(new Nl(s).sub(l).div(o).toNumber()),u=i+c+1;return u>r?Vrt(t,s,r,n,a+1):(u0?c+(r-u):c,i=s>0?i:i+(r-u)),{step:o,tickMin:l.sub(new Nl(i).mul(o)),tickMax:l.add(new Nl(c).mul(o))})}function yds(t){var s=LD(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=qrt([r,n]),c=LD(i,2),u=c[0],p=c[1];if(u===-1/0||p===1/0){var f=p===1/0?[u].concat(Kbe(Wbe(0,a-1).map(function(){return 1/0}))):[].concat(Kbe(Wbe(0,a-1).map(function(){return-1/0})),[p]);return r>n?Gbe(f):f}if(u===p)return gds(u,a,o);var g=Vrt(u,p,l,o),b=g.step,_=g.tickMin,j=g.tickMax,w=Mhe.rangeStep(_,j.add(new Nl(.1).mul(b)),b);return r>n?Gbe(w):w}function vds(t,s){var r=LD(t,2),n=r[0],a=r[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=qrt([n,a]),i=LD(l,2),c=i[0],u=i[1];if(c===-1/0||u===1/0)return[n,a];if(c===u)return[c];var p=Math.max(s,2),f=Urt(new Nl(u).sub(c).div(p-1),o,0),g=[].concat(Kbe(Mhe.rangeStep(new Nl(c),new Nl(u).sub(new Nl(.99).mul(f)),f)),[u]);return n>a?Gbe(g):g}var bds=Brt(yds),_ds=Brt(vds),wds="Invariant failed";function rC(t,s){throw new Error(wds)}var jds=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function nA(t){"@babel/helpers - typeof";return nA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},nA(t)}function gce(){return gce=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 Ads(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 Eds(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Pds(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0,l=-1,i=(r=n==null?void 0:n.length)!==null&&r!==void 0?r:0;if(i<=1)return 0;if(o&&o.axisType==="angleAxis"&&Math.abs(Math.abs(o.range[1]-o.range[0])-360)<=1e-6)for(var c=o.range,u=0;u0?a[u-1].coordinate:a[i-1].coordinate,f=a[u].coordinate,g=u>=i-1?a[0].coordinate:a[u+1].coordinate,b=void 0;if(Tm(f-p)!==Tm(g-f)){var _=[];if(Tm(g-f)===Tm(c[1]-c[0])){b=g;var j=f+c[1]-c[0];_[0]=Math.min(j,(j+p)/2),_[1]=Math.max(j,(j+p)/2)}else{b=p;var w=g+c[1]-c[0];_[0]=Math.min(f,(w+f)/2),_[1]=Math.max(f,(w+f)/2)}var k=[Math.min(f,(b+f)/2),Math.max(f,(b+f)/2)];if(s>k[0]&&s<=k[1]||s>=_[0]&&s<=_[1]){l=a[u].index;break}}else{var S=Math.min(p,g),M=Math.max(p,g);if(s>(S+f)/2&&s<=(M+f)/2){l=a[u].index;break}}}else for(var L=0;L0&&L(n[L].coordinate+n[L-1].coordinate)/2&&s<=(n[L].coordinate+n[L+1].coordinate)/2||L===i-1&&s>(n[L].coordinate+n[L-1].coordinate)/2){l=n[L].index;break}return l},H4e=function(s){var r,n=s,a=n.type.displayName,o=(r=s.type)!==null&&r!==void 0&&r.defaultProps?pd(pd({},s.type.defaultProps),s.props):s.props,l=o.stroke,i=o.fill,c;switch(a){case"Line":c=l;break;case"Area":case"Radar":c=l&&l!=="none"?l:i;break;default:c=i;break}return c},Zds=function(s){var r=s.barSize,n=s.totalSize,a=s.stackGroups,o=a===void 0?{}:a;if(!o)return{};for(var l={},i=Object.keys(o),c=0,u=i.length;c=0});if(k&&k.length){var S=k[0].type.defaultProps,M=S!==void 0?pd(pd({},S),k[0].props):k[0].props,L=M.barSize,I=M[w];l[I]||(l[I]=[]);var O=$i(L)?r:L;l[I].push({item:k[0],stackList:k.slice(1),barSize:$i(O)?void 0:Am(O,n,0)})}}return l},Yds=function(s){var r=s.barGap,n=s.barCategoryGap,a=s.bandSize,o=s.sizeList,l=o===void 0?[]:o,i=s.maxBarSize,c=l.length;if(c<1)return null;var u=Am(r,a,0,!0),p,f=[];if(l[0].barSize===+l[0].barSize){var g=!1,b=a/c,_=l.reduce(function(L,I){return L+I.barSize||0},0);_+=(c-1)*u,_>=a&&(_-=(c-1)*u,u=0),_>=a&&b>0&&(g=!0,b*=.9,_=c*b);var j=(a-_)/2>>0,w={offset:j-u,size:0};p=l.reduce(function(L,I){var O={item:I.item,position:{offset:w.offset+w.size+u,size:g?b:I.barSize}},q=[].concat(HOe(L),[O]);return w=q[q.length-1].position,I.stackList&&I.stackList.length&&I.stackList.forEach(function(U){q.push({item:U,position:w})}),q},f)}else{var k=Am(n,a,0,!0);a-2*k-(c-1)*u<=0&&(u=0);var S=(a-2*k-(c-1)*u)/c;S>1&&(S>>=0);var M=i===+i?Math.min(S,i):S;p=l.reduce(function(L,I,O){var q=[].concat(HOe(L),[{item:I.item,position:{offset:k+(S+u)*O+(S-M)/2,size:M}}]);return I.stackList&&I.stackList.length&&I.stackList.forEach(function(U){q.push({item:U,position:q[q.length-1].position})}),q},f)}return p},Xds=function(s,r,n,a){var o=n.children,l=n.width,i=n.margin,c=l-(i.left||0)-(i.right||0),u=Krt({children:o,legendWidth:c});if(u){var p=a||{},f=p.width,g=p.height,b=u.align,_=u.verticalAlign,j=u.layout;if((j==="vertical"||j==="horizontal"&&_==="middle")&&b!=="center"&&ln(s[b]))return pd(pd({},s),{},oT({},b,s[b]+(f||0)));if((j==="horizontal"||j==="vertical"&&b==="center")&&_!=="middle"&&ln(s[_]))return pd(pd({},s),{},oT({},_,s[_]+(g||0)))}return s},Qds=function(s,r,n){return $i(r)?!0:s==="horizontal"?r==="yAxis":s==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},Zrt=function(s,r,n,a,o){var l=r.props.children,i=jf(l,hR).filter(function(u){return Qds(a,o,u.props.direction)});if(i&&i.length){var c=i.map(function(u){return u.props.dataKey});return s.reduce(function(u,p){var f=_u(p,n);if($i(f))return u;var g=Array.isArray(f)?[She(f),khe(f)]:[f,f],b=c.reduce(function(_,j){var w=_u(p,j,0),k=g[0]-Math.abs(Array.isArray(w)?w[0]:w),S=g[1]+Math.abs(Array.isArray(w)?w[1]:w);return[Math.min(k,_[0]),Math.max(S,_[1])]},[1/0,-1/0]);return[Math.min(b[0],u[0]),Math.max(b[1],u[1])]},[1/0,-1/0])}return null},Jds=function(s,r,n,a,o){var l=r.map(function(i){return Zrt(s,i,n,o,a)}).filter(function(i){return!$i(i)});return l&&l.length?l.reduce(function(i,c){return[Math.min(i[0],c[0]),Math.max(i[1],c[1])]},[1/0,-1/0]):null},Yrt=function(s,r,n,a,o){var l=r.map(function(c){var u=c.props.dataKey;return n==="number"&&u&&Zrt(s,c,u,a)||m8(s,u,n,o)});if(n==="number")return l.reduce(function(c,u){return[Math.min(c[0],u[0]),Math.max(c[1],u[1])]},[1/0,-1/0]);var i={};return l.reduce(function(c,u){for(var p=0,f=u.length;p=2?Tm(i[0]-i[1])*2*u:u,r&&(s.ticks||s.niceTicks)){var p=(s.ticks||s.niceTicks).map(function(f){var g=o?o.indexOf(f):f;return{coordinate:a(g)+u,value:f,offset:u}});return p.filter(function(f){return!nR(f.coordinate)})}return s.isCategorical&&s.categoricalDomain?s.categoricalDomain.map(function(f,g){return{coordinate:a(f)+u,value:f,index:g,offset:u}}):a.ticks&&!n?a.ticks(s.tickCount).map(function(f){return{coordinate:a(f)+u,value:f,offset:u}}):a.domain().map(function(f,g){return{coordinate:a(f)+u,value:o?o[f]:f,index:g,offset:u}})},aye=new WeakMap,Oz=function(s,r){if(typeof r!="function")return s;aye.has(s)||aye.set(s,new WeakMap);var n=aye.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},Jrt=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:MD(),realScaleType:"band"}:l==="radial"&&i==="angleAxis"?{scale:hce(),realScaleType:"linear"}:o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:h8(),realScaleType:"point"}:o==="category"?{scale:MD(),realScaleType:"band"}:{scale:hce(),realScaleType:"linear"};if(JS(a)){var c="scale".concat(uhe(a));return{scale:(zOe[c]||h8)(),realScaleType:zOe[c]?c:"point"}}return Mi(a)?{scale:a}:{scale:h8(),realScaleType:"point"}},GOe=1e-4,ent=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])-GOe,l=Math.max(a[0],a[1])+GOe,i=s(r[0]),c=s(r[n-1]);(il||cl)&&s.domain([r[0],r[n-1]])}},eus=function(s,r){if(!s)return null;for(var n=0,a=s.length;na)&&(o[1]=a),o[0]>a&&(o[0]=a),o[1]=0?(s[i][n][0]=o,s[i][n][1]=o+c,o=s[i][n][1]):(s[i][n][0]=l,s[i][n][1]=l+c,l=s[i][n][1])}},rus=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)}},nus={sign:sus,expand:jXt,none:YT,silhouette:NXt,wiggle:kXt,positive:rus},aus=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=nus[n],l=wXt().keys(a).value(function(i,c){return+_u(i,c,0)}).order(wbe).offset(o);return l(s)},ius=function(s,r,n,a,o,l){if(!s)return null;var i=l?r.reverse():r,c={},u=i.reduce(function(f,g){var b,_=(b=g.type)!==null&&b!==void 0&&b.defaultProps?pd(pd({},g.type.defaultProps),g.props):g.props,j=_.stackId,w=_.hide;if(w)return f;var k=_[n],S=f[k]||{hasStack:!1,stackGroups:{}};if(ju(j)){var M=S.stackGroups[j]||{numericAxisId:n,cateAxisId:a,items:[]};M.items.push(g),S.hasStack=!0,S.stackGroups[j]=M}else S.stackGroups[xE("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[g]};return pd(pd({},f),{},oT({},k,S))},c),p={};return Object.keys(u).reduce(function(f,g){var b=u[g];if(b.hasStack){var _={};b.stackGroups=Object.keys(b.stackGroups).reduce(function(j,w){var k=b.stackGroups[w];return pd(pd({},j),{},oT({},w,{numericAxisId:n,cateAxisId:a,items:k.items,stackedData:aus(s,k.items,o)}))},_)}return pd(pd({},f),{},oT({},g,b))},p)},tnt=function(s,r){var n=r.realScaleType,a=r.type,o=r.tickCount,l=r.originalDomain,i=r.allowDecimals,c=n||r.scale;if(c!=="auto"&&c!=="linear")return null;if(o&&a==="number"&&l&&(l[0]==="auto"||l[1]==="auto")){var u=s.domain();if(!u.length)return null;var p=bds(u,o,i);return s.domain([She(p),khe(p)]),{niceTicks:p}}if(o&&a==="number"){var f=s.domain(),g=_ds(f,o,i);return{niceTicks:g}}return null};function KOe(t){var s=t.axis,r=t.ticks,n=t.bandSize,a=t.entry,o=t.index,l=t.dataKey;if(s.type==="category"){if(!s.allowDuplicatedCategory&&s.dataKey&&!$i(a[s.dataKey])){var i=Hle(r,"value",a[s.dataKey]);if(i)return i.coordinate+n/2}return r[o]?r[o].coordinate+n/2:null}var c=_u(a,$i(l)?s.dataKey:l);return $i(c)?null:s.scale(c)}var ZOe=function(s){var r=s.axis,n=s.ticks,a=s.offset,o=s.bandSize,l=s.entry,i=s.index;if(r.type==="category")return n[i]?n[i].coordinate+a:null;var c=_u(l,r.dataKey,r.domain[i]);return $i(c)?null:r.scale(c)-o/2+a},ous=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]},lus=function(s,r){var n,a=(n=s.type)!==null&&n!==void 0&&n.defaultProps?pd(pd({},s.type.defaultProps),s.props):s.props,o=a.stackId;if(ju(o)){var l=r[o];if(l){var i=l.items.indexOf(s);return i>=0?l.stackedData[i]:null}}return null},cus=function(s){return s.reduce(function(r,n){return[She(n.concat([r[0]]).filter(ln)),khe(n.concat([r[1]]).filter(ln))]},[1/0,-1/0])},snt=function(s,r,n){return Object.keys(s).reduce(function(a,o){var l=s[o],i=l.stackedData,c=i.reduce(function(u,p){var f=cus(p.slice(r,n+1));return[Math.min(u[0],f[0]),Math.max(u[1],f[1])]},[1/0,-1/0]);return[Math.min(c[0],a[0]),Math.max(c[1],a[1])]},[1/0,-1/0]).map(function(a){return a===1/0||a===-1/0?0:a})},YOe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,XOe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Qbe=function(s,r,n){if(Mi(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(ln(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(YOe.test(s[0])){var o=+YOe.exec(s[0])[1];a[0]=r[0]-o}else Mi(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(ln(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(XOe.test(s[1])){var l=+XOe.exec(s[1])[1];a[1]=r[1]+l}else Mi(s[1])?a[1]=s[1](r[1]):a[1]=r[1];return a},vce=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=v4e(r,function(f){return f.coordinate}),l=1/0,i=1,c=o.length;it.length)&&(s=t.length);for(var r=0,n=new Array(s);r2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(s-(n.left||0)-(n.right||0)),Math.abs(r-(n.top||0)-(n.bottom||0)))/2},yus=function(s,r,n,a,o){var l=s.width,i=s.height,c=s.startAngle,u=s.endAngle,p=Am(s.cx,l,l/2),f=Am(s.cy,i,i/2),g=ant(l,i,n),b=Am(s.innerRadius,g,0),_=Am(s.outerRadius,g,g*.8),j=Object.keys(r);return j.reduce(function(w,k){var S=r[k],M=S.domain,L=S.reversed,I;if($i(S.range))a==="angleAxis"?I=[c,u]:a==="radiusAxis"&&(I=[b,_]),L&&(I=[I[1],I[0]]);else{I=S.range;var O=I,q=hus(O,2);c=q[0],u=q[1]}var U=Jrt(S,o),B=U.realScaleType,V=U.scale;V.domain(M).range(I),ent(V);var Z=tnt(V,Iv(Iv({},S),{},{realScaleType:B})),X=Iv(Iv(Iv({},S),Z),{},{range:I,radius:_,realScaleType:B,scale:V,cx:p,cy:f,innerRadius:b,outerRadius:_,startAngle:c,endAngle:u});return Iv(Iv({},w),{},nnt({},k,X))},{})},vus=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))},bus=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=vus({x:n,y:a},{x:o,y:l});if(i<=0)return{radius:i};var c=(n-o)/i,u=Math.acos(c);return a>l&&(u=2*Math.PI-u),{radius:i,angle:gus(u),angleInRadian:u}},_us=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}},wus=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},tRe=function(s,r){var n=s.x,a=s.y,o=bus({x:n,y:a},r),l=o.radius,i=o.angle,c=r.innerRadius,u=r.outerRadius;if(lu)return!1;if(l===0)return!0;var p=_us(r),f=p.startAngle,g=p.endAngle,b=i,_;if(f<=g){for(;b>g;)b-=360;for(;b=f&&b<=g}else{for(;b>f;)b-=360;for(;b=g&&b<=f}return _?Iv(Iv({},r),{},{radius:l,angle:wus(b,r)}):null},int=function(s){return!N.isValidElement(s)&&!Mi(s)&&typeof s!="boolean"?s.className:""};function FD(t){"@babel/helpers - typeof";return FD=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},FD(t)}var jus=["offset"];function Nus(t){return Mus(t)||Cus(t)||Sus(t)||kus()}function kus(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sus(t,s){if(t){if(typeof t=="string")return Jbe(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 Jbe(t,s)}}function Cus(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Mus(t){if(Array.isArray(t))return Jbe(t)}function Jbe(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 Aus(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 sRe(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 hu(t){for(var s=1;s=0?1:-1,M,L;a==="insideStart"?(M=b+S*l,L=j):a==="insideEnd"?(M=_-S*l,L=!j):a==="end"&&(M=_+S*l,L=j),L=k<=0?L:!L;var I=rc(u,p,w,M),O=rc(u,p,w,M+(L?1:-1)*359),q="M".concat(I.x,",").concat(I.y,` A`).concat(w,",").concat(w,",0,1,").concat(L?0:1,`, `).concat(O.x,",").concat(O.y),U=$i(s.id)?xE("recharts-radial-line-"):s.id;return ht.createElement("text",zD({},n,{dominantBaseline:"central",className:Vi("recharts-radial-bar-label",i)}),ht.createElement("defs",null,ht.createElement("path",{id:U,d:q})),ht.createElement("textPath",{xlinkHref:"#".concat(U)},r))},Rus=function(s){var r=s.viewBox,n=s.offset,a=s.position,o=r,l=o.cx,i=o.cy,c=o.innerRadius,u=o.outerRadius,p=o.startAngle,f=o.endAngle,g=(p+f)/2;if(a==="outside"){var b=rc(l,i,u+n,g),_=b.x,j=b.y;return{x:_,y:j,textAnchor:_>=l?"start":"end",verticalAnchor:"middle"}}if(a==="center")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(a==="centerTop")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"start"};if(a==="centerBottom")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"end"};var w=(c+u)/2,k=rc(l,i,w,g),S=k.x,M=k.y;return{x:S,y:M,textAnchor:"middle",verticalAnchor:"middle"}},Fus=function(s){var r=s.viewBox,n=s.parentViewBox,a=s.offset,o=s.position,l=r,i=l.x,c=l.y,u=l.width,p=l.height,f=p>=0?1:-1,g=f*a,b=f>0?"end":"start",_=f>0?"start":"end",j=u>=0?1:-1,w=j*a,k=j>0?"end":"start",S=j>0?"start":"end";if(o==="top"){var M={x:i+u/2,y:c-f*a,textAnchor:"middle",verticalAnchor:b};return hu(hu({},M),n?{height:Math.max(c-n.y,0),width:u}:{})}if(o==="bottom"){var L={x:i+u/2,y:c+p+g,textAnchor:"middle",verticalAnchor:_};return hu(hu({},L),n?{height:Math.max(n.y+n.height-(c+p),0),width:u}:{})}if(o==="left"){var I={x:i-w,y:c+p/2,textAnchor:k,verticalAnchor:"middle"};return hu(hu({},I),n?{width:Math.max(I.x-n.x,0),height:p}:{})}if(o==="right"){var O={x:i+u+w,y:c+p/2,textAnchor:S,verticalAnchor:"middle"};return hu(hu({},O),n?{width:Math.max(n.x+n.width-O.x,0),height:p}:{})}var q=n?{width:u,height:p}:{};return o==="insideLeft"?hu({x:i+w,y:c+p/2,textAnchor:S,verticalAnchor:"middle"},q):o==="insideRight"?hu({x:i+u-w,y:c+p/2,textAnchor:k,verticalAnchor:"middle"},q):o==="insideTop"?hu({x:i+u/2,y:c+g,textAnchor:"middle",verticalAnchor:_},q):o==="insideBottom"?hu({x:i+u/2,y:c+p-g,textAnchor:"middle",verticalAnchor:b},q):o==="insideTopLeft"?hu({x:i+w,y:c+g,textAnchor:S,verticalAnchor:_},q):o==="insideTopRight"?hu({x:i+u-w,y:c+g,textAnchor:k,verticalAnchor:_},q):o==="insideBottomLeft"?hu({x:i+w,y:c+p-g,textAnchor:S,verticalAnchor:b},q):o==="insideBottomRight"?hu({x:i+u-w,y:c+p-g,textAnchor:k,verticalAnchor:b},q):hE(o)&&(ln(o.x)||S4(o.x))&&(ln(o.y)||S4(o.y))?hu({x:i+Am(o.x,u),y:c+Am(o.y,p),textAnchor:"end",verticalAnchor:"end"},q):hu({x:i+u/2,y:c+p/2,textAnchor:"middle",verticalAnchor:"middle"},q)},zus=function(s){return"cx"in s&&ln(s.cx)};function Yu(t){var s=t.offset,r=s===void 0?5:s,n=Tus(t,jus),a=hu({offset:r},n),o=a.viewBox,l=a.position,i=a.value,c=a.children,u=a.content,p=a.className,f=p===void 0?"":p,g=a.textBreakAll;if(!o||$i(i)&&$i(c)&&!N.isValidElement(u)&&!Mi(u))return null;if(N.isValidElement(u))return N.cloneElement(u,a);var b;if(Mi(u)){if(b=N.createElement(u,a),N.isValidElement(b))return b}else b=Lus(a);var _=zus(o),j=ai(a,!0);if(_&&(l==="insideStart"||l==="insideEnd"||l==="end"))return Ous(a,b,j);var w=_?Rus(a):Fus(a);return ht.createElement(tC,zD({className:Vi("recharts-label",f)},j,w,{breakAll:g}),b)}Yu.displayName="Label";var ont=function(s){var r=s.cx,n=s.cy,a=s.angle,o=s.startAngle,l=s.endAngle,i=s.r,c=s.radius,u=s.innerRadius,p=s.outerRadius,f=s.x,g=s.y,b=s.top,_=s.left,j=s.width,w=s.height,k=s.clockWise,S=s.labelViewBox;if(S)return S;if(ln(j)&&ln(w)){if(ln(f)&&ln(g))return{x:f,y:g,width:j,height:w};if(ln(b)&&ln(_))return{x:b,y:_,width:j,height:w}}return ln(f)&&ln(g)?{x:f,y:g,width:0,height:0}:ln(r)&&ln(n)?{cx:r,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:u||0,outerRadius:p||c||i||0,clockWise:k}:s.viewBox?s.viewBox:{}},Bus=function(s,r){return s?s===!0?ht.createElement(Yu,{key:"label-implicit",viewBox:r}):ju(s)?ht.createElement(Yu,{key:"label-implicit",viewBox:r,value:s}):N.isValidElement(s)?s.type===Yu?N.cloneElement(s,{key:"label-implicit",viewBox:r}):ht.createElement(Yu,{key:"label-implicit",content:s,viewBox:r}):Mi(s)?ht.createElement(Yu,{key:"label-implicit",content:s,viewBox:r}):hE(s)?ht.createElement(Yu,zD({viewBox:r},s,{key:"label-implicit"})):null:null},$us=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=ont(s),l=jf(a,Yu).map(function(c,u){return N.cloneElement(c,{viewBox:r||o,key:"label-".concat(u)})});if(!n)return l;var i=Bus(s.label,r||o);return[i].concat(Nus(l))};Yu.parseViewBox=ont;Yu.renderCallByParent=$us;function qus(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var Uus=qus;const Vus=Po(Uus);function BD(t){"@babel/helpers - typeof";return BD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},BD(t)}var Hus=["valueAccessor"],Wus=["data","dataKey","clockWise","id","textBreakAll"];function Gus(t){return Xus(t)||Yus(t)||Zus(t)||Kus()}function Kus(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zus(t,s){if(t){if(typeof t=="string")return e_e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e_e(t,s)}}function Yus(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Xus(t){if(Array.isArray(t))return e_e(t)}function e_e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function 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 shs=function(s){return Array.isArray(s.value)?Vus(s.value):s.value};function v1(t){var s=t.valueAccessor,r=s===void 0?shs:s,n=aRe(t,Hus),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,c=n.textBreakAll,u=aRe(n,Wus);return!a||!a.length?null:ht.createElement(Zo,{className:"recharts-label-list"},a.map(function(p,f){var g=$i(o)?r(p,f):_u(p&&p.payload,o),b=$i(i)?{}:{id:"".concat(i,"-").concat(f)};return ht.createElement(Yu,_ce({},ai(p,!0),u,b,{parentViewBox:p.parentViewBox,value:g,textBreakAll:c,viewBox:Yu.parseViewBox($i(l)?p:nRe(nRe({},p),{},{clockWise:l})),key:"label-".concat(f),index:f}))}))}v1.displayName="LabelList";function rhs(t,s){return t?t===!0?ht.createElement(v1,{key:"labelList-implicit",data:s}):ht.isValidElement(t)||Mi(t)?ht.createElement(v1,{key:"labelList-implicit",data:s,content:t}):hE(t)?ht.createElement(v1,_ce({data:s},t,{key:"labelList-implicit"})):null:null}function nhs(t,s){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&r&&!t.label)return null;var n=t.children,a=jf(n,v1).map(function(l,i){return N.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=rhs(t.label,s);return[o].concat(Gus(a))}v1.renderCallByParent=nhs;function $D(t){"@babel/helpers - typeof";return $D=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},$D(t)}function t_e(){return t_e=Object.assign?Object.assign.bind():function(t){for(var s=1;s180),",").concat(+(l>u),`, `).concat(f.x,",").concat(f.y,` `);if(a>0){var b=rc(r,n,a,l),_=rc(r,n,a,u);g+="L ".concat(_.x,",").concat(_.y,` A `).concat(a,",").concat(a,`,0, `).concat(+(Math.abs(c)>180),",").concat(+(l<=u),`, `).concat(b.x,",").concat(b.y," Z")}else g+="L ".concat(r,",").concat(n," Z");return g},chs=function(s){var r=s.cx,n=s.cy,a=s.innerRadius,o=s.outerRadius,l=s.cornerRadius,i=s.forceCornerRadius,c=s.cornerIsExternal,u=s.startAngle,p=s.endAngle,f=Tm(p-u),g=Rz({cx:r,cy:n,radius:o,angle:u,sign:f,cornerRadius:l,cornerIsExternal:c}),b=g.circleTangency,_=g.lineTangency,j=g.theta,w=Rz({cx:r,cy:n,radius:o,angle:p,sign:-f,cornerRadius:l,cornerIsExternal:c}),k=w.circleTangency,S=w.lineTangency,M=w.theta,L=c?Math.abs(u-p):Math.abs(u-p)-j-M;if(L<0)return i?"M ".concat(_.x,",").concat(_.y,` a`).concat(l,",").concat(l,",0,0,1,").concat(l*2,`,0 a`).concat(l,",").concat(l,",0,0,1,").concat(-l*2,`,0 `):lnt({cx:r,cy:n,innerRadius:a,outerRadius:o,startAngle:u,endAngle:p});var I="M ".concat(_.x,",").concat(_.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(b.x,",").concat(b.y,` A`).concat(o,",").concat(o,",0,").concat(+(L>180),",").concat(+(f<0),",").concat(k.x,",").concat(k.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(S.x,",").concat(S.y,` `);if(a>0){var O=Rz({cx:r,cy:n,radius:a,angle:u,sign:f,isExternal:!0,cornerRadius:l,cornerIsExternal:c}),q=O.circleTangency,U=O.lineTangency,B=O.theta,V=Rz({cx:r,cy:n,radius:a,angle:p,sign:-f,isExternal:!0,cornerRadius:l,cornerIsExternal:c}),Z=V.circleTangency,X=V.lineTangency,ee=V.theta,Q=c?Math.abs(u-p):Math.abs(u-p)-B-ee;if(Q<0&&l===0)return"".concat(I,"L").concat(r,",").concat(n,"Z");I+="L".concat(X.x,",").concat(X.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(Z.x,",").concat(Z.y,` A`).concat(a,",").concat(a,",0,").concat(+(Q>180),",").concat(+(f>0),",").concat(q.x,",").concat(q.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(U.x,",").concat(U.y,"Z")}else I+="L".concat(r,",").concat(n,"Z");return I},dhs={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},cnt=function(s){var r=oRe(oRe({},dhs),s),n=r.cx,a=r.cy,o=r.innerRadius,l=r.outerRadius,i=r.cornerRadius,c=r.forceCornerRadius,u=r.cornerIsExternal,p=r.startAngle,f=r.endAngle,g=r.className;if(l0&&Math.abs(p-f)<360?w=chs({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(j,_/2),forceCornerRadius:c,cornerIsExternal:u,startAngle:p,endAngle:f}):w=lnt({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:p,endAngle:f}),ht.createElement("path",t_e({},ai(r,!0),{className:b,d:w,role:"img"}))};function qD(t){"@babel/helpers - typeof";return qD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},qD(t)}function s_e(){return s_e=Object.assign?Object.assign.bind():function(t){for(var s=1;s0;)if(!r.equals(t[n],s[n],n,n,t,s,r))return!1;return!0}function Ths(t,s){return kC(t.getTime(),s.getTime())}function Ahs(t,s){return t.name===s.name&&t.message===s.message&&t.cause===s.cause&&t.stack===s.stack}function Ehs(t,s){return t===s}function fRe(t,s,r){var n=t.size;if(n!==s.size)return!1;if(!n)return!0;for(var a=new Array(n),o=t.entries(),l,i,c=0;(l=o.next())&&!l.done;){for(var u=s.entries(),p=!1,f=0;(i=u.next())&&!i.done;){if(a[f]){f++;continue}var g=l.value,b=i.value;if(r.equals(g[0],b[0],c,f,t,s,r)&&r.equals(g[1],b[1],g[0],b[0],t,s,r)){p=a[f]=!0;break}f++}if(!p)return!1;c++}return!0}var Phs=kC;function Ihs(t,s,r){var n=pRe(t),a=n.length;if(pRe(s).length!==a)return!1;for(;a-- >0;)if(!mnt(t,s,r,n[a]))return!1;return!0}function aI(t,s,r){var n=hRe(t),a=n.length;if(hRe(s).length!==a)return!1;for(var o,l,i;a-- >0;)if(o=n[a],!mnt(t,s,r,o)||(l=mRe(t,o),i=mRe(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function Lhs(t,s){return kC(t.valueOf(),s.valueOf())}function Dhs(t,s){return t.source===s.source&&t.flags===s.flags}function xRe(t,s,r){var n=t.size;if(n!==s.size)return!1;if(!n)return!0;for(var a=new Array(n),o=t.values(),l,i;(l=o.next())&&!l.done;){for(var c=s.values(),u=!1,p=0;(i=c.next())&&!i.done;){if(!a[p]&&r.equals(l.value,i.value,l.value,i.value,t,s,r)){u=a[p]=!0;break}p++}if(!u)return!1}return!0}function Ohs(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 Rhs(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 mnt(t,s,r,n){return(n===Chs||n===Shs||n===khs)&&(t.$$typeof||s.$$typeof)?!0:Nhs(s,n)&&r.equals(t[n],s[n],n,n,t,s,r)}var Fhs="[object Arguments]",zhs="[object Boolean]",Bhs="[object Date]",$hs="[object Error]",qhs="[object Map]",Uhs="[object Number]",Vhs="[object Object]",Hhs="[object RegExp]",Whs="[object Set]",Ghs="[object String]",Khs="[object URL]",Zhs=Array.isArray,gRe=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,yRe=Object.assign,Yhs=Object.prototype.toString.call.bind(Object.prototype.toString);function Xhs(t){var s=t.areArraysEqual,r=t.areDatesEqual,n=t.areErrorsEqual,a=t.areFunctionsEqual,o=t.areMapsEqual,l=t.areNumbersEqual,i=t.areObjectsEqual,c=t.arePrimitiveWrappersEqual,u=t.areRegExpsEqual,p=t.areSetsEqual,f=t.areTypedArraysEqual,g=t.areUrlsEqual;return function(_,j,w){if(_===j)return!0;if(_==null||j==null)return!1;var k=typeof _;if(k!==typeof j)return!1;if(k!=="object")return k==="number"?l(_,j,w):k==="function"?a(_,j,w):!1;var S=_.constructor;if(S!==j.constructor)return!1;if(S===Object)return i(_,j,w);if(Zhs(_))return s(_,j,w);if(gRe!=null&&gRe(_))return f(_,j,w);if(S===Date)return r(_,j,w);if(S===RegExp)return u(_,j,w);if(S===Map)return o(_,j,w);if(S===Set)return p(_,j,w);var M=Yhs(_);return M===Bhs?r(_,j,w):M===Hhs?u(_,j,w):M===qhs?o(_,j,w):M===Whs?p(_,j,w):M===Vhs?typeof _.then!="function"&&typeof j.then!="function"&&i(_,j,w):M===Khs?g(_,j,w):M===$hs?n(_,j,w):M===Fhs?i(_,j,w):M===zhs||M===Uhs||M===Ghs?c(_,j,w):!1}}function Qhs(t){var s=t.circular,r=t.createCustomConfig,n=t.strict,a={areArraysEqual:n?aI:Mhs,areDatesEqual:Ths,areErrorsEqual:Ahs,areFunctionsEqual:Ehs,areMapsEqual:n?uRe(fRe,aI):fRe,areNumbersEqual:Phs,areObjectsEqual:n?aI:Ihs,arePrimitiveWrappersEqual:Lhs,areRegExpsEqual:Dhs,areSetsEqual:n?uRe(xRe,aI):xRe,areTypedArraysEqual:n?aI:Ohs,areUrlsEqual:Rhs};if(r&&(a=yRe({},a,r(a))),s){var o=zz(a.areArraysEqual),l=zz(a.areMapsEqual),i=zz(a.areObjectsEqual),c=zz(a.areSetsEqual);a=yRe({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:c})}return a}function Jhs(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function ems(t){var s=t.circular,r=t.comparator,n=t.createState,a=t.equals,o=t.strict;if(n)return function(c,u){var p=n(),f=p.cache,g=f===void 0?s?new WeakMap:void 0:f,b=p.meta;return r(c,u,{cache:g,equals:a,meta:b,strict:o})};if(s)return function(c,u){return r(c,u,{cache:new WeakMap,equals:a,meta:void 0,strict:o})};var l={cache:void 0,equals:a,meta:void 0,strict:o};return function(c,u){return r(c,u,l)}}var tms=$w();$w({strict:!0});$w({circular:!0});$w({circular:!0,strict:!0});$w({createInternalComparator:function(){return kC}});$w({strict:!0,createInternalComparator:function(){return kC}});$w({circular:!0,createInternalComparator:function(){return kC}});$w({circular:!0,createInternalComparator:function(){return kC},strict:!0});function $w(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=Qhs(t),c=Xhs(i),u=n?n(c):Jhs(c);return ems({circular:r,comparator:c,createState:a,equals:u,strict:l})}function sms(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function vRe(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):sms(a)};requestAnimationFrame(n)}function r_e(t){"@babel/helpers - typeof";return r_e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},r_e(t)}function rms(t){return oms(t)||ims(t)||ams(t)||nms()}function nms(){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 ams(t,s){if(t){if(typeof t=="string")return bRe(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 bRe(t,s)}}function bRe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r1?1:k<0?0:k},j=function(k){for(var S=k>1?1:k,M=S,L=0;L<8;++L){var I=f(M)-S,O=b(M);if(Math.abs(I-S)0&&arguments[0]!==void 0?arguments[0]:{},r=s.stiff,n=r===void 0?100:r,a=s.damping,o=a===void 0?8:a,l=s.dt,i=l===void 0?17:l,c=function(p,f,g){var b=-(p-f)*n,_=g*o,j=g+(b-_)*i/1e3,w=g*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 Fms(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 iye(t){return qms(t)||$ms(t)||Bms(t)||zms()}function zms(){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 Bms(t,s){if(t){if(typeof t=="string")return l_e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return l_e(t,s)}}function $ms(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function qms(t){if(Array.isArray(t))return l_e(t)}function l_e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);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 kce(t){return kce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},kce(t)}var I0=function(t){Gms(r,t);var s=Kms(r);function r(n,a){var o;Ums(this,r),o=s.call(this,n,a);var l=o.props,i=l.isActive,c=l.attributeName,u=l.from,p=l.to,f=l.steps,g=l.children,b=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(u_e(o)),o.changeStyle=o.changeStyle.bind(u_e(o)),!i||b<=0)return o.state={style:{}},typeof g=="function"&&(o.state={style:p}),d_e(o);if(f&&f.length)o.state={style:f[0].style};else if(u){if(typeof g=="function")return o.state={style:u},d_e(o);o.state={style:c?CI({},c,u):u}}else o.state={style:{}};return o}return Hms(r,[{key:"componentDidMount",value:function(){var a=this.props,o=a.isActive,l=a.canBegin;this.mounted=!0,!(!o||!l)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(a){var o=this.props,l=o.isActive,i=o.canBegin,c=o.attributeName,u=o.shouldReAnimate,p=o.to,f=o.from,g=this.state.style;if(i){if(!l){var b={style:c?CI({},c,p):p};this.state&&g&&(c&&g[c]!==p||!c&&g!==p)&&this.setState(b);return}if(!(tms(a.to,p)&&a.canBegin&&a.isActive)){var _=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var j=_||u?f:a.to;if(this.state&&g){var w={style:c?CI({},c,j):j};(c&&g[c]!==j||!c&&g!==j)&&this.setState(w)}this.runAnimation(kg(kg({},this.props),{},{from:j,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var o=this,l=a.from,i=a.to,c=a.duration,u=a.easing,p=a.begin,f=a.onAnimationEnd,g=a.onAnimationStart,b=Dms(l,i,Nms(u),c,this.changeStyle),_=function(){o.stopJSAnimation=b()};this.manager.start([g,p,_,c,f])}},{key:"runStepAnimation",value:function(a){var o=this,l=a.steps,i=a.begin,c=a.onAnimationStart,u=l[0],p=u.style,f=u.duration,g=f===void 0?0:f,b=function(j,w,k){if(k===0)return j;var S=w.duration,M=w.easing,L=M===void 0?"ease":M,I=w.style,O=w.properties,q=w.onAnimationEnd,U=k>0?l[k-1]:w,B=O||Object.keys(I);if(typeof L=="function"||L==="spring")return[].concat(iye(j),[o.runJSAnimation.bind(o,{from:U.style,to:I,duration:S,easing:L}),S]);var V=jRe(B,S,L),Z=kg(kg(kg({},U.style),I),{},{transition:V});return[].concat(iye(j),[Z,S,q]).filter(hms)};return this.manager.start([c].concat(iye(l.reduce(b,[p,Math.max(g,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=lms());var o=a.begin,l=a.duration,i=a.attributeName,c=a.to,u=a.easing,p=a.onAnimationStart,f=a.onAnimationEnd,g=a.steps,b=a.children,_=this.manager;if(this.unSubscribe=_.subscribe(this.handleStyleChange),typeof u=="function"||typeof b=="function"||u==="spring"){this.runJSAnimation(a);return}if(g.length>1){this.runStepAnimation(a);return}var j=i?CI({},i,c):c,w=jRe(Object.keys(j),l,u);_.start([p,o,kg(kg({},j),{},{transition:w}),l,f])}},{key:"render",value:function(){var a=this.props,o=a.children;a.begin;var l=a.duration;a.attributeName,a.easing;var i=a.isActive;a.steps,a.from,a.to,a.canBegin,a.onAnimationEnd,a.shouldReAnimate,a.onAnimationReStart;var c=Rms(a,Oms),u=N.Children.count(o),p=this.state.style;if(typeof o=="function")return o(p);if(!i||u===0||l<=0)return o;var f=function(b){var _=b.props,j=_.style,w=j===void 0?{}:j,k=_.className,S=N.cloneElement(b,kg(kg({},c),{},{style:kg(kg({},w),p),className:k}));return S};return u===1?f(N.Children.only(o)):ht.createElement("div",null,N.Children.map(o,function(g){return f(g)}))}}]),r}(N.PureComponent);I0.displayName="Animate";I0.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};I0.propTypes={from:ol.oneOfType([ol.object,ol.string]),to:ol.oneOfType([ol.object,ol.string]),attributeName:ol.string,duration:ol.number,begin:ol.number,easing:ol.oneOfType([ol.string,ol.func]),steps:ol.arrayOf(ol.shape({duration:ol.number.isRequired,style:ol.object.isRequired,easing:ol.oneOfType([ol.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),ol.func]),properties:ol.arrayOf("string"),onAnimationEnd:ol.func})),children:ol.oneOfType([ol.node,ol.func]),isActive:ol.bool,canBegin:ol.bool,onAnimationEnd:ol.func,shouldReAnimate:ol.bool,onAnimationStart:ol.func,onAnimationReStart:ol.func};function HD(t){"@babel/helpers - typeof";return HD=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},HD(t)}function Sce(){return Sce=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0?1:-1,c=n>=0?1:-1,u=a>=0&&n>=0||a<0&&n<0?1:0,p;if(l>0&&o instanceof Array){for(var f=[0,0,0,0],g=0,b=4;gl?l:o[g];p="M".concat(s,",").concat(r+i*f[0]),f[0]>0&&(p+="A ".concat(f[0],",").concat(f[0],",0,0,").concat(u,",").concat(s+c*f[0],",").concat(r)),p+="L ".concat(s+n-c*f[1],",").concat(r),f[1]>0&&(p+="A ".concat(f[1],",").concat(f[1],",0,0,").concat(u,`, `).concat(s+n,",").concat(r+i*f[1])),p+="L ".concat(s+n,",").concat(r+a-i*f[2]),f[2]>0&&(p+="A ".concat(f[2],",").concat(f[2],",0,0,").concat(u,`, `).concat(s+n-c*f[2],",").concat(r+a)),p+="L ".concat(s+c*f[3],",").concat(r+a),f[3]>0&&(p+="A ".concat(f[3],",").concat(f[3],",0,0,").concat(u,`, `).concat(s,",").concat(r+a-i*f[3])),p+="Z"}else if(l>0&&o===+o&&o>0){var _=Math.min(l,o);p="M ".concat(s,",").concat(r+i*_,` A `).concat(_,",").concat(_,",0,0,").concat(u,",").concat(s+c*_,",").concat(r,` L `).concat(s+n-c*_,",").concat(r,` A `).concat(_,",").concat(_,",0,0,").concat(u,",").concat(s+n,",").concat(r+i*_,` L `).concat(s+n,",").concat(r+a-i*_,` A `).concat(_,",").concat(_,",0,0,").concat(u,",").concat(s+n-c*_,",").concat(r+a,` L `).concat(s+c*_,",").concat(r+a,` A `).concat(_,",").concat(_,",0,0,").concat(u,",").concat(s,",").concat(r+a-i*_," Z")}else p="M ".concat(s,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return p},nps=function(s,r){if(!s||!r)return!1;var n=s.x,a=s.y,o=r.x,l=r.y,i=r.width,c=r.height;if(Math.abs(i)>0&&Math.abs(c)>0){var u=Math.min(o,o+i),p=Math.max(o,o+i),f=Math.min(l,l+c),g=Math.max(l,l+c);return n>=u&&n<=p&&a>=f&&a<=g}return!1},aps={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},W4e=function(s){var r=ERe(ERe({},aps),s),n=N.useRef(),a=N.useState(-1),o=Yms(a,2),l=o[0],i=o[1];N.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var L=n.current.getTotalLength();L&&i(L)}catch{}},[]);var c=r.x,u=r.y,p=r.width,f=r.height,g=r.radius,b=r.className,_=r.animationEasing,j=r.animationDuration,w=r.animationBegin,k=r.isAnimationActive,S=r.isUpdateAnimationActive;if(c!==+c||u!==+u||p!==+p||f!==+f||p===0||f===0)return null;var M=Vi("recharts-rectangle",b);return S?ht.createElement(I0,{canBegin:l>0,from:{width:p,height:f,x:c,y:u},to:{width:p,height:f,x:c,y:u},duration:j,animationEasing:_,isActive:S},function(L){var I=L.width,O=L.height,q=L.x,U=L.y;return ht.createElement(I0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:j,isActive:k,easing:_},ht.createElement("path",Sce({},ai(r,!0),{className:M,d:PRe(q,U,I,O,g),ref:n})))}):ht.createElement("path",Sce({},ai(r,!0),{className:M,d:PRe(c,u,p,f,g)}))},ips=["points","className","baseLinePoints","connectNulls"];function hM(){return hM=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function lps(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function IRe(t){return hps(t)||ups(t)||dps(t)||cps()}function cps(){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 dps(t,s){if(t){if(typeof t=="string")return h_e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h_e(t,s)}}function ups(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function hps(t){if(Array.isArray(t))return h_e(t)}function h_e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return s.forEach(function(n){LRe(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),LRe(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},f8=function(s,r){var n=mps(s);r&&(n=[n.reduce(function(o,l){return[].concat(IRe(o),IRe(l))},[])]);var a=n.map(function(o){return o.reduce(function(l,i,c){return"".concat(l).concat(c===0?"M":"L").concat(i.x,",").concat(i.y)},"")}).join("");return n.length===1?"".concat(a,"Z"):a},pps=function(s,r,n){var a=f8(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(f8(r.reverse(),n).slice(1))},fps=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=ops(s,ips);if(!r||!r.length)return null;var i=Vi("recharts-polygon",n);if(a&&a.length){var c=l.stroke&&l.stroke!=="none",u=pps(r,a,o);return ht.createElement("g",{className:i},ht.createElement("path",hM({},ai(l,!0),{fill:u.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:u})),c?ht.createElement("path",hM({},ai(l,!0),{fill:"none",d:f8(r,o)})):null,c?ht.createElement("path",hM({},ai(l,!0),{fill:"none",d:f8(a,o)})):null)}var p=f8(r,o);return ht.createElement("path",hM({},ai(l,!0),{fill:p.slice(-1)==="Z"?l.fill:"none",className:i,d:p}))};function m_e(){return m_e=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function wps(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 jps=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},Nps=function(s){var r=s.x,n=r===void 0?0:r,a=s.y,o=a===void 0?0:a,l=s.top,i=l===void 0?0:l,c=s.left,u=c===void 0?0:c,p=s.width,f=p===void 0?0:p,g=s.height,b=g===void 0?0:g,_=s.className,j=_ps(s,xps),w=gps({x:n,y:o,top:i,left:u,width:f,height:b},j);return!ln(n)||!ln(o)||!ln(f)||!ln(b)||!ln(i)||!ln(u)?null:ht.createElement("path",p_e({},ai(w,!0),{className:Vi("recharts-cross",_),d:jps(n,o,f,b,i,u)}))},kps=Nhe,Sps=Ert,Cps=$0;function Mps(t,s){return t&&t.length?kps(t,Cps(s),Sps):void 0}var Tps=Mps;const Aps=Po(Tps);var Eps=Nhe,Pps=$0,Ips=Prt;function Lps(t,s){return t&&t.length?Eps(t,Pps(s),Ips):void 0}var Dps=Lps;const Ops=Po(Dps);var Rps=["cx","cy","angle","ticks","axisLine"],Fps=["ticks","tick","angle","tickFormatter","stroke"];function iA(t){"@babel/helpers - typeof";return iA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},iA(t)}function x8(){return x8=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 zps(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 Bps(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function FRe(t,s){for(var r=0;r$Re?l=a==="outer"?"start":"end":o<-$Re?l=a==="outer"?"end":"start":l="middle",l}},{key:"renderAxisLine",value:function(){var n=this.props,a=n.cx,o=n.cy,l=n.radius,i=n.axisLine,c=n.axisLineType,u=q2(q2({},ai(this.props,!1)),{},{fill:"none"},ai(i,!1));if(c==="circle")return ht.createElement(The,h4({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:o,r:l}));var p=this.props.ticks,f=p.map(function(g){return rc(a,o,l,g.coordinate)});return ht.createElement(fps,h4({className:"recharts-polar-angle-axis-line"},u,{points:f}))}},{key:"renderTicks",value:function(){var n=this,a=this.props,o=a.ticks,l=a.tick,i=a.tickLine,c=a.tickFormatter,u=a.stroke,p=ai(this.props,!1),f=ai(l,!1),g=q2(q2({},p),{},{fill:"none"},ai(i,!1)),b=o.map(function(_,j){var w=n.getTickLineCoord(_),k=n.getTickTextAnchor(_),S=q2(q2(q2({textAnchor:k},p),{},{stroke:"none",fill:u},f),{},{index:j,payload:_,x:w.x2,y:w.y2});return ht.createElement(Zo,h4({className:Vi("recharts-polar-angle-axis-tick",int(l)),key:"tick-".concat(_.coordinate)},eC(n.props,_,j)),i&&ht.createElement("line",h4({className:"recharts-polar-angle-axis-tick-line"},g,w)),l&&s.renderTickItem(l,S,c?c(_.value,j):_.value))});return ht.createElement(Zo,{className:"recharts-polar-angle-axis-ticks"},b)}},{key:"render",value:function(){var n=this.props,a=n.ticks,o=n.radius,l=n.axisLine;return o<=0||!a||!a.length?null:ht.createElement(Zo,{className:Vi("recharts-polar-angle-axis",this.props.className)},l&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,a,o){var l;return ht.isValidElement(n)?l=ht.cloneElement(n,a):Mi(n)?l=n(a):l=ht.createElement(tC,h4({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(N.PureComponent);Phe(Ihe,"displayName","PolarAngleAxis");Phe(Ihe,"axisType","angleAxis");Phe(Ihe,"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 tfs=Cst,sfs=tfs(Object.getPrototypeOf,Object),rfs=sfs,nfs=$1,afs=rfs,ifs=q1,ofs="[object Object]",lfs=Function.prototype,cfs=Object.prototype,Nnt=lfs.toString,dfs=cfs.hasOwnProperty,ufs=Nnt.call(Object);function hfs(t){if(!ifs(t)||nfs(t)!=ofs)return!1;var s=afs(t);if(s===null)return!0;var r=dfs.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&Nnt.call(r)==ufs}var mfs=hfs;const pfs=Po(mfs);var ffs=$1,xfs=q1,gfs="[object Boolean]";function yfs(t){return t===!0||t===!1||xfs(t)&&ffs(t)==gfs}var vfs=yfs;const bfs=Po(vfs);function GD(t){"@babel/helpers - typeof";return GD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},GD(t)}function Tce(){return Tce=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0,from:{upperWidth:0,lowerWidth:0,height:g,x:c,y:u},to:{upperWidth:p,lowerWidth:f,height:g,x:c,y:u},duration:j,animationEasing:_,isActive:k},function(M){var L=M.upperWidth,I=M.lowerWidth,O=M.height,q=M.x,U=M.y;return ht.createElement(I0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:j,easing:_},ht.createElement("path",Tce({},ai(r,!0),{className:S,d:HRe(q,U,L,I,O),ref:n})))}):ht.createElement("g",null,ht.createElement("path",Tce({},ai(r,!0),{className:S,d:HRe(c,u,p,f,g)})))},Efs=["option","shapeType","propTransformer","activeClassName","isActive"];function KD(t){"@babel/helpers - typeof";return KD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},KD(t)}function Pfs(t,s){if(t==null)return{};var r=Ifs(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 Ifs(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 WRe(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 Ace(t){for(var s=1;s0?wf(M,"paddingAngle",0):0;if(I){var q=nf(I.endAngle-I.startAngle,M.endAngle-M.startAngle),U=Wl(Wl({},M),{},{startAngle:S+O,endAngle:S+q(j)+O});w.push(U),S=U.endAngle}else{var B=M.endAngle,V=M.startAngle,Z=nf(0,B-V),X=Z(j),ee=Wl(Wl({},M),{},{startAngle:S+O,endAngle:S+X+O});w.push(ee),S=ee.endAngle}}),ht.createElement(Zo,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||!uR(l,a))?this.renderSectorsWithAnimation():this.renderSectorsStatically(a)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var n=this,a=this.props,o=a.hide,l=a.sectors,i=a.className,c=a.label,u=a.cx,p=a.cy,f=a.innerRadius,g=a.outerRadius,b=a.isAnimationActive,_=this.state.isAnimationFinished;if(o||!l||!l.length||!ln(u)||!ln(p)||!ln(f)||!ln(g))return null;var j=Vi("recharts-pie",i);return ht.createElement(Zo,{tabIndex:this.props.rootTabIndex,className:j,ref:function(k){n.pieRef=k}},this.renderSectors(),c&&this.renderLabels(l),Yu.renderCallByParent(this.props,null,!1),(!b||_)&&v1.renderCallByParent(this.props,l,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return a.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:n.sectors!==a.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,a){return n>a?"start":n=360?S:S-1)*c,L=w-S*b-M,I=a.reduce(function(U,B){var V=_u(B,k,0);return U+(ln(V)?V:0)},0),O;if(I>0){var q;O=a.map(function(U,B){var V=_u(U,k,0),Z=_u(U,p,B),X=(ln(V)?V:0)/I,ee;B?ee=q.endAngle+Tm(j)*c*(V!==0?1:0):ee=l;var Q=ee+Tm(j)*((V!==0?b:0)+X*L),ie=(ee+Q)/2,re=(_.innerRadius+_.outerRadius)/2,oe=[{name:Z,value:V,payload:U,dataKey:k,type:g}],ce=rc(_.cx,_.cy,re,ie);return q=Wl(Wl(Wl({percent:X,cornerRadius:o,name:Z,tooltipPayload:oe,midAngle:ie,middleRadius:re,tooltipPosition:ce},U),_),{},{value:_u(U,k),startAngle:ee,endAngle:Q,payload:U,paddingAngle:Tm(j)*c}),q})}return Wl(Wl({},_),{},{sectors:O,data:a})});var exs=Math.ceil,txs=Math.max;function sxs(t,s,r,n){for(var a=-1,o=txs(exs((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var rxs=sxs,nxs=Wst,YRe=1/0,axs=17976931348623157e292;function ixs(t){if(!t)return t===0?t:0;if(t=nxs(t),t===YRe||t===-YRe){var s=t<0?-1:1;return s*axs}return t===t?t:0}var Mnt=ixs,oxs=rxs,lxs=ghe,oye=Mnt;function cxs(t){return function(s,r,n){return n&&typeof n!="number"&&lxs(s,r,n)&&(r=n=void 0),s=oye(s),r===void 0?(r=s,s=0):r=oye(r),n=n===void 0?s0&&n.handleDrag(a.changedTouches[0])}),Jp(n,"handleDragEnd",function(){n.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var a=n.props,o=a.endIndex,l=a.onDragEnd,i=a.startIndex;l==null||l({endIndex:o,startIndex:i})}),n.detachDragEndListener()}),Jp(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),Jp(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),Jp(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),Jp(n,"handleSlideDragStart",function(a){var o=tFe(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 jxs(s,t),vxs(s,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(n){var a=n.startX,o=n.endX,l=this.state.scaleValues,i=this.props,c=i.gap,u=i.data,p=u.length-1,f=Math.min(a,o),g=Math.max(a,o),b=s.getIndexInRange(l,f),_=s.getIndexInRange(l,g);return{startIndex:b-b%c,endIndex:_===p?p:_-_%c}}},{key:"getTextOfTick",value:function(n){var a=this.props,o=a.data,l=a.tickFormatter,i=a.dataKey,c=_u(o[n],i,n);return Mi(l)?l(c,n):c}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(n){var a=this.state,o=a.slideMoveStartX,l=a.startX,i=a.endX,c=this.props,u=c.x,p=c.width,f=c.travellerWidth,g=c.startIndex,b=c.endIndex,_=c.onChange,j=n.pageX-o;j>0?j=Math.min(j,u+p-f-i,u+p-f-l):j<0&&(j=Math.max(j,u-l,u-i));var w=this.getIndex({startX:l+j,endX:i+j});(w.startIndex!==g||w.endIndex!==b)&&_&&_(w),this.setState({startX:l+j,endX:i+j,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var o=tFe(a)?a.changedTouches[0]:a;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:n,brushMoveStartX:o.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(n){var a=this.state,o=a.brushMoveStartX,l=a.movingTravellerId,i=a.endX,c=a.startX,u=this.state[l],p=this.props,f=p.x,g=p.width,b=p.travellerWidth,_=p.onChange,j=p.gap,w=p.data,k={startX:this.state.startX,endX:this.state.endX},S=n.pageX-o;S>0?S=Math.min(S,f+g-b-u):S<0&&(S=Math.max(S,f-u)),k[l]=u+S;var M=this.getIndex(k),L=M.startIndex,I=M.endIndex,O=function(){var U=w.length-1;return l==="startX"&&(i>c?L%j===0:I%j===0)||ic?I%j===0:L%j===0)||i>c&&I===U};this.setState(Jp(Jp({},l,u+S),"brushMoveStartX",n.pageX),function(){_&&O()&&_(M)})}},{key:"handleTravellerMoveKeyboard",value:function(n,a){var o=this,l=this.state,i=l.scaleValues,c=l.startX,u=l.endX,p=this.state[a],f=i.indexOf(p);if(f!==-1){var g=f+n;if(!(g===-1||g>=i.length)){var b=i[g];a==="startX"&&b>=u||a==="endX"&&b<=c||this.setState(Jp({},a,b),function(){o.props.onChange(o.getIndex({startX:o.state.startX,endX:o.state.endX}))})}}}},{key:"renderBackground",value:function(){var n=this.props,a=n.x,o=n.y,l=n.width,i=n.height,c=n.fill,u=n.stroke;return ht.createElement("rect",{stroke:u,fill:c,x:a,y:o,width:l,height:i})}},{key:"renderPanorama",value:function(){var n=this.props,a=n.x,o=n.y,l=n.width,i=n.height,c=n.data,u=n.children,p=n.padding,f=N.Children.only(u);return f?ht.cloneElement(f,{x:a,y:o,width:l,height:i,margin:p,compact:!0,data:c}):null}},{key:"renderTravellerLayer",value:function(n,a){var o,l,i=this,c=this.props,u=c.y,p=c.travellerWidth,f=c.height,g=c.traveller,b=c.ariaLabel,_=c.data,j=c.startIndex,w=c.endIndex,k=Math.max(n,this.props.x),S=lye(lye({},ai(this.props,!1)),{},{x:k,y:u,width:p,height:f}),M=b||"Min value: ".concat((o=_[j])===null||o===void 0?void 0:o.name,", Max value: ").concat((l=_[w])===null||l===void 0?void 0:l.name);return ht.createElement(Zo,{tabIndex:0,role:"slider","aria-label":M,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(I){["ArrowLeft","ArrowRight"].includes(I.key)&&(I.preventDefault(),I.stopPropagation(),i.handleTravellerMoveKeyboard(I.key==="ArrowRight"?1:-1,a))},onFocus:function(){i.setState({isTravellerFocused:!0})},onBlur:function(){i.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},s.renderTraveller(g,S))}},{key:"renderSlide",value:function(n,a){var o=this.props,l=o.y,i=o.height,c=o.stroke,u=o.travellerWidth,p=Math.min(n,a)+u,f=Math.max(Math.abs(a-n)-u,0);return ht.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:c,fillOpacity:.2,x:p,y:l,width:f,height:i})}},{key:"renderText",value:function(){var n=this.props,a=n.startIndex,o=n.endIndex,l=n.y,i=n.height,c=n.travellerWidth,u=n.stroke,p=this.state,f=p.startX,g=p.endX,b=5,_={pointerEvents:"none",fill:u};return ht.createElement(Zo,{className:"recharts-brush-texts"},ht.createElement(tC,Ice({textAnchor:"end",verticalAnchor:"middle",x:Math.min(f,g)-b,y:l+i/2},_),this.getTextOfTick(a)),ht.createElement(tC,Ice({textAnchor:"start",verticalAnchor:"middle",x:Math.max(f,g)+c+b,y:l+i/2},_),this.getTextOfTick(o)))}},{key:"render",value:function(){var n=this.props,a=n.data,o=n.className,l=n.children,i=n.x,c=n.y,u=n.width,p=n.height,f=n.alwaysShowText,g=this.state,b=g.startX,_=g.endX,j=g.isTextActive,w=g.isSlideMoving,k=g.isTravellerMoving,S=g.isTravellerFocused;if(!a||!a.length||!ln(i)||!ln(c)||!ln(u)||!ln(p)||u<=0||p<=0)return null;var M=Vi("recharts-brush",o),L=ht.Children.count(l)===1,I=gxs("userSelect","none");return ht.createElement(Zo,{className:M,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:I},this.renderBackground(),L&&this.renderPanorama(),this.renderSlide(b,_),this.renderTravellerLayer(b,"startX"),this.renderTravellerLayer(_,"endX"),(j||w||k||S||f)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var a=n.x,o=n.y,l=n.width,i=n.height,c=n.stroke,u=Math.floor(o+i/2)-1;return ht.createElement(ht.Fragment,null,ht.createElement("rect",{x:a,y:o,width:l,height:i,fill:c,stroke:"none"}),ht.createElement("line",{x1:a+1,y1:u,x2:a+l-1,y2:u,fill:"none",stroke:"#fff"}),ht.createElement("line",{x1:a+1,y1:u+2,x2:a+l-1,y2:u+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(n,a){var o;return ht.isValidElement(n)?o=ht.cloneElement(n,a):Mi(n)?o=n(a):o=s.renderDefaultTraveller(a),o}},{key:"getDerivedStateFromProps",value:function(n,a){var o=n.data,l=n.width,i=n.x,c=n.travellerWidth,u=n.updateId,p=n.startIndex,f=n.endIndex;if(o!==a.prevData||u!==a.prevUpdateId)return lye({prevData:o,prevTravellerWidth:c,prevUpdateId:u,prevX:i,prevWidth:l},o&&o.length?kxs({data:o,width:l,x:i,travellerWidth:c,startIndex:p,endIndex:f}):{scale:null,scaleValues:null});if(a.scale&&(l!==a.prevWidth||i!==a.prevX||c!==a.prevTravellerWidth)){a.scale.range([i,i+l-c]);var g=a.scale.domain().map(function(b){return a.scale(b)});return{prevData:o,prevTravellerWidth:c,prevUpdateId:u,prevX:i,prevWidth:l,startX:a.scale(n.startIndex),endX:a.scale(n.endIndex),scaleValues:g}}return null}},{key:"getIndexInRange",value:function(n,a){for(var o=n.length,l=0,i=o-1;i-l>1;){var c=Math.floor((l+i)/2);n[c]>a?i=c:l=c}return a>=n[i]?i:l}}])}(N.PureComponent);Jp(dA,"displayName","Brush");Jp(dA,"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 Sxs=y4e;function Cxs(t,s){var r;return Sxs(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var Mxs=Cxs,Txs=vst,Axs=$0,Exs=Mxs,Pxs=Ip,Ixs=ghe;function Lxs(t,s,r){var n=Pxs(t)?Txs:Exs;return r&&Ixs(t,s,r)&&(s=void 0),n(t,Axs(s))}var Dxs=Lxs;const Oxs=Po(Dxs);var N0=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},sFe=$st;function Rxs(t,s,r){s=="__proto__"&&sFe?sFe(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var Fxs=Rxs,zxs=Fxs,Bxs=zst,$xs=$0;function qxs(t,s){var r={};return s=$xs(s),Bxs(t,function(n,a,o){zxs(r,a,s(n,a,o))}),r}var Uxs=qxs;const Vxs=Po(Uxs);function Hxs(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 lgs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function cgs(t,s){var r=t.x,n=t.y,a=ogs(t,rgs),o="".concat(r),l=parseInt(o,10),i="".concat(n),c=parseInt(i,10),u="".concat(s.height||a.height),p=parseInt(u,10),f="".concat(s.width||a.width),g=parseInt(f,10);return iI(iI(iI(iI(iI({},s),a),l?{x:l}:{}),c?{y:c}:{}),{},{height:p,width:g,name:s.name,radius:s.radius})}function nFe(t){return ht.createElement(knt,v_e({shapeType:"rectangle",propTransformer:cgs,activeClassName:"recharts-active-bar"},t))}var dgs=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=ln(n)||DZt(n);return o?s(n,a):(o||rC(),r)}},ugs=["value","background"],Int;function uA(t){"@babel/helpers - typeof";return uA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},uA(t)}function hgs(t,s){if(t==null)return{};var r=mgs(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 mgs(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 Dce(){return Dce=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(ie)0&&Math.abs(Q)0&&(ee=Math.min((Me||0)-(Q[Ne-1]||0),ee))}),Number.isFinite(ee)){var ie=ee/X,re=j.layout==="vertical"?n.height:n.width;if(j.padding==="gap"&&(q=ie*re/2),j.padding==="no-gap"){var oe=Am(s.barCategoryGap,ie*re),ce=ie*re/2;q=ce-oe-(ce-oe)/re*oe}}}a==="xAxis"?U=[n.left+(M.left||0)+(q||0),n.left+n.width-(M.right||0)-(q||0)]:a==="yAxis"?U=c==="horizontal"?[n.top+n.height-(M.bottom||0),n.top+(M.top||0)]:[n.top+(M.top||0)+(q||0),n.top+n.height-(M.bottom||0)-(q||0)]:U=j.range,I&&(U=[U[1],U[0]]);var xe=Jrt(j,o,g),ge=xe.scale,ue=xe.realScaleType;ge.domain(k).range(U),ent(ge);var pe=tnt(ge,Fg(Fg({},j),{},{realScaleType:ue}));a==="xAxis"?(Z=w==="top"&&!L||w==="bottom"&&L,B=n.left,V=f[O]-Z*j.height):a==="yAxis"&&(Z=w==="left"&&!L||w==="right"&&L,B=f[O]-Z*j.width,V=n.top);var be=Fg(Fg(Fg({},j),pe),{},{realScaleType:ue,x:B,y:V,scale:ge,width:a==="xAxis"?n.width:j.width,height:a==="yAxis"?n.height:j.height});return be.bandSize=vce(be,pe),!j.hide&&a==="xAxis"?f[O]+=(Z?-1:1)*be.height:j.hide||(f[O]+=(Z?-1:1)*be.width),Fg(Fg({},b),{},Ohe({},_,be))},{})},Fnt=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)}},Ngs=function(s){var r=s.x1,n=s.y1,a=s.x2,o=s.y2;return Fnt({x:r,y:n},{x:a,y:o})},znt=function(){function t(s){_gs(this,t),this.scale=s}return wgs(t,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.bandAware,o=n.position;if(r!==void 0){if(o)switch(o){case"start":return this.scale(r);case"middle":{var l=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+l}case"end":{var i=this.bandwidth?this.bandwidth():0;return this.scale(r)+i}default:return this.scale(r)}if(a){var c=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+c}return this.scale(r)}}},{key:"isInRange",value:function(r){var n=this.range(),a=n[0],o=n[n.length-1];return a<=o?r>=a&&r<=o:r>=o&&r<=a}}],[{key:"create",value:function(r){return new t(r)}}])}();Ohe(znt,"EPS",1e-4);var G4e=function(s){var r=Object.keys(s).reduce(function(n,a){return Fg(Fg({},n),{},Ohe({},a,znt.create(s[a])))},{});return Fg(Fg({},r),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return Vxs(a,function(c,u){return r[u].apply(c,{bandAware:l,position:i})})},isInRange:function(a){return Pnt(a,function(o,l){return r[l].isInRange(o)})}})};function kgs(t){return(t%180+180)%180}var Sgs=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=kgs(a),l=o*Math.PI/180,i=Math.atan(n/r),c=l>i&&l-1?a[o?s[l]:l]:void 0}}var Egs=Ags,Pgs=Mnt;function Igs(t){var s=Pgs(t),r=s%1;return s===s?r?s-r:s:0}var Lgs=Igs,Dgs=Ist,Ogs=$0,Rgs=Lgs,Fgs=Math.max;function zgs(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:Rgs(r);return a<0&&(a=Fgs(n+a,0)),Dgs(t,Ogs(s),a)}var Bgs=zgs,$gs=Egs,qgs=Bgs,Ugs=$gs(qgs),Vgs=Ugs;const Hgs=Po(Vgs);var Wgs=$Kt(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("")}),K4e=N.createContext(void 0),Z4e=N.createContext(void 0),Bnt=N.createContext(void 0),$nt=N.createContext({}),qnt=N.createContext(void 0),Unt=N.createContext(0),Vnt=N.createContext(0),cFe=function(s){var r=s.state,n=r.xAxisMap,a=r.yAxisMap,o=r.offset,l=s.clipPathId,i=s.children,c=s.width,u=s.height,p=Wgs(o);return ht.createElement(K4e.Provider,{value:n},ht.createElement(Z4e.Provider,{value:a},ht.createElement($nt.Provider,{value:o},ht.createElement(Bnt.Provider,{value:p},ht.createElement(qnt.Provider,{value:l},ht.createElement(Unt.Provider,{value:u},ht.createElement(Vnt.Provider,{value:c},i)))))))},Ggs=function(){return N.useContext(qnt)},Hnt=function(s){var r=N.useContext(K4e);r==null&&rC();var n=r[s];return n==null&&rC(),n},Kgs=function(){var s=N.useContext(K4e);return o_(s)},Zgs=function(){var s=N.useContext(Z4e),r=Hgs(s,function(n){return Pnt(n.domain,Number.isFinite)});return r||o_(s)},Wnt=function(s){var r=N.useContext(Z4e);r==null&&rC();var n=r[s];return n==null&&rC(),n},Ygs=function(){var s=N.useContext(Bnt);return s},Xgs=function(){return N.useContext($nt)},Y4e=function(){return N.useContext(Vnt)},X4e=function(){return N.useContext(Unt)};function hA(t){"@babel/helpers - typeof";return hA=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},hA(t)}function Qgs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Jgs(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 Lys(t,s){return Jnt(t,s+1)}function Dys(t,s,r,n,a){for(var o=(n||[]).slice(),l=s.start,i=s.end,c=0,u=1,p=l,f=function(){var _=n==null?void 0:n[c];if(_===void 0)return{v:Jnt(n,u)};var j=c,w,k=function(){return w===void 0&&(w=r(_,j)),w},S=_.coordinate,M=c===0||Bce(t,S,k,p,i);M||(c=0,p=l,u+=1),M&&(p=S+t*(k()/2+a),c+=u)},g;u<=o.length;)if(g=f(),g)return g.v;return[]}function JD(t){"@babel/helpers - typeof";return JD=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},JD(t)}function gFe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function $h(t){for(var s=1;s0?b.coordinate-w*t:b.coordinate})}else o[g]=b=$h($h({},b),{},{tickCoord:b.coordinate});var k=Bce(t,b.tickCoord,j,i,c);k&&(c=b.tickCoord-t*(j()/2+a),o[g]=$h($h({},b),{},{isShow:!0}))},p=l-1;p>=0;p--)u(p);return o}function Bys(t,s,r,n,a,o){var l=(n||[]).slice(),i=l.length,c=s.start,u=s.end;if(o){var p=n[i-1],f=r(p,i-1),g=t*(p.coordinate+t*f/2-u);l[i-1]=p=$h($h({},p),{},{tickCoord:g>0?p.coordinate-g*t:p.coordinate});var b=Bce(t,p.tickCoord,function(){return f},c,u);b&&(u=p.tickCoord-t*(f/2+a),l[i-1]=$h($h({},p),{},{isShow:!0}))}for(var _=o?i-1:i,j=function(S){var M=l[S],L,I=function(){return L===void 0&&(L=r(M,S)),L};if(S===0){var O=t*(M.coordinate-t*I()/2-c);l[S]=M=$h($h({},M),{},{tickCoord:O<0?M.coordinate-O*t:M.coordinate})}else l[S]=M=$h($h({},M),{},{tickCoord:M.coordinate});var q=Bce(t,M.tickCoord,I,c,u);q&&(c=M.tickCoord+t*(I()/2+a),l[S]=$h($h({},M),{},{isShow:!0}))},w=0;w<_;w++)j(w);return l}function eSe(t,s,r){var n=t.tick,a=t.ticks,o=t.viewBox,l=t.minTickGap,i=t.orientation,c=t.interval,u=t.tickFormatter,p=t.unit,f=t.angle;if(!a||!a.length||!n)return[];if(ln(c)||wC.isSsr)return Lys(a,typeof c=="number"&&ln(c)?c:0);var g=[],b=i==="top"||i==="bottom"?"width":"height",_=p&&b==="width"?u8(p,{fontSize:s,letterSpacing:r}):{width:0,height:0},j=function(M,L){var I=Mi(u)?u(M.value,L):M.value;return b==="width"?Pys(u8(I,{fontSize:s,letterSpacing:r}),_,f):u8(I,{fontSize:s,letterSpacing:r})[b]},w=a.length>=2?Tm(a[1].coordinate-a[0].coordinate):1,k=Iys(o,w,b);return c==="equidistantPreserveStart"?Dys(w,k,j,a,l):(c==="preserveStart"||c==="preserveStartEnd"?g=Bys(w,k,j,a,l,c==="preserveStartEnd"):g=zys(w,k,j,a,l),g.filter(function(S){return S.isShow}))}var $ys=["viewBox"],qys=["viewBox"],Uys=["ticks"];function fA(t){"@babel/helpers - typeof";return fA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},fA(t)}function pM(){return pM=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 Vys(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 Hys(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function vFe(t,s){for(var r=0;r0?c(this.props):c(b)),l<=0||i<=0||!_||!_.length?null:ht.createElement(Zo,{className:Vi("recharts-cartesian-axis",u),ref:function(w){n.layerReference=w}},o&&this.renderAxisLine(),this.renderTicks(_,this.state.fontSize,this.state.letterSpacing),Yu.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,o){var l,i=Vi(a.className,"recharts-cartesian-axis-tick-value");return ht.isValidElement(n)?l=ht.cloneElement(n,uu(uu({},a),{},{className:i})):Mi(n)?l=n(uu(uu({},a),{},{className:i})):l=ht.createElement(tC,pM({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(N.Component);tSe(jE,"displayName","CartesianAxis");tSe(jE,"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 Qys=["x1","y1","x2","y2","key"],Jys=["offset"];function nC(t){"@babel/helpers - typeof";return nC=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},nC(t)}function bFe(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 Vh(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function r0s(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 n0s=function(s){var r=s.fill;if(!r||r==="none")return null;var n=s.fillOpacity,a=s.x,o=s.y,l=s.width,i=s.height,c=s.ry;return ht.createElement("rect",{x:a,y:o,ry:c,width:l,height:i,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function sat(t,s){var r;if(ht.isValidElement(t))r=ht.cloneElement(t,s);else if(Mi(t))r=t(s);else{var n=s.x1,a=s.y1,o=s.x2,l=s.y2,i=s.key,c=_Fe(s,Qys),u=ai(c,!1);u.offset;var p=_Fe(u,Jys);r=ht.createElement("line",T4({},p,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function a0s(t){var s=t.x,r=t.width,n=t.horizontal,a=n===void 0?!0:n,o=t.horizontalPoints;if(!a||!o||!o.length)return null;var l=o.map(function(i,c){var u=Vh(Vh({},t),{},{x1:s,y1:i,x2:s+r,y2:i,key:"line-".concat(c),index:c});return sat(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function i0s(t){var s=t.y,r=t.height,n=t.vertical,a=n===void 0?!0:n,o=t.verticalPoints;if(!a||!o||!o.length)return null;var l=o.map(function(i,c){var u=Vh(Vh({},t),{},{x1:i,y1:s,x2:i,y2:s+r,key:"line-".concat(c),index:c});return sat(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function o0s(t){var s=t.horizontalFill,r=t.fillOpacity,n=t.x,a=t.y,o=t.width,l=t.height,i=t.horizontalPoints,c=t.horizontal,u=c===void 0?!0:c;if(!u||!s||!s.length)return null;var p=i.map(function(g){return Math.round(g+a-a)}).sort(function(g,b){return g-b});a!==p[0]&&p.unshift(0);var f=p.map(function(g,b){var _=!p[b+1],j=_?a+l-g:p[b+1]-g;if(j<=0)return null;var w=b%s.length;return ht.createElement("rect",{key:"react-".concat(b),y:g,x:n,height:j,width:o,stroke:"none",fill:s[w],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},f)}function l0s(t){var s=t.vertical,r=s===void 0?!0:s,n=t.verticalFill,a=t.fillOpacity,o=t.x,l=t.y,i=t.width,c=t.height,u=t.verticalPoints;if(!r||!n||!n.length)return null;var p=u.map(function(g){return Math.round(g+o-o)}).sort(function(g,b){return g-b});o!==p[0]&&p.unshift(0);var f=p.map(function(g,b){var _=!p[b+1],j=_?o+i-g:p[b+1]-g;if(j<=0)return null;var w=b%n.length;return ht.createElement("rect",{key:"react-".concat(b),x:g,y:l,width:j,height:c,stroke:"none",fill:n[w],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},f)}var c0s=function(s,r){var n=s.xAxis,a=s.width,o=s.height,l=s.offset;return Qrt(eSe(Vh(Vh(Vh({},jE.defaultProps),n),{},{ticks:Qv(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,r)},d0s=function(s,r){var n=s.yAxis,a=s.width,o=s.height,l=s.offset;return Qrt(eSe(Vh(Vh(Vh({},jE.defaultProps),n),{},{ticks:Qv(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,r)},A5={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function rat(t){var s,r,n,a,o,l,i=Y4e(),c=X4e(),u=Xgs(),p=Vh(Vh({},t),{},{stroke:(s=t.stroke)!==null&&s!==void 0?s:A5.stroke,fill:(r=t.fill)!==null&&r!==void 0?r:A5.fill,horizontal:(n=t.horizontal)!==null&&n!==void 0?n:A5.horizontal,horizontalFill:(a=t.horizontalFill)!==null&&a!==void 0?a:A5.horizontalFill,vertical:(o=t.vertical)!==null&&o!==void 0?o:A5.vertical,verticalFill:(l=t.verticalFill)!==null&&l!==void 0?l:A5.verticalFill,x:ln(t.x)?t.x:u.left,y:ln(t.y)?t.y:u.top,width:ln(t.width)?t.width:u.width,height:ln(t.height)?t.height:u.height}),f=p.x,g=p.y,b=p.width,_=p.height,j=p.syncWithTicks,w=p.horizontalValues,k=p.verticalValues,S=Kgs(),M=Zgs();if(!ln(b)||b<=0||!ln(_)||_<=0||!ln(f)||f!==+f||!ln(g)||g!==+g)return null;var L=p.verticalCoordinatesGenerator||c0s,I=p.horizontalCoordinatesGenerator||d0s,O=p.horizontalPoints,q=p.verticalPoints;if((!O||!O.length)&&Mi(I)){var U=w&&w.length,B=I({yAxis:M?Vh(Vh({},M),{},{ticks:U?w:M.ticks}):void 0,width:i,height:c,offset:u},U?!0:j);sy(Array.isArray(B),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(nC(B),"]")),Array.isArray(B)&&(O=B)}if((!q||!q.length)&&Mi(L)){var V=k&&k.length,Z=L({xAxis:S?Vh(Vh({},S),{},{ticks:V?k:S.ticks}):void 0,width:i,height:c,offset:u},V?!0:j);sy(Array.isArray(Z),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(nC(Z),"]")),Array.isArray(Z)&&(q=Z)}return ht.createElement("g",{className:"recharts-cartesian-grid"},ht.createElement(n0s,{fill:p.fill,fillOpacity:p.fillOpacity,x:p.x,y:p.y,width:p.width,height:p.height,ry:p.ry}),ht.createElement(a0s,T4({},p,{offset:u,horizontalPoints:O,xAxis:S,yAxis:M})),ht.createElement(i0s,T4({},p,{offset:u,verticalPoints:q,xAxis:S,yAxis:M})),ht.createElement(o0s,T4({},p,{horizontalPoints:O})),ht.createElement(l0s,T4({},p,{verticalPoints:q})))}rat.displayName="CartesianGrid";var u0s=["type","layout","connectNulls","ref"],h0s=["key"];function xA(t){"@babel/helpers - typeof";return xA=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},xA(t)}function wFe(t,s){if(t==null)return{};var r=m0s(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 m0s(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function g8(){return g8=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);rf){b=[].concat(E5(c.slice(0,_)),[f-j]);break}var w=b.length%2===0?[0,g]:[g];return[].concat(E5(s.repeat(c,p)),E5(b),w).map(function(k){return"".concat(k,"px")}).join(", ")}),zg(r,"id",xE("recharts-line-")),zg(r,"pathRef",function(l){r.mainCurve=l}),zg(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),zg(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return j0s(s,t),v0s(s,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();this.setState({totalLength:n})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();n!==this.state.totalLength&&this.setState({totalLength:n})}}},{key:"getTotalLength",value:function(){var n=this.mainCurve;try{return n&&n.getTotalLength&&n.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(n,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,l=o.points,i=o.xAxis,c=o.yAxis,u=o.layout,p=o.children,f=jf(p,hR);if(!f)return null;var g=function(j,w){return{x:j.x,y:j.y,value:j.value,errorVal:_u(j.payload,w)}},b={clipPath:n?"url(#clipPath-".concat(a,")"):null};return ht.createElement(Zo,b,f.map(function(_){return ht.cloneElement(_,{key:"bar-".concat(_.props.dataKey),data:l,xAxis:i,yAxis:c,layout:u,dataPointFormatter:g})}))}},{key:"renderDots",value:function(n,a,o){var l=this.props.isAnimationActive;if(l&&!this.state.isAnimationFinished)return null;var i=this.props,c=i.dot,u=i.points,p=i.dataKey,f=ai(this.props,!1),g=ai(c,!0),b=u.map(function(j,w){var k=Qp(Qp(Qp({key:"dot-".concat(w),r:3},f),g),{},{index:w,cx:j.x,cy:j.y,value:j.value,dataKey:p,payload:j.payload,points:u});return s.renderDotItem(c,k)}),_={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return ht.createElement(Zo,g8({className:"recharts-line-dots",key:"dots"},_),b)}},{key:"renderCurveStatically",value:function(n,a,o,l){var i=this.props,c=i.type,u=i.layout,p=i.connectNulls;i.ref;var f=wFe(i,u0s),g=Qp(Qp(Qp({},ai(f,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(o,")"):null,points:n},l),{},{type:c,layout:u,connectNulls:p});return ht.createElement(wce,g8({},g,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,a){var o=this,l=this.props,i=l.points,c=l.strokeDasharray,u=l.isAnimationActive,p=l.animationBegin,f=l.animationDuration,g=l.animationEasing,b=l.animationId,_=l.animateNewValues,j=l.width,w=l.height,k=this.state,S=k.prevPoints,M=k.totalLength;return ht.createElement(I0,{begin:p,duration:f,isActive:u,easing:g,from:{t:0},to:{t:1},key:"line-".concat(b),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(L){var I=L.t;if(S){var O=S.length/i.length,q=i.map(function(X,ee){var Q=Math.floor(ee*O);if(S[Q]){var ie=S[Q],re=nf(ie.x,X.x),oe=nf(ie.y,X.y);return Qp(Qp({},X),{},{x:re(I),y:oe(I)})}if(_){var ce=nf(j*2,X.x),xe=nf(w/2,X.y);return Qp(Qp({},X),{},{x:ce(I),y:xe(I)})}return Qp(Qp({},X),{},{x:X.x,y:X.y})});return o.renderCurveStatically(q,n,a)}var U=nf(0,M),B=U(I),V;if(c){var Z="".concat(c).split(/[,\s]+/gim).map(function(X){return parseFloat(X)});V=o.getStrokeDasharray(B,M,Z)}else V=o.generateSimpleStrokeDasharray(M,B);return o.renderCurveStatically(i,n,a,{strokeDasharray:V})})}},{key:"renderCurve",value:function(n,a){var o=this.props,l=o.points,i=o.isAnimationActive,c=this.state,u=c.prevPoints,p=c.totalLength;return i&&l&&l.length&&(!u&&p>0||!uR(u,l))?this.renderCurveWithAnimation(n,a):this.renderCurveStatically(l,n,a)}},{key:"render",value:function(){var n,a=this.props,o=a.hide,l=a.dot,i=a.points,c=a.className,u=a.xAxis,p=a.yAxis,f=a.top,g=a.left,b=a.width,_=a.height,j=a.isAnimationActive,w=a.id;if(o||!i||!i.length)return null;var k=this.state.isAnimationFinished,S=i.length===1,M=Vi("recharts-line",c),L=u&&u.allowDataOverflow,I=p&&p.allowDataOverflow,O=L||I,q=$i(w)?this.id:w,U=(n=ai(l,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},B=U.r,V=B===void 0?3:B,Z=U.strokeWidth,X=Z===void 0?2:Z,ee=GZt(l)?l:{},Q=ee.clipDot,ie=Q===void 0?!0:Q,re=V*2+X;return ht.createElement(Zo,{className:M},L||I?ht.createElement("defs",null,ht.createElement("clipPath",{id:"clipPath-".concat(q)},ht.createElement("rect",{x:L?g:g-b/2,y:I?f:f-_/2,width:L?b:b*2,height:I?_:_*2})),!ie&&ht.createElement("clipPath",{id:"clipPath-dots-".concat(q)},ht.createElement("rect",{x:g-re/2,y:f-re/2,width:b+re,height:_+re}))):null,!S&&this.renderCurve(O,q),this.renderErrorBar(O,q),(S||l)&&this.renderDots(O,ie,q),(!j||k)&&v1.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:a.curPoints}:n.points!==a.curPoints?{curPoints:n.points}:null}},{key:"repeat",value:function(n,a){for(var o=n.length%2!==0?[].concat(E5(n),[0]):n,l=[],i=0;it.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function hvs(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 mvs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function pvs(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r0?l:s&&s.length&&ln(a)&&ln(o)?s.slice(a,o+1):[]};function vat(t){return t==="number"?[0,"auto"]:void 0}var F_e=function(s,r,n,a){var o=s.graphicalItems,l=s.tooltipAxis,i=$he(r,s);return n<0||!o||!o.length||n>=i.length?null:o.reduce(function(c,u){var p,f=(p=u.props.data)!==null&&p!==void 0?p:r;f&&s.dataStartIndex+s.dataEndIndex!==0&&s.dataEndIndex-s.dataStartIndex>=n&&(f=f.slice(s.dataStartIndex,s.dataEndIndex+1));var g;if(l.dataKey&&!l.allowDuplicatedCategory){var b=f===void 0?i:f;g=Hle(b,l.dataKey,a)}else g=f&&f[n]||i[n];return g?[].concat(bA(c),[rnt(u,g)]):c},[])},AFe=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=Svs(o,n),i=s.orderedTooltipTicks,c=s.tooltipAxis,u=s.tooltipTicks,p=Kds(l,i,u,c);if(p>=0&&u){var f=u[p]&&u[p].value,g=F_e(s,r,p,f),b=Cvs(n,i,p,o);return{activeTooltipIndex:p,activeLabel:f,activePayload:g,activeCoordinate:b}}return null},Mvs=function(s,r){var n=r.axes,a=r.graphicalItems,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,p=s.layout,f=s.children,g=s.stackOffset,b=Xrt(p,o);return n.reduce(function(_,j){var w,k=j.type.defaultProps!==void 0?wr(wr({},j.type.defaultProps),j.props):j.props,S=k.type,M=k.dataKey,L=k.allowDataOverflow,I=k.allowDuplicatedCategory,O=k.scale,q=k.ticks,U=k.includeHidden,B=k[l];if(_[B])return _;var V=$he(s.data,{graphicalItems:a.filter(function(pe){var be,Me=l in pe.props?pe.props[l]:(be=pe.type.defaultProps)===null||be===void 0?void 0:be[l];return Me===B}),dataStartIndex:c,dataEndIndex:u}),Z=V.length,X,ee,Q;evs(k.domain,L,S)&&(X=Qbe(k.domain,null,L),b&&(S==="number"||O!=="auto")&&(Q=m8(V,M,"category")));var ie=vat(S);if(!X||X.length===0){var re,oe=(re=k.domain)!==null&&re!==void 0?re:ie;if(M){if(X=m8(V,M,S),S==="category"&&b){var ce=RZt(X);I&&ce?(ee=X,X=Pce(0,Z)):I||(X=QOe(oe,X,j).reduce(function(pe,be){return pe.indexOf(be)>=0?pe:[].concat(bA(pe),[be])},[]))}else if(S==="category")I?X=X.filter(function(pe){return pe!==""&&!$i(pe)}):X=QOe(oe,X,j).reduce(function(pe,be){return pe.indexOf(be)>=0||be===""||$i(be)?pe:[].concat(bA(pe),[be])},[]);else if(S==="number"){var xe=Jds(V,a.filter(function(pe){var be,Me,Ne=l in pe.props?pe.props[l]:(be=pe.type.defaultProps)===null||be===void 0?void 0:be[l],Pe="hide"in pe.props?pe.props.hide:(Me=pe.type.defaultProps)===null||Me===void 0?void 0:Me.hide;return Ne===B&&(U||!Pe)}),M,o,p);xe&&(X=xe)}b&&(S==="number"||O!=="auto")&&(Q=m8(V,M,"category"))}else b?X=Pce(0,Z):i&&i[B]&&i[B].hasStack&&S==="number"?X=g==="expand"?[0,1]:snt(i[B].stackGroups,c,u):X=Yrt(V,a.filter(function(pe){var be=l in pe.props?pe.props[l]:pe.type.defaultProps[l],Me="hide"in pe.props?pe.props.hide:pe.type.defaultProps.hide;return be===B&&(U||!Me)}),S,p,!0);if(S==="number")X=D_e(f,X,B,o,q),oe&&(X=Qbe(oe,X,L));else if(S==="category"&&oe){var ge=oe,ue=X.every(function(pe){return ge.indexOf(pe)>=0});ue&&(X=ge)}}return wr(wr({},_),{},mi({},B,wr(wr({},k),{},{axisType:o,domain:X,categoricalDomain:Q,duplicateDomain:ee,originalDomain:(w=k.domain)!==null&&w!==void 0?w:ie,isCategorical:b,layout:p})))},{})},Tvs=function(s,r){var n=r.graphicalItems,a=r.Axis,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,p=s.layout,f=s.children,g=$he(s.data,{graphicalItems:n,dataStartIndex:c,dataEndIndex:u}),b=g.length,_=Xrt(p,o),j=-1;return n.reduce(function(w,k){var S=k.type.defaultProps!==void 0?wr(wr({},k.type.defaultProps),k.props):k.props,M=S[l],L=vat("number");if(!w[M]){j++;var I;return _?I=Pce(0,b):i&&i[M]&&i[M].hasStack?(I=snt(i[M].stackGroups,c,u),I=D_e(f,I,M,o)):(I=Qbe(L,Yrt(g,n.filter(function(O){var q,U,B=l in O.props?O.props[l]:(q=O.type.defaultProps)===null||q===void 0?void 0:q[l],V="hide"in O.props?O.props.hide:(U=O.type.defaultProps)===null||U===void 0?void 0:U.hide;return B===M&&!V}),"number",p),a.defaultProps.allowDataOverflow),I=D_e(f,I,M,o)),wr(wr({},w),{},mi({},M,wr(wr({axisType:o},a.defaultProps),{},{hide:!0,orientation:wf(Nvs,"".concat(o,".").concat(j%2),null),domain:I,originalDomain:L,isCategorical:_,layout:p})))}return w},{})},Avs=function(s,r){var n=r.axisType,a=n===void 0?"xAxis":n,o=r.AxisComp,l=r.graphicalItems,i=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,p=s.children,f="".concat(a,"Id"),g=jf(p,o),b={};return g&&g.length?b=Mvs(s,{axes:g,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:c,dataEndIndex:u}):l&&l.length&&(b=Tvs(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:c,dataEndIndex:u})),b},Evs=function(s){var r=o_(s),n=Qv(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:v4e(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:vce(r,n)}},EFe=function(s){var r=s.children,n=s.defaultShowTooltip,a=tf(r,dA),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}},Pvs=function(s){return!s||!s.length?!1:s.some(function(r){var n=g1(r&&r.type);return n&&n.indexOf("Bar")>=0})},PFe=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"}},Ivs=function(s,r){var n=s.props,a=s.graphicalItems,o=s.xAxisMap,l=o===void 0?{}:o,i=s.yAxisMap,c=i===void 0?{}:i,u=n.width,p=n.height,f=n.children,g=n.margin||{},b=tf(f,dA),_=tf(f,nT),j=Object.keys(c).reduce(function(I,O){var q=c[O],U=q.orientation;return!q.mirror&&!q.hide?wr(wr({},I),{},mi({},U,I[U]+q.width)):I},{left:g.left||0,right:g.right||0}),w=Object.keys(l).reduce(function(I,O){var q=l[O],U=q.orientation;return!q.mirror&&!q.hide?wr(wr({},I),{},mi({},U,wf(I,"".concat(U))+q.height)):I},{top:g.top||0,bottom:g.bottom||0}),k=wr(wr({},w),j),S=k.bottom;b&&(k.bottom+=b.props.height||dA.defaultProps.height),_&&r&&(k=Xds(k,a,n,r));var M=u-k.left-k.right,L=p-k.top-k.bottom;return wr(wr({brushBottom:S},k),{},{width:Math.max(M,0),height:Math.max(L,0)})},Lvs=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},sSe=function(s){var r=s.chartName,n=s.GraphicalChild,a=s.defaultTooltipEventType,o=a===void 0?"axis":a,l=s.validateTooltipEventTypes,i=l===void 0?["axis"]:l,c=s.axisComponents,u=s.legendContent,p=s.formatAxisMap,f=s.defaultProps,g=function(k,S){var M=S.graphicalItems,L=S.stackGroups,I=S.offset,O=S.updateId,q=S.dataStartIndex,U=S.dataEndIndex,B=k.barSize,V=k.layout,Z=k.barGap,X=k.barCategoryGap,ee=k.maxBarSize,Q=PFe(V),ie=Q.numericAxisName,re=Q.cateAxisName,oe=Pvs(M),ce=[];return M.forEach(function(xe,ge){var ue=$he(k.data,{graphicalItems:[xe],dataStartIndex:q,dataEndIndex:U}),pe=xe.type.defaultProps!==void 0?wr(wr({},xe.type.defaultProps),xe.props):xe.props,be=pe.dataKey,Me=pe.maxBarSize,Ne=pe["".concat(ie,"Id")],Pe=pe["".concat(re,"Id")],Oe={},Te=c.reduce(function(ct,qe){var Ze=S["".concat(qe.axisType,"Map")],Qe=pe["".concat(qe.axisType,"Id")];Ze&&Ze[Qe]||qe.axisType==="zAxis"||rC();var He=Ze[Qe];return wr(wr({},ct),{},mi(mi({},qe.axisType,He),"".concat(qe.axisType,"Ticks"),Qv(He)))},Oe),ke=Te[re],Be=Te["".concat(re,"Ticks")],nt=L&&L[Ne]&&L[Ne].hasStack&&lus(xe,L[Ne].stackGroups),Ae=g1(xe.type).indexOf("Bar")>=0,ft=vce(ke,Be),fe=[],Ve=oe&&Zds({barSize:B,stackGroups:L,totalSize:Lvs(Te,re)});if(Ae){var at,et,Ce=$i(Me)?ee:Me,rt=(at=(et=vce(ke,Be,!0))!==null&&et!==void 0?et:Ce)!==null&&at!==void 0?at:0;fe=Yds({barGap:Z,barCategoryGap:X,bandSize:rt!==ft?rt:ft,sizeList:Ve[Pe],maxBarSize:Ce}),rt!==ft&&(fe=fe.map(function(ct){return wr(wr({},ct),{},{position:wr(wr({},ct.position),{},{offset:ct.position.offset-rt/2})})}))}var Ge=xe&&xe.type&&xe.type.getComposedData;Ge&&ce.push({props:wr(wr({},Ge(wr(wr({},Te),{},{displayedData:ue,props:k,dataKey:be,item:xe,bandSize:ft,barPosition:fe,offset:I,stackedData:nt,layout:V,dataStartIndex:q,dataEndIndex:U}))),{},mi(mi(mi({key:xe.key||"item-".concat(ge)},ie,Te[ie]),re,Te[re]),"animationId",O)),childIndex:YZt(xe,k.children),item:xe})}),ce},b=function(k,S){var M=k.props,L=k.dataStartIndex,I=k.dataEndIndex,O=k.updateId;if(!H8e({props:M}))return null;var q=M.children,U=M.layout,B=M.stackOffset,V=M.data,Z=M.reverseStackOrder,X=PFe(U),ee=X.numericAxisName,Q=X.cateAxisName,ie=jf(q,n),re=ius(V,ie,"".concat(ee,"Id"),"".concat(Q,"Id"),B,Z),oe=c.reduce(function(pe,be){var Me="".concat(be.axisType,"Map");return wr(wr({},pe),{},mi({},Me,Avs(M,wr(wr({},be),{},{graphicalItems:ie,stackGroups:be.axisType===ee&&re,dataStartIndex:L,dataEndIndex:I}))))},{}),ce=Ivs(wr(wr({},oe),{},{props:M,graphicalItems:ie}),S==null?void 0:S.legendBBox);Object.keys(oe).forEach(function(pe){oe[pe]=p(M,oe[pe],ce,pe.replace("Map",""),r)});var xe=oe["".concat(Q,"Map")],ge=Evs(xe),ue=g(M,wr(wr({},oe),{},{dataStartIndex:L,dataEndIndex:I,updateId:O,graphicalItems:ie,stackGroups:re,offset:ce}));return wr(wr({formattedGraphicalItems:ue,graphicalItems:ie,offset:ce,stackGroups:re},ge),oe)},_=function(w){function k(S){var M,L,I;return mvs(this,k),I=xvs(this,k,[S]),mi(I,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),mi(I,"accessibilityManager",new J0s),mi(I,"handleLegendBBoxUpdate",function(O){if(O){var q=I.state,U=q.dataStartIndex,B=q.dataEndIndex,V=q.updateId;I.setState(wr({legendBBox:O},b({props:I.props,dataStartIndex:U,dataEndIndex:B,updateId:V},wr(wr({},I.state),{},{legendBBox:O}))))}}),mi(I,"handleReceiveSyncEvent",function(O,q,U){if(I.props.syncId===O){if(U===I.eventEmitterSymbol&&typeof I.props.syncMethod!="function")return;I.applySyncEvent(q)}}),mi(I,"handleBrushChange",function(O){var q=O.startIndex,U=O.endIndex;if(q!==I.state.dataStartIndex||U!==I.state.dataEndIndex){var B=I.state.updateId;I.setState(function(){return wr({dataStartIndex:q,dataEndIndex:U},b({props:I.props,dataStartIndex:q,dataEndIndex:U,updateId:B},I.state))}),I.triggerSyncEvent({dataStartIndex:q,dataEndIndex:U})}}),mi(I,"handleMouseEnter",function(O){var q=I.getMouseInfo(O);if(q){var U=wr(wr({},q),{},{isTooltipActive:!0});I.setState(U),I.triggerSyncEvent(U);var B=I.props.onMouseEnter;Mi(B)&&B(U,O)}}),mi(I,"triggeredAfterMouseMove",function(O){var q=I.getMouseInfo(O),U=q?wr(wr({},q),{},{isTooltipActive:!0}):{isTooltipActive:!1};I.setState(U),I.triggerSyncEvent(U);var B=I.props.onMouseMove;Mi(B)&&B(U,O)}),mi(I,"handleItemMouseEnter",function(O){I.setState(function(){return{isTooltipActive:!0,activeItem:O,activePayload:O.tooltipPayload,activeCoordinate:O.tooltipPosition||{x:O.cx,y:O.cy}}})}),mi(I,"handleItemMouseLeave",function(){I.setState(function(){return{isTooltipActive:!1}})}),mi(I,"handleMouseMove",function(O){O.persist(),I.throttleTriggeredAfterMouseMove(O)}),mi(I,"handleMouseLeave",function(O){I.throttleTriggeredAfterMouseMove.cancel();var q={isTooltipActive:!1};I.setState(q),I.triggerSyncEvent(q);var U=I.props.onMouseLeave;Mi(U)&&U(q,O)}),mi(I,"handleOuterEvent",function(O){var q=ZZt(O),U=wf(I.props,"".concat(q));if(q&&Mi(U)){var B,V;/.*touch.*/i.test(q)?V=I.getMouseInfo(O.changedTouches[0]):V=I.getMouseInfo(O),U((B=V)!==null&&B!==void 0?B:{},O)}}),mi(I,"handleClick",function(O){var q=I.getMouseInfo(O);if(q){var U=wr(wr({},q),{},{isTooltipActive:!0});I.setState(U),I.triggerSyncEvent(U);var B=I.props.onClick;Mi(B)&&B(U,O)}}),mi(I,"handleMouseDown",function(O){var q=I.props.onMouseDown;if(Mi(q)){var U=I.getMouseInfo(O);q(U,O)}}),mi(I,"handleMouseUp",function(O){var q=I.props.onMouseUp;if(Mi(q)){var U=I.getMouseInfo(O);q(U,O)}}),mi(I,"handleTouchMove",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&I.throttleTriggeredAfterMouseMove(O.changedTouches[0])}),mi(I,"handleTouchStart",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&I.handleMouseDown(O.changedTouches[0])}),mi(I,"handleTouchEnd",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&I.handleMouseUp(O.changedTouches[0])}),mi(I,"handleDoubleClick",function(O){var q=I.props.onDoubleClick;if(Mi(q)){var U=I.getMouseInfo(O);q(U,O)}}),mi(I,"handleContextMenu",function(O){var q=I.props.onContextMenu;if(Mi(q)){var U=I.getMouseInfo(O);q(U,O)}}),mi(I,"triggerSyncEvent",function(O){I.props.syncId!==void 0&&dye.emit(uye,I.props.syncId,O,I.eventEmitterSymbol)}),mi(I,"applySyncEvent",function(O){var q=I.props,U=q.layout,B=q.syncMethod,V=I.state.updateId,Z=O.dataStartIndex,X=O.dataEndIndex;if(O.dataStartIndex!==void 0||O.dataEndIndex!==void 0)I.setState(wr({dataStartIndex:Z,dataEndIndex:X},b({props:I.props,dataStartIndex:Z,dataEndIndex:X,updateId:V},I.state)));else if(O.activeTooltipIndex!==void 0){var ee=O.chartX,Q=O.chartY,ie=O.activeTooltipIndex,re=I.state,oe=re.offset,ce=re.tooltipTicks;if(!oe)return;if(typeof B=="function")ie=B(ce,O);else if(B==="value"){ie=-1;for(var xe=0;xe=0){var nt,Ae;if(ee.dataKey&&!ee.allowDuplicatedCategory){var ft=typeof ee.dataKey=="function"?Be:"payload.".concat(ee.dataKey.toString());nt=Hle(xe,ft,ie),Ae=ge&&ue&&Hle(ue,ft,ie)}else nt=xe==null?void 0:xe[Q],Ae=ge&&ue&&ue[Q];if(Pe||Ne){var fe=O.props.activeIndex!==void 0?O.props.activeIndex:Q;return[N.cloneElement(O,wr(wr(wr({},B.props),Te),{},{activeIndex:fe})),null,null]}if(!$i(nt))return[ke].concat(bA(I.renderActivePoints({item:B,activePoint:nt,basePoint:Ae,childIndex:Q,isRange:ge})))}else{var Ve,at=(Ve=I.getItemByXY(I.state.activeCoordinate))!==null&&Ve!==void 0?Ve:{graphicalItem:ke},et=at.graphicalItem,Ce=et.item,rt=Ce===void 0?O:Ce,Ge=et.childIndex,ct=wr(wr(wr({},B.props),Te),{},{activeIndex:Ge});return[N.cloneElement(rt,ct),null,null]}return ge?[ke,null,null]:[ke,null]}),mi(I,"renderCustomized",function(O,q,U){return N.cloneElement(O,wr(wr({key:"recharts-customized-".concat(U)},I.props),I.state))}),mi(I,"renderMap",{CartesianGrid:{handler:$z,once:!0},ReferenceArea:{handler:I.renderReferenceElement},ReferenceLine:{handler:$z},ReferenceDot:{handler:I.renderReferenceElement},XAxis:{handler:$z},YAxis:{handler:$z},Brush:{handler:I.renderBrush,once:!0},Bar:{handler:I.renderGraphicChild},Line:{handler:I.renderGraphicChild},Area:{handler:I.renderGraphicChild},Radar:{handler:I.renderGraphicChild},RadialBar:{handler:I.renderGraphicChild},Scatter:{handler:I.renderGraphicChild},Pie:{handler:I.renderGraphicChild},Funnel:{handler:I.renderGraphicChild},Tooltip:{handler:I.renderCursor,once:!0},PolarGrid:{handler:I.renderPolarGrid,once:!0},PolarAngleAxis:{handler:I.renderPolarAxis},PolarRadiusAxis:{handler:I.renderPolarAxis},Customized:{handler:I.renderCustomized}}),I.clipPathId="".concat((M=S.id)!==null&&M!==void 0?M:xE("recharts"),"-clip"),I.throttleTriggeredAfterMouseMove=Gst(I.triggeredAfterMouseMove,(L=S.throttleDelay)!==null&&L!==void 0?L:1e3/60),I.state={},I}return vvs(k,w),fvs(k,[{key:"componentDidMount",value:function(){var M,L;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(M=this.props.margin.left)!==null&&M!==void 0?M:0,top:(L=this.props.margin.top)!==null&&L!==void 0?L:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var M=this.props,L=M.children,I=M.data,O=M.height,q=M.layout,U=tf(L,hp);if(U){var B=U.props.defaultIndex;if(!(typeof B!="number"||B<0||B>this.state.tooltipTicks.length-1)){var V=this.state.tooltipTicks[B]&&this.state.tooltipTicks[B].value,Z=F_e(this.state,I,B,V),X=this.state.tooltipTicks[B].coordinate,ee=(this.state.offset.top+O)/2,Q=q==="horizontal",ie=Q?{x:X,y:ee}:{y:X,x:ee},re=this.state.formattedGraphicalItems.find(function(ce){var xe=ce.item;return xe.type.name==="Scatter"});re&&(ie=wr(wr({},ie),re.props.points[B].tooltipPosition),Z=re.props.points[B].tooltipPayload);var oe={activeTooltipIndex:B,isTooltipActive:!0,activeLabel:V,activePayload:Z,activeCoordinate:ie};this.setState(oe),this.renderCursor(U),this.accessibilityManager.setIndex(B)}}}},{key:"getSnapshotBeforeUpdate",value:function(M,L){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==L.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==M.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==M.margin){var I,O;this.accessibilityManager.setDetails({offset:{left:(I=this.props.margin.left)!==null&&I!==void 0?I:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0}})}return null}},{key:"componentDidUpdate",value:function(M){mbe([tf(M.children,hp)],[tf(this.props.children,hp)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var M=tf(this.props.children,hp);if(M&&typeof M.props.shared=="boolean"){var L=M.props.shared?"axis":"item";return i.indexOf(L)>=0?L:o}return o}},{key:"getMouseInfo",value:function(M){if(!this.container)return null;var L=this.container,I=L.getBoundingClientRect(),O=wis(I),q={chartX:Math.round(M.pageX-O.left),chartY:Math.round(M.pageY-O.top)},U=I.width/L.offsetWidth||1,B=this.inRange(q.chartX,q.chartY,U);if(!B)return null;var V=this.state,Z=V.xAxisMap,X=V.yAxisMap,ee=this.getTooltipEventType(),Q=AFe(this.state,this.props.data,this.props.layout,B);if(ee!=="axis"&&Z&&X){var ie=o_(Z).scale,re=o_(X).scale,oe=ie&&ie.invert?ie.invert(q.chartX):null,ce=re&&re.invert?re.invert(q.chartY):null;return wr(wr({},q),{},{xValue:oe,yValue:ce},Q)}return Q?wr(wr({},q),Q):null}},{key:"inRange",value:function(M,L){var I=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,O=this.props.layout,q=M/I,U=L/I;if(O==="horizontal"||O==="vertical"){var B=this.state.offset,V=q>=B.left&&q<=B.left+B.width&&U>=B.top&&U<=B.top+B.height;return V?{x:q,y:U}:null}var Z=this.state,X=Z.angleAxisMap,ee=Z.radiusAxisMap;if(X&&ee){var Q=o_(X);return tRe({x:q,y:U},Q)}return null}},{key:"parseEventsOfWrapper",value:function(){var M=this.props.children,L=this.getTooltipEventType(),I=tf(M,hp),O={};I&&L==="axis"&&(I.props.trigger==="click"?O={onClick:this.handleClick}:O={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var q=Wle(this.props,this.handleOuterEvent);return wr(wr({},q),O)}},{key:"addListener",value:function(){dye.on(uye,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){dye.removeListener(uye,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(M,L,I){for(var O=this.state.formattedGraphicalItems,q=0,U=O.length;q{const{data:S,error:M}=await H.from("email_campaigns").select("*").eq("status","sent").order("sent_at",{ascending:!0});if(M)throw M;return S}}),{data:n}=mt({queryKey:["campaign-agent-profiles"],queryFn:async()=>{const{data:S,error:M}=await H.from("profiles").select("id, name, email");if(M)throw M;return S}});if(r)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading analytics..."});const a=s||[],o=new Map((n||[]).map(S=>[S.id,S])),l=a.reduce((S,M)=>S+(M.sent_count||0),0),i=a.reduce((S,M)=>S+(M.open_count||0),0),c=a.reduce((S,M)=>S+(M.click_count||0),0),u=a.reduce((S,M)=>S+(M.bounce_count||0),0),p=a.reduce((S,M)=>S+(M.complaint_count||0),0),f=l>0?(i/l*100).toFixed(1):"0.0",g=l>0?(c/l*100).toFixed(1):"0.0",b=[{label:"Campaigns Sent",value:a.length,icon:Bn,color:"text-foreground"},{label:"Total Emails Sent",value:l,icon:pr,color:"text-green-600"},{label:"Avg Open Rate",value:`${f}%`,icon:On,color:"text-blue-600"},{label:"Avg Click Rate",value:`${g}%`,icon:wh,color:"text-purple-600"},{label:"Total Bounces",value:u,icon:Ku,color:"text-orange-600"},{label:"Complaints",value:p,icon:ul,color:"text-destructive"}],_=new Map;a.forEach(S=>{var I,O;const M=S.user_id,L=_.get(M)||{name:((I=o.get(M))==null?void 0:I.name)||((O=o.get(M))==null?void 0:O.email)||"Unknown",campaigns:0,sent:0,opens:0,clicks:0};L.campaigns++,L.sent+=S.sent_count||0,L.opens+=S.open_count||0,L.clicks+=S.click_count||0,_.set(M,L)});const j=[..._.entries()].map(([S,M])=>({id:S,...M,openRate:M.sent>0?+(M.opens/M.sent*100).toFixed(1):0})).sort((S,M)=>M.sent-S.sent),w=j.slice(0,6).map(S=>({name:S.name,value:S.sent})),k=a.map(S=>{var M;return{name:S.name.length>20?S.name.slice(0,20)+"…":S.name,agent:((M=o.get(S.user_id))==null?void 0:M.name)||"Unknown",openRate:S.sent_count>0?+(S.open_count/S.sent_count*100).toFixed(1):0,clickRate:S.sent_count>0?+(S.click_count/S.sent_count*100).toFixed(1):0,sent:S.sent_count,date:S.sent_at?ms(new Date(S.sent_at),"MMM d"):""}});return e.jsx("div",{className:"space-y-6",children:a.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Bn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No campaigns sent yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Campaign analytics will appear here after the first send."})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:b.map(S=>e.jsx(Ee,{children:e.jsxs(De,{className:"p-4 text-center",children:[e.jsx(S.icon,{className:`h-5 w-5 mx-auto mb-1 ${S.color}`}),e.jsx("p",{className:"text-2xl font-bold",children:S.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.label})]})},S.label))}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Open & Click Rates by Campaign"})}),e.jsx(De,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(aT,{width:"100%",height:"100%",children:e.jsxs(bat,{data:k,children:[e.jsx(aC,{dataKey:"date",fontSize:11}),e.jsx(iC,{fontSize:11,unit:"%"}),e.jsx(hp,{formatter:S=>`${S}%`}),e.jsx(I1,{dataKey:"openRate",fill:"hsl(220, 70%, 50%)",name:"Open Rate",radius:[2,2,0,0]}),e.jsx(I1,{dataKey:"clickRate",fill:"hsl(270, 70%, 50%)",name:"Click Rate",radius:[2,2,0,0]})]})})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Send Volume by Agent"})}),e.jsx(De,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(aT,{width:"100%",height:"100%",children:e.jsxs(_at,{children:[e.jsx(q0,{data:w,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:100,label:({name:S,percent:M})=>`${S} (${(M*100).toFixed(0)}%)`,fontSize:11,children:w.map((S,M)=>e.jsx(iR,{fill:IFe[M%IFe.length]},M))}),e.jsx(hp,{})]})})})})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Send Volume Trend"})}),e.jsx(De,{children:e.jsx("div",{className:"h-[240px]",children:e.jsx(aT,{width:"100%",height:"100%",children:e.jsxs(Dvs,{data:k,children:[e.jsx(aC,{dataKey:"date",fontSize:11}),e.jsx(iC,{fontSize:11}),e.jsx(hp,{}),e.jsx(mR,{type:"monotone",dataKey:"sent",stroke:"hsl(142, 71%, 45%)",strokeWidth:2,name:"Emails Sent",dot:{r:4}})]})})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Agent Performance"})}),e.jsx(De,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"pb-2 font-medium",children:"Agent"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Campaigns"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Sent"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Opens"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Clicks"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Open Rate"})]})}),e.jsx("tbody",{children:j.map(S=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-2.5 font-medium",children:S.name}),e.jsx("td",{className:"py-2.5 text-center",children:S.campaigns}),e.jsx("td",{className:"py-2.5 text-center",children:S.sent}),e.jsx("td",{className:"py-2.5 text-center",children:S.opens}),e.jsx("td",{className:"py-2.5 text-center",children:S.clicks}),e.jsx("td",{className:"py-2.5 text-center",children:e.jsxs(tt,{variant:"outline",children:[S.openRate,"%"]})})]},S.id))})]})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Campaign Leaderboard"})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-2",children:[...a].sort((S,M)=>{const L=S.sent_count>0?S.open_count/S.sent_count:0;return(M.sent_count>0?M.open_count/M.sent_count:0)-L}).slice(0,10).map((S,M)=>{const L=S.sent_count>0?(S.open_count/S.sent_count*100).toFixed(1):"0.0",I=S.sent_count>0?(S.click_count/S.sent_count*100).toFixed(1):"0.0",O=o.get(S.user_id);return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/30 cursor-pointer",onClick:()=>t(`/admin/email-campaigns/${S.id}`),children:[e.jsxs("span",{className:"text-lg font-bold text-muted-foreground w-6",children:["#",M+1]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:S.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(O==null?void 0:O.name)||"Unknown"," · ",S.sent_at?ms(new Date(S.sent_at),"MMM d, yyyy"):""," · ",S.sent_count," sent"]})]}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(On,{className:"h-3 w-3"})," ",L,"%"]}),e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(wh,{className:"h-3 w-3"})," ",I,"%"]})]})]},S.id)})})})]})]})})}const Rvs=()=>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(ba,{defaultValue:"analytics",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"analytics",children:"Analytics"}),e.jsx(ns,{value:"content",children:"Content"}),e.jsx(ns,{value:"email-campaigns",children:"Email Campaigns"}),e.jsx(ns,{value:"activity",children:"Activity"}),e.jsx(ns,{value:"shares",children:"Shares"})]}),e.jsx(bs,{value:"analytics",className:"space-y-4",children:e.jsx(sWt,{})}),e.jsx(bs,{value:"content",className:"space-y-4",children:e.jsx(nWt,{})}),e.jsx(bs,{value:"email-campaigns",className:"space-y-4",children:e.jsx(Ovs,{})}),e.jsx(bs,{value:"activity",className:"space-y-4",children:e.jsx(tWt,{})}),e.jsx(bs,{value:"shares",className:"space-y-4",children:e.jsx(Ptt,{})})]})]})});function Fvs(){const t=Qt(),[s,r]=N.useState(!1),[n,a]=N.useState(null),[o,l]=N.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),[i,c]=N.useState(null),[u,p]=N.useState(""),[f,g]=N.useState([]),[b,_]=N.useState([]),[j,w]=N.useState([]),[k,S]=N.useState(!1),[M,L]=N.useState(null),[I,O]=N.useState(""),{data:q,isLoading:U}=mt({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:Ae,error:ft}=await H.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(ft)throw ft;return Ae}}),{data:B}=mt({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:Ae,error:ft}=await H.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(ft)throw ft;return Ae}}),{data:V}=mt({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:Ae,error:ft}=await H.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(ft)throw ft;return Ae}}),{data:Z}=mt({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:Ae,error:ft}=await H.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(ft)throw ft;return Ae}}),{data:X,isLoading:ee}=mt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:Ae,error:ft}=await H.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(ft)throw ft;return Ae}}),Q=()=>{l({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),c(null),p(""),g([]),_([]),w([]),a(null),O("")},ie=Ae=>{a(Ae),l({title:Ae.title,description:Ae.description||"",publish_date:Ae.publish_date.split("T")[0],is_published:Ae.is_published,category_id:Ae.category_id||""}),p(Ae.preview_image_url||""),O("");const ft=(B==null?void 0:B.filter(at=>at.resource_id===Ae.id))||[];g(ft.map(at=>({id:at.id,name:at.name,file_url:at.file_url,file_size:at.file_size,sort_order:at.sort_order})));const fe=(V==null?void 0:V.filter(at=>at.resource_id===Ae.id))||[];_(fe.map(at=>({id:at.id,title:at.title,video_url:at.video_url,sort_order:at.sort_order})));const Ve=(Z==null?void 0:Z.filter(at=>at.resource_id===Ae.id))||[];w(Ve.map(at=>({id:at.id,title:at.title,canva_share_link:at.canva_share_link,sort_order:at.sort_order}))),r(!0)},re=Ae=>{var fe;const ft=(fe=Ae.target.files)==null?void 0:fe[0];ft&&(c(ft),p(URL.createObjectURL(ft)))},oe=()=>{g([...f,{name:"",file_url:"",sort_order:f.length}])},ce=Ae=>{g(f.filter((ft,fe)=>fe!==Ae))},xe=(Ae,ft,fe)=>{const Ve=[...f];if(ft==="file"&&fe instanceof File){const at=fe.name.replace(/\.[^/.]+$/,"");Ve[Ae]={...Ve[Ae],file:fe,file_size:fe.size,name:Ve[Ae].name||at}}else Ve[Ae]={...Ve[Ae],[ft]:fe};g(Ve)},ge=()=>{_([...b,{title:"",video_url:"",sort_order:b.length}])},ue=Ae=>{_(b.filter((ft,fe)=>fe!==Ae))},pe=(Ae,ft,fe)=>{const Ve=[...b];ft==="file"&&fe instanceof File?Ve[Ae]={...Ve[Ae],file:fe}:Ve[Ae]={...Ve[Ae],[ft]:fe},_(Ve)},be=()=>{w([...j,{title:"",canva_share_link:"",sort_order:j.length}])},Me=Ae=>{w(j.filter((ft,fe)=>fe!==Ae))},Ne=(Ae,ft,fe)=>{const Ve=[...j];Ve[Ae]={...Ve[Ae],[ft]:fe},w(Ve)},Pe=async(Ae,ft)=>{try{const fe=await H.functions.invoke("bunny-upload",{body:{action:"create",title:Ae.name}});if(fe.error)throw fe.error;const{videoId:Ve,uploadUrl:at,libraryId:et}=fe.data,Ce=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Ve,libraryId:et}});if(Ce.error)throw Ce.error;const{uploadUrl:rt,apiKey:Ge}=Ce.data,ct=new XMLHttpRequest;return ct.open("PUT",rt,!0),ct.setRequestHeader("AccessKey",Ge),ct.upload.onprogress=qe=>{if(qe.lengthComputable){const Ze=Math.round(qe.loaded/qe.total*100),Qe=[...b];Qe[ft]={...Qe[ft],uploadProgress:Ze},_(Qe)}},await new Promise((qe,Ze)=>{ct.onload=()=>ct.status>=200&&ct.status<300?qe():Ze(new Error("Upload failed")),ct.onerror=()=>Ze(new Error("Upload failed")),ct.send(Ae)}),`https://iframe.mediadelivery.net/embed/${et}/${Ve}`}catch(fe){throw console.error("Bunny upload error:",fe),fe}},Oe=Dt({mutationFn:async Ae=>{const{data:ft,error:fe}=await H.from("brokerage_resource_categories").insert({name:Ae,sort_order:(X==null?void 0:X.length)||0}).select().single();if(fe)throw fe;return ft},onSuccess:Ae=>{t.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:Ae.id}),O(""),me.success("Category created")},onError:Ae=>{me.error("Failed to create category: "+Ae.message)}}),Te=Dt({mutationFn:async()=>{S(!0);let Ae=(n==null?void 0:n.preview_image_url)||null;if(i){const Ve=i.name.split(".").pop(),at=`${Date.now()}.${Ve}`,{error:et}=await H.storage.from("brokerage-resources").upload(`previews/${at}`,i);if(et)throw et;const{data:Ce}=H.storage.from("brokerage-resources").getPublicUrl(`previews/${at}`);Ae=Ce.publicUrl}const ft={title:o.title,description:o.description||null,preview_image_url:Ae,publish_date:o.publish_date,is_published:o.is_published,category_id:o.category_id||null};let fe;if(n){const{error:Ve}=await H.from("brokerage_resources").update(ft).eq("id",n.id);if(Ve)throw Ve;fe=n.id;const at=(B==null?void 0:B.filter(He=>He.resource_id===n.id).map(He=>He.id))||[],et=f.filter(He=>He.id).map(He=>He.id),Ce=at.filter(He=>!et.includes(He));Ce.length>0&&await H.from("brokerage_resource_pdfs").delete().in("id",Ce);const rt=(V==null?void 0:V.filter(He=>He.resource_id===n.id).map(He=>He.id))||[],Ge=b.filter(He=>He.id).map(He=>He.id),ct=rt.filter(He=>!Ge.includes(He));ct.length>0&&await H.from("brokerage_resource_videos").delete().in("id",ct);const qe=(Z==null?void 0:Z.filter(He=>He.resource_id===n.id).map(He=>He.id))||[],Ze=j.filter(He=>He.id).map(He=>He.id),Qe=qe.filter(He=>!Ze.includes(He));Qe.length>0&&await H.from("brokerage_resource_links").delete().in("id",Qe)}else{const{data:Ve,error:at}=await H.from("brokerage_resources").insert(ft).select().single();if(at)throw at;fe=Ve.id}for(let Ve=0;Ve{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),me.success(n?"Resource updated":"Resource created"),r(!1),Q(),S(!1)},onError:Ae=>{me.error("Failed to save resource: "+Ae.message),S(!1)}}),ke=Dt({mutationFn:async Ae=>{const{error:ft}=await H.from("brokerage_resources").delete().eq("id",Ae);if(ft)throw ft},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),me.success("Resource deleted")},onError:Ae=>{me.error("Failed to delete: "+Ae.message)}}),Be=Ae=>{if(Ae.preventDefault(),!o.title){me.error("Please enter a title");return}Te.mutate()},nt=Ae=>{const ft=(B==null?void 0:B.filter(at=>at.resource_id===Ae).length)||0,fe=(V==null?void 0:V.filter(at=>at.resource_id===Ae).length)||0,Ve=(Z==null?void 0:Z.filter(at=>at.resource_id===Ae).length)||0;return{pdfCount:ft,videoCount:fe,linkCount:Ve}};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(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:(q==null?void 0:q.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:(q==null?void 0:q.filter(Ae=>Ae.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{Q(),r(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),e.jsx(Ee,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Content"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:U?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):(q==null?void 0:q.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No brokerage resources yet. Create your first one!"})}):q==null?void 0:q.map(Ae=>{const{pdfCount:ft,videoCount:fe,linkCount:Ve}=nt(Ae.id),at=X==null?void 0:X.find(et=>et.id===Ae.category_id);return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ae.preview_image_url?e.jsx("img",{src:Ae.preview_image_url,alt:Ae.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(Gh,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ae.title}),Ae.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Ae.description})]})]})}),e.jsx(dt,{children:at?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:at.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-3.5 w-3.5"}),ft]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(An,{className:"h-3.5 w-3.5"}),fe]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Bo,{className:"h-3.5 w-3.5"}),Ve]})]})}),e.jsx(dt,{children:ms(new Date(Ae.publish_date),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Ae.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Ae.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const et=(B==null?void 0:B.filter(Ge=>Ge.resource_id===Ae.id))||[],Ce=(V==null?void 0:V.filter(Ge=>Ge.resource_id===Ae.id))||[],rt=(Z==null?void 0:Z.filter(Ge=>Ge.resource_id===Ae.id))||[];L({...Ae,pdfs:et,videos:Ce,links:rt})},children:e.jsx(On,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ie(Ae),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&ke.mutate(Ae.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Ae.id)})})]})})}),e.jsx(fs,{open:s,onOpenChange:r,children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:n?"Edit Brokerage Resource":"Add Brokerage Resource"})}),e.jsxs("form",{onSubmit:Be,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(Gh,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(ze,{type:"file",accept:"image/*",onChange:re})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:o.title,onChange:Ae=>l({...o,title:Ae.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(Fm,{className:"h-4 w-4"}),"Category"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Zs,{value:o.category_id,onValueChange:Ae=>l({...o,category_id:Ae}),children:[e.jsx(Ws,{className:"flex-1",children:e.jsx(Xs,{placeholder:"Select a category"})}),e.jsx(Gs,{children:X==null?void 0:X.map(Ae=>e.jsx(Mt,{value:Ae.id,children:Ae.name},Ae.id))})]}),o.category_id&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>l({...o,category_id:""}),children:e.jsx(Rr,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Or create new category...",value:I,onChange:Ae=>O(Ae.target.value),className:"flex-1"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",disabled:!I.trim()||Oe.isPending,onClick:()=>Oe.mutate(I.trim()),children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(my,{content:o.description,onChange:Ae=>l({...o,description:Ae}),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(ze,{id:"publish_date",type:"date",value:o.publish_date,onChange:Ae=>l({...o,publish_date:Ae.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(qr,{checked:o.is_published,onCheckedChange:Ae=>l({...o,is_published:Ae})}),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(Sn,{className:"h-4 w-4"}),"PDF Documents (",f.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:oe,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add PDF"]})]}),f.map((Ae,ft)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(ze,{placeholder:"PDF Name",value:Ae.name,onChange:fe=>xe(ft,"name",fe.target.value),className:"flex-1"}),e.jsx(ze,{type:"file",accept:".pdf",onChange:fe=>{var at;const Ve=(at=fe.target.files)==null?void 0:at[0];Ve&&xe(ft,"file",Ve)},className:"flex-1"}),Ae.file_url&&!Ae.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>ce(ft),children:e.jsx(Rr,{className:"h-4 w-4"})})]},ft))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(An,{className:"h-4 w-4"}),"Videos (",b.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ge,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),b.map((Ae,ft)=>e.jsxs("div",{className:"space-y-2 p-3 border rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{placeholder:"Video Title",value:Ae.title,onChange:fe=>pe(ft,"title",fe.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>ue(ft),children:e.jsx(Rr,{className:"h-4 w-4"})})]}),e.jsx(ze,{type:"file",accept:"video/*",onChange:fe=>{var at;const Ve=(at=fe.target.files)==null?void 0:at[0];Ve&&pe(ft,"file",Ve)}}),Ae.uploadProgress!==void 0&&Ae.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:`${Ae.uploadProgress}%`}})}),Ae.video_url&&!Ae.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Video uploaded"})]},ft))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-4 w-4"}),"Canva Links (",j.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:be,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),j.map((Ae,ft)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(ze,{placeholder:"Link Title",value:Ae.title,onChange:fe=>Ne(ft,"title",fe.target.value),className:"flex-1"}),e.jsx(ze,{placeholder:"Canva Share Link",value:Ae.canva_share_link,onChange:fe=>Ne(ft,"canva_share_link",fe.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>Me(ft),children:e.jsx(Rr,{className:"h-4 w-4"})})]},ft))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:Te.isPending||k,children:Te.isPending||k?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(fs,{open:!!M,onOpenChange:()=>L(null),children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:M==null?void 0:M.title})}),M&&e.jsxs("div",{className:"space-y-4",children:[M.preview_image_url&&e.jsx("img",{src:M.preview_image_url,alt:M.title,className:"w-full h-48 object-cover rounded-lg"}),M.description&&e.jsx("p",{className:"text-muted-foreground",children:M.description}),M.pdfs&&M.pdfs.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4"}),"PDF Documents (",M.pdfs.length,")"]}),e.jsx("div",{className:"space-y-1",children:M.pdfs.map(Ae=>e.jsx("a",{href:Ae.file_url,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:Ae.name},Ae.id))})]}),M.videos&&M.videos.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(An,{className:"h-4 w-4"}),"Videos (",M.videos.length,")"]}),e.jsx("div",{className:"space-y-2",children:M.videos.map(Ae=>e.jsx("div",{className:"p-2 border rounded",children:e.jsx("p",{className:"font-medium text-sm",children:Ae.title})},Ae.id))})]}),M.links&&M.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Bo,{className:"h-4 w-4"}),"Canva Links (",M.links.length,")"]}),e.jsx("div",{className:"space-y-1",children:M.links.map(Ae=>e.jsx("a",{href:Ae.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:Ae.title},Ae.id))})]})]})]})})]})})}const wat=[{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 zvs(){const[t,s]=N.useState([]),[r,n]=N.useState(!0),[a,o]=N.useState(!1),[l,i]=N.useState(!1),[c,u]=N.useState(null),[p,f]=N.useState(!1),[g,b]=N.useState(!1),[_,j]=N.useState(""),[w,k]=N.useState(""),[S,M]=N.useState(""),[L,I]=N.useState(""),[O,q]=N.useState("Learn More"),[U,B]=N.useState("top"),[V,Z]=N.useState(""),[X,ee]=N.useState(!0),[Q,ie]=N.useState(""),[re,oe]=N.useState("");N.useEffect(()=>{ce()},[]);const ce=async()=>{try{const{data:Oe,error:Te}=await H.from("dashboard_banners").select("*").order("placement").order("sort_order");if(Te)throw Te;s(Oe||[])}catch(Oe){me.error("Failed to load banners: "+Oe.message)}finally{n(!1)}},xe=()=>{j(""),k(""),M(""),I(""),q("Learn More"),B("top"),Z(""),ee(!0),ie(""),oe(""),u(null)},ge=Oe=>{u(Oe),j(Oe.title),k(Oe.description||""),M(Oe.image_url),I(Oe.link_url||""),q(Oe.link_text||"Learn More"),B(Oe.placement),Z(Oe.section_after||""),ee(Oe.is_active),ie(Oe.start_date?ms(new Date(Oe.start_date),"yyyy-MM-dd'T'HH:mm"):""),oe(Oe.end_date?ms(new Date(Oe.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},ue=async Oe=>{var ke;const Te=(ke=Oe.target.files)==null?void 0:ke[0];if(Te){f(!0);try{const Be=Te.name.split(".").pop(),nt=`${Date.now()}.${Be}`,{error:Ae}=await H.storage.from("banner-images").upload(nt,Te);if(Ae)throw Ae;const{data:{publicUrl:ft}}=H.storage.from("banner-images").getPublicUrl(nt);M(ft),me.success("Image uploaded successfully")}catch(Be){me.error("Failed to upload image: "+Be.message)}finally{f(!1)}}},pe=async()=>{if(!_.trim()||!S){me.error("Please fill in required fields (title and image)");return}b(!0);try{const Oe={title:_.trim(),description:w.trim()||null,image_url:S,link_url:L.trim()||null,link_text:O.trim()||"Learn More",placement:U,section_after:U==="between"?V:null,is_active:X,start_date:Q?new Date(Q).toISOString():null,end_date:re?new Date(re).toISOString():null};if(c){const{error:Te}=await H.from("dashboard_banners").update(Oe).eq("id",c.id);if(Te)throw Te;me.success("Banner updated successfully")}else{const Te=t.filter(Be=>Be.placement===U).length,{error:ke}=await H.from("dashboard_banners").insert({...Oe,sort_order:Te});if(ke)throw ke;me.success("Banner created successfully")}o(!1),xe(),ce()}catch(Oe){me.error("Failed to save banner: "+Oe.message)}finally{b(!1)}},be=async()=>{if(c)try{const{error:Oe}=await H.from("dashboard_banners").delete().eq("id",c.id);if(Oe)throw Oe;me.success("Banner deleted successfully"),i(!1),u(null),ce()}catch(Oe){me.error("Failed to delete banner: "+Oe.message)}},Me=async Oe=>{try{const{error:Te}=await H.from("dashboard_banners").update({is_active:!Oe.is_active}).eq("id",Oe.id);if(Te)throw Te;me.success(Oe.is_active?"Banner deactivated":"Banner activated"),ce()}catch(Te){me.error("Failed to update banner: "+Te.message)}},Ne=t.filter(Oe=>Oe.placement==="top"),Pe=t.filter(Oe=>Oe.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(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(gl,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(gr,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(fs,{open:a&&U==="top",onOpenChange:Oe=>{Oe||xe(),o(Oe),Oe&&B("top")},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:()=>{xe(),B("top")},children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Add Hero Banner"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsxs(vs,{children:[c?"Edit":"Create"," Banner"]}),e.jsx(Gr,{children:"Configure the banner's content and display settings"})]}),e.jsx(LFe,{title:_,setTitle:j,description:w,setDescription:k,imageUrl:S,linkUrl:L,setLinkUrl:I,linkText:O,setLinkText:q,placement:U,setPlacement:B,sectionAfter:V,setSectionAfter:Z,isActive:X,setIsActive:ee,startDate:Q,setStartDate:ie,endDate:re,setEndDate:oe,handleImageUpload:ue,uploading:p,showPlacementOptions:!1}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),xe()},children:"Cancel"}),e.jsx(K,{onClick:pe,disabled:g,children:g?"Saving...":c?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(De,{children:Ne.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No hero banners yet. Add your first banner above."}):e.jsx("div",{className:"space-y-3",children:Ne.map(Oe=>e.jsx(DFe,{banner:Oe,onEdit:()=>ge(Oe),onDelete:()=>{u(Oe),i(!0)},onToggleActive:()=>Me(Oe)},Oe.id))})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(gl,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(gr,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(fs,{open:a&&U==="between",onOpenChange:Oe=>{Oe||xe(),o(Oe),Oe&&B("between")},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:()=>{xe(),B("between")},children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Add Section Banner"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsxs(vs,{children:[c?"Edit":"Create"," Section Banner"]}),e.jsx(Gr,{children:"Configure where this banner appears between sections"})]}),e.jsx(LFe,{title:_,setTitle:j,description:w,setDescription:k,imageUrl:S,linkUrl:L,setLinkUrl:I,linkText:O,setLinkText:q,placement:U,setPlacement:B,sectionAfter:V,setSectionAfter:Z,isActive:X,setIsActive:ee,startDate:Q,setStartDate:ie,endDate:re,setEndDate:oe,handleImageUpload:ue,uploading:p,showPlacementOptions:!0}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),xe()},children:"Cancel"}),e.jsx(K,{onClick:pe,disabled:g,children:g?"Saving...":c?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(De,{children:Pe.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:Pe.map(Oe=>e.jsx(DFe,{banner:Oe,onEdit:()=>ge(Oe),onDelete:()=>{u(Oe),i(!0)},onToggleActive:()=>Me(Oe),showSection:!0},Oe.id))})})]})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Delete Banner"}),e.jsxs(Gr,{children:['Are you sure you want to delete "',c==null?void 0:c.title,'"? This action cannot be undone.']})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:be,children:"Delete"})]})]})})]})}function LFe({title:t,setTitle:s,description:r,setDescription:n,imageUrl:a,linkUrl:o,setLinkUrl:l,linkText:i,setLinkText:c,placement:u,setPlacement:p,sectionAfter:f,setSectionAfter:g,isActive:b,setIsActive:_,startDate:j,setStartDate:w,endDate:k,setEndDate:S,handleImageUpload:M,uploading:L,showPlacementOptions:I}){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(ze,{id:"title",placeholder:"Banner headline...",value:t,onChange:O=>s(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",placeholder:"Optional banner description...",value:r,onChange:O=>n(O.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Banner Image *"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:M,disabled:L,className:"flex-1"}),L&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),a&&e.jsx("div",{className:"mt-2 relative rounded-lg overflow-hidden border",children:e.jsx("img",{src:a,alt:"Preview",className:"w-full h-40 object-cover"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"linkUrl",children:"Link URL (optional)"}),e.jsx(ze,{id:"linkUrl",placeholder:"https://...",value:o,onChange:O=>l(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"linkText",children:"Button Text"}),e.jsx(ze,{id:"linkText",placeholder:"Learn More",value:i,onChange:O=>c(O.target.value)})]})]}),I&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Placement"}),e.jsxs(Zs,{value:f,onValueChange:g,children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select section placement..."})}),e.jsx(Gs,{children:wat.map(O=>e.jsx(Mt,{value:O.value,children:O.label},O.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"startDate",className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"Start Date (optional)"]}),e.jsx(ze,{id:"startDate",type:"datetime-local",value:j,onChange:O=>w(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"endDate",className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"End Date (optional)"]}),e.jsx(ze,{id:"endDate",type:"datetime-local",value:k,onChange:O=>S(O.target.value)})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"isActive",checked:b,onCheckedChange:_}),e.jsx(ve,{htmlFor:"isActive",children:"Active"})]})})]})}function DFe({banner:t,onEdit:s,onDelete:r,onToggleActive:n,showSection:a=!1}){var l;const o=(l=wat.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(Cu,{className:"h-5 w-5 text-muted-foreground cursor-grab"}),e.jsx("img",{src:t.image_url,alt:t.title,className:"w-24 h-14 object-cover rounded"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-medium truncate",children:t.title}),!t.is_active&&e.jsx(tt,{variant:"secondary",children:"Inactive"}),t.start_date&&new Date(t.start_date)>new Date&&e.jsx(tt,{variant:"outline",children:"Scheduled"})]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:t.description}),a&&o&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t.link_url&&e.jsx("a",{href:t.link_url,target:"_blank",rel:"noopener noreferrer",children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(tn,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:n,children:t.is_active?e.jsx(On,{className:"h-4 w-4"}):e.jsx(kp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:s,children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})]})}const qz={open:{label:"Open",icon:un,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:$c,color:"bg-blue-500"},resolved:{label:"Resolved",icon:xi,color:"bg-green-500"},closed:{label:"Closed",icon:vc,color:"bg-muted-foreground"}},OFe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function Bvs(){var O,q;const{user:t}=Ds(),s=Qt(),[r,n]=N.useState(null),[a,o]=N.useState(""),[l,i]=N.useState("all"),[c,u]=N.useState("all"),[p,f]=N.useState(!1),{data:g=[],isLoading:b}=mt({queryKey:["admin-support-tickets",l,c],queryFn:async()=>{let U=H.from("support_tickets").select("*, profiles!support_tickets_user_id_fkey(name, email)").order("created_at",{ascending:!1});l!=="all"&&(U=U.eq("status",l)),c!=="all"&&(U=U.eq("category",c));const{data:B,error:V}=await U;if(V)throw V;return B}}),{data:_=[]}=mt({queryKey:["admin-users-notifications"],queryFn:async()=>{const{data:U,error:B}=await H.from("user_roles").select("user_id").eq("role","admin");if(B)throw B;const V=U.map(re=>re.user_id),{data:Z,error:X}=await H.from("profiles").select("id, name, email").in("id",V);if(X)throw X;const{data:ee,error:Q}=await H.from("support_notification_settings").select("user_id, receive_notifications");if(Q)throw Q;const ie=new Map((ee==null?void 0:ee.map(re=>[re.user_id,re.receive_notifications]))||[]);return Z.map(re=>({...re,receives_notifications:ie.get(re.id)||!1}))}}),{data:j=[]}=mt({queryKey:["admin-ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:U,error:B}=await H.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(B)throw B;return U},enabled:!!r}),w=Dt({mutationFn:async({userId:U,enabled:B})=>{const{data:V}=await H.from("support_notification_settings").select("id").eq("user_id",U).maybeSingle();if(V){const{error:Z}=await H.from("support_notification_settings").update({receive_notifications:B}).eq("user_id",U);if(Z)throw Z}else{const{error:Z}=await H.from("support_notification_settings").insert({user_id:U,receive_notifications:B});if(Z)throw Z}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users-notifications"]}),me.success("Notification settings updated")},onError:()=>{me.error("Failed to update settings")}}),k=Dt({mutationFn:async({ticketId:U,status:B})=>{const{error:V}=await H.from("support_tickets").update({status:B}).eq("id",U);if(V)throw V},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),r&&n({...r,status:r.status}),me.success("Status updated")},onError:()=>{me.error("Failed to update status")}}),S=Dt({mutationFn:async({ticketId:U,assignedTo:B})=>{const{error:V}=await H.from("support_tickets").update({assigned_to:B}).eq("id",U);if(V)throw V},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),me.success("Ticket assigned")},onError:()=>{me.error("Failed to assign ticket")}}),M=Dt({mutationFn:async U=>{var V,Z;if(!r||!t)throw new Error("Missing data");const{error:B}=await H.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:U,is_admin_reply:!0});if(B)throw B;try{await H.functions.invoke("support-reply-notify",{body:{ticketId:r.id,ticketSubject:r.subject,replyContent:U,userEmail:(V=r.profiles)==null?void 0:V.email,userName:(Z=r.profiles)==null?void 0:Z.name}})}catch(X){console.error("Failed to send reply notification:",X)}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-ticket-replies",r==null?void 0:r.id]}),o(""),me.success("Reply sent!")},onError:()=>{me.error("Failed to send reply")}}),L=()=>{a.trim()&&M.mutate(a)};N.useEffect(()=>{const U=H.channel("admin-tickets").on("postgres_changes",{event:"*",schema:"public",table:"support_tickets"},()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]})}).subscribe();return()=>{H.removeChannel(U)}},[s]);const I=g.filter(U=>U.status==="open").length;return r?(qz[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(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(tt,{variant:"secondary",children:OFe[r.category]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["from ",((O=r.profiles)==null?void 0:O.name)||"Unknown"," (",(q=r.profiles)==null?void 0:q.email,")"]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm",children:"Status"})}),e.jsx(De,{children:e.jsxs(Zs,{value:r.status,onValueChange:U=>{k.mutate({ticketId:r.id,status:U}),n({...r,status:U})},children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"open",children:"Open"}),e.jsx(Mt,{value:"in_progress",children:"In Progress"}),e.jsx(Mt,{value:"resolved",children:"Resolved"}),e.jsx(Mt,{value:"closed",children:"Closed"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm",children:"Assigned To"})}),e.jsx(De,{children:e.jsxs(Zs,{value:r.assigned_to||"unassigned",onValueChange:U=>{const B=U==="unassigned"?null:U;S.mutate({ticketId:r.id,assignedTo:B}),n({...r,assigned_to:B})},children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Unassigned"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"unassigned",children:"Unassigned"}),_.map(U=>e.jsx(Mt,{value:U.id,children:U.name},U.id))]})]})})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(gr,{children:["Created on ",ms(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(De,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Conversation"})}),e.jsxs(De,{children:[e.jsx(Gi,{className:"h-[300px] pr-4",children:j.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:j.map(U=>{var B,V;return e.jsxs("div",{className:`p-4 rounded-lg ${U.is_admin_reply?"bg-primary/10 ml-4":"bg-muted mr-4"}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("span",{className:"font-medium text-sm",children:U.is_admin_reply?`${((B=U.profiles)==null?void 0:B.name)||"Admin"} (Support)`:((V=U.profiles)==null?void 0:V.name)||"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(U.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:U.content})]},U.id)})})}),e.jsx(rl,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Type your reply...",value:a,onChange:U=>o(U.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:L,disabled:!a.trim()||M.isPending,className:"self-end",children:e.jsx(Bn,{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",I>0&&e.jsxs(tt,{variant:"destructive",className:"ml-2",children:[I," open"]})]})]}),e.jsxs(fs,{open:p,onOpenChange:f,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(Xo,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Email Notification Settings"}),e.jsx(Gr,{children:"Choose which admins receive email notifications for new support tickets."})]}),e.jsx("div",{className:"space-y-4 mt-4",children:_.map(U=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(to,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:U.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:U.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[U.receives_notifications?e.jsx(Lm,{className:"h-4 w-4 text-primary"}):e.jsx(t1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(qr,{checked:U.receives_notifications,onCheckedChange:B=>w.mutate({userId:U.id,enabled:B})})]})]},U.id))})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[e.jsx(ba,{value:l,onValueChange:i,className:"w-auto",children:e.jsxs(pa,{children:[e.jsx(ns,{value:"all",children:"All"}),e.jsx(ns,{value:"open",children:"Open"}),e.jsx(ns,{value:"in_progress",children:"In Progress"}),e.jsx(ns,{value:"resolved",children:"Resolved"}),e.jsx(ns,{value:"closed",children:"Closed"})]})}),e.jsxs(Zs,{value:c,onValueChange:u,children:[e.jsx(Ws,{className:"w-[180px]",children:e.jsx(Xs,{placeholder:"All Categories"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Categories"}),e.jsx(Mt,{value:"general",children:"General Support"}),e.jsx(Mt,{value:"technology",children:"Technology Support"}),e.jsx(Mt,{value:"crm",children:"CRM Support"}),e.jsx(Mt,{value:"marketing",children:"Marketing Support"})]})]})]}),e.jsx("div",{className:"mt-4",children:b?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):g.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"text-center py-12",children:[e.jsx($c,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No tickets found"}),e.jsx("p",{className:"text-muted-foreground",children:"No support tickets match the current filters."})]})}):e.jsx("div",{className:"space-y-3",children:g.map(U=>{var V,Z;const B=qz[U.status].icon;return e.jsx(Ee,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(U),children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:U.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[e.jsx(tt,{variant:"outline",className:"text-xs",children:OFe[U.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(V=U.profiles)==null?void 0:V.name," • ",ms(new Date(U.created_at),"MMM d, yyyy")]}),U.assigned_to&&e.jsxs(tt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(to,{className:"h-3 w-3"}),((Z=_.find(X=>X.id===U.assigned_to))==null?void 0:Z.name)||"Assigned"]})]})]}),e.jsxs(tt,{className:qz[U.status].color,children:[e.jsx(B,{className:"h-3 w-3 mr-1"}),qz[U.status].label]})]})})},U.id)})})})]})]})})}const jat=Ih.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 $vs({content:t,onChange:s,variables:r}){const n=nke({extensions:[ike,xke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),gke.configure({types:["heading","paragraph"]}),yke,jat],content:t,onUpdate:({editor:l})=>{s(l.getHTML())}});N.useEffect(()=>{n&&t!==n.getHTML()&&n.commands.setContent(t)},[t,n]);const a=l=>{n&&n.chain().focus().insertContent(`{{${l.key}}}`).run()},o=()=>{if(!n)return;const l=n.getAttributes("link").href,i=window.prompt("URL",l);if(i!==null){if(i===""){n.chain().focus().extendMarkRange("link").unsetLink().run();return}n.chain().focus().extendMarkRange("link").setLink({href:i}).run()}};return n?e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBold().run(),className:n.isActive("bold")?"bg-muted":"",children:e.jsx(Z4,{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(tS,{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(Mh,{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(m0,{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(W4,{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(H4,{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(G4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:o,className:n.isActive("link")?"bg-muted":"",children:e.jsx(Bo,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleCodeBlock().run(),className:n.isActive("codeBlock")?"bg-muted":"",children:e.jsx(X4,{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(fS,{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(hS,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),r.length>0&&e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(UM,{className:"h-4 w-4"}),"Insert Variable"]})}),e.jsx(Bd,{align:"end",className:"w-64",children:r.map(l=>e.jsxs(Ma,{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(ske,{editor:n,className:"prose prose-sm max-w-none p-4 min-h-[300px] focus:outline-none [&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[280px]"}),r.length>0&&e.jsxs("div",{className:"border-t p-3 bg-muted/20",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Available variables (click to copy):"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(l=>e.jsx(tt,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 font-mono text-xs",onClick:()=>{navigator.clipboard.writeText(`{{${l.key}}}`)},children:`{{${l.key}}}`},l.key))})]})]}):null}function qvs(){const t=Qt(),[s,r]=N.useState(null),[n,a]=N.useState(null),[o,l]=N.useState(""),[i,c]=N.useState(""),[u,p]=N.useState(""),[f,g]=N.useState(!0),[b,_]=N.useState("visual"),{data:j,isLoading:w}=mt({queryKey:["email-templates"],queryFn:async()=>{const{data:I,error:O}=await H.from("email_templates").select("*").order("name");if(O)throw O;return I.map(q=>({...q,available_variables:q.available_variables||[]}))}}),k=Dt({mutationFn:async I=>{const{error:O}=await H.from("email_templates").update({subject:I.subject,body_html:I.body_html,description:I.description,is_active:I.is_active}).eq("id",I.id);if(O)throw O},onSuccess:()=>{t.invalidateQueries({queryKey:["email-templates"]}),me.success("Email template updated successfully"),r(null)},onError:I=>{me.error("Failed to update template: "+I.message)}}),S=I=>{r(I),l(I.subject),c(I.body_html),p(I.description||""),g(I.is_active),_("visual")},M=()=>{s&&k.mutate({id:s.id,subject:o,body_html:i,description:u,is_active:f})},L=(I,O)=>{let q=I;return O.forEach(U=>{const B=`{{${U.key}}}`,V=`[${U.label}]`;q=q.replace(new RegExp(B.replace(/[{}]/g,"\\$&"),"g"),V)}),q};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(Ja,{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(On,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{onClick:M,disabled:k.isPending,children:[e.jsx(qc,{className:"h-4 w-4 mr-2"}),k.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),s.name]}),e.jsxs(gr,{className:"mt-1",children:["Template slug: ",e.jsx("code",{className:"bg-muted px-1 rounded",children:s.slug})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{htmlFor:"active-toggle",children:"Active"}),e.jsx(qr,{id:"active-toggle",checked:f,onCheckedChange:g})]})]})}),e.jsxs(De,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",value:u,onChange:I=>p(I.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(ze,{id:"subject",value:o,onChange:I=>l(I.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(ba,{value:b,onValueChange:I=>_(I),children:e.jsxs(pa,{className:"h-8",children:[e.jsxs(ns,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(cS,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(ns,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(X4,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),b==="visual"?e.jsx($vs,{content:i,onChange:c,variables:s.available_variables}):e.jsx(Er,{value:i,onChange:I=>c(I.target.value),className:"font-mono text-sm min-h-[400px]",placeholder:"HTML email body"})]})]})]})]}),e.jsx(fs,{open:!!n,onOpenChange:()=>a(null),children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Email Preview"}),e.jsxs(Gr,{children:["Subject: ",o.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),e.jsx("div",{className:"border rounded-lg p-4 bg-white",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:L(i,s.available_variables)}})})]})})]}):e.jsx(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((I,O)=>e.jsx(Ee,{children:e.jsxs(Pt,{children:[e.jsx(ys,{className:"h-5 w-48"}),e.jsx(ys,{className:"h-4 w-96"})]})},O))}):e.jsx("div",{className:"grid gap-4",children:j==null?void 0:j.map(I=>e.jsxs(Ee,{className:"hover:shadow-md transition-shadow",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Rt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(cr,{className:"h-5 w-5 text-muted-foreground"}),I.name,!I.is_active&&e.jsx(tt,{variant:"secondary",children:"Inactive"})]}),e.jsx(gr,{children:I.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>a(I),children:[e.jsx(On,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{size:"sm",onClick:()=>S(I),children:[e.jsx(ud,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})}),e.jsx(De,{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:I.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:I.available_variables.map(O=>e.jsx(tt,{variant:"outline",className:"font-mono text-xs",children:`{{${O.key}}}`},O.key))})]})]})})]},I.id))}),e.jsx(fs,{open:!!n&&!s,onOpenChange:()=>a(null),children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(_s,{children:[e.jsxs(vs,{children:["Email Preview: ",n==null?void 0:n.name]}),e.jsxs(Gr,{children:["Subject: ",n==null?void 0:n.subject.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),n&&e.jsx("div",{className:"border rounded-lg p-4 bg-white",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:L(n.body_html,n.available_variables)}})})]})})]})})}function Uvs(){const t=Qt(),[s,r]=N.useState("templates"),[n,a]=N.useState(null),[o,l]=N.useState(null),[i,c]=N.useState(!1),[u,p]=N.useState(!1),[f,g]=N.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[b,_]=N.useState({name:"",description:"",icon:"📧"}),{data:j=[]}=mt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:V,error:Z}=await H.from("email_template_categories").select("*").order("sort_order");if(Z)throw Z;return V}}),{data:w=[],isLoading:k}=mt({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:V,error:Z}=await H.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(Z)throw Z;return V}}),S=Dt({mutationFn:async V=>{const Z={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:X}=await H.from("agent_email_templates").update(Z).eq("id",V.id);if(X)throw X}else{const{error:X}=await H.from("agent_email_templates").insert(Z);if(X)throw X}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),c(!1),me.success(n?"Template updated":"Template created")},onError:()=>me.error("Failed to save template")}),M=Dt({mutationFn:async V=>{const{error:Z}=await H.from("agent_email_templates").delete().eq("id",V);if(Z)throw Z},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),me.success("Template deleted")}}),L=Dt({mutationFn:async V=>{const Z={name:V.name,description:V.description||null,icon:V.icon};if(V.id){const{error:X}=await H.from("email_template_categories").update(Z).eq("id",V.id);if(X)throw X}else{const X=j.length>0?Math.max(...j.map(Q=>Q.sort_order))+1:0,{error:ee}=await H.from("email_template_categories").insert({...Z,sort_order:X});if(ee)throw ee}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),p(!1),me.success(o?"Category updated":"Category created")},onError:()=>me.error("Failed to save category")}),I=Dt({mutationFn:async V=>{const{error:Z}=await H.from("email_template_categories").delete().eq("id",V);if(Z)throw Z},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),me.success("Category deleted")}}),O=()=>{a(null),g({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),c(!0)},q=V=>{a(V),g({title:V.title,subject:V.subject,body:V.body,description:V.description||"",tone:V.tone||"",category_id:V.category_id||"",is_active:V.is_active}),c(!0)},U=()=>{l(null),_({name:"",description:"",icon:"📧"}),p(!0)},B=V=>{l(V),_({name:V.name,description:V.description||"",icon:V.icon}),p(!0)};return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(oh,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),e.jsxs(ba,{value:s,onValueChange:r,children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"templates",className:"gap-2",children:[e.jsx(cr,{className:"h-4 w-4"})," Templates"]}),e.jsxs(ns,{value:"categories",className:"gap-2",children:[e.jsx(Om,{className:"h-4 w-4"})," Categories"]})]}),e.jsxs(bs,{value:"templates",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:O,className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"})," Add Template"]})}),e.jsx(Ee,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Template"}),e.jsx(St,{className:"hidden md:table-cell",children:"Category"}),e.jsx(St,{className:"hidden md:table-cell",children:"Tone"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:k?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin mx-auto"})})}):w.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):w.map(V=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:V.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:V.subject})]})}),e.jsx(dt,{className:"hidden md:table-cell",children:V.category?e.jsxs(tt,{variant:"outline",className:"gap-1",children:[V.category.icon," ",V.category.name]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{className:"hidden md:table-cell",children:V.tone?e.jsx(tt,{variant:"secondary",children:V.tone}):"—"}),e.jsx(dt,{children:e.jsx(tt,{variant:V.is_active?"default":"secondary",children:V.is_active?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>q(V),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&M.mutate(V.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},V.id))})]})})})]}),e.jsxs(bs,{value:"categories",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:U,className:"gap-2",children:[e.jsx($s,{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(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:V.icon})," ",V.name]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>B(V),children:e.jsx(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?")&&I.mutate(V.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(De,{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(Z=>Z.category_id===V.id).length," templates"]})]})]},V.id))})]})]}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{className:"sm:max-w-[700px] max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{value:f.title,onChange:V=>g(Z=>({...Z,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(Zs,{value:f.category_id,onValueChange:V=>g(Z=>({...Z,category_id:V})),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select category"})}),e.jsx(Gs,{children:j.map(V=>e.jsxs(Mt,{value:V.id,children:[V.icon," ",V.name]},V.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Subject Line"}),e.jsx(ze,{value:f.subject,onChange:V=>g(Z=>({...Z,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(Er,{value:f.body,onChange:V=>g(Z=>({...Z,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(ze,{value:f.description,onChange:V=>g(Z=>({...Z,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(ze,{value:f.tone,onChange:V=>g(Z=>({...Z,tone:V.target.value})),placeholder:"e.g. Warm & Casual"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:f.is_active,onCheckedChange:V=>g(Z=>({...Z,is_active:V}))}),e.jsx(ve,{children:"Active"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>S.mutate({...f,id:n==null?void 0:n.id}),disabled:S.isPending||!f.title||!f.subject||!f.body,children:[S.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),n?"Save Changes":"Create Template"]})]})]})}),e.jsx(fs,{open:u,onOpenChange:p,children:e.jsxs(ps,{className:"sm:max-w-[450px]",children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{value:b.icon,onChange:V=>_(Z=>({...Z,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(ze,{value:b.name,onChange:V=>_(Z=>({...Z,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(ze,{value:b.description,onChange:V=>_(Z=>({...Z,description:V.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>L.mutate({...b,id:o==null?void 0:o.id}),disabled:L.isPending||!b.name,children:[L.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const Vvs=({brokerageId:t})=>{var Fo,$t;const{toast:s}=Ua(),r=fr(),[n,a]=N.useState([]),[o,l]=N.useState(!0),[i,c]=N.useState(""),[u,p]=N.useState("all"),[f,g]=N.useState(new Set),[b,_]=N.useState(!1),[j,w]=N.useState({}),[k,S]=N.useState(!1),[M,L]=N.useState(!1),[I,O]=N.useState({email:"",name:"",password:"",phone:""}),[q,U]=N.useState(!1),[B,V]=N.useState(null),[Z,X]=N.useState(!1),[ee,Q]=N.useState(!1),[ie,re]=N.useState(!1),[oe,ce]=N.useState(""),[xe,ge]=N.useState(!1),[ue,pe]=N.useState([]),[be,Me]=N.useState(!1),[Ne,Pe]=N.useState(!1),[Oe,Te]=N.useState(null),[ke,Be]=N.useState({name:"",phone:"",email:""}),[nt,Ae]=N.useState(!1),[ft,fe]=N.useState(!1),[Ve,at]=N.useState(null),[et,Ce]=N.useState("asc"),[rt,Ge]=N.useState(!1),[ct,qe]=N.useState(null),[Ze,Qe]=N.useState(!1),[He,Je]=N.useState(null),[it,Lt]=N.useState(""),[Vt,hs]=N.useState(!1),[Ts,Cs]=N.useState(null);N.useEffect(()=>{er(),cs()},[t]);const cs=async()=>{try{const{data:je,error:$e}=await H.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if($e)throw $e;pe((je==null?void 0:je.map(Ye=>Ye.user_id))||[])}catch(je){console.error("Error loading brokerage managers:",je)}},er=async()=>{try{l(!0);const{data:je,error:$e}=await H.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if($e)throw $e;const Ye=je.agents||[];if(a(Ye),Ye.length>0){const bt=Ye.map(Ft=>Ft.id),{data:gt}=await H.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",bt);if(gt&>.length>0){const Ft=gt.map(Xt=>Xt.assistant_id),{data:Zt}=await H.from("profiles").select("id, name, email").in("id",Ft),Ut={};for(const Xt of gt){const Ps=Zt==null?void 0:Zt.find(gs=>gs.id===Xt.assistant_id);Ps&&(Ut[Xt.agent_id]={name:Ps.name||"",email:Ps.email||""})}w(Ut)}else w({})}}catch(je){console.error("Error loading agents:",je),s({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{l(!1)}},xt=async()=>{if(!I.email||!I.name||!I.password){s({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}L(!0);try{const{data:{session:je}}=await H.auth.getSession(),$e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${je==null?void 0:je.access_token}`},body:JSON.stringify({...I,brokerageId:t})}),Ye=await $e.json();if(!$e.ok)throw new Error(Ye.error||"Failed to create agent");s({title:"Success",description:`Agent ${I.email} created successfully`}),O({email:"",name:"",password:"",phone:""}),S(!1),er()}catch(je){console.error("Error creating agent:",je),s({title:"Error",description:je.message||"Failed to create agent",variant:"destructive"})}finally{L(!1)}},Es=async je=>{try{const{data:{session:$e}}=await H.auth.getSession(),Ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${$e==null?void 0:$e.access_token}`},body:JSON.stringify({userId:je})}),bt=await Ye.json();if(!Ye.ok)throw new Error(bt.error||"Failed to resend welcome email");s({title:"Success",description:"Welcome email sent successfully"})}catch($e){console.error("Error resending welcome email:",$e),s({title:"Error",description:$e.message||"Failed to resend welcome email",variant:"destructive"})}},ur=async(je,$e)=>{try{const{error:Ye}=await H.functions.invoke("send-password-reset",{body:{email:je,redirectTo:window.location.origin}});if(Ye)throw Ye;s({title:"Password Reset Sent",description:`Password reset email sent to ${$e}`})}catch(Ye){console.error("Error sending password reset:",Ye),s({title:"Error",description:Ye.message||"Failed to send password reset email",variant:"destructive"})}},Mr=je=>{V(je),U(!0)},Lr=je=>{Te(je),Be({name:je.name,phone:je.phone||"",email:je.email}),Pe(!0)},fn=async()=>{if(!Oe)return;if(!ke.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const je=ke.email.trim().toLowerCase()!==Oe.email.toLowerCase();Ae(!0);try{if(je){if(!ke.email.trim())throw new Error("Email is required");fe(!0);const{data:{session:Ye}}=await H.auth.getSession(),bt=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ye==null?void 0:Ye.access_token}`},body:JSON.stringify({agentId:Oe.id,newEmail:ke.email.trim(),brokerageId:t})}),gt=await bt.json();if(fe(!1),!bt.ok)throw new Error(gt.error||"Failed to update email")}const{error:$e}=await H.from("profiles").update({name:ke.name.trim(),phone:ke.phone.trim()||null}).eq("id",Oe.id);if($e)throw $e;s({title:"Success",description:"Agent profile updated successfully"}),Pe(!1),Te(null),er()}catch($e){console.error("Error updating agent:",$e),s({title:"Error",description:$e.message||"Failed to update agent",variant:"destructive"})}finally{Ae(!1),fe(!1)}},ki=async()=>{if(!oe){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}ge(!0);try{const{data:{session:je}}=await H.auth.getSession(),$e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${je==null?void 0:je.access_token}`},body:JSON.stringify({userId:oe,role:"brokerage_manager",action:"add",brokerageId:t})}),Ye=await $e.json();if(!$e.ok)throw new Error(Ye.error||"Failed to add brokerage manager");s({title:"Success",description:"Brokerage manager added successfully"}),re(!1),ce(""),cs()}catch(je){console.error("Error adding brokerage manager:",je),s({title:"Error",description:je.message||"Failed to add brokerage manager",variant:"destructive"})}finally{ge(!1)}},Ea=async je=>{try{const{data:{session:$e}}=await H.auth.getSession(),Ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${$e==null?void 0:$e.access_token}`},body:JSON.stringify({userId:je,role:"brokerage_manager",action:"remove",brokerageId:t})}),bt=await Ye.json();if(!Ye.ok)throw new Error(bt.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),cs()}catch($e){console.error("Error removing brokerage manager:",$e),s({title:"Error",description:$e.message||"Failed to remove brokerage manager",variant:"destructive"})}},dr=je=>ue.includes(je),Jr=je=>{Je(je),Lt(""),Qe(!0)},Wr=async()=>{if(!(!He||!it)){if(it.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}hs(!0);try{const{data:{session:je}}=await H.auth.getSession(),$e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${je==null?void 0:je.access_token}`},body:JSON.stringify({agentId:He.id,brokerageId:t,action:"set_password",newPassword:it})}),Ye=await $e.json();if(!$e.ok)throw new Error(Ye.error||"Failed to set password");s({title:"Success",description:`Password set for ${He.name}`}),Qe(!1),Je(null),Lt("")}catch(je){console.error("Error setting password:",je),s({title:"Error",description:je.message||"Failed to set password",variant:"destructive"})}finally{hs(!1)}}},dn=async je=>{Cs(je.id);try{const{data:{session:$e}}=await H.auth.getSession(),Ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${$e==null?void 0:$e.access_token}`},body:JSON.stringify({agentId:je.id,brokerageId:t,action:"claim_account"})}),bt=await Ye.json();if(!Ye.ok)throw new Error(bt.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${je.name}`}),er()}catch($e){console.error("Error claiming account:",$e),s({title:"Error",description:$e.message||"Failed to claim account",variant:"destructive"})}finally{Cs(null)}},Yr=async()=>{if(B){X(!0);try{const{data:{session:je}}=await H.auth.getSession(),$e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/remove-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${je==null?void 0:je.access_token}`},body:JSON.stringify({userId:B.id,brokerageId:t})}),Ye=await $e.json();if(!$e.ok)throw new Error(Ye.error||"Failed to remove agent");s({title:"Success",description:`${B.name} has been removed from your brokerage`}),U(!1),V(null),er()}catch(je){console.error("Error removing agent:",je),s({title:"Error",description:je.message||"Failed to remove agent",variant:"destructive"})}finally{X(!1)}}},vi=je=>{const $e=je.trim().split(" ");return $e.length>1?$e[$e.length-1].toLowerCase():je.toLowerCase()},pt=je=>{Ve===je?Ce(et==="asc"?"desc":"asc"):(at(je),Ce("asc"))},ir=je=>Ve!==je?e.jsx(vd,{className:"ml-1 h-4 w-4"}):et==="asc"?e.jsx(ku,{className:"ml-1 h-4 w-4"}):e.jsx(Wh,{className:"ml-1 h-4 w-4"}),Vn=n.filter(je=>{if(u==="active"&&!je.claimed||u==="pending"&&je.claimed)return!1;if(!i)return!0;const $e=i.toLowerCase();return je.name.toLowerCase().includes($e)||je.email.toLowerCase().includes($e)}),Sr=[...Vn].sort((je,$e)=>{if(!Ve)return 0;let Ye=0;return Ve==="name"?Ye=vi(je.name).localeCompare(vi($e.name)):Ve==="status"&&(Ye=je.claimed===$e.claimed?0:je.claimed?-1:1),et==="asc"?Ye:-Ye});Vn.filter(je=>je.claimed&&!dr(je.id));const jr=je=>{g($e=>{const Ye=new Set($e);return Ye.has(je)?Ye.delete(je):Ye.add(je),Ye})},ea=()=>{f.size===Sr.length?g(new Set):g(new Set(Sr.map(je=>je.id)))},Pa=()=>{g(new Set)},Ii=async()=>{const je=Array.from(f);if(je.length===0)return;_(!0);let $e=0,Ye=0;try{const{data:{session:bt}}=await H.auth.getSession();for(const gt of je)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${bt==null?void 0:bt.access_token}`},body:JSON.stringify({userId:gt})})).ok?$e++:Ye++}catch{Ye++}$e>0?s({title:"Success",description:`Welcome emails sent to ${$e} agent${$e>1?"s":""}${Ye>0?` (${Ye} failed)`:""}`}):s({title:"Error",description:"Failed to send welcome emails",variant:"destructive"}),Pa()}catch(bt){console.error("Error bulk sending welcome emails:",bt),s({title:"Error",description:bt.message||"Failed to send welcome emails",variant:"destructive"})}finally{_(!1)}};return o?e.jsx(Ee,{children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Agents"}),e.jsx(gr,{children:"Manage your brokerage's agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>re(!0),children:[e.jsx(th,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(K,{variant:"outline",onClick:()=>Q(!0),children:[e.jsx(r1,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(K,{onClick:()=>S(!0),children:[e.jsx(Tl,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]})}),e.jsxs(De,{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(cn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:i,onChange:je=>c(je.target.value),className:"pl-9"})]}),e.jsxs(Zs,{value:u,onValueChange:je=>p(je),children:[e.jsx(Ws,{className:"w-[160px]",children:e.jsx(Xs,{placeholder:"Filter by status"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Agents"}),e.jsx(Mt,{value:"active",children:"Active"}),e.jsx(Mt,{value:"pending",children:"Pending"})]})]})]}),f.size>0&&e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border bg-muted/50 p-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[f.size," agent",f.size>1?"s":""," selected"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{const $e=n.filter(Ye=>f.has(Ye.id)&&Ye.email).map(Ye=>({email:Ye.email,name:Ye.name}));sessionStorage.setItem("campaign_direct_recipients",JSON.stringify($e)),r("/admin/email-campaigns/new?directMode=1",{state:{directRecipients:$e}})},disabled:b,children:[e.jsx(Ah,{className:"mr-2 h-4 w-4"}),"Email Agents (",f.size,")"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:Ii,disabled:b,children:[e.jsx(cr,{className:"mr-2 h-4 w-4"}),b?"Sending...":"Resend Welcome Email"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:Pa,children:"Clear"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Oo,{checked:Sr.length>0&&f.size===Sr.length,onCheckedChange:ea,"aria-label":"Select all"})}),e.jsx(St,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>pt("name"),children:["Name (Last)",ir("name")]})}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>pt("status"),children:["Status",ir("status")]})}),e.jsx(St,{children:"Actions"})]})}),e.jsx(zn,{children:Sr.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):Sr.map(je=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx(Oo,{checked:f.has(je.id),onCheckedChange:()=>jr(je.id),"aria-label":`Select ${je.name}`})}),e.jsx(dt,{className:"font-medium",children:je.name}),e.jsx(dt,{children:je.email}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[je.claimed?e.jsx(tt,{variant:"default",children:"Active"}):e.jsx(tt,{variant:"secondary",children:"Pending"}),dr(je.id)&&e.jsxs(tt,{variant:"outline",className:"border-primary text-primary",children:[e.jsx(CL,{className:"mr-1 h-3 w-3"}),"Manager"]}),j[je.id]&&e.jsxs(tt,{variant:"outline",className:"text-xs",children:[e.jsx(pr,{className:"mr-1 h-3 w-3"}),"Asst: ",j[je.id].name||j[je.id].email]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{qe(je),Ge(!0)},title:"Send celebration",className:"text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",children:e.jsx(ru,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Lr(je),title:"Edit agent",children:e.jsx(Ra,{className:"h-4 w-4"})}),!je.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Es(je.id),title:"Resend welcome email",children:e.jsx(cr,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>dn(je),title:"Claim account for agent",disabled:Ts===je.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:e.jsx(W_,{className:"h-4 w-4"})})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Jr(je),title:"Set password",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",children:e.jsx(Th,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>ur(je.email,je.name),title:"Send password reset email",children:e.jsx(sS,{className:"h-4 w-4"})}),dr(je.id)&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Ea(je.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:e.jsx(th,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Mr(je),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},je.id))})]})})]})]}),e.jsx(fs,{open:k,onOpenChange:S,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Add New Agent"}),e.jsx(Gr,{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(ze,{id:"name",value:I.name,onChange:je=>O({...I,name:je.target.value}),placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:I.email,onChange:je=>O({...I,email:je.target.value}),placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(ze,{id:"phone",type:"tel",value:I.phone,onChange:je=>O({...I,phone:je.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"password",children:"Temporary Password"}),e.jsx(ze,{id:"password",type:"password",value:I.password,onChange:je=>O({...I,password:je.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(K,{onClick:xt,disabled:M,children:M?"Creating...":"Create Agent"})]})]})}),e.jsx(fs,{open:q,onOpenChange:U,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Remove Agent"}),e.jsxs(Gr,{children:["Are you sure you want to remove ",e.jsx("strong",{children:B==null?void 0:B.name})," from your brokerage? This will revoke their access to the dashboard."]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>U(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Yr,disabled:Z,children:Z?"Removing...":"Remove Agent"})]})]})}),e.jsx(stt,{open:ee,onOpenChange:Q,fixedBrokerageId:t,onSuccess:er}),e.jsx(fs,{open:ie,onOpenChange:re,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Add Brokerage Manager"}),e.jsx(Gr,{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($o,{open:be,onOpenChange:Me,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":be,className:"w-full justify-between",children:[oe?((Fo=n.find(je=>je.id===oe))==null?void 0:Fo.name)+" ("+(($t=n.find(je=>je.id===oe))==null?void 0:$t.email)+")":"Select an agent to promote...",e.jsx(Sx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-full p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search by name or email..."}),e.jsxs(Ox,{className:"max-h-[200px]",children:[e.jsx(Rx,{children:"No eligible agents found."}),e.jsx(Fx,{children:n.filter(je=>!dr(je.id)).map(je=>e.jsxs(bp,{value:`${je.name} ${je.email}`,onSelect:()=>{ce(je.id),Me(!1)},children:[e.jsx(va,{className:`mr-2 h-4 w-4 ${oe===je.id?"opacity-100":"opacity-0"}`}),je.name," (",je.email,")"]},je.id))})]})]})})]}),n.filter(je=>!dr(je.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>re(!1),children:"Cancel"}),e.jsx(K,{onClick:ki,disabled:xe||!oe,children:xe?"Adding...":"Add as Manager"})]})]})}),e.jsx(fs,{open:Ne,onOpenChange:Pe,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Edit Agent"}),e.jsxs(Gr,{children:["Update profile information for ",Oe==null?void 0:Oe.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"edit-name",children:"Name"}),e.jsx(ze,{id:"edit-name",value:ke.name,onChange:je=>Be({...ke,name:je.target.value}),placeholder:"Agent name"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"edit-email",children:"Email"}),e.jsx(ze,{id:"edit-email",type:"email",value:ke.email,onChange:je=>Be({...ke,email:je.target.value}),placeholder:"agent@example.com"}),ke.email.trim().toLowerCase()!==(Oe==null?void 0:Oe.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(ze,{id:"edit-phone",type:"tel",value:ke.phone,onChange:je=>Be({...ke,phone:je.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Pe(!1),children:"Cancel"}),e.jsx(K,{onClick:fn,disabled:nt||ft,children:ft?"Updating email...":nt?"Saving...":"Save Changes"})]})]})}),ct&&e.jsx(rtt,{open:rt,onOpenChange:je=>{Ge(je),je||qe(null)},userId:ct.id,userName:ct.name}),e.jsx(fs,{open:Ze,onOpenChange:Qe,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Set Password"}),e.jsxs(Gr,{children:["Set a new password for ",He==null?void 0:He.name,". They will be able to log in with this password immediately."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"new-password",children:"New Password"}),e.jsx(ze,{id:"new-password",type:"password",value:it,onChange:je=>Lt(je.target.value),placeholder:"Enter new password (min 6 characters)"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Make sure to communicate this password to the agent through a secure channel."})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Qe(!1),children:"Cancel"}),e.jsx(K,{onClick:Wr,disabled:Vt||!it||it.length<6,children:Vt?"Setting...":"Set Password"})]})]})})]})},Hvs={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},Wvs={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},Gvs=t=>{switch(t){case"academy_video":return e.jsx(An,{className:"h-4 w-4"});case"template":return e.jsx(Sn,{className:"h-4 w-4"});case"toolbox":return e.jsx(Sn,{className:"h-4 w-4"});case"newsletter":return e.jsx(l1,{className:"h-4 w-4"});case"social_swag":return e.jsx(pn,{className:"h-4 w-4"});case"event":return e.jsx(hn,{className:"h-4 w-4"});default:return e.jsx(tn,{className:"h-4 w-4"})}},Kvs=({brokerageId:t})=>{const{toast:s}=Ua(),[r,n]=N.useState([]),[a,o]=N.useState([]),[l,i]=N.useState([]),[c,u]=N.useState(!0),[p,f]=N.useState(null);N.useEffect(()=>{g()},[t]);const g=async()=>{try{u(!0);const{data:j,error:w}=await H.from("profiles").select("id, name, email").eq("brokerage_id",t);if(w)throw w;const k=j.map(Z=>Z.id),S=new Map(j.map(Z=>[Z.id,Z]));if(k.length===0){n([]),o([]),i([]);return}const{data:M,error:L}=await H.from("activity_logs").select("*").in("user_id",k).order("launched_at",{ascending:!1});if(L)throw L;const I=M.map(Z=>{var X,ee;return{id:Z.id,user_id:Z.user_id,app_name:Z.app_name,launched_at:Z.launched_at,user_name:((X=S.get(Z.user_id))==null?void 0:X.name)||"Unknown",user_email:((ee=S.get(Z.user_id))==null?void 0:ee.email)||"Unknown"}});n(I);const{data:O,error:q}=await H.from("content_engagement_logs").select("*").in("user_id",k).order("created_at",{ascending:!1});if(q)throw q;const U=(O||[]).map(Z=>{var X,ee;return{id:Z.id,user_id:Z.user_id,resource_type:Z.resource_type,resource_id:Z.resource_id,resource_title:Z.resource_title,action_type:Z.action_type,created_at:Z.created_at,user_name:((X=S.get(Z.user_id))==null?void 0:X.name)||"Unknown",user_email:((ee=S.get(Z.user_id))==null?void 0:ee.email)||"Unknown"}});o(U);const B=new Map;j.forEach(Z=>{B.set(Z.id,{user_id:Z.id,user_name:Z.name,user_email:Z.email,app_launches:0,content_views:0,last_activity:""})}),I.forEach(Z=>{const X=B.get(Z.user_id);X&&(X.app_launches++,(!X.last_activity||new Date(Z.launched_at)>new Date(X.last_activity))&&(X.last_activity=Z.launched_at))}),U.forEach(Z=>{const X=B.get(Z.user_id);X&&(X.content_views++,(!X.last_activity||new Date(Z.created_at)>new Date(X.last_activity))&&(X.last_activity=Z.created_at))});const V=Array.from(B.values()).filter(Z=>Z.app_launches>0||Z.content_views>0).sort((Z,X)=>new Date(X.last_activity).getTime()-new Date(Z.last_activity).getTime());i(V)}catch(j){console.error("Error loading activity:",j),s({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{u(!1)}},b=j=>r.filter(w=>w.user_id===j),_=j=>a.filter(w=>w.user_id===j);return c?e.jsx(Ee,{children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Agent Activity"}),e.jsx(gr,{children:"Track app usage and content engagement - click an agent for details"})]}),e.jsx(De,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"App Launches"}),e.jsx(St,{className:"text-center",children:"Content Views"}),e.jsx(St,{children:"Last Active"})]})}),e.jsx(zn,{children:l.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(j=>e.jsxs(Ss,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>f({id:j.user_id,name:j.user_name,email:j.user_email}),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:j.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:j.user_email})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(nl,{className:"h-3 w-3"}),j.app_launches]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"}),j.content_views]})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:j.last_activity&&Uc(new Date(j.last_activity),{addSuffix:!0})})]},j.user_id))})]})})})]}),e.jsx(fs,{open:!!p,onOpenChange:j=>!j&&f(null),children:e.jsxs(ps,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(vs,{children:[p==null?void 0:p.name,"'s Activity"]}),e.jsx(Gr,{children:p==null?void 0:p.email})]}),e.jsxs(ba,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2",children:[e.jsx(ns,{value:"content",children:"Content Engagement"}),e.jsx(ns,{value:"apps",children:"App Launches"})]}),e.jsx(bs,{value:"content",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Resource"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Action"}),e.jsx(St,{children:"Time"})]})}),e.jsx(zn,{children:p&&_(p.id).length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):p&&_(p.id).map(j=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"max-w-[200px] truncate font-medium",children:j.resource_title}),e.jsx(dt,{children:e.jsxs(tt,{variant:"outline",className:"gap-1",children:[Gvs(j.resource_type),Hvs[j.resource_type]||j.resource_type]})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:Wvs[j.action_type]||j.action_type})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Uc(new Date(j.created_at),{addSuffix:!0})})]},j.id))})]})})}),e.jsx(bs,{value:"apps",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"App"}),e.jsx(St,{children:"Time"})]})}),e.jsx(zn,{children:p&&b(p.id).length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):p&&b(p.id).map(j=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx(tt,{variant:"outline",children:j.app_name})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Uc(new Date(j.launched_at),{addSuffix:!0})})]},j.id))})]})})})]})]})})]})},Zvs=({brokerageId:t})=>{const{toast:s}=Ua(),[r,n]=N.useState({totalAgents:0,activeAgents:0,pendingAgents:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0}),[a,o]=N.useState(!0);N.useEffect(()=>{l()},[t]);const l=async()=>{try{o(!0);const{data:i,error:c}=await H.from("profiles").select("id").eq("brokerage_id",t);if(c)throw c;const u=i.map(I=>I.id),p=u.length;if(u.length===0){o(!1);return}const{data:f,error:g}=await H.from("profiles").select("id, email").in("id",u);if(g)throw g;const{count:b}=await H.from("profiles").select("*",{count:"exact",head:!0}).eq("brokerage_id",t).not("last_login","is",null),_=b||0,j=p-_,{count:w}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u),k=new Date;k.setDate(k.getDate()-7);const{count:S}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",k.toISOString()),M=new Date;M.setMonth(M.getMonth()-1);const{count:L}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",M.toISOString());n({totalAgents:p,activeAgents:_,pendingAgents:j,totalLaunches:w||0,launchesThisWeek:S||0,launchesThisMonth:L||0})}catch(i){console.error("Error loading analytics:",i),s({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{o(!1)}};return a?e.jsx(Ee,{children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Agents"}),e.jsx(pr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalAgents}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.activeAgents," active, ",r.pendingAgents," pending"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(xi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.activeAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.totalAgents>0?`${Math.round(r.activeAgents/r.totalAgents*100)}% of total`:"0% of total"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(un,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.pendingAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(kh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"This Week"}),e.jsx(kh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"This Month"}),e.jsx(kh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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"})]})]})]})},Yvs=({brokerageId:t})=>{const[s,r]=N.useState([]),[n,a]=N.useState(!0),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState({description:"",maxUses:""});N.useEffect(()=>{f()},[t]);const f=async()=>{try{const{data:k,error:S}=await H.from("invite_codes").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(S)throw S;r(k||[])}catch(k){console.error("Error loading invite codes:",k),me.error("Failed to load invite links")}finally{a(!1)}},g=()=>Math.random().toString(36).substring(2,8).toUpperCase(),b=async()=>{l(!0);try{const k=g(),{error:S}=await H.from("invite_codes").insert({code:k,description:u.description||null,max_uses:u.maxUses?parseInt(u.maxUses):null,brokerage_id:t,is_active:!0});if(S)throw S;me.success("Invite link created!"),c(!1),p({description:"",maxUses:""}),f()}catch(k){console.error("Error creating invite code:",k),me.error("Failed to create invite link")}finally{l(!1)}},_=async k=>{try{const{error:S}=await H.from("invite_codes").delete().eq("id",k);if(S)throw S;me.success("Invite link deleted"),r(s.filter(M=>M.id!==k))}catch(S){console.error("Error deleting invite code:",S),me.error("Failed to delete invite link")}},j=async(k,S)=>{try{const{error:M}=await H.from("invite_codes").update({is_active:!S}).eq("id",k);if(M)throw M;r(s.map(L=>L.id===k?{...L,is_active:!S}:L)),me.success(`Invite link ${S?"deactivated":"activated"}`)}catch(M){console.error("Error toggling invite code:",M),me.error("Failed to update invite link")}},w=k=>{const S=`${window.location.origin}/join?code=${k}`;navigator.clipboard.writeText(S),me.success("Link copied to clipboard!")};return n?e.jsx(Ee,{children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(gr,{children:"Create shareable links for agents to join your brokerage"})]}),e.jsxs(fs,{open:i,onOpenChange:c,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Create Link"]})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create Invite Link"}),e.jsx(Gr,{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(ze,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:u.description,onChange:k=>p({...u,description:k.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"maxUses",children:"Max Uses (optional)"}),e.jsx(ze,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:u.maxUses,onChange:k=>p({...u,maxUses:k.target.value})})]}),e.jsx(K,{onClick:b,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Invite Link"})]})]})]})]}),e.jsx(De,{children:s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Bo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No invite links yet"}),e.jsx("p",{className:"text-sm",children:"Create one to start inviting agents"})]}):e.jsx("div",{className:"space-y-3",children:s.map(k=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-sm font-mono bg-muted px-2 py-0.5 rounded",children:k.code}),e.jsx(tt,{variant:k.is_active?"default":"secondary",children:k.is_active?"Active":"Inactive"})]}),k.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:k.description}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[k.uses_count," uses",k.max_uses&&` / ${k.max_uses} max`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(k.code),title:"Copy link",children:e.jsx(gi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>j(k.id,k.is_active),title:k.is_active?"Deactivate":"Activate",children:k.is_active?"Disable":"Enable"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(k.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(Nr,{className:"h-4 w-4"})})]})]},k.id))})})]})},Xvs=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,c]=N.useState(""),[u,p]=N.useState([]),[f,g]=N.useState(""),[b,_]=N.useState(!1),j=L=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(L),w=()=>{const L=i.trim().toLowerCase();if(L&&j(L)&&!u.includes(L)){if(u.length>=10){me.error("Maximum 10 emails per invite");return}p([...u,L]),c("")}else L&&!j(L)?me.error("Please enter a valid email address"):u.includes(L)&&me.error("Email already added")},k=L=>{p(u.filter(I=>I!==L))},S=L=>{(L.key==="Enter"||L.key===",")&&(L.preventDefault(),w())},M=async()=>{if(u.length===0){me.error("Please add at least one email address");return}_(!0);try{const{data:L,error:I}=await H.functions.invoke("send-referral-invite",{body:{emails:u,personalMessage:f.trim()||void 0,referralCode:r,brokerageId:n,senderName:a,brokerageName:o}});if(I)throw I;L.successCount===L.totalCount?me.success(`${L.successCount} invite${L.successCount>1?"s":""} sent successfully!`):me.warning(`${L.successCount} of ${L.totalCount} invites sent. Some failed.`),p([]),g(""),s(!1),l==null||l()}catch(L){console.error("Error sending invites:",L),me.error("Failed to send invites. Please try again.")}finally{_(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[550px]",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5 text-primary"}),"Invite Broker Friends"]}),e.jsx(Gr,{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(ko,{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(ze,{id:"email",type:"email",placeholder:"Enter email and press Enter",value:i,onChange:L=>c(L.target.value),onKeyDown:S,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(L=>e.jsxs(tt,{variant:"secondary",className:"flex items-center gap-1 pr-1",children:[L,e.jsx("button",{type:"button",onClick:()=>k(L),className:"ml-1 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Rr,{className:"h-3 w-3"})})]},L))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"message",children:"Personal Message (optional)"}),e.jsx(Er,{id:"message",placeholder:"Add a personal note that will appear at the top of the email...",value:f,onChange:L=>g(L.target.value),rows:3,maxLength:500}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[f.length,"/500 characters"]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(pn,{className:"h-4 w-4 text-primary"}),"What they'll receive:"]}),e.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Beautiful branded email from you"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Your personal message (if added)"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Key LevelUp features for brokerages"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Direct signup link with your referral code"]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:M,disabled:u.length===0||b,children:b?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent mr-2"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Send ",u.length>0&&`(${u.length})`," Invite",u.length!==1?"s":""]})})]})]})})},Qvs=({brokerageId:t,refreshTrigger:s})=>{const[r,n]=N.useState([]),[a,o]=N.useState(!0);N.useEffect(()=>{l()},[t,s]);const l=async()=>{try{const{data:c,error:u}=await H.from("referral_invites").select("*").eq("referrer_brokerage_id",t).order("sent_at",{ascending:!1}).limit(20);if(u)throw u;n(c||[])}catch(c){console.error("Error fetching invites:",c)}finally{o(!1)}},i=c=>{switch(c){case"signed_up":return e.jsxs(tt,{className:"bg-green-100 text-green-800 gap-1",children:[e.jsx(xi,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(tt,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx(vc,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),"Pending"]})}};return a?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):r.length===0?e.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[e.jsx(cr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No invites sent yet"}),e.jsx("p",{className:"text-xs",children:"Start inviting broker friends to earn rewards!"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium mb-3",children:"Recent Invites"}),r.map(c=>e.jsxs("div",{className:"flex items-center justify-between p-2.5 bg-muted/30 rounded-lg",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:c.recipient_email}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sent ",ms(new Date(c.sent_at),"MMM d, yyyy")]})]}),i(c.status)]},c.id))]})},Jvs=()=>{const{brokerageId:t,user:s}=Ds(),[r,n]=N.useState(null),[a,o]=N.useState(""),[l,i]=N.useState(""),[c,u]=N.useState([]),[p,f]=N.useState(!0),[g,b]=N.useState(!1),[_,j]=N.useState(0);N.useEffect(()=>{t&&w()},[t]);const w=async()=>{try{const[O,q]=await Promise.all([H.from("brokerages").select("name").eq("id",t).single(),s?H.from("profiles").select("name").eq("id",s.id).single():Promise.resolve({data:null})]);O.data&&o(O.data.name),q.data&&i(q.data.name||"A LevelUp Member");const{data:U}=await H.from("referral_codes").select("code").eq("brokerage_id",t).single();if(U)n(U.code);else{const V=`REF${t==null?void 0:t.slice(0,8).toUpperCase()}`;await H.from("referral_codes").insert({brokerage_id:t,code:V}),n(V)}const{data:B}=await H.from("referrals").select(` *, referred_user:profiles!referred_user_id(name, email), referred_brokerage:brokerages!referred_brokerage_id(name) `).eq("referrer_brokerage_id",t).order("created_at",{ascending:!1});u(B||[])}catch(O){console.error("Error fetching referral data:",O)}finally{f(!1)}},k=()=>{const O=`https://dashboard.relevelup.com/?ref=${r}`;navigator.clipboard.writeText(O),me.success("Referral link copied to clipboard!")},S=c.filter(O=>O.status==="qualified").length,M=c.filter(O=>O.status==="pending").length,L=S*25,I=Math.max(0,Math.ceil((299-L)/25));return p?null:e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-primary/10 via-primary/5 to-background border-b",children:e.jsxs("div",{className:"px-6 py-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"bg-primary/20 rounded-full p-2",children:e.jsx(ko,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold",children:"Referral Rewards Program"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Earn $25/month off your membership for every broker you refer"})]})]}),e.jsx("div",{className:"mt-4 bg-background/80 rounded-lg p-4 border",children:e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-3xl font-bold text-primary",children:["$",L]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Savings"})]}),L>0&&e.jsxs("div",{className:"flex items-center gap-1 text-green-600",children:[e.jsx(xi,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Active"})]})]}),I>0&&L<299&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Refer ",I," more = ",e.jsx("span",{className:"text-primary",children:"FREE membership!"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your membership could cost $0/month"})]}),L>=299&&e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(pn,{className:"h-5 w-5"}),e.jsx("span",{className:"font-bold",children:"FREE Membership Unlocked!"})]})]})})]})}),e.jsxs(De,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(K,{onClick:()=>b(!0),className:"w-full",size:"lg",children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),e.jsxs(K,{onClick:k,variant:"outline",className:"w-full",size:"lg",children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy Referral Link"]})]}),e.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Your Referral Link"}),e.jsxs("code",{className:"block px-3 py-2 bg-background rounded border text-sm break-all",children:["https://dashboard.relevelup.com/?ref=",r]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"text-center p-4 bg-green-50 dark:bg-green-950/20 rounded-lg border border-green-200 dark:border-green-900",children:[e.jsx(nc,{className:"h-5 w-5 mx-auto text-green-600 mb-1"}),e.jsxs("p",{className:"text-2xl font-bold text-green-700 dark:text-green-400",children:["$",L]}),e.jsx("p",{className:"text-xs text-green-600 dark:text-green-500",children:"Monthly Savings"})]}),e.jsxs("div",{className:"text-center p-4 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsx(pr,{className:"h-5 w-5 mx-auto text-primary mb-1"}),e.jsx("p",{className:"text-2xl font-bold",children:S}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified Referrals"})]}),e.jsxs("div",{className:"text-center p-4 bg-amber-50 dark:bg-amber-950/20 rounded-lg border border-amber-200 dark:border-amber-900",children:[e.jsx(un,{className:"h-5 w-5 mx-auto text-amber-600 mb-1"}),e.jsx("p",{className:"text-2xl font-bold text-amber-700 dark:text-amber-400",children:M}),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:"Pending (30 days)"})]})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4",children:[e.jsx("h4",{className:"font-semibold text-sm mb-3",children:"How It Works"}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"1"}),e.jsx("p",{children:"Share your referral link or send an invite email to broker friends"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"2"}),e.jsx("p",{children:"They sign up and subscribe to LevelUp"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"3"}),e.jsx("p",{children:"After 30 days, you get $25/month off your membership - forever!"})]})]})]}),e.jsx(Qvs,{brokerageId:t,refreshTrigger:_}),c.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Your Referrals"}),c.slice(0,5).map(O=>{var q,U;return e.jsxs("div",{className:"flex items-center justify-between p-2.5 bg-muted/30 rounded-lg",children:[e.jsx("span",{className:"text-sm truncate",children:((q=O.referred_brokerage)==null?void 0:q.name)||((U=O.referred_user)==null?void 0:U.email)||"Pending setup"}),e.jsxs(tt,{variant:O.status==="qualified"?"default":O.status==="pending"?"secondary":"destructive",className:O.status==="qualified"?"bg-green-600":"",children:[O.status==="qualified"&&e.jsx(xi,{className:"h-3 w-3 mr-1"}),O.status]})]},O.id)})]})]})]}),e.jsx(Xvs,{open:g,onOpenChange:b,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>j(O=>O+1)})]})},e1s=({brokerageId:t})=>{const s=fr(),{teams:r,isLoading:n}=bC(t),{data:a,isLoading:o}=mt({queryKey:["team-aggregate-stats",t,r.map(p=>p.id)],queryFn:async()=>{if(r.length===0)return[];const p=r.map(O=>O.id),{data:f}=await H.from("team_members").select("team_id, user_id, role").in("team_id",p);if(!f||f.length===0)return r.map(O=>({team_id:O.id,team_name:O.name,member_count:0,leader_name:null,leader_avatar:null,total_contacts:0,total_deals:0,total_videos:0}));const g=f.map(O=>O.user_id),b=f.filter(O=>O.role==="team_leader").map(O=>O.user_id),{data:_}=await H.from("profiles").select("id, name, avatar_url").in("id",b),j=new Map((_||[]).map(O=>[O.id,O])),{data:w}=await H.from("innercircle_contacts").select("owner_user_id").in("owner_user_id",g),{data:k}=await H.from("deal_pipeline").select("owner_user_id").in("owner_user_id",g),{data:S}=await H.from("agent_videos").select("owner_user_id").in("owner_user_id",g).eq("is_deleted",!1),M=new Map;(w||[]).forEach(O=>{M.set(O.owner_user_id,(M.get(O.owner_user_id)||0)+1)});const L=new Map;(k||[]).forEach(O=>{L.set(O.owner_user_id,(L.get(O.owner_user_id)||0)+1)});const I=new Map;return(S||[]).forEach(O=>{I.set(O.owner_user_id,(I.get(O.owner_user_id)||0)+1)}),r.map(O=>{const q=f.filter(Q=>Q.team_id===O.id),U=q.find(Q=>Q.role==="team_leader"),B=U?j.get(U.user_id):null,V=q.map(Q=>Q.user_id),Z=V.reduce((Q,ie)=>Q+(M.get(ie)||0),0),X=V.reduce((Q,ie)=>Q+(L.get(ie)||0),0),ee=V.reduce((Q,ie)=>Q+(I.get(ie)||0),0);return{team_id:O.id,team_name:O.name,member_count:q.length,leader_name:(B==null?void 0:B.name)||null,leader_avatar:(B==null?void 0:B.avatar_url)||null,total_contacts:Z,total_deals:X,total_videos:ee}})},enabled:r.length>0});if(n||o)return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(p=>e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(ys,{className:"h-5 w-32"})}),e.jsx(De,{children:e.jsx(ys,{className:"h-24 w-full"})})]},p))});if(r.length===0)return e.jsx(Ee,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create teams to organize your agents and track their performance."}),e.jsx(K,{onClick:()=>s("/brokerage/teams"),children:"Manage Teams"})]})});const i=(a||[]).reduce((p,f)=>p+f.member_count,0),c=(a||[]).reduce((p,f)=>p+f.total_contacts,0),u=(a||[]).reduce((p,f)=>p+f.total_deals,0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 grid-cols-2 md:grid-cols-4",children:[e.jsx(Ee,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(pr,{className:"h-4 w-4"})," Teams"]}),e.jsx("p",{className:"text-2xl font-bold",children:r.length})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(pr,{className:"h-4 w-4"})," Total Members"]}),e.jsx("p",{className:"text-2xl font-bold",children:i})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(J4,{className:"h-4 w-4"})," Total Contacts"]}),e.jsx("p",{className:"text-2xl font-bold",children:c.toLocaleString()})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Gh,{className:"h-4 w-4"})," Total Deals"]}),e.jsx("p",{className:"text-2xl font-bold",children:u.toLocaleString()})]})})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:(a||[]).map(p=>e.jsxs(Ee,{className:"hover:shadow-md transition-shadow",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Rt,{className:"text-lg",children:p.team_name}),e.jsxs(tt,{variant:"secondary",children:[p.member_count," members"]})]}),p.leader_name&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx($a,{src:p.leader_avatar||""}),e.jsx(kn,{className:"text-xs",children:p.leader_name.charAt(0).toUpperCase()})]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Dm,{className:"h-3 w-3 text-amber-500"}),p.leader_name]})]})]}),e.jsx(De,{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 →"})})]})},t1s=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=Ds(),i=fr(),{toast:c}=Ua(),[u,p]=N.useState(""),[f,g]=N.useState(!0),b=o||(a.length>0?a[0].id:r);N.useEffect(()=>{if(!t||!s&&!n){i("/dashboard");return}!o&&a.length>0&&l(a[0].id),b?_():a.length===0&&!r&&g(!1)},[t,s,n,b,i,a,o]);const _=async()=>{if(!b){g(!1);return}try{const{data:j,error:w}=await H.from("brokerages").select("name").eq("id",b).single();if(w)throw w;p(j.name)}catch(j){console.error("Error loading brokerage info:",j),c({title:"Error",description:"Failed to load brokerage information",variant:"destructive"})}finally{g(!1)}};return f?e.jsx(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"})})}):b?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(Zs,{value:o||"",onValueChange:l,children:[e.jsxs(Ws,{className:"w-[280px]",children:[e.jsx(ka,{className:"mr-2 h-4 w-4"}),e.jsx(Xs,{placeholder:"Select brokerage"})]}),e.jsx(Gs,{children:a.map(j=>e.jsx(Mt,{value:j.id,children:j.name},j.id))})]})]}),e.jsxs(ba,{defaultValue:"agents",className:"space-y-4",children:[e.jsxs(pa,{className:"grid w-full grid-cols-4 md:grid-cols-8",children:[e.jsx(ns,{value:"agents",children:"Agents"}),e.jsx(ns,{value:"teams",children:"Teams"}),e.jsx(ns,{value:"invite",children:"Invite Links"}),e.jsx(ns,{value:"referrals",children:"Referrals"}),e.jsx(ns,{value:"leaderboard",children:"Leaderboard"}),e.jsx(ns,{value:"activity",children:"Activity"}),e.jsx(ns,{value:"analytics",children:"Analytics"}),e.jsx(ns,{value:"shares",children:"Shares"})]}),e.jsx(bs,{value:"agents",className:"space-y-4",children:e.jsx(Vvs,{brokerageId:b})}),e.jsx(bs,{value:"teams",className:"space-y-4",children:e.jsx(e1s,{brokerageId:b})}),e.jsx(bs,{value:"invite",className:"space-y-4",children:e.jsx(Yvs,{brokerageId:b})}),e.jsx(bs,{value:"referrals",className:"space-y-4",children:e.jsx(Jvs,{})}),e.jsx(bs,{value:"leaderboard",className:"space-y-4",children:e.jsx(bet,{brokerageId:b,title:`${u} Event Leaderboard`,showUserStats:!1})}),e.jsx(bs,{value:"activity",className:"space-y-4",children:e.jsx(Kvs,{brokerageId:b})}),e.jsx(bs,{value:"analytics",className:"space-y-4",children:e.jsx(Zvs,{brokerageId:b})}),e.jsx(bs,{value:"shares",className:"space-y-4",children:e.jsx(Ptt,{brokerageOnly:!0,brokerageId:b})})]})]})}):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(ka,{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 s1s({brokerageId:t,canManage:s}){const{user:r}=Ds(),[n,a]=N.useState([]),[o,l]=N.useState(!0),[i,c]=N.useState(!1),[u,p]=N.useState(null),[f,g]=N.useState(null),[b,_]=N.useState(!1),[j,w]=N.useState(""),[k,S]=N.useState(""),[M,L]=N.useState(!1),I=async()=>{try{const{data:V,error:Z}=await H.from("brokerage_announcements").select("*").eq("brokerage_id",t).order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1});if(Z)throw Z;const X=V;if(X&&X.length>0){const ee=[...new Set(X.map(oe=>oe.created_by))],{data:Q}=await H.from("profiles").select("id, name, avatar_url").in("id",ee),ie=new Map((Q==null?void 0:Q.map(oe=>[oe.id,oe]))||[]),re=X.map(oe=>({...oe,author:ie.get(oe.created_by)||{name:"Unknown",avatar_url:null}}));a(re)}else a([])}catch(V){console.error("Error fetching announcements:",V)}finally{l(!1)}};N.useEffect(()=>{I()},[t]);const O=()=>{w(""),S(""),L(!1),p(null)},q=V=>{V?(p(V),w(V.title),S(V.content),L(V.is_pinned)):O(),c(!0)},U=async()=>{if(!j.trim()||!k.trim()){me.error("Please fill in all fields");return}_(!0);try{if(u){const{error:V}=await H.from("brokerage_announcements").update({title:j.trim(),content:k.trim(),is_pinned:M,pinned_at:M?new Date().toISOString():null}).eq("id",u.id);if(V)throw V;me.success("Announcement updated")}else{const{error:V}=await H.from("brokerage_announcements").insert({brokerage_id:t,created_by:r==null?void 0:r.id,title:j.trim(),content:k.trim(),is_pinned:M,pinned_at:M?new Date().toISOString():null});if(V)throw V;me.success("Announcement created")}c(!1),O(),I()}catch(V){console.error("Error saving announcement:",V),me.error("Failed to save announcement")}finally{_(!1)}},B=async()=>{if(f)try{const{error:V}=await H.from("brokerage_announcements").delete().eq("id",f);if(V)throw V;me.success("Announcement deleted"),I()}catch(V){console.error("Error deleting announcement:",V),me.error("Failed to delete announcement")}finally{g(null)}};return o?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Ah,{className:"h-5 w-5"}),"Announcements"]})}),e.jsx(De,{children:e.jsx("div",{className:"animate-pulse space-y-3",children:e.jsx("div",{className:"h-20 bg-muted rounded"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Ah,{className:"h-5 w-5 text-primary"}),"Announcements"]}),s&&e.jsxs(K,{size:"sm",onClick:()=>q(),className:"gap-1",children:[e.jsx($s,{className:"h-4 w-4"}),"New"]})]}),e.jsx(De,{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 Z,X,ee,Q;return e.jsx("div",{className:`p-4 rounded-lg border ${V.is_pinned?"bg-primary/5 border-primary/20":"bg-muted/30"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[V.is_pinned&&e.jsx(U_,{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(Nn,{className:"h-5 w-5",children:[e.jsx($a,{src:((Z=V.author)==null?void 0:Z.avatar_url)||void 0}),e.jsx(kn,{className:"text-[10px]",children:((ee=(X=V.author)==null?void 0:X.name)==null?void 0:ee.charAt(0))||"?"})]}),e.jsx("span",{children:(Q=V.author)==null?void 0:Q.name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:ms(new Date(V.created_at),"MMM d, yyyy")})]})]}),s&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>q(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:()=>g(V.id),children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})},V.id)})})})]}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{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(Er,{id:"content",value:k,onChange:V=>S(V.target.value),placeholder:"Write your announcement...",rows:4})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"pinned",checked:M,onCheckedChange:L}),e.jsxs(ve,{htmlFor:"pinned",className:"flex items-center gap-1 cursor-pointer",children:[e.jsx(U_,{className:"h-4 w-4"}),"Pin to top"]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{onClick:U,disabled:b,children:b?"Saving...":u?"Update":"Create"})]})]})]})}),e.jsx(kc,{open:!!f,onOpenChange:()=>g(null),children:e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Delete Announcement"}),e.jsx(tc,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:B,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function r1s({brokerageId:t,canManage:s=!1}){const{startImpersonation:r,isLoading:n}=Pde(),{user:a}=Ds(),[o,l]=N.useState([]),[i,c]=N.useState(!0),[u,p]=N.useState(""),[f,g]=N.useState(new Set);N.useEffect(()=>{(async()=>{try{const{data:j,error:w}=await H.from("profiles").select("id, name, email, phone, avatar_url, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url").eq("brokerage_id",t).order("name");if(w)throw w;if(l(j||[]),j&&j.length>0){const k=j.map(M=>M.id),{data:S}=await H.from("agent_assistant_assignments").select("agent_id").in("agent_id",k);S&&g(new Set(S.map(M=>M.agent_id)))}}catch(j){console.error("Error fetching agents:",j)}finally{c(!1)}})()},[t]);const b=o.filter(_=>{var j,w;return _.name.toLowerCase().includes(u.toLowerCase())||_.email.toLowerCase().includes(u.toLowerCase())||((j=_.title)==null?void 0:j.toLowerCase().includes(u.toLowerCase()))||((w=_.areas_served)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))});return i?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"Agent Roster"]})}),e.jsx(De,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[1,2,3,4].map(_=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-48 bg-muted rounded-lg"})},_))})})]}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5 text-primary"}),"Agent Roster",e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",o.length,")"]})]}),e.jsxs("div",{className:"relative w-full sm:w-64",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:u,onChange:_=>p(_.target.value),className:"pl-9"})]})]}),e.jsx(De,{children:b.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:u?"No agents match your search":"No agents in this brokerage yet"}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:b.map(_=>e.jsx(n1s,{agent:_,hasAssistant:f.has(_.id),canImpersonate:s&&_.id!==(a==null?void 0:a.id),onImpersonate:()=>r(_.id,"/my-brokerage"),impersonationLoading:n},_.id))})})]})}function n1s({agent:t,hasAssistant:s,canImpersonate:r,onImpersonate:n,impersonationLoading:a}){const o=t.name.split(" ").map(l=>l[0]).join("").toUpperCase().slice(0,2);return e.jsxs("div",{className:"group relative bg-card border rounded-xl p-4 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex flex-col items-center text-center mb-3",children:[e.jsxs(Nn,{className:"h-20 w-20 mb-3 ring-2 ring-background shadow-md",children:[e.jsx($a,{src:t.avatar_url||void 0,alt:t.name}),e.jsx(kn,{className:"text-lg bg-primary/10 text-primary",children:o})]}),e.jsx("h3",{className:"font-semibold text-sm leading-tight",children:t.name}),t.title&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t.title}),s&&e.jsx(tt,{variant:"outline",className:"text-[10px] mt-1",children:"Has Assistant"})]}),t.bio&&e.jsx("p",{className:"text-xs text-muted-foreground text-center line-clamp-2 mb-3",children:t.bio}),e.jsxs("div",{className:"space-y-1.5 mb-3",children:[t.areas_served&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(ma,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:t.areas_served})]}),t.years_experience&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center",children:[t.years_experience," ",t.years_experience===1?"year":"years"," experience"]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r&&e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:n,disabled:a,children:e.jsx(aS,{className:"h-4 w-4"})})}),e.jsxs(Yl,{children:["Login as ",t.name]})]}),t.phone&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:`tel:${t.phone}`,title:`Call ${t.name}`,children:e.jsx(Un,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:`mailto:${t.email}`,title:`Email ${t.name}`,children:e.jsx(cr,{className:"h-4 w-4"})})}),t.linkedin_url&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:t.linkedin_url,target:"_blank",rel:"noopener noreferrer",title:"LinkedIn",children:e.jsx(Mp,{className:"h-4 w-4"})})}),t.instagram_url&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:t.instagram_url,target:"_blank",rel:"noopener noreferrer",title:"Instagram",children:e.jsx(Mu,{className:"h-4 w-4"})})})]})]})}function a1s({brokerageId:t}){const[s,r]=N.useState([]),[n,a]=N.useState(!0);if(N.useEffect(()=>{(async()=>{try{const{data:c,error:u}=await H.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!c||c.length===0){r([]),a(!1);return}const p=c.map(j=>j.id),{data:f,error:g}=await H.from("agent_attendance_stats").select("user_id, total_points").in("user_id",p).order("total_points",{ascending:!1});if(g)throw g;const b=new Map(c.map(j=>[j.id,j])),_=(f||[]).filter(j=>j.total_points>0).map(j=>{const w=b.get(j.user_id);return{user_id:j.user_id,total_points:j.total_points,name:(w==null?void 0:w.name)||"Unknown",avatar_url:(w==null?void 0:w.avatar_url)||null}});r(_)}catch(c){console.error("Error fetching leaderboard:",c)}finally{a(!1)}})()},[t]),n)return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5"}),"Team Leaderboard"]})}),e.jsx(De,{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(o1,{className:It("h-5 w-5",o(i))}):e.jsx("span",{className:"w-5 text-center text-sm text-muted-foreground",children:i});return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5 text-primary"}),"Team Leaderboard"]})}),e.jsx(De,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No points earned yet. Attend events to earn points!"}):e.jsx("div",{className:"space-y-2",children:s.slice(0,10).map((i,c)=>{const u=i.name.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2),p=c+1;return e.jsxs("div",{className:It("flex items-center gap-3 p-2 rounded-lg",p<=3&&"bg-muted/50"),children:[e.jsx("div",{className:"w-6 flex justify-center",children:l(p)}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:i.avatar_url||void 0}),e.jsx(kn,{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 i1s({brokerageId:t}){const s=fr(),[r,n]=N.useState([]),[a,o]=N.useState(!0);N.useEffect(()=>{(async()=>{try{const{data:c,error:u}=await H.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!c||c.length===0){n([]),o(!1);return}const p=c.map(j=>j.id),f=new Map(c.map(j=>[j.id,j])),{data:g,error:b}=await H.from("listings").select(` id, slug, property_address, city, price, property_type, agent_id, listing_photos(photo_url) `).in("agent_id",p).eq("status","active").order("created_at",{ascending:!1}).limit(6);if(b)throw b;const _=(g||[]).map(j=>({id:j.id,slug:j.slug,property_address:j.property_address,city:j.city,price:j.price,property_type:j.property_type,agent_id:j.agent_id,agent:f.get(j.agent_id)||null,photos:j.listing_photos||[]}));n(_)}catch(c){console.error("Error fetching listings:",c)}finally{o(!1)}})()},[t]);const l=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(i);return a?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(bn,{className:"h-5 w-5"}),"Brokerage Listings"]})}),e.jsx(De,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[1,2].map(i=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-32 bg-muted rounded-lg"})},i))})})]}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(bn,{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($s,{className:"h-4 w-4"}),"Add Listing"]})]}),e.jsxs(De,{children:[r.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(bn,{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($s,{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(bn,{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(tn,{className:"h-3 w-3 ml-1"})]})]})]})}function o1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=Ds(),n=fr(),[a,o]=N.useState(!0),[l,i]=N.useState(null),[c,u]=N.useState(""),[p,f]=N.useState(0),[g,b]=N.useState(!1),[_,j]=N.useState(!1);return N.useEffect(()=>{(async()=>{if(t)try{const{data:k}=await H.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(k!=null&&k.brokerage_id)){o(!1);return}i(k.brokerage_id);const{data:S}=await H.from("brokerages").select("name").eq("id",k.brokerage_id).maybeSingle();S&&u(S.name);const{count:M}=await H.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",k.brokerage_id);if(f(M||0),s)b(!0),j(!0);else if(r){const{data:L}=await H.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",k.brokerage_id).maybeSingle();b(!!L),j(!!L)}}catch(k){console.error("Error fetching brokerage info:",k)}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:c||"My Brokerage",description:"Team Hub",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-lg px-4 py-2",children:[e.jsx(pr,{className:"h-5 w-5 text-primary"}),e.jsxs("span",{className:"font-medium",children:[p," ",p===1?"Agent":"Agents"]})]}),_&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>n("/brokerage-content"),children:[e.jsx(Sh,{className:"h-4 w-4 mr-2"}),"Brokerage Content"]}),e.jsxs(K,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})]}),e.jsx(s1s,{brokerageId:l,canManage:g}),e.jsx(r1s,{brokerageId:l,canManage:g}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx(a1s,{brokerageId:l}),e.jsx(i1s,{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(ka,{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 l1s(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 c1s(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 RFe={video:{icon:nl,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:Sn,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:dl,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:hn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:ac,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function d1s({item:t,canManage:s}){const[r,n]=N.useState(!1),[a,o]=N.useState(null),l=vLt(),i=fr(),c=RFe[t.content_type]||RFe.link,u=c.icon,p=N.useMemo(()=>t.thumbnail_url?t.thumbnail_url:t.content_type==="graphic"&&t.file_url?t.file_url:t.content_type==="video"?l1s(t.url):null,[t]);N.useEffect(()=>{p||!t.url||t.content_type!=="video"||!c1s(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(_=>_.ok?_.json():null).then(_=>{_!=null&&_.thumbnail_url&&o(_.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,p]);const f=p||a,g=()=>{i(`/brokerage-content/${t.id}`)},b=async()=>{try{await l.mutateAsync(t.id),me.success("Content deleted")}catch{me.error("Failed to delete")}n(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"group overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30 cursor-pointer",onClick:g,children:[f?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:f,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/30 flex items-center justify-center",children:e.jsx(u,{className:"h-12 w-12 text-muted-foreground/30"})}),e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs(tt,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${c.color}`,children:[e.jsx(u,{className:"h-3 w-3 mr-1"}),c.label]}),t.category&&e.jsxs(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[t.category.icon," ",t.category.name]})]}),e.jsx("h3",{className:"font-semibold text-sm text-foreground group-hover:text-primary transition-colors truncate",children:t.title}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:t.description}),t.content_type==="event"&&t.event_date&&e.jsxs("p",{className:"text-xs text-primary mt-2 font-medium",children:["📅 ",ms(new Date(t.event_date),"MMM d, yyyy · h:mm a")]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Added ",ms(new Date(t.created_at),"MMM d, yyyy")]})]}),s&&e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,onClick:_=>_.stopPropagation(),children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(mx,{className:"h-4 w-4"})})}),e.jsx(Bd,{align:"end",children:e.jsxs(Ma,{onClick:_=>{_.stopPropagation(),n(!0)},className:"text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]})})]}),e.jsx(kc,{open:r,onOpenChange:n,children:e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Delete Content"}),e.jsxs(tc,{children:['Are you sure you want to delete "',t.title,'"? This cannot be undone.']})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:b,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function u1s(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 FFe=[{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 h1s({brokerageId:t,categories:s}){var pe;const{user:r}=Ds(),[n,a]=N.useState(!1),[o,l]=N.useState(!1),[i,c]=N.useState(""),[u,p]=N.useState("📁"),[f,g]=N.useState(!1);N.useRef(null);const[b,_]=N.useState("video"),[j,w]=N.useState(""),[k,S]=N.useState(""),[M,L]=N.useState(""),[I,O]=N.useState(""),[q,U]=N.useState(""),[B,V]=N.useState(""),[Z,X]=N.useState(""),ee=yLt(),Q=bLt(t),ie=_Lt(),re=wLt(t),oe=()=>{_("video"),w(""),S(""),L(""),O(""),U(""),V(""),X("")},ce=async(be,Me)=>{var Pe;const Ne=(Pe=be.target.files)==null?void 0:Pe[0];if(Ne){g(!0);try{const Oe=Ne.name.split(".").pop(),Te=`${t}/${Date.now()}-${Math.random().toString(36).slice(2)}.${Oe}`,{error:ke}=await H.storage.from("brokerage-content").upload(Te,Ne);if(ke)throw ke;const{data:{publicUrl:Be}}=H.storage.from("brokerage-content").getPublicUrl(Te);Me==="file"?(O(Be),b==="graphic"&&!q&&U(Be)):U(Be),me.success("File uploaded")}catch(Oe){me.error(Oe.message||"Upload failed")}finally{g(!1)}}},xe=async()=>{if(!j.trim()){me.error("Title is required");return}if(r)try{await ee.mutateAsync({brokerage_id:t,category_id:Z||null,content_type:b,title:j.trim(),description:k.trim()||null,url:M.trim()||null,file_url:I.trim()||null,thumbnail_url:q.trim()||null,event_date:B?new Date(B).toISOString():null,created_by:r.id}),me.success("Content added!"),oe(),a(!1)}catch(be){me.error(be.message||"Failed to add content")}},ge=async()=>{if(i.trim())try{await Q.mutateAsync({name:i.trim(),icon:u,sort_order:s.length}),c(""),p("📁"),me.success("Category created")}catch(be){me.error(be.message||"Failed to create category")}},ue=async()=>{try{await re.mutateAsync(),me.success("Default categories created")}catch{me.error("Failed to create defaults")}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(fs,{open:n,onOpenChange:a,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Content"]})}),e.jsxs(ps,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{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(Zs,{value:b,onValueChange:_,children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:FFe.map(be=>e.jsx(Mt,{value:be.value,children:be.label},be.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(pe=FFe.find(be=>be.value===b))==null?void 0:pe.hint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Category"}),e.jsxs(Zs,{value:Z,onValueChange:X,children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select category (optional)"})}),e.jsx(Gs,{children:s.map(be=>e.jsxs(Mt,{value:be.id,children:[be.icon," ",be.name]},be.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Title *"}),e.jsx(ze,{value:j,onChange:be=>w(be.target.value),placeholder:"Content title"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Description"}),e.jsx(Er,{value:k,onChange:be=>S(be.target.value),placeholder:"Brief description...",rows:2})]}),["video","link","graphic","event"].includes(b)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:b==="video"?"Video URL":b==="graphic"?"Canva / Image URL":b==="event"?"Event Link (Zoom, etc.)":"URL"}),e.jsx(ze,{value:M,onChange:be=>{const Me=be.target.value;if(L(Me),b==="video"&&!q){const Ne=u1s(Me);Ne&&U(Ne)}},placeholder:"https://..."})]}),["pdf","graphic"].includes(b)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:b==="pdf"?"Upload PDF":"Upload Image"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"file",accept:b==="pdf"?".pdf,.doc,.docx":"image/*",onChange:be=>ce(be,"file"),disabled:f}),f&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]}),I&&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(ze,{type:"file",accept:"image/*",onChange:be=>ce(be,"thumbnail"),disabled:f}),q&&e.jsxs("div",{className:"relative w-20 h-20 rounded overflow-hidden",children:[e.jsx("img",{src:q,className:"w-full h-full object-cover",alt:"thumb"}),e.jsx("button",{onClick:()=>U(""),className:"absolute top-0 right-0 bg-background/80 rounded-bl p-0.5",children:e.jsx(Rr,{className:"h-3 w-3"})})]})]}),b==="event"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Event Date & Time"}),e.jsx(ze,{type:"datetime-local",value:B,onChange:be=>V(be.target.value)})]}),e.jsxs(K,{onClick:xe,disabled:ee.isPending||!j.trim(),className:"w-full",children:[ee.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Content"]})]})]})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",children:[e.jsx(Xo,{className:"h-4 w-4 mr-2"}),"Categories"]})}),e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Manage Categories"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[s.length===0&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No categories yet"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ue,disabled:re.isPending,children:[re.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Default Categories"]})]}),s.map(be=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg border",children:[e.jsxs("span",{className:"text-sm",children:[be.icon," ",be.name]}),!be.is_default&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:async()=>{await ie.mutateAsync(be.id),me.success("Category deleted")},children:e.jsx(Rr,{className:"h-4 w-4"})})]},be.id)),e.jsxs("div",{className:"flex gap-2 pt-2 border-t",children:[e.jsx(ze,{value:u,onChange:be=>p(be.target.value),className:"w-14 text-center",maxLength:2}),e.jsx(ze,{value:i,onChange:be=>c(be.target.value),placeholder:"New category name",className:"flex-1",onKeyDown:be=>be.key==="Enter"&&ge()}),e.jsx(K,{size:"sm",onClick:ge,disabled:!i.trim(),children:"Add"})]})]})]})]})]})}function m1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=Ds(),[n,a]=N.useState(!0),[o,l]=N.useState(null),[i,c]=N.useState(""),[u,p]=N.useState(!1),[f,g]=N.useState(null),[b,_]=N.useState("");N.useEffect(()=>{(async()=>{if(t)try{const{data:L}=await H.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(L!=null&&L.brokerage_id)){a(!1);return}l(L.brokerage_id);const{data:I}=await H.from("brokerages").select("name").eq("id",L.brokerage_id).maybeSingle();if(I&&c(I.name),s)p(!0);else if(r){const{data:O}=await H.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",L.brokerage_id).maybeSingle();p(!!O)}}catch(L){console.error("Error fetching brokerage info:",L)}finally{a(!1)}})()},[t,s,r]);const{data:j=[]}=fLt(o),{data:w=[],isLoading:k}=xLt(o,f),S=N.useMemo(()=>{if(!b.trim())return w;const M=b.toLowerCase();return w.filter(L=>{var I;return L.title.toLowerCase().includes(M)||((I=L.description)==null?void 0:I.toLowerCase().includes(M))||L.content_type.toLowerCase().includes(M)})},[w,b]);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(h1s,{brokerageId:o,categories:j}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search content...",value:b,onChange:M=>_(M.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(K,{variant:f===null?"default":"outline",size:"sm",onClick:()=>g(null),children:"All"}),j.map(M=>e.jsxs(K,{variant:f===M.id?"default":"outline",size:"sm",onClick:()=>g(M.id),children:[e.jsx("span",{className:"mr-1",children:M.icon}),M.name]},M.id))]})]}),k?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):S.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Om,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:b.trim()?"No matching content found":"No content yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:b.trim()?"Try a different search term or category.":u?"Add your first piece of content above.":"Your brokerage hasn't added content yet."})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:S.map(M=>e.jsx(d1s,{item:M,canManage:u},M.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(ka,{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 zFe={video:{icon:nl,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:Sn,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:dl,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:hn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:ac,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function p1s(t){try{const s=new URL(t),r=s.hostname.replace("www.","");if(s.pathname==="/playlist"){const n=s.searchParams.get("list");if(n)return`https://www.youtube.com/embed/videoseries?list=${n}`}if(r==="youtube.com"||r==="m.youtube.com"){const n=s.searchParams.get("v");if(n){const a=s.searchParams.get("list");let o=`https://www.youtube.com/embed/${n}`;return a&&(o+=`?list=${a}`),o}}if(r==="youtu.be"){const n=s.pathname.slice(1);if(n){const a=s.searchParams.get("list");let o=`https://www.youtube.com/embed/${n}`;return a&&(o+=`?list=${a}`),o}}if(r==="youtube.com"&&s.pathname.startsWith("/embed/"))return t}catch{}return null}function f1s(t){try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function x1s(t){try{return new URL(t).hostname.includes("vimeo.com")}catch{return!1}}function g1s(t){try{const s=t.match(/vimeo\.com\/(\d+)/);if(s)return`https://player.vimeo.com/video/${s[1]}`}catch{}return null}function y1s(){const{contentId:t}=yo(),{data:s,isLoading:r}=mt({queryKey:["brokerage-content-detail",t],queryFn:async()=>{const{data:u,error:p}=await H.from("brokerage_content").select(` *, category:brokerage_content_categories(*) `).eq("id",t).single();if(p)throw p;return u},enabled:!!t});if(r)return e.jsx(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(ka,{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(Pi,{to:"/brokerage-content",children:"Back to Content"})})]})});const n=zFe[s.content_type]||zFe.link,a=n.icon,o=s.url||s.file_url,l=o&&f1s(o)?p1s(o):null,i=o&&x1s(o)?g1s(o):null,c=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(Pi,{to:"/brokerage-content",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Content"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(tt,{variant:"secondary",className:`text-xs px-2 py-0.5 ${n.color}`,children:[e.jsx(a,{className:"h-3 w-3 mr-1"}),n.label]}),s.category&&e.jsxs(tt,{variant:"outline",className:"text-xs px-2 py-0.5",children:[s.category.icon," ",s.category.name]}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto",children:["Added ",ms(new Date(s.created_at),"MMMM d, yyyy")]})]}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),c&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"relative w-full bg-black",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:c,className:"absolute top-0 left-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:s.title})})}),s.content_type==="graphic"&&s.file_url&&!c&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("img",{src:s.file_url,alt:s.title,className:"w-full max-h-[600px] object-contain bg-muted"})}),!c&&s.content_type!=="graphic"&&s.thumbnail_url&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("img",{src:s.thumbnail_url,alt:s.title,className:"w-full max-h-[400px] object-cover"})}),s.description&&e.jsx(Ee,{children:e.jsx(De,{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(De,{className:"pt-6 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(hn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Event Date"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:ms(new Date(s.event_date),"EEEE, MMMM d, yyyy · h:mm a")})]})]})}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.file_url&&e.jsx(K,{asChild:!0,size:"lg",children:e.jsxs("a",{href:s.file_url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(yi,{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(tn,{className:"h-4 w-4 mr-2"}),c?"Open on YouTube":s.content_type==="event"?"Join Event":s.content_type==="graphic"?"Open in Canva":"Open Link"]})})]})]})})}function v1s(){const t=fr(),[s,r]=N.useState(""),[n,a]=N.useState("grid"),{data:o,isLoading:l}=mt({queryKey:["newsletters"],queryFn:async()=>{const{data:M,error:L}=await H.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(L)throw L;return M}}),{data:i}=mt({queryKey:["newsletter-likes-all"],queryFn:async()=>{const{data:M}=await H.from("newsletter_likes").select("newsletter_id");return M||[]}}),{data:c}=mt({queryKey:["newsletter-comments-all"],queryFn:async()=>{const{data:M}=await H.from("newsletter_comments").select("newsletter_id");return M||[]}}),{data:u}=mt({queryKey:["newsletter-resource-counts"],queryFn:async()=>{const[M,L,I,O]=await Promise.all([H.from("newsletter_canva_links").select("newsletter_id"),H.from("newsletter_pdfs").select("newsletter_id"),H.from("newsletter_videos").select("newsletter_id"),H.from("newsletter_drive_links").select("newsletter_id")]);return{canva:M.data||[],pdfs:L.data||[],videos:I.data||[],drives:O.data||[]}}}),p=M=>(i==null?void 0:i.filter(L=>L.newsletter_id===M).length)||0,f=M=>(c==null?void 0:c.filter(L=>L.newsletter_id===M).length)||0,g=M=>{var L;return((L=u==null?void 0:u.canva)==null?void 0:L.filter(I=>I.newsletter_id===M).length)||0},b=M=>{var L;return((L=u==null?void 0:u.pdfs)==null?void 0:L.filter(I=>I.newsletter_id===M).length)||0},_=M=>{var L;return((L=u==null?void 0:u.videos)==null?void 0:L.filter(I=>I.newsletter_id===M).length)||0},j=M=>{var L;return((L=u==null?void 0:u.drives)==null?void 0:L.filter(I=>I.newsletter_id===M).length)||0},w=M=>g(M)+b(M)+_(M)+j(M),k=o==null?void 0:o.filter(M=>{var L;return M.title.toLowerCase().includes(s.toLowerCase())||((L=M.description)==null?void 0:L.toLowerCase().includes(s.toLowerCase()))}),S=M=>{t(`/newsletters/${M}`)};return e.jsx(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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search newsletters...",value:s,onChange:M=>r(M.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Mh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[(k==null?void 0:k.length)||0," item",(k==null?void 0:k.length)!==1?"s":""," found"]}),l&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(8)].map((M,L)=>e.jsx(Ee,{children:e.jsxs(De,{className:"p-0",children:[e.jsx(ys,{className:"aspect-[3/2] w-full"}),e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-full"})]})]})},L))}),!l&&(k==null?void 0:k.length)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Sn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No newsletters match your search":"No newsletters available yet"}),s&&e.jsx(K,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&k&&k.length>0&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-3",children:k.map(M=>{const L=w(M.id),I=g(M.id),O=b(M.id),q=_(M.id);return n==="grid"?e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer border-border/50",onClick:()=>S(M.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:M.preview_image_url?e.jsx("img",{src:M.preview_image_url,alt:M.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(Sn,{className:"h-16 w-16"})})}),e.jsxs(De,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:M.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(M.publish_date),"MMM d, yyyy")]})]}),M.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:M.description.replace(/<[^>]*>/g,"")}),L>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[I>0&&e.jsxs(tt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(ac,{className:"h-3 w-3"})," ",I," Template",I>1?"s":""]}),O>0&&e.jsxs(tt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(yi,{className:"h-3 w-3"})," ",O," PDF",O>1?"s":""]}),q>0&&e.jsxs(tt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(nl,{className:"h-3 w-3"})," ",q," Video",q>1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground pt-1 border-t border-border/50",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:"h-3 w-3"})," ",p(M.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($c,{className:"h-3 w-3"})," ",f(M.id)]})]})]})]},M.id):e.jsx(Ee,{className:"group overflow-hidden hover:shadow-md transition-all duration-200 cursor-pointer border-border/50",onClick:()=>S(M.id),children:e.jsxs("div",{className:"flex flex-row",children:[e.jsx("div",{className:"relative overflow-hidden bg-muted w-40 sm:w-48 shrink-0",children:M.preview_image_url?e.jsx("img",{src:M.preview_image_url,alt:M.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground min-h-[100px]",children:e.jsx(Sn,{className:"h-10 w-10"})})}),e.jsxs(De,{className:"p-4 flex-1 flex flex-col justify-center gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:M.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(M.publish_date),"MMM d, yyyy")]})]}),M.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:M.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[L>0&&e.jsxs("span",{children:[L," resource",L>1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:"h-3 w-3"})," ",p(M.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($c,{className:"h-3 w-3"})," ",f(M.id)]})]})]})]})},M.id)})})]})})}function b1s({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(De,{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 _1s(){const{id:t}=yo(),s=fr(),{user:r}=Ds(),{toast:n}=Ua(),a=Qt(),{trackEngagement:o}=HO(),[l,i]=N.useState(""),{data:c,isLoading:u}=mt({queryKey:["newsletter",t],queryFn:async()=>{const{data:I,error:O}=await H.from("newsletter_content").select("*").eq("id",t).single();if(O)throw O;return I},enabled:!!t});N.useEffect(()=>{c&&o("newsletter",c.id,c.title,"view")},[c==null?void 0:c.id]);const{data:p}=mt({queryKey:["newsletter-drives",t],queryFn:async()=>{const{data:I}=await H.from("newsletter_drive_links").select("*").eq("newsletter_id",t).order("sort_order");return I||[]},enabled:!!t}),{data:f}=mt({queryKey:["newsletter-pdfs",t],queryFn:async()=>{const{data:I}=await H.from("newsletter_pdfs").select("*").eq("newsletter_id",t).order("sort_order");return I||[]},enabled:!!t}),{data:g}=mt({queryKey:["newsletter-videos",t],queryFn:async()=>{const{data:I}=await H.from("newsletter_videos").select("*").eq("newsletter_id",t).order("sort_order");return I||[]},enabled:!!t}),{data:b}=mt({queryKey:["newsletter-canva-links",t],queryFn:async()=>{const{data:I}=await H.from("newsletter_canva_links").select("*").eq("newsletter_id",t).order("sort_order");return I||[]},enabled:!!t}),{data:_}=mt({queryKey:["newsletter-likes",t],queryFn:async()=>{const{data:I}=await H.from("newsletter_likes").select("*").eq("newsletter_id",t);return I||[]},enabled:!!t}),{data:j}=mt({queryKey:["newsletter-comments",t],queryFn:async()=>{const{data:I}=await H.from("newsletter_comments").select("*, profiles:user_id(name)").eq("newsletter_id",t).order("created_at",{ascending:!1});return I||[]},enabled:!!t}),w=_==null?void 0:_.some(I=>I.user_id===(r==null?void 0:r.id)),k=Dt({mutationFn:async()=>{w?await H.from("newsletter_likes").delete().eq("newsletter_id",t).eq("user_id",r==null?void 0:r.id):await H.from("newsletter_likes").insert({newsletter_id:t,user_id:r==null?void 0:r.id})},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-likes",t]})}}),S=Dt({mutationFn:async I=>{const{error:O}=await H.from("newsletter_comments").insert({newsletter_id:t,user_id:r==null?void 0:r.id,content:I});if(O)throw O},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),i(""),n({title:"Comment added"})}}),M=Dt({mutationFn:async I=>{const{error:O}=await H.from("newsletter_comments").delete().eq("id",I);if(O)throw O},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),n({title:"Comment deleted"})}}),L=I=>{if(I.includes("player.mediadelivery.net")||I.includes("iframe.mediadelivery.net")){const O=I.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(O)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://iframe.mediadelivery.net/embed/${O[1]}/${O[2]}?autoplay=false`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}if(I.includes("youtube.com")||I.includes("youtu.be")){const O=I.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([^&\s]+)/);if(O)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${O[1]}`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}return e.jsxs("a",{href:I,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(nl,{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(ys,{className:"h-8 w-32"}),e.jsx(ys,{className:"h-64 w-full"}),e.jsx(ys,{className:"h-32 w-full"})]})}):c?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(Ja,{className:"mr-2 h-4 w-4"})," Back to Newsletters"]}),c.preview_image_url&&e.jsx("img",{src:c.preview_image_url,alt:c.title,className:"w-full h-64 md:h-80 object-cover rounded-lg"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:c.title}),e.jsx("p",{className:"text-muted-foreground mt-1",children:ms(new Date(c.publish_date),"MMMM d, yyyy")})]}),c.description&&e.jsx("div",{className:"text-lg text-muted-foreground prose prose-sm max-w-none dark:prose-invert [&_p]:mb-4 [&_p:last-child]:mb-0 whitespace-pre-line",dangerouslySetInnerHTML:{__html:c.description}}),e.jsx(b1s,{rows:c.content_blocks||[]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(iE,{resourceType:"newsletter",resourceId:c.id,resourceTitle:c.title}),e.jsxs(K,{variant:w?"default":"outline",size:"sm",onClick:()=>k.mutate(),children:[e.jsx(ni,{className:`h-4 w-4 mr-1 ${w?"fill-current":""}`}),(_==null?void 0:_.length)||0," ",(_==null?void 0:_.length)===1?"Like":"Likes"]})]}),b&&b.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Canva Templates"})}),e.jsx(De,{className:"space-y-2",children:b.map(I=>e.jsxs("a",{href:I.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",c.id,c.title,"click_canva"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(ac,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:I.title}),e.jsx(tn,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},I.id))})]}),p&&p.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Google Drive Files"})}),e.jsx(De,{className:"space-y-2",children:p.map(I=>e.jsxs("a",{href:I.drive_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",c.id,c.title,"click_link"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(tn,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:I.title})]},I.id))})]}),f&&f.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"PDF Downloads"})}),e.jsx(De,{className:"space-y-2",children:f.map(I=>e.jsxs("a",{href:I.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",c.id,c.title,"click_pdf"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(Sn,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-medium flex-1",children:I.name}),e.jsx(yi,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]}),g&&g.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Videos"})}),e.jsx(De,{className:"space-y-6",children:g.map(I=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:I.title}),L(I.video_url)]},I.id))})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-lg",children:["Comments (",(j==null?void 0:j.length)||0,")"]})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Er,{placeholder:"Write a comment...",value:l,onChange:I=>i(I.target.value),className:"flex-1"}),e.jsx(K,{onClick:()=>l.trim()&&S.mutate(l),disabled:!l.trim()||S.isPending,children:e.jsx(Bn,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-4",children:j==null?void 0:j.map(I=>{var O,q,U;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{children:((q=(O=I.profiles)==null?void 0:O.name)==null?void 0:q[0])||"U"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium text-sm",children:((U=I.profiles)==null?void 0:U.name)||"User"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(I.created_at),"MMM d, yyyy")}),I.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>M.mutate(I.id),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:I.content})]})]},I.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 w1s({rows:t,onChange:s}){const[r,n]=N.useState(null),a=()=>{s([...t,{columns:[{title:"",description:""},{title:"",description:""},{title:"",description:""}]}])},o=u=>{s(t.filter((p,f)=>f!==u))},l=(u,p,f,g)=>{const b=[...t];b[u]={...b[u],columns:b[u].columns.map((_,j)=>j===p?{..._,[f]:g}:_)},s(b)},i=async(u,p,f)=>{var _;const g=(_=f.target.files)==null?void 0:_[0];if(!g)return;const b=`${u}-${p}`;n(b);try{const j=`content-blocks/${Date.now()}-${g.name}`,{error:w}=await H.storage.from("newsletter-content").upload(j,g);if(!w){const{data:k}=H.storage.from("newsletter-content").getPublicUrl(j);l(u,p,"image_url",k.publicUrl)}}finally{n(null)}},c=(u,p)=>{l(u,p,"image_url","")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(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($s,{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(Rr,{className:"h-4 w-4"})}),e.jsxs(De,{className:"p-4 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Row ",p+1]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:u.columns.map((f,g)=>{const b=`${p}-${g}`;return e.jsxs("div",{className:"space-y-2 border border-border/50 rounded-md p-3 bg-muted/20",children:[e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:["Column ",g+1]}),f.image_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:f.image_url,alt:"",className:"w-full h-20 object-cover rounded"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>c(p,g),children:e.jsx(Rr,{className:"h-3 w-3"})})]}):e.jsxs("div",{children:[e.jsx(ze,{type:"file",accept:"image/*",className:"hidden",id:`block-img-${b}`,onChange:_=>i(p,g,_)}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"w-full text-xs h-8",disabled:r===b,asChild:!0,children:e.jsx("label",{htmlFor:`block-img-${b}`,className:"cursor-pointer",children:r===b?"Uploading...":e.jsxs(e.Fragment,{children:[e.jsx(gl,{className:"h-3 w-3 mr-1"})," Image"]})})})]}),e.jsx(ze,{placeholder:"Title",value:f.title,onChange:_=>l(p,g,"title",_.target.value),className:"h-8 text-sm"}),e.jsx(Er,{placeholder:"Description",value:f.description,onChange:_=>l(p,g,"description",_.target.value),className:"text-sm min-h-[60px] resize-none"})]},g)})})]})]},p))]})}function j1s(){const{toast:t}=Ua(),s=Qt(),[r,n]=N.useState(!1),[a,o]=N.useState(null),[l,i]=N.useState({title:"",description:"",publish_date:ms(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[c,u]=N.useState(null),[p,f]=N.useState(null),[g,b]=N.useState([]),[_,j]=N.useState([]),[w,k]=N.useState([]),[S,M]=N.useState([]),[L,I]=N.useState([]),[O,q]=N.useState([]),[U,B]=N.useState(!1),{data:V,isLoading:Z}=mt({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:Ne,error:Pe}=await H.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Pe)throw Pe;return Ne}}),X=Dt({mutationFn:async Ne=>{const{data:Pe,error:Oe}=await H.from("newsletter_content").insert({title:Ne.title,description:Ne.description||null,preview_image_url:Ne.preview_image_url,publish_date:Ne.publish_date,is_published:Ne.is_published,content_blocks:Ne.content_blocks}).select().single();if(Oe)throw Oe;return Pe},onSuccess:async Ne=>{await ie(Ne.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),Ne.is_published&&oVt(Ne.title,Ne.id),ce()},onError:Ne=>{t({title:"Error creating newsletter",description:Ne.message,variant:"destructive"})}}),ee=Dt({mutationFn:async Ne=>{const{error:Pe}=await H.from("newsletter_content").update({title:Ne.title,description:Ne.description||null,preview_image_url:Ne.preview_image_url,publish_date:Ne.publish_date,is_published:Ne.is_published,content_blocks:Ne.content_blocks}).eq("id",Ne.id);if(Pe)throw Pe;return Ne.id},onSuccess:async Ne=>{await ie(Ne),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter updated successfully"}),ce()},onError:Ne=>{t({title:"Error updating newsletter",description:Ne.message,variant:"destructive"})}}),Q=Dt({mutationFn:async Ne=>{const{error:Pe}=await H.from("newsletter_content").delete().eq("id",Ne);if(Pe)throw Pe},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter deleted successfully"})},onError:Ne=>{t({title:"Error deleting newsletter",description:Ne.message,variant:"destructive"})}}),ie=async Ne=>{await H.from("newsletter_drive_links").delete().eq("newsletter_id",Ne),await H.from("newsletter_pdfs").delete().eq("newsletter_id",Ne),await H.from("newsletter_videos").delete().eq("newsletter_id",Ne),await H.from("newsletter_canva_links").delete().eq("newsletter_id",Ne);for(const Pe of O){const Oe=`${Ne}/${Date.now()}-${Pe.file.name}`,{error:Te}=await H.storage.from("newsletter-content").upload(Oe,Pe.file);if(!Te){const{data:ke}=H.storage.from("newsletter-content").getPublicUrl(Oe);_.push({name:Pe.name,file_url:ke.publicUrl,file_size:Pe.file.size,sort_order:_.length})}}g.length>0&&await H.from("newsletter_drive_links").insert(g.map((Pe,Oe)=>({newsletter_id:Ne,title:Pe.title,drive_url:Pe.drive_url,sort_order:Oe}))),_.length>0&&await H.from("newsletter_pdfs").insert(_.map((Pe,Oe)=>({newsletter_id:Ne,name:Pe.name,file_url:Pe.file_url,file_size:Pe.file_size||null,sort_order:Oe}))),w.length>0&&await H.from("newsletter_videos").insert(w.map((Pe,Oe)=>({newsletter_id:Ne,title:Pe.title,video_url:Pe.video_url,sort_order:Oe}))),S.length>0&&await H.from("newsletter_canva_links").insert(S.map((Pe,Oe)=>({newsletter_id:Ne,title:Pe.title,canva_share_link:Pe.canva_share_link,sort_order:Oe})))},re=async Ne=>{o(Ne),i({title:Ne.title,description:Ne.description||"",publish_date:ms(new Date(Ne.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:Ne.is_published}),f(Ne.preview_image_url),I(Ne.content_blocks||[]);const[Pe,Oe,Te,ke]=await Promise.all([H.from("newsletter_drive_links").select("*").eq("newsletter_id",Ne.id).order("sort_order"),H.from("newsletter_pdfs").select("*").eq("newsletter_id",Ne.id).order("sort_order"),H.from("newsletter_videos").select("*").eq("newsletter_id",Ne.id).order("sort_order"),H.from("newsletter_canva_links").select("*").eq("newsletter_id",Ne.id).order("sort_order")]);b(Pe.data||[]),j(Oe.data||[]),k(Te.data||[]),M(ke.data||[]),q([]),n(!0)},oe=async Ne=>{const[Pe,Oe,Te,ke]=await Promise.all([H.from("newsletter_drive_links").select("*").eq("newsletter_id",Ne.id).order("sort_order"),H.from("newsletter_pdfs").select("*").eq("newsletter_id",Ne.id).order("sort_order"),H.from("newsletter_videos").select("*").eq("newsletter_id",Ne.id).order("sort_order"),H.from("newsletter_canva_links").select("*").eq("newsletter_id",Ne.id).order("sort_order")]);o(null),i({title:`${Ne.title} (Copy)`,description:Ne.description||"",publish_date:ms(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),f(Ne.preview_image_url),I(Ne.content_blocks||[]),b((Pe.data||[]).map(({id:Be,...nt})=>nt)),j((Oe.data||[]).map(({id:Be,...nt})=>nt)),k((Te.data||[]).map(({id:Be,...nt})=>nt)),M((ke.data||[]).map(({id:Be,...nt})=>nt)),q([]),n(!0)},ce=()=>{n(!1),o(null),i({title:"",description:"",publish_date:ms(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),u(null),f(null),b([]),j([]),k([]),M([]),I([]),q([])},xe=async Ne=>{var Oe;const Pe=(Oe=Ne.target.files)==null?void 0:Oe[0];Pe&&(u(Pe),f(URL.createObjectURL(Pe)))},ge=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}B(!0);let Ne=p;if(c){const Pe=`previews/${Date.now()}-${c.name}`,{error:Oe}=await H.storage.from("newsletter-content").upload(Pe,c);if(!Oe){const{data:Te}=H.storage.from("newsletter-content").getPublicUrl(Pe);Ne=Te.publicUrl}}a?ee.mutate({id:a.id,...l,preview_image_url:Ne,content_blocks:L}):X.mutate({...l,preview_image_url:Ne,content_blocks:L}),B(!1)},ue=()=>b([...g,{title:"",drive_url:"",sort_order:g.length}]),pe=()=>k([...w,{title:"",video_url:"",sort_order:w.length}]),be=()=>M([...S,{title:"",canva_share_link:"",sort_order:S.length}]),Me=Ne=>{const Pe=Ne.target.files;if(!Pe)return;const Oe=Array.from(Pe).map(Te=>({file:Te,name:Te.name.replace(/\.[^/.]+$/,"")}));q([...O,...Oe])};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(oh,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources"}),e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.filter(Ne=>Ne.is_published).length)||0})})]})]}),e.jsxs(fs,{open:r,onOpenChange:Ne=>!Ne&&ce(),children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx($s,{className:"mr-2 h-4 w-4"})," Add Newsletter"]})}),e.jsxs(ps,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{value:l.title,onChange:Ne=>i({...l,title:Ne.target.value}),placeholder:"Newsletter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Publish Date"}),e.jsx(ze,{type:"datetime-local",value:l.publish_date,onChange:Ne=>i({...l,publish_date:Ne.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(my,{content:l.description,onChange:Ne=>i({...l,description:Ne}),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(Rr,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:xe,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(li,{className:"mr-2 h-4 w-4"})," Upload Image"]})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:l.is_published,onCheckedChange:Ne=>i({...l,is_published:Ne})}),e.jsx(ve,{children:"Published"})]}),e.jsx(w1s,{rows:L,onChange:I}),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:be,children:[e.jsx($s,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),S.map((Ne,Pe)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ze,{placeholder:"Link title",value:Ne.title,onChange:Oe=>{const Te=[...S];Te[Pe].title=Oe.target.value,M(Te)},className:"w-1/3"}),e.jsx(ze,{placeholder:"Canva share link",value:Ne.canva_share_link,onChange:Oe=>{const Te=[...S];Te[Pe].canva_share_link=Oe.target.value,M(Te)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>M(S.filter((Oe,Te)=>Te!==Pe)),children:e.jsx(Rr,{className:"h-4 w-4"})})]},Pe))]}),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:ue,children:[e.jsx($s,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),g.map((Ne,Pe)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ze,{placeholder:"Link title",value:Ne.title,onChange:Oe=>{const Te=[...g];Te[Pe].title=Oe.target.value,b(Te)},className:"w-1/3"}),e.jsx(ze,{placeholder:"Google Drive URL",value:Ne.drive_url,onChange:Oe=>{const Te=[...g];Te[Pe].drive_url=Oe.target.value,b(Te)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>b(g.filter((Oe,Te)=>Te!==Pe)),children:e.jsx(Rr,{className:"h-4 w-4"})})]},Pe))]}),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(ze,{type:"file",accept:".pdf",multiple:!0,onChange:Me,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(li,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),_.map((Ne,Pe)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:Ne.name}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>j(_.filter((Oe,Te)=>Te!==Pe)),children:e.jsx(Rr,{className:"h-4 w-4"})})]},`existing-${Pe}`)),O.map((Ne,Pe)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:Ne.name,onChange:Oe=>{const Te=[...O];Te[Pe].name=Oe.target.value,q(Te)},className:"flex-1 h-8",placeholder:"PDF name"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"(new)"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>q(O.filter((Oe,Te)=>Te!==Pe)),children:e.jsx(Rr,{className:"h-4 w-4"})})]},`pending-${Pe}`))]}),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:pe,children:[e.jsx($s,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),w.map((Ne,Pe)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ze,{placeholder:"Video title",value:Ne.title,onChange:Oe=>{const Te=[...w];Te[Pe].title=Oe.target.value,k(Te)},className:"w-1/3"}),e.jsx(ze,{placeholder:"Video URL",value:Ne.video_url,onChange:Oe=>{const Te=[...w];Te[Pe].video_url=Oe.target.value,k(Te)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>k(w.filter((Oe,Te)=>Te!==Pe)),children:e.jsx(Rr,{className:"h-4 w-4"})})]},Pe))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:ce,children:"Cancel"}),e.jsx(K,{onClick:ge,disabled:U||X.isPending||ee.isPending,children:U?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:Z?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(V==null?void 0:V.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No newsletters yet. Create your first one!"})}):V==null?void 0:V.map(Ne=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ne.preview_image_url?e.jsx("img",{src:Ne.preview_image_url,alt:Ne.title,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(Sn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ne.title}),Ne.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Ne.description.replace(/<[^>]*>/g,"")})]})]})}),e.jsx(dt,{children:ms(new Date(Ne.publish_date),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Ne.is_published?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"}`,children:Ne.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>re(Ne),title:"Edit",children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>oe(Ne),title:"Duplicate",children:e.jsx(gi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",title:"Delete",onClick:()=>{confirm("Are you sure you want to delete this newsletter?")&&Q.mutate(Ne.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},Ne.id))})]})})})]})})}const BFe={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 N1s(){const{user:t}=Ds(),{toast:s}=Ua(),r=fr(),n=Qt(),[a,o]=N.useState(""),[l,i]=N.useState("popular"),[c,u]=N.useState(!1),[p,f]=N.useState(""),[g,b]=N.useState(""),[_,j]=N.useState(!1),{data:w=[],isLoading:k}=mt({queryKey:["wishlist-items",l,_],queryFn:async()=>{let O=H.from("wishlist_items").select("*");_&&t&&(O=O.eq("user_id",t.id)),l==="latest"?O=O.order("created_at",{ascending:!1}):l==="popular"?O=O.order("vote_count",{ascending:!1}):l==="trending"&&(O=O.order("vote_count",{ascending:!1}));const{data:q,error:U}=await O;if(U)throw U;const B=[...new Set((q==null?void 0:q.map(re=>re.user_id))||[])],{data:V}=await H.from("profiles").select("id, name").in("id",B),Z=new Map((V==null?void 0:V.map(re=>[re.id,re]))||[]);let X=[];if(t){const{data:re}=await H.from("wishlist_votes").select("item_id").eq("user_id",t.id);X=(re==null?void 0:re.map(oe=>oe.item_id))||[]}const ee=(q==null?void 0:q.map(re=>re.id))||[],{data:Q}=await H.from("wishlist_comments").select("item_id").in("item_id",ee),ie=new Map;return Q==null||Q.forEach(re=>{ie.set(re.item_id,(ie.get(re.item_id)||0)+1)}),q==null?void 0:q.map(re=>{const oe=Z.get(re.user_id),ce=(oe==null?void 0:oe.name)||"Unknown";return{...re,user_name:ce,user_initials:ce.split(" ").map(xe=>xe[0]).join("").toUpperCase().slice(0,2),has_voted:X.includes(re.id),comment_count:ie.get(re.id)||0}})}}),S=Dt({mutationFn:async({title:O,description:q})=>{const{error:U}=await H.from("wishlist_items").insert({user_id:t.id,title:O,description:q});if(U)throw U},onSuccess:()=>{n.invalidateQueries({queryKey:["wishlist-items"]}),u(!1),f(""),b(""),s({title:"Idea submitted!",description:"Your idea has been added to the wishlist."})},onError:O=>{s({title:"Error",description:O.message,variant:"destructive"})}}),M=Dt({mutationFn:async({itemId:O,hasVoted:q})=>{if(q){const{error:U}=await H.from("wishlist_votes").delete().eq("item_id",O).eq("user_id",t.id);if(U)throw U;return{itemId:O,wasAdded:!1}}else{const{error:U}=await H.from("wishlist_votes").insert({item_id:O,user_id:t.id});if(U)throw U;return{itemId:O,wasAdded:!0}}},onSuccess:async O=>{if(n.invalidateQueries({queryKey:["wishlist-items"]}),O!=null&&O.wasAdded){const q=w.find(B=>B.id===O.itemId),U=((q==null?void 0:q.vote_count)||0)+1;H.functions.invoke("wishlist-notify",{body:{itemId:O.itemId,voteCount:U}}).catch(console.error)}},onError:O=>{s({title:"Error",description:O.message,variant:"destructive"})}}),L=w.filter(O=>O.title.toLowerCase().includes(a.toLowerCase())||O.description.toLowerCase().includes(a.toLowerCase())),I=()=>{if(!p.trim()||!g.trim()){s({title:"Error",description:"Please fill in both title and description.",variant:"destructive"});return}S.mutate({title:p.trim(),description:g.trim()})};return e.jsx(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($_,{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(fs,{open:c,onOpenChange:u,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Add Idea"]})}),e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{id:"title",placeholder:"Give your idea a clear title...",value:p,onChange:O=>f(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",placeholder:"Describe your idea in detail. What problem does it solve? How would it help agents?",value:g,onChange:O=>b(O.target.value),rows:4})]}),e.jsx(K,{onClick:I,className:"w-full",disabled:S.isPending,children:S.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Idea"})]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search ideas...",value:a,onChange:O=>o(O.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ba,{value:l,onValueChange:O=>i(O),children:e.jsxs(pa,{children:[e.jsx(ns,{value:"popular",children:"Most Popular"}),e.jsx(ns,{value:"latest",children:"Latest"}),e.jsx(ns,{value:"trending",children:"Trending"})]})})})]}),e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsx(K,{variant:_?"default":"outline",size:"sm",onClick:()=>j(!_),children:_?"Show All Ideas":"My Ideas"})}),k?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):L.length===0?e.jsxs("div",{className:"text-center py-12 bg-muted/30 rounded-lg",children:[e.jsx($_,{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($s,{className:"h-4 w-4 mr-2"}),"Add Idea"]})]}):e.jsx("div",{className:"space-y-3",children:L.map(O=>e.jsx("div",{className:"bg-card border rounded-lg p-4 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>r(`/wishlist/${O.id}`),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:q=>{q.stopPropagation(),M.mutate({itemId:O.id,hasVoted:O.has_voted||!1})},className:It("flex flex-col items-center justify-center min-w-[50px] py-2 px-3 rounded-lg border transition-colors",O.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(ku,{className:It("h-4 w-4",O.has_voted&&"fill-current")}),e.jsx("span",{className:"text-sm font-semibold",children:O.vote_count})]}),e.jsx(Nn,{className:"h-10 w-10 bg-primary/20",children:e.jsx(kn,{className:"bg-primary/20 text-primary text-sm font-medium",children:O.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:O.title}),e.jsx(tt,{className:It("text-xs",BFe[O.status].color),children:BFe[O.status].label})]}),e.jsx("p",{className:"text-muted-foreground text-sm line-clamp-2",children:O.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:O.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(O.created_at).toLocaleDateString()})]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(so,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:O.comment_count})]})]})},O.id))})]})})}const $Fe={open:{label:"Open",color:"bg-blue-100 text-blue-800"},under_review:{label:"Under Review",color:"bg-yellow-100 text-yellow-800"},planned:{label:"Planned",color:"bg-purple-100 text-purple-800"},in_progress:{label:"In Progress",color:"bg-orange-100 text-orange-800"},launched:{label:"Launched",color:"bg-green-100 text-green-800"},declined:{label:"Declined",color:"bg-gray-100 text-gray-800"}};function k1s(){const{itemId:t}=yo(),s=fr(),{user:r}=Ds(),{toast:n}=Ua(),a=Qt(),[o,l]=N.useState(""),{data:i=!1}=mt({queryKey:["user-is-admin",r==null?void 0:r.id],queryFn:async()=>{if(!r)return!1;const{data:w,error:k}=await H.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!k&&!!w},enabled:!!r}),{data:c,isLoading:u}=mt({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:w,error:k}=await H.from("wishlist_items").select("*").eq("id",t).single();if(k)throw k;const{data:S}=await H.from("profiles").select("name").eq("id",w.user_id).single();let M=!1;if(r){const{data:L}=await H.from("wishlist_votes").select("id").eq("item_id",t).eq("user_id",r.id).maybeSingle();M=!!L}return{...w,user_name:(S==null?void 0:S.name)||"Unknown",user_initials:((S==null?void 0:S.name)||"U").split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),has_voted:M}}}),{data:p=[],isLoading:f}=mt({queryKey:["wishlist-comments",t],queryFn:async()=>{const{data:w,error:k}=await H.from("wishlist_comments").select("*").eq("item_id",t).order("created_at",{ascending:!0});if(k)throw k;const S=[...new Set((w==null?void 0:w.map(I=>I.user_id))||[])],{data:M}=await H.from("profiles").select("id, name").in("id",S),L=new Map((M==null?void 0:M.map(I=>[I.id,I]))||[]);return w==null?void 0:w.map(I=>{const O=L.get(I.user_id),q=(O==null?void 0:O.name)||"Unknown";return{...I,user_name:q,user_initials:q.split(" ").map(U=>U[0]).join("").toUpperCase().slice(0,2)}})}}),g=Dt({mutationFn:async w=>{if(w){const{error:k}=await H.from("wishlist_votes").delete().eq("item_id",t).eq("user_id",r.id);if(k)throw k;return{wasAdded:!1}}else{const{error:k}=await H.from("wishlist_votes").insert({item_id:t,user_id:r.id});if(k)throw k;return{wasAdded:!0}}},onSuccess:async w=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),w!=null&&w.wasAdded&&c){const k=(c.vote_count||0)+1;H.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:k}}).catch(console.error)}},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),b=Dt({mutationFn:async w=>{const{error:k}=await H.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:w});if(k)throw k},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),_=Dt({mutationFn:async w=>{const{error:k}=await H.from("wishlist_comments").delete().eq("id",w);if(k)throw k},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),n({title:"Comment deleted"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),j=()=>{o.trim()&&b.mutate(o.trim())};return u?e.jsx(Ms,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx(ys,{className:"h-8 w-32 mb-6"}),e.jsx(ys,{className:"h-48 w-full mb-6"}),e.jsx(ys,{className:"h-32 w-full"})]})}):c?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(Ja,{className:"h-4 w-4 mr-2"}),"Back to Wishlist"]}),e.jsx("div",{className:"bg-card border rounded-lg p-6 mb-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:()=>g.mutate(c.has_voted),className:It("flex flex-col items-center justify-center min-w-[60px] py-3 px-4 rounded-lg border transition-colors",c.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(ku,{className:It("h-5 w-5",c.has_voted&&"fill-current")}),e.jsx("span",{className:"text-lg font-bold",children:c.vote_count}),e.jsx("span",{className:"text-xs",children:"votes"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h1",{className:"text-xl font-bold",children:c.title}),e.jsx(tt,{className:It("text-xs",$Fe[c.status].color),children:$Fe[c.status].label})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap mb-4",children:c.description}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Nn,{className:"h-6 w-6",children:e.jsx(kn,{className:"bg-primary/20 text-primary text-xs",children:c.user_initials})}),e.jsx("span",{children:c.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(c.created_at).toLocaleDateString()})]})]})]})}),e.jsxs("div",{className:"bg-card border rounded-lg p-6",children:[e.jsxs("h2",{className:"text-lg font-semibold mb-4",children:["Comments (",p.length,")"]}),e.jsxs("div",{className:"flex gap-3 mb-6",children:[e.jsx(zle,{placeholder:i?"Share your thoughts... Use # to link templates":"Share your thoughts on this idea...",value:o,onChange:l,minHeight:"60px",mentionFormat:"encoded",enableTemplateMentions:i}),e.jsx(K,{onClick:j,disabled:!o.trim()||b.isPending,size:"icon",className:"h-auto",children:b.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4"})})]}),f?e.jsx("div",{className:"space-y-4",children:[1,2].map(w=>e.jsx(ys,{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(Nn,{className:"h-8 w-8",children:e.jsx(kn,{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(Lke,{content:w.content,className:"text-sm text-foreground"})]}),(r==null?void 0:r.id)===w.user_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>_.mutate(w.id),children:e.jsx(Nr,{className:"h-4 w-4"})})]},w.id))})]})]})}):e.jsx(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 qFe={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"}},UFe=["open","under_review","planned","in_progress","launched","declined"];function S1s(){const{toast:t}=Ua(),s=fr(),r=Qt(),[n,a]=N.useState(""),[o,l]=N.useState("all"),[i,c]=N.useState(!1),[u,p]=N.useState(null),{data:f=[],isLoading:g}=mt({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:k,error:S}=await H.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(S)throw S;const M=[...new Set((k==null?void 0:k.map(B=>B.user_id))||[])],{data:L}=await H.from("profiles").select("id, name, email").in("id",M),I=new Map((L==null?void 0:L.map(B=>[B.id,B]))||[]),O=(k==null?void 0:k.map(B=>B.id))||[],{data:q}=await H.from("wishlist_comments").select("item_id").in("item_id",O),U=new Map;return q==null||q.forEach(B=>{U.set(B.item_id,(U.get(B.item_id)||0)+1)}),k==null?void 0:k.map(B=>{const V=I.get(B.user_id);return{...B,user_name:(V==null?void 0:V.name)||"Unknown",user_email:(V==null?void 0:V.email)||"",comment_count:U.get(B.id)||0}})}}),b=Dt({mutationFn:async({itemId:k,status:S})=>{const{error:M}=await H.from("wishlist_items").update({status:S}).eq("id",k);if(M)throw M},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),t({title:"Status updated!"})},onError:k=>{t({title:"Error",description:k.message,variant:"destructive"})}}),_=Dt({mutationFn:async k=>{const{error:S}=await H.from("wishlist_items").delete().eq("id",k);if(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),c(!1),p(null),t({title:"Item deleted!"})},onError:k=>{t({title:"Error",description:k.message,variant:"destructive"})}}),j=f.filter(k=>{const S=k.title.toLowerCase().includes(n.toLowerCase())||k.description.toLowerCase().includes(n.toLowerCase())||k.user_name.toLowerCase().includes(n.toLowerCase()),M=o==="all"||k.status===o;return S&&M}),w={total:f.length,open:f.filter(k=>k.status==="open").length,inProgress:f.filter(k=>k.status==="in_progress").length,launched:f.filter(k=>k.status==="launched").length,highVotes:f.filter(k=>k.vote_count>=10).length};return e.jsx(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(Ja,{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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search ideas, users...",value:n,onChange:k=>a(k.target.value),className:"pl-10"})]}),e.jsxs(Zs,{value:o,onValueChange:k=>l(k),children:[e.jsx(Ws,{className:"w-[180px]",children:e.jsx(Xs,{placeholder:"Filter by status"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Statuses"}),UFe.map(k=>e.jsx(Mt,{value:k,children:qFe[k].label},k))]})]})]}),g?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(k=>e.jsx(ys,{className:"h-16 w-full"},k))}):e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[60px]",children:"Votes"}),e.jsx(St,{children:"Title"}),e.jsx(St,{className:"hidden md:table-cell",children:"Submitted By"}),e.jsx(St,{className:"hidden sm:table-cell",children:"Comments"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(zn,{children:j.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):j.map(k=>e.jsxs(Ss,{className:It(k.vote_count>=10&&"bg-primary/5"),children:[e.jsx(dt,{children:e.jsx(tt,{variant:k.vote_count>=10?"default":"secondary",children:k.vote_count})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium line-clamp-1",children:k.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:k.description})]})}),e.jsx(dt,{className:"hidden md:table-cell",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:k.user_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:k.user_email})]})}),e.jsx(dt,{className:"hidden sm:table-cell",children:k.comment_count}),e.jsx(dt,{children:e.jsxs(Zs,{value:k.status,onValueChange:S=>b.mutate({itemId:k.id,status:S}),children:[e.jsx(Ws,{className:"w-[140px] h-8",children:e.jsx(Xs,{})}),e.jsx(Gs,{children:UFe.map(S=>e.jsx(Mt,{value:S,children:qFe[S].label},S))})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/wishlist/${k.id}`,"_blank"),children:e.jsx(tn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{p(k.id),c(!0)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},k.id))})]})}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Delete Wishlist Item"})}),e.jsx("p",{className:"text-muted-foreground",children:"Are you sure you want to delete this idea? This will also delete all votes and comments."}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:()=>u&&_.mutate(u),disabled:_.isPending,children:_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function C1s(){const{user:t}=Ds(),[s,r]=N.useState([]),[n,a]=N.useState(!0),[o,l]=N.useState(!1),[i,c]=N.useState(null),[u,p]=N.useState(!1),[f,g]=N.useState(null),[b,_]=N.useState(""),[j,w]=N.useState(""),[k,S]=N.useState(""),[M,L]=N.useState(""),[I,O]=N.useState(""),[q,U]=N.useState(!1),[B,V]=N.useState(""),[Z,X]=N.useState("once"),[ee,Q]=N.useState([]),[ie,re]=N.useState([]),[oe,ce]=N.useState(!1),[xe,ge]=N.useState(!1),[ue,pe]=N.useState([]),[be,Me]=N.useState({total:0,dismissed:0});N.useEffect(()=>{Ne()},[]);const Ne=async()=>{const{data:Ze,error:Qe}=await H.from("levelup_briefs").select("*").order("created_at",{ascending:!1});Qe?(me.error("Failed to fetch briefs"),console.error(Qe)):r(Ze||[]),a(!1)},Pe=()=>{_(""),w(""),S(""),L(""),O(""),U(!1),V(new Date().toISOString().slice(0,16)),X("once"),Q([]),re([]),c(null)},Oe=()=>{Pe(),l(!0)},Te=async Ze=>{c(Ze),_(Ze.title),w(Ze.description||""),S(Ze.video_url||""),L(Ze.graphic_url||""),O(Ze.graphic_link_url||""),U(Ze.is_published),V(Ze.publish_date.slice(0,16)),X(Ze.show_frequency);const{data:Qe}=await H.from("levelup_brief_links").select("*").eq("brief_id",Ze.id).order("sort_order");Q((Qe==null?void 0:Qe.map(Je=>({title:Je.title,url:Je.url})))||[]);const{data:He}=await H.from("levelup_brief_polls").select("*").eq("brief_id",Ze.id).order("sort_order");if(He){const Je=[];for(const it of He){const{data:Lt}=await H.from("levelup_brief_poll_options").select("*").eq("poll_id",it.id).order("sort_order");Je.push({question:it.question,poll_type:it.poll_type,options:(Lt==null?void 0:Lt.map(Vt=>Vt.option_text))||[]})}re(Je)}l(!0)},ke=async Ze=>{var He;const Qe=(He=Ze.target.files)==null?void 0:He[0];if(Qe){ce(!0);try{const Je=await H.functions.invoke("bunny-upload",{body:{action:"create",title:Qe.name.replace(/\.[^/.]+$/,"")}});if(Je.error)throw Je.error;const{videoId:it,libraryId:Lt}=Je.data,Vt=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:it}});if(Vt.error)throw Vt.error;const{uploadUrl:hs,apiKey:Ts}=Vt.data,Cs=new XMLHttpRequest;await new Promise((er,xt)=>{Cs.upload.addEventListener("progress",Es=>{if(Es.lengthComputable){const ur=Math.round(Es.loaded/Es.total*100);console.log("Upload progress:",ur)}}),Cs.addEventListener("load",()=>{Cs.status>=200&&Cs.status<300?er():xt(new Error(`Upload failed with status ${Cs.status}`))}),Cs.addEventListener("error",()=>xt(new Error("Upload failed"))),Cs.open("PUT",hs),Cs.setRequestHeader("AccessKey",Ts),Cs.send(Qe)});const cs=`https://player.mediadelivery.net/embed/${Lt}/${it}`;S(cs),me.success("Video uploaded successfully! It may take a few minutes to process.")}catch(Je){console.error("Upload error:",Je),me.error("Failed to upload video")}finally{ce(!1)}}},Be=async()=>{if(!b.trim()){me.error("Title is required");return}try{let Ze;if(i){const{error:Qe}=await H.from("levelup_briefs").update({title:b,description:j||null,video_url:k||null,graphic_url:M||null,graphic_link_url:I||null,is_published:q,publish_date:B,show_frequency:Z}).eq("id",i.id);if(Qe)throw Qe;Ze=i.id,await H.from("levelup_brief_links").delete().eq("brief_id",Ze);const{data:He}=await H.from("levelup_brief_polls").select("id").eq("brief_id",Ze);if(He)for(const Je of He)await H.from("levelup_brief_poll_options").delete().eq("poll_id",Je.id);await H.from("levelup_brief_polls").delete().eq("brief_id",Ze)}else{const{data:Qe,error:He}=await H.from("levelup_briefs").insert({title:b,description:j||null,video_url:k||null,graphic_url:M||null,graphic_link_url:I||null,is_published:q,publish_date:B,show_frequency:Z,created_by:t==null?void 0:t.id}).select().single();if(He)throw He;Ze=Qe.id}if(ee.length>0){const Qe=ee.map((He,Je)=>({brief_id:Ze,title:He.title,url:He.url,sort_order:Je}));await H.from("levelup_brief_links").insert(Qe)}for(let Qe=0;Qe0){const Lt=He.options.map((Vt,hs)=>({poll_id:Je.id,option_text:Vt,sort_order:hs}));await H.from("levelup_brief_poll_options").insert(Lt)}}me.success(i?"Brief updated":"Brief created"),l(!1),Pe(),Ne()}catch(Ze){console.error("Error saving brief:",Ze),me.error("Failed to save brief")}},nt=async Ze=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:Qe}=await H.from("levelup_briefs").delete().eq("id",Ze);if(Qe)throw Qe;me.success("Brief deleted"),Ne()}catch(Qe){console.error("Error deleting brief:",Qe),me.error("Failed to delete brief")}},Ae=async Ze=>{g(Ze);const{count:Qe}=await H.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ze.id),{count:He}=await H.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ze.id).not("dismissed_at","is",null);Me({total:Qe||0,dismissed:He||0});const{data:Je}=await H.from("levelup_brief_polls").select("*").eq("brief_id",Ze.id).order("sort_order");if(Je){const it=[];for(const Lt of Je){const{data:Vt}=await H.from("levelup_brief_poll_options").select("*").eq("poll_id",Lt.id).order("sort_order"),{data:hs}=await H.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",Lt.id),Ts=[...new Set((hs==null?void 0:hs.map(Es=>Es.user_id))||[])];let Cs={};if(Ts.length>0){const{data:Es}=await H.from("profiles").select("id, name, email").in("id",Ts);Es&&Es.forEach(ur=>{Cs[ur.id]=ur.name||ur.email||"Unknown"})}const cs=(hs||[]).map(Es=>({optionId:Es.option_id,userName:Cs[Es.user_id]||"Unknown",userId:Es.user_id})),er={};let xt=0;Vt&&Vt.forEach(Es=>{const ur=(hs==null?void 0:hs.filter(Mr=>Mr.option_id===Es.id).length)||0;er[Es.id]=ur,xt+=ur}),it.push({...Lt,options:Vt||[],results:er,respondents:cs,totalResponses:Lt.poll_type==="single"?new Set(hs==null?void 0:hs.map(Es=>Es.user_id)).size:xt})}pe(it)}p(!0)},ft=()=>{Q([...ee,{title:"",url:""}])},fe=(Ze,Qe,He)=>{const Je=[...ee];Je[Ze][Qe]=He,Q(Je)},Ve=Ze=>{Q(ee.filter((Qe,He)=>He!==Ze))},at=()=>{re([...ie,{question:"",poll_type:"single",options:["",""]}])},et=(Ze,Qe)=>{const He=[...ie];He[Ze].question=Qe,re(He)},Ce=(Ze,Qe)=>{const He=[...ie];He[Ze].poll_type=Qe,re(He)},rt=Ze=>{const Qe=[...ie];Qe[Ze].options.push(""),re(Qe)},Ge=(Ze,Qe,He)=>{const Je=[...ie];Je[Ze].options[Qe]=He,re(Je)},ct=(Ze,Qe)=>{const He=[...ie];He[Ze].options=He[Ze].options.filter((Je,it)=>it!==Qe),re(He)},qe=Ze=>{re(ie.filter((Qe,He)=>He!==Ze))};return e.jsxs(Ms,{title:"The LevelUp Brief",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"The LevelUp Brief",description:"Create engaging popup briefs for your agents",children:e.jsxs(K,{onClick:Oe,children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),e.jsx(Ee,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Frequency"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:n?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(Ze=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:Ze.title}),e.jsx(dt,{children:e.jsx(tt,{variant:Ze.is_published?"default":"secondary",children:Ze.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"capitalize",children:Ze.show_frequency.replace("_"," ")}),e.jsx(dt,{children:ms(new Date(Ze.publish_date),"MMM d, yyyy h:mm a")}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ae(Ze),children:e.jsx(No,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Te(Ze),children:e.jsx(ud,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>nt(Ze.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Ze.id))})]})})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:i?"Edit Brief":"Create New Brief"})}),e.jsxs(ba,{defaultValue:"content",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-4",children:[e.jsx(ns,{value:"content",children:"Content"}),e.jsx(ns,{value:"media",children:"Media"}),e.jsx(ns,{value:"links",children:"Links"}),e.jsx(ns,{value:"polls",children:"Polls"})]}),e.jsxs(bs,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Title *"}),e.jsx(ze,{value:b,onChange:Ze=>_(Ze.target.value),placeholder:"What's happening at LevelUp..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(my,{content:j,onChange:Ze=>w(Ze),placeholder:"Brief overview for agents...",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Publish Date"}),e.jsx(ze,{type:"datetime-local",value:B,onChange:Ze=>V(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Show Frequency"}),e.jsxs(Zs,{value:Z,onValueChange:X,children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"once",children:"Once (until dismissed)"}),e.jsx(Mt,{value:"every_login",children:"Every login"}),e.jsx(Mt,{value:"daily",children:"Daily"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(qr,{checked:q,onCheckedChange:U}),e.jsx(ve,{children:"Publish immediately"})]})]}),e.jsxs(bs,{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(ze,{type:"file",accept:"video/*",onChange:ke,disabled:oe})}),oe&&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(ze,{value:k,onChange:Ze=>S(Ze.target.value),placeholder:"https://iframe.mediadelivery.net/embed/..."})]}),k&&e.jsx("div",{className:"aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:k,className:"w-full h-full",allow:"autoplay; fullscreen",allowFullScreen:!0})})]}),e.jsxs("div",{className:"border-t pt-4 space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Graphic / Image (optional)"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Upload Image"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ze,{type:"file",accept:"image/*",onChange:async Ze=>{var He;const Qe=(He=Ze.target.files)==null?void 0:He[0];if(Qe){ge(!0);try{const Je=Qe.name.split(".").pop(),it=`brief-graphics/${Date.now()}.${Je}`,{error:Lt}=await H.storage.from("banner-images").upload(it,Qe,{upsert:!0});if(Lt)throw Lt;const{data:Vt}=H.storage.from("banner-images").getPublicUrl(it);L(Vt.publicUrl),me.success("Image uploaded!")}catch(Je){console.error(Je),me.error("Failed to upload image")}finally{ge(!1)}}},disabled:xe})}),xe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Or paste Image URL"}),e.jsx(ze,{value:M,onChange:Ze=>L(Ze.target.value),placeholder:"https://example.com/image.png"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Click-through Link (optional)"}),e.jsx(ze,{value:I,onChange:Ze=>O(Ze.target.value),placeholder:"https://example.com/landing-page"})]}),M&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted border",children:e.jsx("img",{src:M,alt:"Brief graphic preview",className:"w-full object-contain max-h-64"})})]})]}),e.jsxs(bs,{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:ft,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),ee.map((Ze,Qe)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(ze,{value:Ze.title,onChange:He=>fe(Qe,"title",He.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(ze,{value:Ze.url,onChange:He=>fe(Qe,"url",He.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ve(Qe),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]},Qe)),ee.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No links added yet"})]}),e.jsxs(bs,{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:at,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),ie.map((Ze,Qe)=>e.jsx(Ee,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ze,{value:Ze.question,onChange:He=>et(Qe,He.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs(Zs,{value:Ze.poll_type,onValueChange:He=>Ce(Qe,He),children:[e.jsx(Ws,{className:"w-32",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"single",children:"Single"}),e.jsx(Mt,{value:"multi",children:"Multi-select"})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>qe(Qe),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"space-y-2 pl-4",children:[Ze.options.map((He,Je)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:He,onChange:it=>Ge(Qe,Je,it.target.value),placeholder:`Option ${Je+1}`}),Ze.options.length>2&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ct(Qe,Je),children:e.jsx(Nr,{className:"h-4 w-4 text-muted-foreground"})})]},Je)),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>rt(Qe),children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},Qe)),ie.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:Be,children:i?"Update Brief":"Create Brief"})]})]})}),e.jsx(fs,{open:u,onOpenChange:p,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(vs,{children:["Results: ",f==null?void 0:f.title]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Views"})}),e.jsx(De,{children:e.jsx("p",{className:"text-2xl font-bold",children:be.total})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Dismissed"})}),e.jsx(De,{children:e.jsx("p",{className:"text-2xl font-bold",children:be.dismissed})})]})]}),ue.length>0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:"Poll Results"}),ue.map(Ze=>e.jsxs(Ee,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:Ze.question}),e.jsx("div",{className:"space-y-2",children:Ze.options.map(Qe=>{const He=Ze.results[Qe.id]||0,Je=Ze.totalResponses>0?Math.round(He/Ze.totalResponses*100):0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:Qe.option_text}),e.jsxs("span",{className:"text-muted-foreground",children:[He," (",Je,"%)"]})]}),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:`${Je}%`}})}),He>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(Ze.respondents||[]).filter(it=>it.optionId===Qe.id).map((it,Lt)=>e.jsx(tt,{variant:"secondary",className:"text-xs font-normal",children:it.userName},Lt))})]},Qe.id)})})]},Ze.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const M1s=()=>{const{user:t}=Ds(),{toast:s}=Ua(),r=Qt(),[n,a]=N.useState(!1),[o,l]=N.useState(null),[i,c]=N.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=N.useState(null),[f,g]=N.useState(""),{data:b=[],isLoading:_}=mt({queryKey:["additional-services-admin"],queryFn:async()=>{const{data:I,error:O}=await H.from("additional_services").select("*").order("publish_date",{ascending:!1});if(O)throw O;return I}}),j=Dt({mutationFn:async I=>{let O=I.existingImageUrl;if(I.image){const U=I.image.name.split(".").pop(),B=`${Date.now()}-${Math.random().toString(36).substring(7)}.${U}`,{error:V}=await H.storage.from("service-images").upload(B,I.image);if(V)throw V;const{data:Z}=H.storage.from("service-images").getPublicUrl(B);O=Z.publicUrl}const q={name:I.item.name,description:I.item.description||null,preview_image_url:O,signup_link_url:I.item.signup_link_url,publish_date:I.item.publish_date?new Date(I.item.publish_date).toISOString():new Date().toISOString(),is_published:I.item.is_published,created_by:t==null?void 0:t.id};if(I.itemId){const{error:U}=await H.from("additional_services").update(q).eq("id",I.itemId);if(U)throw U}else{const{error:U}=await H.from("additional_services").insert(q);if(U)throw U}},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:o?"Service updated":"Service created"}),a(!1),k()},onError:I=>{s({title:"Error saving service",description:I.message,variant:"destructive"})}}),w=Dt({mutationFn:async I=>{const{error:O}=await H.from("additional_services").delete().eq("id",I);if(O)throw O},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:"Service deleted"})},onError:I=>{s({title:"Error deleting service",description:I.message,variant:"destructive"})}}),k=()=>{c({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),g(""),l(null)},S=I=>{l(I),c({name:I.name,description:I.description||"",signup_link_url:I.signup_link_url,publish_date:I.publish_date?new Date(I.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:I.is_published}),g(I.preview_image_url||""),a(!0)},M=I=>{var q;const O=(q=I.target.files)==null?void 0:q[0];O&&(p(O),g(URL.createObjectURL(O)))},L=I=>{if(I.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(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Services"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:b.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:b.filter(I=>I.is_published).length})})]})]}),e.jsxs(fs,{open:n,onOpenChange:I=>{a(I),I||k()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Add Service"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:o?"Edit Service":"Add New Service"})}),e.jsxs("form",{onSubmit:L,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Name *"}),e.jsx(ze,{id:"name",value:i.name,onChange:I=>c({...i,name:I.target.value}),placeholder:"Enter service name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(my,{content:i.description,onChange:I=>c({...i,description:I}),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(ze,{id:"signup_link_url",type:"url",value:i.signup_link_url,onChange:I=>c({...i,signup_link_url:I.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(ze,{id:"publish_date",type:"date",value:i.publish_date,onChange:I=>c({...i,publish_date:I.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qr,{id:"is_published",checked:i.is_published,onCheckedChange:I=>c({...i,is_published:I})}),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),g("")},children:e.jsx(Rr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(gl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(ze,{type:"file",accept:"image/*",onChange:M,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:j.isPending,children:j.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(De,{className:"p-0",children:_?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):b.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'No services yet. Click "Add Service" to create your first one.'}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-16",children:"Preview"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Signup Link"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:b.map(I=>e.jsxs(Ss,{children:[e.jsx(dt,{children:I.preview_image_url?e.jsx("img",{src:I.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(gl,{className:"h-5 w-5 text-muted-foreground"})})}),e.jsx(dt,{className:"font-medium",children:I.name}),e.jsx(dt,{children:e.jsxs("a",{href:I.signup_link_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1",children:[e.jsx(tn,{className:"h-3 w-3"}),"Link"]})}),e.jsx(dt,{children:new Date(I.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(tt,{variant:I.is_published?"default":"secondary",children:I.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(I),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(I.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},I.id))})]})})})]})})};function T1s(){const{toast:t}=Ua(),[s,r]=N.useState([]),[n,a]=N.useState(!0),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});N.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:w,error:k}=await H.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(k)throw k;r(w.coupons||[])}catch(w){console.error("Error fetching coupons:",w),t({title:"Error",description:"Failed to load coupons",variant:"destructive"})}finally{a(!1)}},g=async()=>{if(!u.name){t({title:"Error",description:"Please enter a coupon name",variant:"destructive"});return}if(u.discountType==="percent"&&!u.percentOff){t({title:"Error",description:"Please enter a percent off value",variant:"destructive"});return}if(u.discountType==="amount"&&!u.amountOff){t({title:"Error",description:"Please enter an amount off value",variant:"destructive"});return}if(u.duration==="repeating"&&!u.durationInMonths){t({title:"Error",description:"Please enter duration in months",variant:"destructive"});return}l(!0);try{const w={action:"create",name:u.name,duration:u.duration,promotion_code:u.promotionCode.trim()||void 0};u.discountType==="percent"?w.percent_off=parseFloat(u.percentOff):(w.amount_off=Math.round(parseFloat(u.amountOff)*100),w.currency="usd"),u.duration==="repeating"&&(w.duration_in_months=parseInt(u.durationInMonths));const{data:k,error:S}=await H.functions.invoke("stripe-manage-coupons",{body:w});if(S)throw S;t({title:"Success",description:"Coupon created successfully"}),c(!1),p({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""}),f()}catch(w){console.error("Error creating coupon:",w),t({title:"Error",description:w.message||"Failed to create coupon",variant:"destructive"})}finally{l(!1)}},b=async w=>{if(confirm("Are you sure you want to delete this coupon?"))try{const{error:k}=await H.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:w}});if(k)throw k;t({title:"Success",description:"Coupon deleted successfully"}),f()}catch(k){console.error("Error deleting coupon:",k),t({title:"Error",description:k.message||"Failed to delete coupon",variant:"destructive"})}},_=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(oh,{title:"Subscription Discounts",description:"Create and manage discount coupons for subscriptions",children:e.jsxs(fs,{open:i,onOpenChange:c,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Create Coupon"]})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create New Coupon"}),e.jsx(Gr,{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(ze,{placeholder:"e.g., BROKERAGE50",value:u.promotionCode,onChange:w=>p({...u,promotionCode:w.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")}),className:"font-mono uppercase"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters and numbers only. This is the code users enter at checkout."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Coupon Name (internal label)"}),e.jsx(ze,{placeholder:"e.g., 50% Off Brokerage Launch",value:u.name,onChange:w=>p({...u,name:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Discount Type"}),e.jsxs(Zs,{value:u.discountType,onValueChange:w=>{const k=w==="amount"&&u.duration==="forever"?"once":u.duration;p({...u,discountType:w,duration:k})},children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"percent",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(uS,{className:"mr-2 h-4 w-4"}),"Percentage Off"]})}),e.jsx(Mt,{value:"amount",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(nc,{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(ze,{type:"number",min:"1",max:"100",placeholder:"20",value:u.percentOff,onChange:w=>p({...u,percentOff:w.target.value})}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(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(ze,{type:"number",min:"1",placeholder:"10.00",className:"pl-7",value:u.amountOff,onChange:w=>p({...u,amountOff:w.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Duration"}),e.jsxs(Zs,{value:u.duration,onValueChange:w=>p({...u,duration:w}),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"once",children:"Once (first payment only)"}),e.jsx(Mt,{value:"repeating",children:"Multiple months"}),e.jsxs(Mt,{value:"forever",disabled:u.discountType==="amount",children:["Forever ",u.discountType==="amount"&&"(% discounts only)"]})]})]}),u.discountType==="amount"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:'Note: "Forever" duration is only available for percentage-based discounts.'})]}),u.duration==="repeating"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Number of Months"}),e.jsx(ze,{type:"number",min:"1",placeholder:"3",value:u.durationInMonths,onChange:w=>p({...u,durationInMonths:w.target.value})})]}),e.jsx(K,{onClick:g,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Active Coupons"}),e.jsx(gr,{children:"Share coupon codes with users to give them discounts on subscriptions"})]}),e.jsx(De,{children:n?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No coupons created yet. Create your first coupon to get started."}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Promo Code"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Discount"}),e.jsx(St,{children:"Duration"}),e.jsx(St,{children:"Redemptions"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:s.map(w=>{var k;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-mono font-medium",children:((k=w.promotion_codes)==null?void 0:k.length)>0?w.promotion_codes.join(", "):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),e.jsx(dt,{children:w.name||"-"}),e.jsx(dt,{children:_(w)}),e.jsx(dt,{children:j(w)}),e.jsx(dt,{children:w.times_redeemed}),e.jsx(dt,{children:e.jsx(tt,{variant:w.valid?"default":"secondary",children:w.valid?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(w.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})})]},w.id)})})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"How to Use Coupons"})}),e.jsxs(De,{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 mye={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 A1s(){const[t,s]=N.useState(""),[r,n]=N.useState("all"),[a,o]=N.useState(null),{data:l,isLoading:i,refetch:c}=mt({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:_,error:j}=await H.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(j)throw j;return _}}),{data:u}=mt({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:_,error:j}=await H.from("brokerages").select("*").order("name");if(j)throw j;return await Promise.all((_||[]).map(async k=>{const{data:S}=await H.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",k.id),{data:M}=await H.from("user_roles").select("user_id").eq("role","brokerage_manager"),L=(M==null?void 0:M.map(q=>q.user_id))||[],I=(S==null?void 0:S.filter(q=>L.includes(q.id)))||[],O=(S==null?void 0:S.length)||0;return{...k,managers:I,agentCount:O}}))}}),p=_=>{if(_.is_grandfathered)return{status:"Grandfathered",badge:"Legacy",variant:"secondary"};if(_.brokerage_id&&!_.subscription_product_id)return{status:"Brokerage",badge:"Team Member",variant:"outline"};if(_.is_trial&&_.trial_expires_at)return new Date(_.trial_expires_at)>new Date?{status:"Trial",badge:"Active Trial",variant:"default"}:{status:"Trial Expired",badge:"Expired",variant:"destructive"};if(_.subscription_status==="active"||_.subscription_status==="trialing"){const j=mye[_.subscription_product_id];return{status:(j==null?void 0:j.name)||"Active",badge:_.subscription_status==="trialing"?"Trial":"Active",variant:"default"}}return _.subscription_status==="canceled"||_.subscription_status==="past_due"?{status:"Canceled",badge:"Inactive",variant:"destructive"}:{status:"None",badge:"No Subscription",variant:"outline"}},f=l==null?void 0:l.filter(_=>{var w,k;if(!(((w=_.name)==null?void 0:w.toLowerCase().includes(t.toLowerCase()))||((k=_.email)==null?void 0:k.toLowerCase().includes(t.toLowerCase()))))return!1;switch(p(_),r){case"active":return _.subscription_status==="active";case"trialing":return _.subscription_status==="trialing"||_.is_trial&&new Date(_.trial_expires_at)>new Date;case"grandfathered":return _.is_grandfathered;case"brokerage":return _.brokerage_id&&!_.subscription_product_id&&!_.is_grandfathered;case"expired":return _.subscription_status==="canceled"||_.subscription_status==="past_due"||_.is_trial&&new Date(_.trial_expires_at)<=new Date;case"none":return!_.subscription_status||_.subscription_status==="none";default:return!0}}),g={totalUsers:(l==null?void 0:l.length)||0,activeSubscriptions:(l==null?void 0:l.filter(_=>_.subscription_status==="active").length)||0,trials:(l==null?void 0:l.filter(_=>_.subscription_status==="trialing"||_.is_trial&&new Date(_.trial_expires_at)>new Date).length)||0,grandfathered:(l==null?void 0:l.filter(_=>_.is_grandfathered).length)||0,brokerageMembers:(l==null?void 0:l.filter(_=>_.brokerage_id&&!_.subscription_product_id&&!_.is_grandfathered).length)||0,individualSubscribers:(l==null?void 0:l.filter(_=>_.subscription_status==="active"&&_.subscription_product_id==="prod_Tc07cYplXUGNkm").length)||0,brokerageSubscribers:(l==null?void 0:l.filter(_=>_.subscription_status==="active"&&(_.subscription_product_id==="prod_Tc08MupgoVySDG"||_.subscription_product_id==="prod_Tc09N1tJ4RrAFn")).length)||0},b=_=>{window.open(`https://dashboard.stripe.com/customers/${_}`,"_blank")};return e.jsx(Ms,{title:"Subscription Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Subscription Management",description:"Track and manage all subscriptions",children:e.jsxs(K,{onClick:()=>c(),variant:"outline",size:"sm",children:[e.jsx(Go,{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(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Users"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:g.totalUsers})]})}),e.jsx(Ee,{className:"border-green-500/50",children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cx,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Active Paid"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-green-600",children:g.activeSubscriptions})]})}),e.jsx(Ee,{className:"border-blue-500/50",children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Trials"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-blue-600",children:g.trials})]})}),e.jsx(Ee,{className:"border-purple-500/50",children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dm,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Grandfathered"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-purple-600",children:g.grandfathered})]})}),e.jsx(Ee,{className:"border-orange-500/50",children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage Members"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-orange-600",children:g.brokerageMembers})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W_,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Individual"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:g.individualSubscribers})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage Subs"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:g.brokerageSubscribers})]})})]}),e.jsxs(ba,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"users",children:"All Users"}),e.jsx(ns,{value:"brokerages",children:"Brokerages"})]}),e.jsxs(bs,{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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:t,onChange:_=>s(_.target.value),className:"pl-9"})]}),e.jsxs(Zs,{value:r,onValueChange:_=>n(_),children:[e.jsx(Ws,{className:"w-[200px]",children:e.jsx(Xs,{placeholder:"Filter by status"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Users"}),e.jsx(Mt,{value:"active",children:"Active Subscriptions"}),e.jsx(Mt,{value:"trialing",children:"Trials"}),e.jsx(Mt,{value:"grandfathered",children:"Grandfathered"}),e.jsx(Mt,{value:"brokerage",children:"Brokerage Members"}),e.jsx(Mt,{value:"expired",children:"Expired/Canceled"}),e.jsx(Mt,{value:"none",children:"No Subscription"})]})]})]}),e.jsx(Ee,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"User"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Plan"}),e.jsx(St,{children:"Brokerage"}),e.jsx(St,{children:"End Date"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:i?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(f==null?void 0:f.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):f==null?void 0:f.map(_=>{var k,S;const j=p(_),w=mye[_.subscription_product_id];return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:_.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:_.email})]})}),e.jsx(dt,{children:e.jsx(tt,{variant:j.variant,children:j.badge})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm",children:_.is_grandfathered?"Legacy Access":_.brokerage_id&&!_.subscription_product_id?"Brokerage Subscription":(w==null?void 0:w.name)||j.status})}),e.jsx(dt,{children:(k=_.brokerages)!=null&&k.name?e.jsx("span",{className:"text-sm",children:_.brokerages.name}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(dt,{children:_.subscription_end_date?e.jsx("span",{className:"text-sm",children:ms(new Date(_.subscription_end_date),"MMM d, yyyy")}):_.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",ms(new Date(_.trial_expires_at),"MMM d, yyyy")]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[_.stripe_customer_id&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(_.stripe_customer_id),children:e.jsx(tn,{className:"h-4 w-4"})}),e.jsxs(fs,{children:[e.jsx(qi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",onClick:()=>o(_),children:"Details"})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Subscription Details"}),e.jsxs(Gr,{children:[_.name," (",_.email,")"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Status"}),e.jsx(tt,{variant:j.variant,className:"mt-1",children:j.badge})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Plan"}),e.jsx("p",{className:"font-medium",children:_.is_grandfathered?"Grandfathered (Legacy)":_.brokerage_id&&!_.subscription_product_id?"Brokerage Subscription":(w==null?void 0:w.name)||"None"})]}),_.brokerage_id&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Brokerage"}),e.jsx("p",{className:"font-medium",children:((S=_.brokerages)==null?void 0:S.name)||"Unknown"})]}),_.subscription_end_date&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Current Period End"}),e.jsx("p",{className:"font-medium",children:ms(new Date(_.subscription_end_date),"MMMM d, yyyy")})]}),_.trial_expires_at&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Trial Expires"}),e.jsx("p",{className:"font-medium",children:ms(new Date(_.trial_expires_at),"MMMM d, yyyy")})]}),_.stripe_customer_id&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Stripe Customer ID"}),e.jsx("p",{className:"font-mono text-sm",children:_.stripe_customer_id})]})]}),_.stripe_customer_id&&e.jsxs(K,{className:"w-full",onClick:()=>b(_.stripe_customer_id),children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},_.id)})})]})})})]}),e.jsx(bs,{value:"brokerages",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:u==null?void 0:u.map(_=>{var w,k;const j=(w=_.managers)==null?void 0:w.some(S=>S.subscription_status==="active"&&(S.subscription_product_id==="prod_Tc08MupgoVySDG"||S.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(ka,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:_.name}),e.jsxs(gr,{children:[_.agentCount," agents"]})]})]}),e.jsx(tt,{variant:j?"default":"outline",children:j?"Active Subscription":"No Active Subscription"})]})}),e.jsx(De,{children:((k=_.managers)==null?void 0:k.length)>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Managers:"}),_.managers.map(S=>{const M=mye[S.subscription_product_id];return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.email})]}),e.jsx("div",{className:"text-right",children:M?e.jsxs("div",{children:[e.jsx(tt,{variant:"default",children:M.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:M.price})]}):e.jsx(tt,{variant:"outline",children:"No Subscription"})})]},S.id)})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},_.id)})})})]})]})})}function E1s(){const[t,s]=N.useState([]),[r,n]=N.useState(!0),[a,o]=N.useState(""),[l,i]=N.useState("all"),[c,u]=N.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});N.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:_,error:j}=await H.from("referrals").select(` *, referrer_brokerage:brokerages!referrer_brokerage_id(name), referred_brokerage:brokerages!referred_brokerage_id(name), referred_user:profiles!referred_user_id(name, email) `).order("created_at",{ascending:!1});if(j)throw j;s(_||[]);const w=(_==null?void 0:_.filter(M=>M.status==="qualified").length)||0,k=(_==null?void 0:_.filter(M=>M.status==="pending").length)||0,S=(_==null?void 0:_.filter(M=>M.status==="cancelled").length)||0;u({total:(_==null?void 0:_.length)||0,qualified:w,pending:k,cancelled:S,totalDiscounts:w*25})}catch(_){console.error("Error fetching referrals:",_),me.error("Failed to load referrals")}finally{n(!1)}},f=async()=>{try{me.loading("Processing qualifications...");const{error:_}=await H.functions.invoke("process-referral-qualifications");if(_)throw _;me.dismiss(),me.success("Qualifications processed successfully"),p()}catch(_){me.dismiss(),console.error("Error processing qualifications:",_),me.error("Failed to process qualifications")}},g=t.filter(_=>{var k,S,M,L,I,O;const j=((S=(k=_.referrer_brokerage)==null?void 0:k.name)==null?void 0:S.toLowerCase().includes(a.toLowerCase()))||((L=(M=_.referred_brokerage)==null?void 0:M.name)==null?void 0:L.toLowerCase().includes(a.toLowerCase()))||((O=(I=_.referred_user)==null?void 0:I.email)==null?void 0:O.toLowerCase().includes(a.toLowerCase())),w=l==="all"||_.status===l;return j&&w}),b=_=>{switch(_){case"qualified":return e.jsxs(tt,{className:"bg-green-100 text-green-800",children:[e.jsx(xi,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(tt,{variant:"secondary",children:[e.jsx(un,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(tt,{variant:"destructive",children:[e.jsx(vc,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(tt,{children:_})}};return e.jsx(Ms,{title:"Referral Program",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Referral Program",description:"Track and manage brokerage referrals",children:e.jsxs(K,{onClick:f,variant:"outline",children:[e.jsx(Go,{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(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Referrals"})]})]})})}),e.jsx(Ee,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xi,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.qualified}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified"})]})]})})}),e.jsx(Ee,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-5 w-5 text-amber-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.pending}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pending"})]})]})})}),e.jsx(Ee,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vc,{className:"h-5 w-5 text-red-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.cancelled}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Cancelled"})]})]})})}),e.jsx(Ee,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nc,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:["$",c.totalDiscounts]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Discounts"})]})]})})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"All Referrals"}),e.jsx(gr,{children:"View and manage all referral relationships"})]}),e.jsxs(De,{children:[e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by brokerage or email...",value:a,onChange:_=>o(_.target.value),className:"pl-10"})]}),e.jsxs(Zs,{value:l,onValueChange:i,children:[e.jsx(Ws,{className:"w-[180px]",children:e.jsx(Xs,{placeholder:"Filter by status"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Statuses"}),e.jsx(Mt,{value:"pending",children:"Pending"}),e.jsx(Mt,{value:"qualified",children:"Qualified"}),e.jsx(Mt,{value:"cancelled",children:"Cancelled"})]})]})]}),r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Referrer"}),e.jsx(St,{children:"Referred"}),e.jsx(St,{children:"Signup Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Qualified Date"}),e.jsx(St,{children:"Discount"})]})}),e.jsx(zn,{children:g.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):g.map(_=>{var j,w,k,S;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:((j=_.referrer_brokerage)==null?void 0:j.name)||"Unknown"}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{children:((w=_.referred_brokerage)==null?void 0:w.name)||((k=_.referred_user)==null?void 0:k.name)||"Pending setup"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(S=_.referred_user)==null?void 0:S.email})]})}),e.jsx(dt,{children:ms(new Date(_.signup_date),"MMM d, yyyy")}),e.jsx(dt,{children:b(_.status)}),e.jsx(dt,{children:_.qualified_date?ms(new Date(_.qualified_date),"MMM d, yyyy"):"-"}),e.jsx(dt,{children:_.discount_applied?e.jsx(tt,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},_.id)})})]})]})]})]})})}const pye=[{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"}],P1s=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function I1s(){const[t,s]=N.useState([]),[r,n]=N.useState(!0),[a,o]=N.useState(!1),[l,i]=N.useState(null),[c,u]=N.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});N.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:S,error:M}=await H.from("onboarding_checklist_items").select("*").order("target_role").order("sort_order");if(M)throw M;s(S||[])}catch(S){console.error("Error fetching checklist items:",S),me.error("Failed to load checklist items")}finally{n(!1)}},f=()=>{i(null),u({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0}),o(!0)},g=S=>{i(S),u({title:S.title,description:S.description||"",action_type:S.action_type,target_role:S.target_role,is_active:S.is_active}),o(!0)},b=async()=>{if(!c.title.trim()){me.error("Title is required");return}try{if(l){const{error:S}=await H.from("onboarding_checklist_items").update({title:c.title,description:c.description||null,action_type:c.action_type,target_role:c.target_role,is_active:c.is_active}).eq("id",l.id);if(S)throw S;me.success("Checklist item updated")}else{const S=t.filter(L=>L.target_role===c.target_role).reduce((L,I)=>Math.max(L,I.sort_order),-1),{error:M}=await H.from("onboarding_checklist_items").insert({title:c.title,description:c.description||null,action_type:c.action_type,target_role:c.target_role,is_active:c.is_active,sort_order:S+1});if(M)throw M;me.success("Checklist item created")}o(!1),p()}catch(S){console.error("Error saving checklist item:",S),me.error("Failed to save checklist item")}},_=async S=>{if(confirm("Are you sure you want to delete this checklist item?"))try{const{error:M}=await H.from("onboarding_checklist_items").delete().eq("id",S);if(M)throw M;me.success("Checklist item deleted"),p()}catch(M){console.error("Error deleting checklist item:",M),me.error("Failed to delete checklist item")}},j=async S=>{try{const{error:M}=await H.from("onboarding_checklist_items").update({is_active:!S.is_active}).eq("id",S.id);if(M)throw M;me.success(S.is_active?"Item deactivated":"Item activated"),p()}catch(M){console.error("Error toggling item:",M),me.error("Failed to update item")}},w=t.filter(S=>S.target_role==="brokerage_manager"),k=t.filter(S=>S.target_role==="agent");return e.jsxs(Ms,{title:"Onboarding Checklist",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Onboarding Checklist"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage checklist items shown to new users on their dashboard"})]}),e.jsxs(K,{onClick:f,className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Add Item"]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(tt,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx(De,{children:w.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-12",children:"#"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Action Type"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:w.map((S,M)=>{var L;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"text-muted-foreground",children:M+1}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:S.description})]})}),e.jsx(dt,{children:e.jsx(tt,{variant:"outline",children:((L=pye.find(I=>I.value===S.action_type))==null?void 0:L.label)||S.action_type})}),e.jsx(dt,{children:e.jsx(qr,{checked:S.is_active,onCheckedChange:()=>j(S)})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>g(S),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(S.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(tt,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),e.jsx(De,{children:k.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for agents"}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-12",children:"#"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Action Type"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:k.map((S,M)=>{var L;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"text-muted-foreground",children:M+1}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:S.description})]})}),e.jsx(dt,{children:e.jsx(tt,{variant:"outline",children:((L=pye.find(I=>I.value===S.action_type))==null?void 0:L.label)||S.action_type})}),e.jsx(dt,{children:e.jsx(qr,{checked:S.is_active,onCheckedChange:()=>j(S)})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>g(S),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(S.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]})]}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{id:"title",value:c.title,onChange:S=>u({...c,title:S.target.value}),placeholder:"e.g., Watch your first academy video"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",value:c.description,onChange:S=>u({...c,description:S.target.value}),placeholder:"Optional description for the checklist item",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Target Role"}),e.jsxs(Zs,{value:c.target_role,onValueChange:S=>u({...c,target_role:S}),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:P1s.map(S=>e.jsx(Mt,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Action Type"}),e.jsxs(Zs,{value:c.action_type,onValueChange:S=>u({...c,action_type:S}),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:pye.map(S=>e.jsx(Mt,{value:S.value,children:S.label},S.value))})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_active",checked:c.is_active,onCheckedChange:S=>u({...c,is_active:S})}),e.jsx(ve,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:b,children:l?"Save Changes":"Create Item"})]})]})})]})}function L1s(){const[t,s]=N.useState(""),[r,n]=N.useState("all"),[a,o]=N.useState("name"),[l,i]=N.useState("asc"),[c,u]=N.useState(""),[p,f]=N.useState(""),[g,b]=N.useState(""),[_,j]=N.useState(""),{data:w}=mt({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:V,error:Z}=await H.from("brokerages").select("id, name").order("name");if(Z)throw Z;return V}}),k=async V=>{let X=[],ee=0,Q=!0;for(;Q;){const{data:ie,error:re}=await V(ee,ee+1e3-1);if(re)throw re;ie&&ie.length>0?(X=[...X,...ie],ee+=1e3,Q=ie.length===1e3):Q=!1}return X},{data:S,isLoading:M}=mt({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const V=await k((Te,ke)=>H.from("profiles").select("id, name, email, brokerage_id, created_at").range(Te,ke)),{data:Z}=await H.from("brokerages").select("id, name"),X=new Map((Z==null?void 0:Z.map(Te=>[Te.id,Te.name]))||[]),[{data:ee},{data:Q},{data:ie},{data:re},{data:oe},{data:ce},{data:xe}]=await Promise.all([H.rpc("get_admin_contact_counts"),H.rpc("get_admin_video_counts"),H.rpc("get_admin_popby_counts"),H.rpc("get_admin_listing_counts"),H.rpc("get_admin_deal_counts"),H.rpc("get_admin_portal_counts"),H.rpc("get_admin_sendable_card_counts")]),ge=new Map;ee==null||ee.forEach(Te=>ge.set(Te.owner_user_id,Te.contact_count));const ue=new Map;Q==null||Q.forEach(Te=>ue.set(Te.owner_user_id,Te.video_count));const pe=new Map;ie==null||ie.forEach(Te=>pe.set(Te.owner_user_id,Te.popby_count));const be=new Map;re==null||re.forEach(Te=>be.set(Te.agent_id,Te.listing_count));const Me=new Map;oe==null||oe.forEach(Te=>Me.set(Te.owner_user_id,Te.deal_count));const Ne=new Map;ce==null||ce.forEach(Te=>Ne.set(Te.owner_user_id,{total:Te.portal_count,active:Te.active_portal_count}));const Pe=new Map;return xe==null||xe.forEach(Te=>Pe.set(Te.owner_user_id,{total:Te.card_count,sent:Te.sent_card_count,views:Te.total_card_views})),V.map(Te=>{const ke=Ne.get(Te.id),Be=Pe.get(Te.id);return{id:Te.id,name:Te.name||"Unknown",email:Te.email||"",brokerage_id:Te.brokerage_id,brokerage_name:Te.brokerage_id&&X.get(Te.brokerage_id)||null,contact_count:ge.get(Te.id)||0,video_count:ue.get(Te.id)||0,popby_count:pe.get(Te.id)||0,listing_count:be.get(Te.id)||0,deal_count:Me.get(Te.id)||0,portal_count:(ke==null?void 0:ke.total)||0,active_portal_count:(ke==null?void 0:ke.active)||0,card_count:(Be==null?void 0:Be.total)||0,sent_card_count:(Be==null?void 0:Be.sent)||0,total_card_views:(Be==null?void 0:Be.views)||0,created_at:Te.created_at}})}}),L=N.useMemo(()=>{if(!S)return[];let V=S.filter(Z=>{const X=t.toLowerCase(),ee=!t||Z.name.toLowerCase().includes(X)||Z.email.toLowerCase().includes(X),Q=r==="all"||r==="none"&&!Z.brokerage_id||Z.brokerage_id===r,ie=parseInt(c)||0,re=parseInt(p)||0,oe=parseInt(g)||0,ce=parseInt(_)||0,xe=Z.contact_count>=ie&&Z.video_count>=re&&Z.popby_count>=oe&&Z.listing_count>=ce;return ee&&Q&&xe});return V.sort((Z,X)=>{let ee=0;return a==="name"?ee=Z.name.localeCompare(X.name):ee=Z[a]-X[a],l==="asc"?ee:-ee}),V},[S,t,r,a,l,c,p,g,_]),I=V=>{a===V?i(l==="asc"?"desc":"asc"):(o(V),i("desc"))},O=()=>{const V=["Name","Email","Brokerage","Contacts","Videos","Popbys","Listings","Deals","Portals (Active)","Cards Created","Cards Sent","Card Views"],Z=L.map(re=>[re.name,re.email,re.brokerage_name||"None",re.contact_count,re.video_count,re.popby_count,re.listing_count,re.deal_count,`${re.portal_count} (${re.active_portal_count})`,re.card_count,re.sent_card_count,re.total_card_views]),X=[V.join(","),...Z.map(re=>re.map(oe=>`"${oe}"`).join(","))].join(` `),ee=new Blob([X],{type:"text/csv"}),Q=URL.createObjectURL(ee),ie=document.createElement("a");ie.href=Q,ie.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,ie.click(),URL.revokeObjectURL(Q)},q=N.useMemo(()=>L.length?L.reduce((V,Z)=>({contacts:V.contacts+Z.contact_count,videos:V.videos+Z.video_count,popbys:V.popbys+Z.popby_count,listings:V.listings+Z.listing_count,deals:V.deals+Z.deal_count,portals:V.portals+Z.portal_count,activePortals:V.activePortals+Z.active_portal_count,cards:V.cards+Z.card_count,sentCards:V.sentCards+Z.sent_card_count,cardViews:V.cardViews+Z.total_card_views}),{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0}):{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0},[L]),U=N.useMemo(()=>L.length?{portals:L.filter(V=>V.portal_count>0).length,cards:L.filter(V=>V.card_count>0).length}:{portals:0,cards:0},[L]),B=({field:V,children:Z})=>e.jsx(St,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>I(V),children:e.jsxs("div",{className:"flex items-center gap-1",children:[Z,e.jsx(vd,{className:`h-3 w-3 ${a===V?"text-primary":"text-muted-foreground"}`})]})});return e.jsx(z1,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ee,{className:"border-blue-500/20 bg-gradient-to-br from-blue-500/5 to-transparent",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(s1,{className:"h-4 w-4 text-blue-500"}),"Client Portals"]})}),e.jsx(De,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:U.portals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:q.portals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Portals"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:q.activePortals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Active Portals"})]})]})})]}),e.jsxs(Ee,{className:"border-violet-500/20 bg-gradient-to-br from-violet-500/5 to-transparent",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(cr,{className:"h-4 w-4 text-violet-500"}),"Card Studio"]})}),e.jsx(De,{children:e.jsxs("div",{className:"grid grid-cols-4 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:U.cards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:q.cards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Cards Created"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:q.sentCards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Cards Sent"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:q.cardViews}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Views"})]})]})})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(gr,{children:"View all users and their Agent OS usage metrics"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:O,children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]})}),e.jsxs(De,{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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:t,onChange:V=>s(V.target.value),className:"pl-9"})]})}),e.jsx("div",{children:e.jsxs(Zs,{value:r,onValueChange:n,children:[e.jsxs(Ws,{children:[e.jsx(ka,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(Xs,{placeholder:"Brokerage"})]}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Brokerages"}),e.jsx(Mt,{value:"none",children:"No Brokerage"}),w==null?void 0:w.map(V=>e.jsx(Mt,{value:V.id,children:V.name},V.id))]})]})}),e.jsx("div",{children:e.jsx(ze,{type:"number",placeholder:"Min contacts",value:c,onChange:V=>u(V.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(ze,{type:"number",placeholder:"Min videos",value:p,onChange:V=>f(V.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(ze,{type:"number",placeholder:"Min popbys",value:g,onChange:V=>b(V.target.value),min:"0"})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-8 text-sm",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:L.length}),e.jsx("div",{className:"text-muted-foreground",children:"Users"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q.contacts.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Contacts"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q.videos.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Videos"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q.popbys.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Popbys"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q.listings.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Listings"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q.deals.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Deals"})]}),e.jsxs("div",{className:"bg-blue-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q.portals.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Portals"})]}),e.jsxs("div",{className:"bg-violet-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q.cards.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Cards"})]})]}),M?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(B,{field:"name",children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Brokerage"}),e.jsx(B,{field:"contact_count",children:"Contacts"}),e.jsx(B,{field:"video_count",children:"Videos"}),e.jsx(B,{field:"popby_count",children:"Popbys"}),e.jsx(B,{field:"listing_count",children:"Listings"}),e.jsx(B,{field:"deal_count",children:"Deals"}),e.jsx(B,{field:"portal_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(s1,{className:"h-3 w-3 text-blue-500"}),"Portals"]})}),e.jsx(B,{field:"card_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(cr,{className:"h-3 w-3 text-violet-500"}),"Cards"]})})]})}),e.jsx(zn,{children:L.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No users found matching your filters"})}):L.map(V=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:V.name}),e.jsx(dt,{className:"text-muted-foreground",children:V.email}),e.jsx(dt,{children:V.brokerage_name?e.jsx(tt,{variant:"secondary",children:V.brokerage_name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{children:e.jsx(tt,{variant:V.contact_count>0?"default":"outline",children:V.contact_count})}),e.jsx(dt,{children:e.jsx(tt,{variant:V.video_count>0?"default":"outline",children:V.video_count})}),e.jsx(dt,{children:e.jsx(tt,{variant:V.popby_count>0?"default":"outline",children:V.popby_count})}),e.jsx(dt,{children:e.jsx(tt,{variant:V.listing_count>0?"default":"outline",children:V.listing_count})}),e.jsx(dt,{children:e.jsx(tt,{variant:V.deal_count>0?"default":"outline",children:V.deal_count})}),e.jsx(dt,{children:V.portal_count>0?e.jsxs(bc,{children:[e.jsx(_c,{children:e.jsxs(tt,{variant:"default",className:"bg-blue-600 hover:bg-blue-700",children:[V.portal_count,V.active_portal_count>0&&e.jsxs("span",{className:"ml-1 opacity-75",children:["(",V.active_portal_count," active)"]})]})}),e.jsxs(Yl,{children:[e.jsxs("p",{children:[V.portal_count," total portals"]}),e.jsxs("p",{children:[V.active_portal_count," currently active"]})]})]}):e.jsx(tt,{variant:"outline",children:"0"})}),e.jsx(dt,{children:V.card_count>0?e.jsxs(bc,{children:[e.jsx(_c,{children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(tt,{variant:"default",className:"bg-violet-600 hover:bg-violet-700",children:V.card_count}),V.sent_card_count>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600",children:[e.jsx(Bn,{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(On,{className:"h-3 w-3"}),V.total_card_views]})]})}),e.jsxs(Yl,{children:[e.jsxs("p",{children:[V.card_count," cards created"]}),e.jsxs("p",{children:[V.sent_card_count," sent"]}),e.jsxs("p",{children:[V.total_card_views," total views"]})]})]}):e.jsx(tt,{variant:"outline",children:"0"})})]},V.id))})]})})]})]})]})})}function D1s(){Ua(),Qt();const[t,s]=N.useState("user-analytics"),{data:r}=mt({queryKey:["admin-feature-flags"],queryFn:async()=>{const{data:b,error:_}=await H.from("feature_flags").select("*").order("key");if(_)throw _;return b}}),{data:n,isLoading:a}=mt({queryKey:["admin-relationship-types"],queryFn:async()=>{const{data:b,error:_}=await H.from("relationship_types").select("*").order("sort_order");if(_)throw _;return b}}),{data:o,isLoading:l}=mt({queryKey:["admin-action-types"],queryFn:async()=>{const{data:b,error:_}=await H.from("action_types").select("*").order("sort_order");if(_)throw _;return b}}),{data:i,isLoading:c}=mt({queryKey:["admin-action-scripts"],queryFn:async()=>{const{data:b,error:_}=await H.from("action_scripts").select("*, action_type:action_types(*)");if(_)throw _;return b}}),{data:u,isLoading:p}=mt({queryKey:["admin-touchpoint-plans"],queryFn:async()=>{const{data:b,error:_}=await H.from("touchpoint_plans").select("*").order("name");if(_)throw _;return b}}),{data:f,isLoading:g}=mt({queryKey:["admin-popby-items"],queryFn:async()=>{const{data:b,error:_}=await H.from("popby_items").select("*").is("owner_user_id",null).order("name");if(_)throw _;return b}});return e.jsx(Ms,{title:"Agent OS Control Center",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),e.jsxs(ba,{value:t,onValueChange:s,children:[e.jsxs(pa,{className:"grid w-full grid-cols-9",children:[e.jsxs(ns,{value:"user-analytics",className:"gap-2",children:[e.jsx(No,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Users"})]}),e.jsxs(ns,{value:"relationship-types",className:"gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Relationships"})]}),e.jsxs(ns,{value:"action-types",className:"gap-2",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Actions"})]}),e.jsxs(ns,{value:"scripts",className:"gap-2",children:[e.jsx(Sn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),e.jsxs(ns,{value:"video-scripts",className:"gap-2",children:[e.jsx(gu,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Video Scripts"})]}),e.jsxs(ns,{value:"plans",className:"gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Plans"})]}),e.jsxs(ns,{value:"popbys",className:"gap-2",children:[e.jsx(ko,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),e.jsxs(ns,{value:"settings",className:"gap-2",children:[e.jsx(Xo,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]}),e.jsxs(ns,{value:"feature-flags",className:"gap-2",children:[e.jsx(n1,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Flags"})]})]}),e.jsx(bs,{value:"user-analytics",className:"mt-6",children:e.jsx(L1s,{})}),e.jsx(bs,{value:"relationship-types",className:"mt-6",children:e.jsx(O1s,{types:n||[],isLoading:a})}),e.jsx(bs,{value:"action-types",className:"mt-6",children:e.jsx(R1s,{types:o||[],isLoading:l})}),e.jsx(bs,{value:"scripts",className:"mt-6",children:e.jsx(F1s,{scripts:i||[],actionTypes:o||[],isLoading:c})}),e.jsx(bs,{value:"video-scripts",className:"mt-6",children:e.jsx(q1s,{})}),e.jsx(bs,{value:"plans",className:"mt-6",children:e.jsx(z1s,{plans:u||[],actionTypes:o||[],scripts:i||[],isLoading:p})}),e.jsx(bs,{value:"popbys",className:"mt-6",children:e.jsx($1s,{items:f||[],isLoading:g})}),e.jsx(bs,{value:"settings",className:"mt-6",children:e.jsx(U1s,{})}),e.jsx(bs,{value:"feature-flags",className:"mt-6",children:e.jsx(B1s,{flags:r||[]})})]})]})})}function O1s({types:t,isLoading:s}){const{toast:r}=Ua(),n=Qt(),[a,o]=N.useState(null),[l,i]=N.useState(!1),c=Dt({mutationFn:async p=>{if(p.id){const{error:f}=await H.from("relationship_types").update({name:p.name,description:p.description,icon:p.icon}).eq("id",p.id);if(f)throw f}else{const{error:f}=await H.from("relationship_types").insert([{name:p.name,description:p.description,icon:p.icon,sort_order:t.length}]);if(f)throw f}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-relationship-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:p=>{r({title:"Error",description:p.message,variant:"destructive"})}}),u=async p=>{await H.from("relationship_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-relationship-types"]})};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Relationship Types"}),e.jsx(gr,{children:"Define the relationship categories for InnerCircle contacts"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Type"]})]}),e.jsx(De,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-12"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(zn,{children:t.map(p=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground cursor-grab"})}),e.jsx(dt,{className:"font-medium",children:p.name}),e.jsx(dt,{className:"text-muted-foreground",children:p.description}),e.jsx(dt,{children:e.jsx(qr,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsxs(vs,{children:[a?"Edit":"Add"," Relationship Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const f=new FormData(p.currentTarget);c.mutate({id:a==null?void 0:a.id,name:f.get("name"),description:f.get("description"),icon:f.get("icon")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"icon",children:"Icon"}),e.jsx(ze,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., star, heart, user"})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:c.isPending,children:[c.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function R1s({types:t,isLoading:s}){const{toast:r}=Ua(),n=Qt(),[a,o]=N.useState(null),[l,i]=N.useState(!1),c=Dt({mutationFn:async p=>{if(p.id){const{error:f}=await H.from("action_types").update({name:p.name,description:p.description,icon:p.icon,color:p.color}).eq("id",p.id);if(f)throw f}else{const{error:f}=await H.from("action_types").insert([{name:p.name,description:p.description,icon:p.icon,color:p.color,sort_order:t.length}]);if(f)throw f}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-action-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:p=>{r({title:"Error",description:p.message,variant:"destructive"})}}),u=async p=>{await H.from("action_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-action-types"]})};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Action Types"}),e.jsx(gr,{children:"Define the types of touchpoint actions agents can take"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Action"]})]}),e.jsx(De,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Color"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(zn,{children:t.map(p=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:p.name}),e.jsx(dt,{className:"text-muted-foreground",children:p.description}),e.jsx(dt,{children:p.color&&e.jsx("div",{className:"w-6 h-6 rounded",style:{backgroundColor:p.color}})}),e.jsx(dt,{children:e.jsx(qr,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsxs(vs,{children:[a?"Edit":"Add"," Action Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const f=new FormData(p.currentTarget);c.mutate({id:a==null?void 0:a.id,name:f.get("name"),description:f.get("description"),icon:f.get("icon"),color:f.get("color")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"icon",children:"Icon"}),e.jsx(ze,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., phone, message"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"color",children:"Color"}),e.jsx(ze,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:c.isPending,children:[c.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function F1s({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=Ua(),a=Qt(),[o,l]=N.useState(null),[i,c]=N.useState(!1),u=Dt({mutationFn:async f=>{if(f.id){const{error:g}=await H.from("action_scripts").update({title:f.title,action_type_id:f.action_type_id,tone:f.tone,script_body:f.script_body,active:f.active}).eq("id",f.id);if(g)throw g}else{const{error:g}=await H.from("action_scripts").insert([{title:f.title,action_type_id:f.action_type_id,tone:f.tone,script_body:f.script_body,active:!0}]);if(g)throw g}},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),c(!1),l(null),n({title:"Saved successfully"})},onError:f=>{n({title:"Error",description:f.message,variant:"destructive"})}}),p=Dt({mutationFn:async f=>{const{error:g}=await H.from("action_scripts").delete().eq("id",f);if(g)throw g},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),n({title:"Deleted successfully"})}});return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Script Library"}),e.jsx(gr,{children:"Create and manage scripts for each action type"})]}),e.jsxs(K,{onClick:()=>{l(null),c(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(De,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Action Type"}),e.jsx(St,{children:"Tone"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(zn,{children:t.map(f=>{var g;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:f.title}),e.jsx(dt,{children:e.jsx(tt,{variant:"outline",children:((g=f.action_type)==null?void 0:g.name)||"Unknown"})}),e.jsx(dt,{className:"text-muted-foreground",children:f.tone}),e.jsx(dt,{children:e.jsx(tt,{variant:f.active?"default":"secondary",children:f.active?"Active":"Inactive"})}),e.jsxs(dt,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{l(f),c(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutate(f.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})]},f.id)})})]})}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(vs,{children:[o?"Edit":"Add"," Script"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const g=new FormData(f.currentTarget);u.mutate({id:o==null?void 0:o.id,title:g.get("title"),action_type_id:g.get("action_type_id"),tone:g.get("tone"),script_body:g.get("script_body"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",name:"title",defaultValue:o==null?void 0:o.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"action_type_id",children:"Action Type"}),e.jsxs(Zs,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select action type"})}),e.jsx(Gs,{children:s.map(f=>e.jsx(Mt,{value:f.id,children:f.name},f.id))})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"tone",children:"Tone (optional)"}),e.jsx(ze,{id:"tone",name:"tone",defaultValue:(o==null?void 0:o.tone)||"",placeholder:"e.g., Friendly, Professional, Casual"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Er,{id:"script_body",name:"script_body",defaultValue:o==null?void 0:o.script_body,rows:8,required:!0,placeholder:`Use {{FirstName}}, {{LastName}}, and {{AgentName}} as placeholders. Example: Hey {{FirstName}}, it's {{AgentName}}. I was thinking about you and wanted to check in...`})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:u.isPending,children:[u.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function z1s({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=Ua(),o=Qt(),[l,i]=N.useState(null),[c,u]=N.useState(!1),[p,f]=N.useState(null),[g,b]=N.useState(!1),[_,j]=N.useState(null),[w,k]=N.useState(null),{data:S}=mt({queryKey:["plan-items",p],queryFn:async()=>{if(!p)return[];const{data:B,error:V}=await H.from("touchpoint_plan_items").select("*").eq("plan_id",p).order("month_number");if(V)throw V;return B},enabled:!!p}),M=Dt({mutationFn:async B=>{if(B.id){const{error:V}=await H.from("touchpoint_plans").update({name:B.name,description:B.description,active:B.active}).eq("id",B.id);if(V)throw V}else{const{error:V}=await H.from("touchpoint_plans").insert([{name:B.name,description:B.description,active:!0}]);if(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["admin-touchpoint-plans"]}),u(!1),i(null),a({title:"Saved successfully"})},onError:B=>{a({title:"Error",description:B.message,variant:"destructive"})}}),L=Dt({mutationFn:async B=>{if(B.id){const{error:V}=await H.from("touchpoint_plan_items").update({action_type_id:B.action_type_id,default_script_id:B.default_script_id,notes:B.notes}).eq("id",B.id);if(V)throw V}else{const{error:V}=await H.from("touchpoint_plan_items").insert([{plan_id:B.plan_id,month_number:B.month_number,action_type_id:B.action_type_id,default_script_id:B.default_script_id,notes:B.notes}]);if(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]}),a({title:"Item saved"})}}),I=Dt({mutationFn:async B=>{const{error:V}=await H.from("touchpoint_plan_items").delete().eq("id",B);if(V)throw V},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]})}}),O=Dt({mutationFn:async B=>{const{data:V,error:Z}=await H.from("action_scripts").insert([{...B,active:!0}]).select().single();if(Z)throw Z;return V},onSuccess:async B=>{o.invalidateQueries({queryKey:["admin-action-scripts"]}),_&&await L.mutateAsync({id:_.itemId,plan_id:p,month_number:_.month,action_type_id:_.actionTypeId,default_script_id:B.id}),b(!1),j(null),a({title:"Script created and assigned"})},onError:B=>{a({title:"Error",description:B.message,variant:"destructive"})}}),q=(B,V,Z)=>{j({month:B,actionTypeId:V,itemId:Z}),b(!0)},U=B=>r.find(V=>V.id===B);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Touchpoint Plans"}),e.jsx(gr,{children:"Create annual touchpoint plans that agents can apply to their contacts"})]}),e.jsxs(K,{onClick:()=>{i(null),u(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Plan"]})]}),e.jsx(De,{children:n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(B=>e.jsxs(Ee,{className:`cursor-pointer transition-colors ${p===B.id?"border-primary":""}`,onClick:()=>f(B.id),children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Rt,{className:"text-base",children:B.name}),e.jsx(K,{variant:"ghost",size:"icon",onClick:V=>{V.stopPropagation(),i(B),u(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})})]})}),e.jsxs(De,{children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:B.description}),e.jsx(tt,{variant:B.active?"default":"secondary",className:"mt-2",children:B.active?"Active":"Inactive"})]})]},B.id))})})]}),p&&e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Plan Schedule"}),e.jsx(gr,{children:"Configure the monthly touchpoint schedule. Select an action type for each month, then assign or create a script."})]}),e.jsx(De,{children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:12},(B,V)=>V+1).map(B=>{const V=S==null?void 0:S.find(ee=>ee.month_number===B),Z=V!=null&&V.default_script_id?U(V.default_script_id):null,X=r.filter(ee=>ee.action_type_id===(V==null?void 0:V.action_type_id)&&ee.active);return e.jsxs("div",{className:"p-4 border rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"w-20 font-medium text-sm",children:["Month ",B]}),e.jsxs(Zs,{value:(V==null?void 0:V.action_type_id)||"none",onValueChange:ee=>{ee==="none"&&V?I.mutate(V.id):ee!=="none"&&L.mutate({id:V==null?void 0:V.id,plan_id:p,month_number:B,action_type_id:ee,default_script_id:null})},children:[e.jsx(Ws,{className:"w-40",children:e.jsx(Xs,{placeholder:"No action"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:"No action"}),s.filter(ee=>ee.active).map(ee=>e.jsx(Mt,{value:ee.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[ee.color&&e.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:ee.color}}),ee.name]})},ee.id))]})]}),V&&e.jsxs(e.Fragment,{children:[e.jsxs(Zs,{value:V.default_script_id||"none",onValueChange:ee=>{k(null),L.mutate({id:V.id,default_script_id:ee==="none"?null:ee})},children:[e.jsx(Ws,{className:"w-56",children:e.jsx(Xs,{placeholder:"Select script"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:"No default script"}),X.map(ee=>e.jsxs(Mt,{value:ee.id,children:[ee.title," ",ee.tone&&`(${ee.tone})`]},ee.id))]})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>q(B,V.action_type_id,V.id),children:[e.jsx($s,{className:"h-3 w-3 mr-1"}),"New Script"]}),Z&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k((w==null?void 0:w.id)===Z.id?null:Z),children:(w==null?void 0:w.id)===Z.id?"Hide":"Preview"})]})]}),w&&(V==null?void 0:V.default_script_id)===w.id&&e.jsxs("div",{className:"ml-24 p-3 bg-muted rounded-lg text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(tt,{variant:"outline",children:w.title}),w.tone&&e.jsx(tt,{variant:"secondary",children:w.tone})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:w.script_body})]})]},B)})})})]}),e.jsx(fs,{open:c,onOpenChange:u,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsxs(vs,{children:[l?"Edit":"Add"," Touchpoint Plan"]})}),e.jsxs("form",{onSubmit:B=>{B.preventDefault();const V=new FormData(B.currentTarget);M.mutate({id:l==null?void 0:l.id,name:V.get("name"),description:V.get("description"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",name:"name",defaultValue:l==null?void 0:l.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:M.isPending,children:[M.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})}),e.jsx(fs,{open:g,onOpenChange:b,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create New Script"}),e.jsxs(Gr,{children:["Create a script for Month ",_==null?void 0:_.month,". Use ","{{FirstName}}",", ","{{LastName}}",", and ","{{AgentName}}"," as placeholders."]})]}),e.jsxs("form",{onSubmit:B=>{B.preventDefault();const V=new FormData(B.currentTarget);O.mutate({title:V.get("title"),action_type_id:_.actionTypeId,tone:V.get("tone"),script_body:V.get("script_body")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script_title",children:"Title"}),e.jsx(ze,{id:"script_title",name:"title",placeholder:"e.g., Warm Check-In",required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script_tone",children:"Tone"}),e.jsx(ze,{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(Er,{id:"script_body",name:"script_body",rows:6,required:!0,placeholder:"Hey {{FirstName}}, it's {{AgentName}}. I was thinking about you and wanted to check in..."})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:O.isPending,children:[O.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function B1s({flags:t}){const{toast:s}=Ua(),r=Qt(),n=async(a,o)=>{const{error:l}=await H.from("feature_flags").update({...o,updated_at:new Date().toISOString()}).eq("id",a.id);l?s({title:"Error",description:l.message,variant:"destructive"}):(r.invalidateQueries({queryKey:["admin-feature-flags"]}),s({title:"Flag updated"}))};return e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Feature Flags"}),e.jsx(gr,{children:"Control which features are enabled for members"})]}),e.jsx(De,{children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Flag"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Notes"}),e.jsx(St,{children:"Last Updated"})]})}),e.jsx(zn,{children:t.map(a=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-mono text-sm",children:a.key}),e.jsx(dt,{children:e.jsx(qr,{checked:a.enabled,onCheckedChange:o=>n(a,{enabled:o})})}),e.jsx(dt,{children:e.jsx(ze,{defaultValue:a.notes||"",placeholder:"Add notes...",className:"max-w-xs",onBlur:o=>{o.target.value!==a.notes&&n(a,{notes:o.target.value})}})}),e.jsx(dt,{className:"text-muted-foreground text-sm",children:new Date(a.updated_at).toLocaleDateString()})]},a.id))})]})})]})}function $1s({items:t,isLoading:s}){const{toast:r}=Ua(),n=Qt(),[a,o]=N.useState(null),[l,i]=N.useState(!1),c=Dt({mutationFn:async f=>{if(f.id){const{error:g}=await H.from("popby_items").update({name:f.name,description:f.description}).eq("id",f.id);if(g)throw g}else{const{error:g}=await H.from("popby_items").insert([{name:f.name,description:f.description,owner_user_id:null}]);if(g)throw g}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:f=>{r({title:"Error",description:f.message,variant:"destructive"})}}),u=async f=>{await H.from("popby_items").update({is_active:!f.is_active}).eq("id",f.id),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]})},p=async f=>{await H.from("popby_items").delete().eq("id",f),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),r({title:"Deleted successfully"})};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Popby Ideas"}),e.jsx(gr,{children:"Manage global popby ideas that all agents can see"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsx(De,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):t.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ko,{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(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(zn,{children:t.map(f=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:f.name}),e.jsx(dt,{className:"text-muted-foreground",children:f.description}),e.jsx(dt,{children:e.jsx(qr,{checked:f.is_active,onCheckedChange:()=>u(f)})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(f),i(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p(f.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},f.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsxs(vs,{children:[a?"Edit":"Add"," Popby Idea"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const g=new FormData(f.currentTarget);c.mutate({id:a==null?void 0:a.id,name:g.get("name"),description:g.get("description")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0,placeholder:"e.g., Homemade Cookies"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:c.isPending,children:[c.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function q1s(){var b;const{toast:t}=Ua(),s=Qt(),[r,n]=N.useState(null),[a,o]=N.useState(!1),{data:l,isLoading:i}=mt({queryKey:["admin-video-script-categories"],queryFn:async()=>{const{data:_,error:j}=await H.from("video_script_categories").select("*").order("sort_order");if(j)throw j;return _}}),{data:c,isLoading:u}=mt({queryKey:["admin-video-scripts"],queryFn:async()=>{const{data:_,error:j}=await H.from("video_scripts").select("*, category:video_script_categories(*)").order("title");if(j)throw j;return _}}),p=Dt({mutationFn:async _=>{var j,w;if(_.id){const{error:k}=await H.from("video_scripts").update({title:_.title,script_text:_.script_text,category_id:_.category_id,tags:((j=_.tags)==null?void 0:j.split(",").map(S=>S.trim()).filter(Boolean))||[]}).eq("id",_.id);if(k)throw k}else{const{error:k}=await H.from("video_scripts").insert([{title:_.title,script_text:_.script_text,category_id:_.category_id||null,tags:((w=_.tags)==null?void 0:w.split(",").map(S=>S.trim()).filter(Boolean))||[]}]);if(k)throw k}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-video-scripts"]}),o(!1),n(null),t({title:"Video script saved!"})},onError:_=>t({title:"Error",description:_.message,variant:"destructive"})}),f=async _=>{await H.from("video_scripts").update({is_active:!_.is_active}).eq("id",_.id),s.invalidateQueries({queryKey:["admin-video-scripts"]})},g=async _=>{confirm("Delete this video script?")&&(await H.from("video_scripts").delete().eq("id",_),s.invalidateQueries({queryKey:["admin-video-scripts"]}),t({title:"Script deleted"}))};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Video Scripts"}),e.jsx(gr,{children:"Manage teleprompter scripts for Quick Video Touch"})]}),e.jsxs(K,{onClick:()=>{n(null),o(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(De,{children:u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(zn,{children:c==null?void 0:c.map(_=>{var j;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:_.title}),e.jsx(dt,{className:"text-muted-foreground",children:((j=_.category)==null?void 0:j.name)||"Uncategorized"}),e.jsx(dt,{children:e.jsx(qr,{checked:_.is_active,onCheckedChange:()=>f(_)})}),e.jsxs(dt,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{n(_),o(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>g(_.id),children:e.jsx(Nr,{className:"h-4 w-4"})})]})]},_.id)})})]})}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(vs,{children:[r?"Edit":"Add"," Video Script"]})}),e.jsxs("form",{onSubmit:_=>{_.preventDefault();const j=new FormData(_.currentTarget);p.mutate({id:r==null?void 0:r.id,title:j.get("title"),script_text:j.get("script_text"),category_id:j.get("category_id")||null,tags:j.get("tags")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",name:"title",defaultValue:r==null?void 0:r.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"category_id",children:"Category"}),e.jsxs(Zs,{name:"category_id",defaultValue:(r==null?void 0:r.category_id)||"",children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select category"})}),e.jsx(Gs,{children:l==null?void 0:l.map(_=>e.jsx(Mt,{value:_.id,children:_.name},_.id))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script_text",children:"Script Text"}),e.jsx(Er,{id:"script_text",name:"script_text",defaultValue:r==null?void 0:r.script_text,rows:6,required:!0,placeholder:"Enter the teleprompter script..."})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"tags",children:"Tags (comma-separated)"}),e.jsx(ze,{id:"tags",name:"tags",defaultValue:((b=r==null?void 0:r.tags)==null?void 0:b.join(", "))||"",placeholder:"birthday, follow-up, thank-you"})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:p.isPending,children:[p.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function U1s(){const{toast:t}=Ua(),[s,r]=N.useState(""),[n,a]=N.useState(!0),[o,l]=N.useState(!1);N.useEffect(()=>{(async()=>{a(!0);try{const{data:u}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();u!=null&&u.value&&r(u.value)}catch(u){console.error("Error fetching settings:",u)}a(!1)})()},[]);const i=async()=>{l(!0);try{await H.from("settings").upsert({key:"mapbox_public_token",value:s.trim()}),t({title:"Mapbox token saved!"})}catch{t({title:"Error saving token",variant:"destructive"})}l(!1)};return n?e.jsx(Ee,{children:e.jsx(De,{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(ma,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(gr,{children:"Configure the map feature for popbys"})]}),e.jsxs(De,{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(ze,{id:"mapbox-token",placeholder:"pk.eyJ1I...",value:s,onChange:c=>r(c.target.value)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token at"," ",e.jsx("a",{href:"https://mapbox.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"mapbox.com"}),". This token will be used by all agents for the popby map feature."]})]}),e.jsxs(K,{onClick:i,disabled:o,children:[o&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),s&&e.jsx(tt,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const V1s=()=>{const[t,s]=N.useState(""),[r,n]=N.useState("grid"),a=fr(),{data:o=[],isLoading:l}=mt({queryKey:["additional-services"],queryFn:async()=>{const{data:c,error:u}=await H.from("additional_services").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(u)throw u;return c}}),i=o.filter(c=>{var p;return c.name.toLowerCase().includes(t.toLowerCase())||((p=c.description)==null?void 0:p.toLowerCase().includes(t.toLowerCase()))});return e.jsx(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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search services...",value:t,onChange:c=>s(c.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[t&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>s(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:r==="grid"?"secondary":"outline",size:"icon",onClick:()=>n("grid"),className:"rounded-full",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:r==="list"?"secondary":"outline",size:"icon",onClick:()=>n("list"),className:"rounded-full",children:e.jsx(Mh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," service",i.length!==1?"s":""," found"]}),l&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(4)].map((c,u)=>e.jsx(Ee,{children:e.jsxs(De,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"})]})},u))}),!l&&i.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:t?"No services match your search":"No additional services available yet"}),t&&e.jsx(K,{variant:"outline",onClick:()=>s(""),children:"Clear Search"})]}),!l&&i.length>0&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:i.map(c=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${r==="list"?"flex flex-row":""}`,onClick:()=>a(`/additional-services/${c.id}`),children:[e.jsx("div",{className:`relative overflow-hidden bg-muted ${r==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:c.preview_image_url?e.jsx("img",{src:c.preview_image_url,alt:c.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(pn,{className:"h-8 w-8"})})}),e.jsxs(De,{className:`p-4 flex flex-col ${r==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:c.name}),c.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 flex-1",children:wde(c.description)})]})]},c.id))})]})})},H1s=()=>{const{serviceId:t}=yo(),s=fr(),{data:r,isLoading:n}=mt({queryKey:["additional-service",t],queryFn:async()=>{const{data:a,error:o}=await H.from("additional_services").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;return a},enabled:!!t});return n?e.jsx(Ms,{title:"Loading...",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx(ys,{className:"h-8 w-48"}),e.jsx(ys,{className:"h-64 w-full rounded-lg"}),e.jsx(ys,{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(Ja,{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(pn,{className:"h-16 w-16"})})})}),e.jsx(Ee,{children:e.jsxs(De,{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:r.name}),e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(hn,{className:"h-4 w-4 mr-1"}),"Published ",ms(new Date(r.publish_date),"MMMM d, yyyy")]})]}),r.description&&e.jsx("div",{className:"prose prose-sm max-w-none text-muted-foreground [&_a]:text-primary [&_a]:underline",dangerouslySetInnerHTML:{__html:r.description}}),e.jsx("div",{className:"pt-4 border-t",children:e.jsxs(K,{size:"lg",className:"gap-2",onClick:()=>window.open(r.signup_link_url,"_blank"),children:[e.jsx(tn,{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(Ja,{className:"h-4 w-4 mr-2"}),"Back to Services"]})]})})},oI=[{id:"content-calendar",name:"Social Media Content Calendar Generator",iframe:``},{id:"property-promotion",name:"Property Promotion AI Tool",iframe:''},{id:"bio-boost",name:"Realtor Bio-Boost",iframe:''},{id:"market-report",name:"Market Report & Video Script Generator",iframe:''},{id:"property-description",name:"Property Description Writer",iframe:''},{id:"newsletter-generator",name:"Local Real Estate Newsletter Generator",iframe:''}];function W1s(){const[t,s]=N.useState(oI[0].id),r=oI.find(n=>n.id===t)||oI[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(kM,{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(Zs,{value:t,onValueChange:s,children:[e.jsx(Ws,{className:"w-full",children:e.jsx(Xs,{placeholder:"Select a tool"})}),e.jsx(Gs,{children:oI.map(n=>e.jsx(Mt,{value:n.id,children:n.name},n.id))})]})}),e.jsx("div",{className:"hidden md:block",children:e.jsx(ba,{value:t,onValueChange:s,className:"w-full",children:e.jsx(pa,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:oI.map(n=>e.jsx(ns,{value:n.id,className:"flex-1 min-w-[150px] text-xs lg:text-sm whitespace-normal h-auto py-2",children:n.name},n.id))})})}),e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-full max-w-[700px]",dangerouslySetInnerHTML:{__html:r.iframe}})})]})})}const VFe="agent-os-onboarding-completed",Uz=[{icon:f0,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:Zh,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:pr,iconColor:"text-white",bgGradient:"from-blue-500 via-indigo-500 to-purple-500",title:"Contacts",description:"Import and organize your sphere of influence. Tag contacts by relationship type (Top 25, Past Clients, Referral Partners, etc.) to prioritize your outreach.",highlights:["Import contacts via CSV","Tag by relationship type","Track birthdays and home anniversaries","See relationship health scores"]},{icon:Dd,iconColor:"text-white",bgGradient:"from-emerald-500 via-teal-500 to-cyan-500",title:"Touchpoint Plans",description:"Assign automated touchpoint schedules to your contact groups. Each plan tells you exactly who to reach out to and when—with pre-written scripts to make it easy.",highlights:["Pre-built 12-month plans","Create your own custom plans","Scripts for calls, texts, and emails","Automatic daily action items"]},{icon:ko,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:No,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"]}],G1s=()=>{const[t,s]=N.useState(!1),[r,n]=N.useState(0),[a,o]=N.useState(!1);N.useEffect(()=>{if(!localStorage.getItem(VFe)){const _=setTimeout(()=>s(!0),500);return()=>clearTimeout(_)}},[]);const l=()=>{r{n(r+1),o(!1)},150)):c()},i=()=>{c()},c=()=>{localStorage.setItem(VFe,"true"),s(!1)},u=Uz[r],p=u.icon,f=r===Uz.length-1,g=b=>{b||c(),s(b)};return e.jsx(fs,{open:t,onOpenChange:g,children:e.jsxs(ps,{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(pn,{className:"h-3 w-3"}),"Beta"]})]}),e.jsxs("div",{className:"p-6 pt-4",children:[e.jsxs(_s,{className:"text-center sm:text-center pb-2",children:[e.jsx(vs,{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(Gr,{className:`text-base pt-2 transition-all duration-300 delay-75 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.description})]}),u.highlights&&e.jsx("div",{className:`space-y-2.5 py-4 transition-all duration-300 delay-100 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.highlights.map((b,_)=>e.jsxs("div",{className:"flex items-center gap-3 group",style:{transitionDelay:`${150+_*50}ms`},children:[e.jsx("div",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-gradient-to-br ${u.bgGradient} shadow-sm`,children:e.jsx(va,{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:Uz.map((b,_)=>e.jsx("button",{onClick:()=>{_!==r&&(o(!0),setTimeout(()=>{n(_),o(!1)},150))},className:`h-2 rounded-full transition-all duration-300 ${_===r?"w-8 bg-gradient-to-r "+u.bgGradient:_{const{user:t}=Ds();return mt({queryKey:["contact-snoozes",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_snoozes").select("*").gte("snoozed_until",new Date().toISOString());if(r)throw r;return s},enabled:!!t})},Z1s=()=>{const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async({contactId:r,days:n})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const a=El(new Date,n);await H.from("contact_snoozes").delete().eq("contact_id",r);const{error:o}=await H.from("contact_snoozes").insert({contact_id:r,owner_user_id:s.id,snoozed_until:a.toISOString()});if(o)throw o},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),t.invalidateQueries({queryKey:["today-actions"]}),t.invalidateQueries({queryKey:["popby-logs"]}),wn({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{wn({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},Y1s=()=>{const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("contact_snoozes").delete().eq("contact_id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),wn({title:"Snooze cancelled"})},onError:s=>{wn({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},X1s=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function qhe({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=N.useState(null),l=Z1s(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},c=u=>ms(El(new Date,u),"MMM d, yyyy");return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-5 w-5"}),"Snooze Touch"]}),e.jsxs(Gr,{children:["Postpone the next scheduled touch for ",n,". Select how long to snooze."]})]}),e.jsx("div",{className:"space-y-3 py-4",children:X1s.map(u=>e.jsxs("button",{type:"button",onClick:()=>o(u.days),className:It("w-full flex items-center justify-between p-3 rounded-lg border transition-colors",a===u.days?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-accent/50"),children:[e.jsx("span",{className:"font-medium",children:u.label}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),"Until ",c(u.days)]})]},u.days))}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:i,disabled:!a||l.isPending,children:l.isPending?"Snoozing...":"Snooze Touch"})]})]})})}const Q1s={Crown:Dm,FileText:Sn,Users:pr,Globe:su,Star:Jn,Phone:Un,MessageSquare:so,PenTool:q_,Video:An,Gift:ko};function J1s({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=fr(),[c,u]=N.useState("name"),[p,f]=N.useState("asc"),[g,b]=N.useState(null),[_,j]=N.useState(""),w=I=>{c===I?f(O=>O==="asc"?"desc":"asc"):(u(I),f("asc"))},k=N.useMemo(()=>[...t].sort((I,O)=>{var U,B;let q=0;switch(c){case"name":{const V=`${I.contact.first_name} ${I.contact.last_name||""}`.toLowerCase(),Z=`${O.contact.first_name} ${O.contact.last_name||""}`.toLowerCase();q=V.localeCompare(Z);break}case"relationship_type":q=(I.relationshipTypeName||"").localeCompare(O.relationshipTypeName||"");break;case"action_type":q=(((U=I.actionType)==null?void 0:U.name)||"").localeCompare(((B=O.actionType)==null?void 0:B.name)||"");break;case"last_touch":q=(I.monthNumber||0)-(O.monthNumber||0);break}return p==="asc"?q:-q}),[t,c,p]),S=I=>Q1s[I||"Phone"]||Un,M=({field:I,children:O})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>w(I),children:[O,c===I?p==="asc"?e.jsx(ku,{className:"ml-2 h-4 w-4"}):e.jsx(Wh,{className:"ml-2 h-4 w-4"}):e.jsx(vd,{className:"ml-2 h-4 w-4 opacity-50"})]}),L=(I,O,q)=>{b(I),j(`${O} ${q||""}`.trim())};return t.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No actions scheduled for today."}),e.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/50",children:[e.jsx(St,{className:"w-[180px]",children:e.jsx(M,{field:"name",children:"Contact"})}),e.jsx(St,{className:"w-[130px]",children:e.jsx(M,{field:"relationship_type",children:"Type"})}),e.jsx(St,{className:"w-[120px]",children:e.jsx(M,{field:"action_type",children:"Action"})}),e.jsx(St,{className:"w-[130px]",children:"Phone"}),e.jsx(St,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(zn,{children:k.map((I,O)=>{var X,ee,Q,ie,re,oe;const q=I.isSpecialDate,U=I.specialDateType,B=q?U==="birthday"?Ch:bn:S(((X=I.actionType)==null?void 0:X.icon)||null),V=I.contact.phone,Z=I.contact.email;return e.jsxs(Ss,{className:It("hover:bg-muted/50 transition-colors",q&&U==="birthday"&&"bg-pink-50/50 dark:bg-pink-950/20",q&&U==="anniversary"&&"bg-purple-50/50 dark:bg-purple-950/20"),children:[e.jsx(dt,{className:"font-medium",children:e.jsx("div",{children:e.jsxs("button",{onClick:()=>i(`/mission-control/contacts/${I.contact.id}`),className:"truncate max-w-[160px] text-left hover:text-primary hover:underline transition-colors",children:[I.contact.first_name," ",I.contact.last_name]})})}),e.jsx(dt,{children:I.relationshipTypeName?e.jsx(tt,{variant:"secondary",className:"text-xs",children:I.relationshipTypeName}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:q?e.jsx(tt,{className:It("gap-1",U==="birthday"&&"bg-pink-500 hover:bg-pink-600",U==="anniversary"&&"bg-purple-500 hover:bg-purple-600"),children:U==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(Ch,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(bn,{className:"h-3 w-3"})," Anniversary"]})}):e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(B,{className:"h-3 w-3"}),(ee=I.actionType)==null?void 0:ee.name]})})}),e.jsx(dt,{children:V?e.jsx("span",{className:"text-sm font-mono",children:I.contact.phone}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[V&&e.jsx("a",{href:`tel:${I.contact.phone}`,className:"p-1.5 rounded bg-primary/10 hover:bg-primary/20 text-primary transition-colors",title:"Call",children:e.jsx(Un,{className:"h-3.5 w-3.5"})}),V&&e.jsx("a",{href:a(I.contact.phone,(Q=I.script)==null?void 0:Q.script_body,I.contact),className:"p-1.5 rounded bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 transition-colors",title:"Text",children:e.jsx(so,{className:"h-3.5 w-3.5"})}),Z&&(l?e.jsx("button",{onClick:()=>l({id:I.contact.id,first_name:I.contact.first_name,last_name:I.contact.last_name,email:I.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(cr,{className:"h-3.5 w-3.5"})}):e.jsx("a",{href:o(I.contact.email,(ie=I.script)==null?void 0:ie.script_body,(re=I.script)==null?void 0:re.email_subject,(oe=I.actionType)==null?void 0:oe.name,I.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(cr,{className:"h-3.5 w-3.5"})})),q&&e.jsxs("button",{onClick:()=>{const ce=`${I.contact.first_name}${I.contact.last_name?" "+I.contact.last_name:""}`,xe=U==="birthday"?"birthday":"home_anniversary",ge=new URLSearchParams({cardType:xe,contactId:I.contact.id,name:ce,...I.contact.address?{address:I.contact.address}:{},...U==="anniversary"&&I.contact.home_anniversary?{date:I.contact.home_anniversary}:{}});i(`/mission-control/card-studio?${ge.toString()}`)},className:It("h-7 px-2 rounded text-xs font-semibold flex items-center gap-1 transition-colors",U==="birthday"?"bg-pink-500/15 hover:bg-pink-500/25 text-pink-600 dark:text-pink-400":"bg-purple-500/15 hover:bg-purple-500/25 text-purple-600 dark:text-purple-400"),title:`Send ${U==="birthday"?"Birthday":"Anniversary"} Card`,children:[e.jsx(cr,{className:"h-3.5 w-3.5"}),"Send Card"]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>L(I.contact.id,I.contact.first_name,I.contact.last_name),title:"Snooze",children:e.jsx(Rm,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"default",size:"sm",className:"h-7 px-2 text-xs ml-1",onClick:()=>{var ce;return s(I.contact.id,I.actionType.id,(ce=I.script)==null?void 0:ce.id)},disabled:n,children:[e.jsx(sa,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${I.contact.id}-${O}`)})})]})}),e.jsx(qhe,{open:!!g,onOpenChange:I=>!I&&b(null),contactId:g||"",contactName:_})]})}function Wx(){const{data:t,isLoading:s}=mt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:a,error:o}=await H.from("gmail_integrations").select("*").maybeSingle();if(o)throw o;return a}}),r=!!(t!=null&&t.is_active),n=(t==null?void 0:t.gmail_email)||null;return{isGmailConnected:r,gmailEmail:n,isLoading:s}}function ebs({onSelect:t}){const[s,r]=N.useState(null),{data:n=[],isLoading:a}=mt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:c,error:u}=await H.from("email_template_categories").select("*").order("sort_order");if(u)throw u;return c}}),{data:o=[],isLoading:l}=mt({queryKey:["agent-email-templates",s],queryFn:async()=>{let c=H.from("agent_email_templates").select("*").eq("is_active",!0).order("sort_order");s&&(c=c.eq("category_id",s));const{data:u,error:p}=await c;if(p)throw p;return u}}),i=n.find(c=>c.id===s);return a?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):s?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{onClick:()=>r(null),className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(cl,{className:"h-3.5 w-3.5"}),"Back to categories"]}),e.jsxs("p",{className:"text-xs font-medium flex items-center gap-1.5",children:[e.jsx("span",{children:i==null?void 0:i.icon})," ",i==null?void 0:i.name]}),l?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):o.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No templates in this category"}):e.jsx(Gi,{className:"max-h-[280px]",children:e.jsx("div",{className:"space-y-1",children:o.map(c=>e.jsxs("button",{onClick:()=>t(c),className:"w-full p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"font-medium text-sm",children:c.title}),c.tone&&e.jsx(tt,{variant:"secondary",className:"text-[10px] shrink-0",children:c.tone})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:c.subject})]},c.id))})})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground px-1 mb-2",children:"Select a category"}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto space-y-1 pr-1",children:n.map(c=>e.jsxs("button",{onClick:()=>r(c.id),className:"w-full flex items-center justify-between p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"text-lg",children:c.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:c.name}),c.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:c.description})]})]}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground shrink-0"})]},c.id))})]})}function rSe(){var a;const{user:t}=Ds(),{data:s,isLoading:r}=mt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,staleTime:60*1e3,queryFn:async()=>{var u,p,f,g;const[o,l]=await Promise.all([H.from("mass_email_settings").select("reply_to_email, display_name").eq("user_id",t.id).maybeSingle(),H.from("profiles").select("email, name").eq("id",t.id).maybeSingle()]),i=o.data,c=l.data;return{reply_to_email:((u=i==null?void 0:i.reply_to_email)==null?void 0:u.trim())||((p=c==null?void 0:c.email)==null?void 0:p.trim())||t.email||null,display_name:((f=i==null?void 0:i.display_name)==null?void 0:f.trim())||((g=c==null?void 0:c.name)==null?void 0:g.trim())||null}}});return{isReady:!!((a=s==null?void 0:s.reply_to_email)!=null&&a.trim()),isLoading:r,settings:s}}const tbs=5*1024*1024,Sv=50,sbs=["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 rbs(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function nbs(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 Db(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 qw({open:t,onOpenChange:s,contact:r,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const{user:c}=Ds(),u=Qt(),{isReady:p,settings:f}=rSe(),g=!!n&&n.length>0,b=g&&p,_=g?n:r?[r]:[],j=_[0],w=g?Math.ceil(_.length/Sv):1,k=g&&_.length>Sv,[S,M]=N.useState((j==null?void 0:j.email)||""),[L,I]=N.useState(a),[O,q]=N.useState(o),[U,B]=N.useState(!1),[V,Z]=N.useState(!1),[X,ee]=N.useState([]),[Q,ie]=N.useState(a),[re,oe]=N.useState(o),[ce,xe]=N.useState("composing"),[ge,ue]=N.useState(0),[pe,be]=N.useState(0),[Me,Ne]=N.useState(0),[Pe,Oe]=N.useState(0),Te=N.useRef(!1),[ke,Be]=N.useState(null);N.useEffect(()=>{t&&(M((j==null?void 0:j.email)||""),ie(a),oe(o),I(Db(a,j||{first_name:""})),q(Db(o,j||{first_name:""})),Z(!a&&!o),ee([]),xe("composing"),ue(0),be(0),Ne(0),Oe(0),Te.current=!1,Be(null))},[t,j,a,o]);const nt=async Qe=>{const He=Qe.target.files;if(!He)return;const Je=X.reduce((Lt,Vt)=>Lt+Vt.size,0),it=[];for(const Lt of Array.from(He)){if(!sbs.includes(Lt.type)){me.error(`${Lt.name}: Unsupported file type`);continue}if(Je+Lt.size>tbs){me.error("Total attachments exceed 5MB limit");break}try{const Vt=await nbs(Lt);it.push({name:Lt.name,type:Lt.type,size:Lt.size,data:Vt})}catch{me.error(`Failed to read ${Lt.name}`)}}ee(Lt=>[...Lt,...it]),Qe.target.value=""},Ae=Qe=>{ee(He=>He.filter((Je,it)=>it!==Qe))},ft=Qe=>{ie(Qe.subject),oe(Qe.body),I(Db(Qe.subject,j||{first_name:""})),q(Db(Qe.body,j||{first_name:""})),Z(!1)},fe=Qe=>Qe.split(/\n\n+/).map(He=>`

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

`).join(""),Ve=async Qe=>{const He=Db(Q,Qe),Je=Db(re,Qe),it=fe(Je);try{if(b){const Lt=(f==null?void 0:f.display_name)||"ReLevelUp",Vt=`${Lt.toLowerCase().replace(/[^a-z]/g,".")}@send.relevelup.com`,hs=`${Lt} <${Vt}>`,{data:Ts,error:Cs}=await H.functions.invoke("ses-send-campaign",{body:{action:"test_send",to:Qe.email,from_email:hs,subject:He,body_html:it,reply_to:(f==null?void 0:f.reply_to_email)||void 0}});if(Cs)throw Cs;if(!(Ts!=null&&Ts.success))throw new Error((Ts==null?void 0:Ts.error)||"Failed to send")}else{const{data:Lt,error:Vt}=await H.functions.invoke("gmail-send",{body:{to:Qe.email,subject:He,body:it,contactId:Qe.id,attachments:X.map(({name:hs,type:Ts,data:Cs})=>({name:hs,type:Ts,data:Cs}))}});if(Vt)throw Vt;if(!(Lt!=null&&Lt.success))throw new Error((Lt==null?void 0:Lt.error)||"Failed to send")}return c&&await H.from("bulk_email_sends").insert({user_id:c.id,contact_id:Qe.id,contact_email:Qe.email,subject:He,source:b?"ses_bulk":"sphere_gaps"}),!0}catch(Lt){return console.error("Send error:",Lt),me.error("Failed to send to "+Qe.first_name+": "+(Lt instanceof Error?Lt.message:"Unknown error")),!1}},at=()=>{const Qe=ge*Sv;return _.slice(Qe,Qe+Sv)},et=async()=>{if(!L||!O){me.error("Please fill in subject and message");return}const Qe=at();B(!0),xe("sending");let He=0,Je=0;for(let Lt=0;LtsetTimeout(hs,150));be(Lt=>Lt+He),Ne(Lt=>Lt+Je),B(!1),u.invalidateQueries({queryKey:["bulk-email-sends"]}),ge>=w-1||Te.current?xe("all_done"):xe("batch_complete")},Ce=async()=>{if(!L||!O){me.error("Please fill in subject and message");return}if(!g){B(!0);const Qe=await Ve(j);B(!1),Qe&&(u.invalidateQueries({queryKey:["bulk-email-sends"]}),me.success("Email sent successfully!"),s(!1),i==null||i());return}await et()},rt=async()=>{ue(Qe=>Qe+1),Oe(0),await new Promise(Qe=>setTimeout(Qe,50)),await et()};N.useEffect(()=>{},[ge]);const Ge=()=>{if(U){Te.current=!0;return}s(!1),i==null||i()},ct=ge*Sv,qe=Math.min(ct+Sv,_.length),Ze=g&&_.length>0?Math.round((pe+Me)/_.length*100):0;return e.jsx(fs,{open:t,onOpenChange:Ge,children:e.jsxs(ps,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:`h-5 w-5 ${b?"text-orange-500":"text-red-500"}`}),g?`Send to ${_.length} Contacts`:"Compose Email"]}),b?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending via ",e.jsx("span",{className:"font-medium",children:"Mass Email"})," (reply-to: ",f==null?void 0:f.reply_to_email,")"]}):l?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending from ",e.jsx("span",{className:"font-medium",children:l})]}):null,g&&ce==="composing"&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Composing email for ",e.jsxs("span",{className:"font-medium",children:[_.length," contacts"]}),". You'll review each personalized email before sending."]})]}),ce==="sending"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(ws,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsxs("p",{className:"font-medium",children:["Sending batch ",ge+1," of ",w,"..."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Pe," of ",at().length," in this batch"]})]}),e.jsx(Bi,{value:Pe/at().length*100,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Overall: ",pe+Me," / ",_.length]}),e.jsxs("span",{children:[pe," sent • ",Me," failed"]})]}),e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{Te.current=!0},children:"Stop Sending"})]}),ce==="batch_complete"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(sa,{className:"h-8 w-8 text-emerald-500 mx-auto"}),e.jsxs("p",{className:"font-medium",children:["Batch ",ge+1," Complete!"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[pe," sent, ",Me," failed so far"]})]}),e.jsx(Bi,{value:Ze,className:"h-2"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[_.length-pe-Me," contacts remaining (",w-ge-1," batches left)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:Ge,children:"Done for Now"}),e.jsxs(K,{className:"flex-1 gap-2",onClick:rt,children:[e.jsx(Bn,{className:"h-4 w-4"}),"Send Next ",Math.min(Sv,_.length-qe)," Contacts"]})]})]}),ce==="all_done"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(sa,{className:"h-10 w-10 text-emerald-500 mx-auto"}),e.jsx("p",{className:"font-semibold text-lg",children:"All Done!"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[pe," emails sent successfully",Me>0&&e.jsxs("span",{className:"text-destructive",children:[" • ",Me," failed"]})]})]}),e.jsx(K,{className:"w-full",onClick:Ge,children:"Close"})]}),ce==="composing"&&e.jsxs("div",{className:"space-y-4",children:[V?e.jsxs("div",{className:"border rounded-lg p-3 bg-muted/30 max-h-[50vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(Sn,{className:"h-4 w-4"})," Choose a Template"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Z(!1),className:"h-7 px-2 text-xs",children:[e.jsx(Rr,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),e.jsx(ebs,{onSelect:ft})]}):e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>Z(!0),children:[e.jsx(Sn,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(rl,{}),!g&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"gmail-to",children:"To"}),e.jsx(ze,{id:"gmail-to",value:S,onChange:Qe=>M(Qe.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(ze,{id:"gmail-subject",value:L,onChange:Qe=>{I(Qe.target.value),ie(Qe.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(tt,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{q(Qe=>Qe+"{{first_name}}"),oe(Qe=>Qe+"{{first_name}}")},children:"{{first_name}}"}),e.jsx(tt,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{q(Qe=>Qe+"{{last_name}}"),oe(Qe=>Qe+"{{last_name}}")},children:"{{last_name}}"})]})]}),e.jsx(Er,{id:"gmail-body",value:O,onChange:Qe=>{q(Qe.target.value),oe(Qe.target.value)},placeholder:"Write your message...",rows:10,className:"resize-y"}),g&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{first_name}}",", ","{{last_name}}"," to personalize. You'll preview each recipient's email in the next step."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",onClick:()=>{var Qe;return(Qe=document.getElementById("gmail-attachments"))==null?void 0:Qe.click()},disabled:U,children:[e.jsx(dS,{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:nt})]}),X.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:X.map((Qe,He)=>e.jsxs(tt,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[e.jsx(dS,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[140px] truncate text-xs",children:Qe.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",rbs(Qe.size),")"]}),e.jsx("button",{type:"button",onClick:()=>Ae(He),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Rr,{className:"h-3 w-3"})})]},He))})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),g?e.jsxs(K,{onClick:()=>{Be(_[0]||null),xe("reviewing")},disabled:!L||!O,className:"gap-2",children:["Review Emails",e.jsx(Qa,{className:"h-4 w-4"})]}):e.jsxs(K,{onClick:Ce,disabled:U||!L||!O,className:"gap-2",children:[U?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4"}),U?"Sending...":"Send Email"]})]})]}),ce==="reviewing"&&g&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-xs text-primary bg-primary/10 rounded-md px-2.5 py-1.5",children:["✉️ Click any recipient below to preview the ",e.jsx("span",{className:"font-semibold",children:"exact personalized email"})," they will receive."]}),k&&e.jsxs("p",{className:"text-xs text-amber-600 bg-amber-500/10 rounded-md px-2.5 py-1.5",children:["📦 ",_.length," contacts will be sent in ",w," batches of up to ",Sv,". You'll confirm before each batch."]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ve,{children:["Recipients (",_.length,")"]}),e.jsx("div",{className:"bg-muted p-1.5 rounded-md space-y-0.5 max-h-32 overflow-y-auto",children:_.map(Qe=>e.jsxs("div",{className:`text-sm px-2 py-1 rounded cursor-pointer transition-colors ${(ke==null?void 0:ke.id)===Qe.id?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>Be(Qe),children:[Qe.first_name," ",Qe.last_name," — ",Qe.email]},Qe.id))})]}),ke&&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(cr,{className:"h-3.5 w-3.5"}),"Preview for ",ke.first_name," ",ke.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:"})," ",ke.email]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Subject:"})," ",Db(Q,ke)]})]}),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:Db(re,ke)})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>{xe("composing"),Be(null)},children:[e.jsx(Ja,{className:"h-4 w-4 mr-1"}),"Back to Edit"]}),e.jsxs(K,{onClick:Ce,disabled:U,className:"gap-2",children:[U?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4"}),k?`Send First ${Sv}`:`Send to ${_.length}`]})]})]})]})})}function abs(){const t=fr(),{data:s}=Gm(),{data:r}=BO(),n=jNe(),{isGmailConnected:a,gmailEmail:o}=Wx(),[l,i]=N.useState(null),[c,u]=N.useState(!1),[p,f]=N.useState(new Set),g=$m(new Date),b=El(g,30),_=L=>{if(!L)return null;const I=L.split(/[-/T]/);if(I.length<3)return null;const O=parseInt(I[1],10)-1,q=parseInt(I[2],10);return isNaN(O)||isNaN(q)?null:new Date(g.getFullYear(),O,q)},j=N.useMemo(()=>{if(!s)return[];const L=[];for(const I of s){if(I.birthday){const O=_(I.birthday);O&&(Cl(O,g)||qS(O,g)&&US(O,b))&&L.push({contact:I,type:"birthday",date:O,daysUntil:hf(O,g),dateStr:I.birthday})}if(I.home_anniversary){const O=_(I.home_anniversary);O&&(Cl(O,g)||qS(O,g)&&US(O,b))&&L.push({contact:I,type:"anniversary",date:O,daysUntil:hf(O,g),dateStr:I.home_anniversary})}}return L.sort((I,O)=>I.daysUntil-O.daysUntil),L},[s]),w=async L=>{const I=(r==null?void 0:r.find(O=>O.name==="Call"))||(r==null?void 0:r[0]);if(I)try{await n.mutateAsync({contactId:L.contact.id,actionTypeId:I.id,notes:`${L.type==="birthday"?"Birthday":"Home Anniversary"} outreach`}),f(O=>new Set(O).add(`${L.contact.id}-${L.type}`)),wn({title:"Touch logged!",description:`Logged outreach for ${L.contact.first_name}`})}catch{wn({title:"Error",description:"Failed to log touch",variant:"destructive"})}},k=L=>{const I=`${L.contact.first_name}${L.contact.last_name?" "+L.contact.last_name:""}`,O=L.type==="birthday"?"birthday":"home_anniversary",q=new URLSearchParams({cardType:O,contactId:L.contact.id,name:I,...L.contact.address?{address:L.contact.address}:{},...L.type==="anniversary"&&L.dateStr?{date:L.dateStr}:{}});t(`/mission-control/card-studio?${q.toString()}`)},S=L=>L===0?"Today!":L===1?"Tomorrow":`${L} days`,M=L=>L===0?"bg-red-500/15 text-red-600 dark:text-red-400 border-red-500/30":L<=3?"bg-amber-500/15 text-amber-600 dark:text-amber-400 border-amber-500/30":L<=7?"bg-blue-500/15 text-blue-600 dark:text-blue-400 border-blue-500/30":"bg-muted text-muted-foreground border-border";return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Dd,{className:"h-5 w-5 text-primary"}),"Upcoming Milestones",e.jsx(tt,{variant:"secondary",className:"text-xs font-normal",children:"Next 30 days"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[j.length," event",j.length!==1?"s":""]})]})}),e.jsxs(De,{className:"space-y-2",children:[j.length===0&&e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ch,{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((L,I)=>{var B,V;const O=`${L.contact.id}-${L.type}`,q=p.has(O),U=`${((B=L.contact.first_name)==null?void 0:B[0])||""}${((V=L.contact.last_name)==null?void 0:V[0])||""}`.toUpperCase();return e.jsxs("div",{className:It("p-3 rounded-lg border transition-colors",L.daysUntil===0&&L.type==="birthday"?"bg-pink-500/10 border-pink-500/30 dark:bg-pink-900/20 dark:border-pink-800/40":L.daysUntil===0&&L.type==="anniversary"?"bg-blue-500/10 border-blue-500/30 dark:bg-blue-900/20 dark:border-blue-800/40":L.type==="birthday"?"bg-pink-50/60 border-pink-200/60 hover:bg-pink-100/60 dark:bg-pink-950/20 dark:border-pink-900/30 dark:hover:bg-pink-950/30":"bg-blue-50/60 border-blue-200/60 hover:bg-blue-100/60 dark:bg-blue-950/20 dark:border-blue-900/30 dark:hover:bg-blue-950/30"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(Nn,{className:It("h-10 w-10",L.type==="birthday"?"ring-2 ring-pink-300/50 dark:ring-pink-700/50":"ring-2 ring-blue-300/50 dark:ring-blue-700/50"),children:e.jsx(kn,{className:It("text-xs font-medium",L.type==="birthday"?"bg-pink-100 text-pink-700 dark:bg-pink-900/40 dark:text-pink-300":"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"),children:U})}),e.jsx("span",{className:"absolute -bottom-1.5 -right-1.5 text-base leading-none drop-shadow-sm",children:L.type==="birthday"?"🎂":"🏠"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[L.contact.first_name," ",L.contact.last_name||""]}),e.jsx(tt,{variant:"outline",className:It("text-[10px] shrink-0 whitespace-nowrap",M(L.daysUntil)),children:S(L.daysUntil)})]}),e.jsxs("div",{className:It("text-xs flex items-center gap-1.5 mt-0.5",L.type==="birthday"?"text-pink-600/80 dark:text-pink-400/80":"text-blue-600/80 dark:text-blue-400/80"),children:[L.type==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(Ch,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(bn,{className:"h-3 w-3"})," Home Anniversary"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:ms(L.date,"MMM d")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 pl-[52px]",children:[L.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Call",asChild:!0,children:e.jsx("a",{href:`tel:${L.contact.phone}`,children:e.jsx(Un,{className:"h-3.5 w-3.5"})})}),L.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Text",asChild:!0,children:e.jsx("a",{href:`sms:${L.contact.phone}`,children:e.jsx(so,{className:"h-3.5 w-3.5"})})}),L.contact.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Email",onClick:()=>{a?(i({id:L.contact.id,first_name:L.contact.first_name,last_name:L.contact.last_name,email:L.contact.email}),u(!0)):window.location.href=`mailto:${L.contact.email}`},children:e.jsx(cr,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Record video",onClick:()=>t(`/mission-control/video/record?contactId=${L.contact.id}`),children:e.jsx(An,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("h-7 px-2 gap-1 text-xs",L.type==="birthday"?"text-pink-600 hover:text-pink-700 dark:text-pink-400":"text-blue-600 hover:text-blue-700 dark:text-blue-400"),title:`Send ${L.type==="birthday"?"birthday":"anniversary"} card`,onClick:()=>k(L),children:[e.jsx(pn,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Card"})]}),e.jsx(K,{variant:"ghost",size:"icon",className:It("h-7 w-7",q&&"text-green-600"),title:"Log a touch",disabled:q||n.isPending,onClick:()=>w(L),children:e.jsx(sa,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"View contact",onClick:()=>t(`/mission-control/contacts/${L.contact.id}`),children:e.jsx(On,{className:"h-3.5 w-3.5"})})]})]},`${O}-${I}`)})]})]}),a&&l&&e.jsx(qw,{open:c,onOpenChange:u,contact:l,gmailEmail:o})]})}const ibs={property_view:{label:"Viewed",icon:On,color:"text-blue-500",bgColor:"bg-blue-500/10"},new_lead:{label:"New Lead",icon:Tl,color:"text-emerald-500",bgColor:"bg-emerald-500/10"},saved_listing:{label:"Saved",icon:ni,color:"text-rose-500",bgColor:"bg-rose-500/10"}};function obs(){const{user:t}=Ds(),s=fr(),{isGmailConnected:r,gmailEmail:n}=Wx(),[a,o]=N.useState(!1),[l,i]=N.useState(null),{data:c,isLoading:u}=mt({queryKey:["lead-site-activity",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:w}=await H.rpc("get_lead_site_activity",{_user_id:t.id});if(w)throw w;return j},enabled:!!t,refetchInterval:6e4});if(u||!(c!=null&&c.has_site))return null;const p=(c.activities||[]).filter(j=>j.visitor_name&&j.visitor_name!=="Site Visitor"),f=p.filter(j=>j.activity_type==="new_lead"),g=(c.activities||[]).filter(j=>j.activity_type==="property_view").length,b=(c.activities||[]).filter(j=>j.activity_type==="saved_listing").length,_=j=>{if(j.visitor_email)if(r){const w=(j.visitor_name||"").split(" ");i({id:j.contact_id||"",first_name:w[0]||"",last_name:w.slice(1).join(" ")||null,email:j.visitor_email}),o(!0)}else window.location.href=`mailto:${j.visitor_email}`};return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-primary/10 rounded-lg",children:e.jsx(su,{className:"h-5 w-5 text-primary"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-lg font-semibold",children:"Website Activity"})})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"text-primary gap-1",onClick:()=>s("/mission-control/website-activity"),children:["View All",e.jsx(Qa,{className:"h-4 w-4"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-emerald-500/5 border border-emerald-200 dark:border-emerald-800",children:[e.jsx(Tl,{className:"h-4 w-4 text-emerald-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-emerald-600 dark:text-emerald-400",children:f.length}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"New Leads"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-blue-500/5 border border-blue-200 dark:border-blue-800",children:[e.jsx(On,{className:"h-4 w-4 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-blue-600 dark:text-blue-400",children:g}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Views"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-rose-500/5 border border-rose-200 dark:border-rose-800",children:[e.jsx(ni,{className:"h-4 w-4 text-rose-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-rose-600 dark:text-rose-400",children:b}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Saved"})]})]})]}),p.length>0?e.jsxs("div",{className:"space-y-2",children:[p.slice(0,5).map((j,w)=>{const k=ibs[j.activity_type],S=k.icon,M=Uc(new Date(j.occurred_at),{addSuffix:!0});return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:shadow-sm transition-shadow",children:[e.jsx("div",{className:`p-1.5 rounded-md ${k.bgColor}`,children:e.jsx(S,{className:`h-3.5 w-3.5 ${k.color}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("button",{className:"font-medium text-sm text-primary hover:underline text-left truncate block",onClick:()=>{j.contact_id&&s(`/mission-control/contacts/${j.contact_id}`)},children:j.visitor_name}),e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:k.label}),j.mls_number&&e.jsxs("span",{children:["· MLS# ",j.mls_number]}),j.lead_type&&e.jsxs("span",{children:["· ",j.lead_type]}),e.jsxs("span",{children:["· ",M]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[j.visitor_email&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>_(j),children:e.jsx(cr,{className:"h-3.5 w-3.5"})}),j.visitor_phone&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>window.location.href=`tel:${j.visitor_phone}`,children:e.jsx(Un,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>window.location.href=`sms:${j.visitor_phone}`,children:e.jsx(so,{className:"h-3.5 w-3.5"})})]}),j.contact_id&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>s(`/mission-control/contacts/${j.contact_id}`),children:e.jsx(da,{className:"h-3.5 w-3.5"})})]})]},`${j.activity_type}-${j.occurred_at}-${w}`)}),p.length>5&&e.jsxs(K,{variant:"outline",className:"w-full text-xs",onClick:()=>s("/mission-control/website-activity"),children:["View ",p.length-5," more activities",e.jsx(Qa,{className:"h-3.5 w-3.5 ml-1"})]})]}):e.jsx(Ee,{children:e.jsxs(De,{className:"p-6 text-center",children:[e.jsx(kh,{className:"h-8 w-8 text-muted-foreground/30 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No actionable website activity yet."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:g>0?`${g} anonymous listing views recorded.`:"Lead engagement will appear here as visitors interact with your site."}),e.jsxs(K,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>s("/mission-control/website-activity"),children:["View Full Activity",e.jsx(Qa,{className:"h-3.5 w-3.5 ml-1"})]})]})}),r&&l&&e.jsx(qw,{open:a,onOpenChange:o,contact:l,gmailEmail:n})]})}const HFe={Crown:Dm,FileText:Sn,Users:pr,Globe:su,Star:Jn,Phone:Un,MessageSquare:so,PenTool:q_,Video:An,Gift:ko},lbs={"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 cbs(){var Ge,ct,qe,Ze,Qe,He;const t=fr(),{user:s}=Ds(),{data:r}=Ux(),{data:n}=WYe(),{data:a}=Gm(),{data:o}=BO(),{data:l}=XYe(),i=mLt(),c=NNe(),u=uLt(90),p=jNe(),[f,g]=N.useState(null),[b,_]=N.useState(null),[j,w]=N.useState(!1),[k,S]=N.useState(""),[M,L]=N.useState(!1),[I,O]=N.useState(""),[q,U]=N.useState(Koe()),[B,V]=N.useState("cards"),[Z,X]=N.useState(!1),[ee,Q]=N.useState(null),[ie,re]=N.useState(null),[oe,ce]=N.useState(""),{isGmailConnected:xe,gmailEmail:ge}=Wx(),ue=()=>{const Je=parseInt(I,10);if(isNaN(Je)||Je<1){wn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}U(Je),YYe(Je),L(!1),wn({title:"Goal updated",description:`Weekly touch goal set to ${Je}`})},pe=()=>{O(q.toString()),L(!0)};N.useEffect(()=>{(async()=>{if(!(s!=null&&s.id))return;const{data:it}=await H.from("profiles").select("name").eq("id",s.id).single();it!=null&&it.name&&S(it.name.split(" ")[0])})()},[s==null?void 0:s.id]),N.useEffect(()=>{i.mutate()},[]);const be=$m(new Date),Me=El(be,7),Ne=Je=>{if(!Je)return null;const it=Je.split(/[-/T]/);if(it.length<3)return null;const Lt=parseInt(it[1],10)-1,Vt=parseInt(it[2],10);return isNaN(Lt)||isNaN(Vt)?null:new Date(be.getFullYear(),Lt,Vt)},Pe=(a==null?void 0:a.filter(Je=>{const it=Ne(Je.birthday),Lt=Ne(Je.home_anniversary);return it&&Cl(it,be)||Lt&&Cl(Lt,be)}))||[];a!=null&&a.filter(Je=>{if(!Je.birthday&&!Je.home_anniversary)return!1;const it=Lt=>{if(!Lt)return!1;const Vt=Ne(Lt);return Vt?qS(Vt,be)&&US(Vt,Me):!1};return it(Je.birthday)||it(Je.home_anniversary)}).slice(0,5);const Oe=[],Te=(o==null?void 0:o.find(Je=>Je.name==="Call"))||(o==null?void 0:o[0]);for(const Je of Pe){const it=Ne(Je.birthday),Lt=Ne(Je.home_anniversary),Vt=it&&Cl(it,be),hs=Lt&&Cl(Lt,be);Vt&&Oe.push({contact:Je,actionType:Te||{id:"special-date-birthday",name:"Birthday Call",icon:"Cake",color:"#EC4899",description:"Wish them happy birthday!",active:!0,sort_order:0,created_at:"",updated_at:""},planName:"🎂 Birthday Today!",relationshipTypeName:((qe=(ct=(Ge=Je.tags)==null?void 0:Ge[0])==null?void 0:ct.relationship_type)==null?void 0:qe.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),hs&&Oe.push({contact:Je,actionType:Te||{id:"special-date-anniversary",name:"Anniversary Call",icon:"Home",color:"#8B5CF6",description:"Celebrate their home anniversary!",active:!0,sort_order:0,created_at:"",updated_at:""},planName:"🏠 Home Anniversary!",relationshipTypeName:((He=(Qe=(Ze=Je.tags)==null?void 0:Ze[0])==null?void 0:Qe.relationship_type)==null?void 0:He.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"anniversary"})}const Be=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((Je,it)=>{var Vt,hs,Ts;const Lt=o==null?void 0:o[it%((o==null?void 0:o.length)||1)];return Lt?{contact:Je,actionType:Lt,planName:"Quick Touch",relationshipTypeName:((Ts=(hs=(Vt=Je.tags)==null?void 0:Vt[0])==null?void 0:hs.relationship_type)==null?void 0:Ts.name)||"",monthNumber:0}:null}).filter(Boolean))||[],nt=[...Oe,...Be],Ae=async(Je,it,Lt)=>{await p.mutateAsync({contactId:Je,actionTypeId:it,scriptUsedId:Lt}),w(!1),_(null)},ft=Je=>{Je.script?(_(Je),w(!0)):Ae(Je.contact.id,Je.actionType.id)},fe=Je=>HFe[Je||"Phone"]||Un,Ve=Je=>HFe[Je||"Users"]||pr,at=(Je,it)=>Je.replace(/\{\{FirstName\}\}/g,it.first_name).replace(/\{\{LastName\}\}/g,it.last_name||"").replace(/\{\{AgentName\}\}/g,k||"there"),et=(Je,it)=>({Call:`Thinking of you, ${it}!`,Text:`Quick hello, ${it}`,Email:`Checking in, ${it}`,"Handwritten Note":`A note for ${it}`,Video:`Video message for ${it}`,Gift:`Something special for you, ${it}`})[Je]||`Hello ${it}!`,Ce=(Je,it,Lt)=>{const Vt=`sms:${Je}`;if(it&&Lt){const hs=at(it,Lt);return`${Vt}?body=${encodeURIComponent(hs)}`}return Vt},rt=(Je,it,Lt,Vt,hs)=>{const Ts=`mailto:${Je}`,Cs=[];if(hs){const cs=Lt||et(Vt||"Email",hs.first_name);if(Cs.push(`subject=${encodeURIComponent(cs)}`),it){const er=at(it,hs);Cs.push(`body=${encodeURIComponent(er)}`)}}return Cs.length>0?`${Ts}?${Cs.join("&")}`:Ts};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.jsx(obs,{}),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(Je=>Je.active).map(Je=>{const it=Ve(Je.icon),Lt=(n==null?void 0:n[Je.id])||0,Vt=f===Je.id,hs=lbs[Je.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{Vt?(g(null),t("/mission-control/contacts")):(g(Je.id),t(`/mission-control/contacts?type=${Je.id}`))},className:` flex items-center gap-2 px-4 py-3 rounded-lg border transition-all ${Vt?hs:"bg-card hover:bg-accent"} `,children:[e.jsx(it,{className:"h-5 w-5"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:Je.name}),e.jsxs("div",{className:`text-sm ${Vt?"opacity-90":"text-muted-foreground"}`,children:[Lt," Contacts"]})]})]},Je.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(gu,{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(da,{className:"h-4 w-4 ml-1"})]}),e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),className:"w-full",children:"Video Library"}),e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/plans"),className:"w-full",children:"Manage Plans"})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Today in Your InnerCircle"}),l!==void 0&&e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(pn,{className:"h-3 w-3"}),"Plan-based"]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 border rounded-lg p-0.5",children:[e.jsx(K,{variant:B==="cards"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("cards"),title:"Card view",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:B==="table"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("table"),title:"Table view",children:e.jsx(Mh,{className:"h-4 w-4"})})]})]}),e.jsx(Ee,{children:e.jsx(De,{className:"p-4",children:nt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No actions scheduled for today."}),e.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."}),e.jsx(K,{variant:"outline",className:"mt-4",onClick:()=>t("/mission-control/plans"),children:"Manage Plans"})]}):B==="table"?e.jsx(J1s,{actions:nt,onMarkComplete:Ae,onViewScript:ft,isLoading:p.isPending,buildSmsLink:Ce,buildEmailLink:rt,onGmailCompose:xe?Je=>{Q(Je),X(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[nt.map((Je,it)=>{var xt,Es,ur,Mr,Lr,fn,ki;const Lt=Je.isSpecialDate,Vt=Je.specialDateType,hs=Lt?Vt==="birthday"?Ch:bn:fe(((xt=Je.actionType)==null?void 0:xt.icon)||null),Ts=Je.contact.phone,Cs=Je.contact.email,cs=Lt?Vt==="birthday"?"#EC4899":"#8B5CF6":((Es=Je.actionType)==null?void 0:Es.color)||"#3B82F6",er=Lt?Vt==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(ur=Je.actionType)==null?void 0:ur.name;return e.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${Lt?"ring-2 ring-offset-2":""}`,style:Lt?{"--tw-ring-color":cs}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:cs},children:[e.jsx(hs,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:er})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>t(`/mission-control/contacts/${Je.contact.id}`),className:"font-medium text-sm hover:text-primary hover:underline transition-colors text-left",children:[Je.contact.first_name," ",Je.contact.last_name]}),e.jsxs("div",{className:"flex gap-1.5",children:[Ts&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`tel:${Je.contact.phone}`,className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-primary/10 hover:bg-primary/20 text-primary rounded text-xs font-medium transition-colors",title:"Call",children:[e.jsx(Un,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:Ce(Je.contact.phone,(Mr=Je.script)==null?void 0:Mr.script_body,Je.contact),className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 rounded text-xs font-medium transition-colors",title:"Text",children:[e.jsx(so,{className:"h-3 w-3"}),"Text"]})]}),Cs&&(xe?e.jsxs("button",{onClick:()=>{Q({id:Je.contact.id,first_name:Je.contact.first_name,last_name:Je.contact.last_name,email:Je.contact.email}),X(!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(cr,{className:"h-3 w-3"}),"Email"]}):e.jsxs("a",{href:rt(Je.contact.email,(Lr=Je.script)==null?void 0:Lr.script_body,(fn=Je.script)==null?void 0:fn.email_subject,(ki=Je.actionType)==null?void 0:ki.name,Je.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(cr,{className:"h-3 w-3"}),"Email"]}))]}),Lt&&e.jsxs("button",{onClick:()=>{const Ea=`${Je.contact.first_name}${Je.contact.last_name?" "+Je.contact.last_name:""}`,dr=Vt==="birthday"?"birthday":"home_anniversary",Jr=new URLSearchParams({cardType:dr,contactId:Je.contact.id,name:Ea,...Je.contact.address?{address:Je.contact.address}:{},...Vt==="anniversary"&&Je.contact.home_anniversary?{date:Je.contact.home_anniversary}:{}});t(`/mission-control/card-studio?${Jr.toString()}`)},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 rounded text-xs font-semibold bg-gradient-to-r from-pink-500/15 to-violet-500/15 hover:from-pink-500/25 hover:to-violet-500/25 text-pink-600 dark:text-pink-400 transition-colors",children:[e.jsx(cr,{className:"h-3 w-3"}),"Send ",Vt==="birthday"?"Birthday":"Anniversary"," Card"]}),!Ts&&!Cs&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No contact info"}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[Je.relationshipTypeName&&e.jsx(tt,{variant:"secondary",className:"text-xs",children:Je.relationshipTypeName}),Je.monthNumber>0&&e.jsxs(tt,{variant:"outline",className:"text-xs",children:["Month ",Je.monthNumber]})]}),Je.script&&e.jsx(K,{size:"sm",variant:"outline",className:"w-full",onClick:()=>ft(Je),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:()=>{re(Je.contact.id),ce(`${Je.contact.first_name} ${Je.contact.last_name||""}`.trim())},children:[e.jsx(Rm,{className:"h-3.5 w-3.5"}),"Snooze"]}),e.jsx(K,{size:"sm",className:"flex-1",onClick:()=>{var Ea;return Ae(Je.contact.id,Je.actionType.id,(Ea=Je.script)==null?void 0:Ea.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]},Je.contact.id+it)}),e.jsx("div",{className:"flex-shrink-0 w-[100px] border rounded-lg flex items-center justify-center",children:e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"h-full w-full",children:[e.jsx(px,{className:"h-5 w-5 mr-2"}),"More"]})}),e.jsx(Bd,{children:e.jsx(Ma,{onClick:()=>t("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rt,{className:"text-lg",children:"Momentum"}),e.jsxs(fs,{open:M,onOpenChange:L,children:[e.jsx(qi,{asChild:!0,children:e.jsx("button",{onClick:pe,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(Xo,{className:"h-4 w-4 text-muted-foreground hover:text-primary"})})}),e.jsxs(ps,{className:"sm:max-w-[360px]",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Set Weekly Goal"}),e.jsx(Gr,{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(ze,{id:"weekly-goal-ic",type:"number",min:"1",value:I,onChange:Je=>O(Je.target.value),placeholder:"20",onKeyDown:Je=>{Je.key==="Enter"&&ue()}})]}),e.jsx(K,{onClick:ue,className:"w-full",children:"Save Goal"})]})]})]})]})}),e.jsxs(De,{className:"space-y-4",children:[e.jsx(Bi,{value:Math.min(c.actionsThisWeek/q*100,100),className:"h-3 w-full max-w-full"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(eh,{className:"h-5 w-5 text-orange-500"}),e.jsxs("span",{className:"font-medium",children:[c.actionsThisWeek," / ",q]}),e.jsx("span",{className:"text-muted-foreground",children:"Actions Completed This Week"})]}),c.streak>0&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-lg",children:"🔥"}),e.jsx("span",{className:"font-medium",children:"Great Job!"}),e.jsxs("span",{className:"text-muted-foreground",children:["Keep Your Streak Going! (",c.streak," days)"]})]}),u.count>0&&e.jsxs("button",{onClick:()=>t("/mission-control/contacts?filter=not-touched-90"),className:"flex items-start gap-2 text-sm pt-2 border-t w-full text-left hover:bg-accent/50 -mx-4 px-4 py-2 rounded-md transition-colors",children:[e.jsx(un,{className:"h-4 w-4 text-orange-500 mt-0.5"}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-orange-600 dark:text-orange-400",children:[u.count," Contact",u.count!==1?"s":""]}),e.jsx("span",{className:"text-muted-foreground",children:" Not Reached in 90+ Days"})]}),e.jsx(da,{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(hXe,{}),e.jsx(abs,{})]})]}),e.jsx(fs,{open:j,onOpenChange:w,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{className:"flex items-center gap-2",children:b&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:b.actionType.color||"#3B82F6"}}),b.actionType.name," Script"]})})}),b&&b.script&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["For: ",e.jsxs("span",{className:"font-medium text-foreground",children:[b.contact.first_name," ",b.contact.last_name]})]}),e.jsx("div",{className:"bg-muted p-4 rounded-lg",children:e.jsx("p",{className:"whitespace-pre-wrap",children:at(b.script.script_body,b.contact)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>w(!1),children:"Close"}),e.jsx(K,{className:"flex-1",onClick:()=>{var Je;return Ae(b.contact.id,b.actionType.id,(Je=b.script)==null?void 0:Je.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]})}),e.jsx(G1s,{})]}),xe&&ee&&e.jsx(qw,{open:Z,onOpenChange:X,contact:ee,gmailEmail:ge}),e.jsx(qhe,{open:!!ie,onOpenChange:Je=>!Je&&re(null),contactId:ie||"",contactName:oe})]})}var Nat="Toggle",nSe=N.forwardRef((t,s)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...o}=t,[l,i]=ah({prop:r,onChange:a,defaultProp:n??!1,caller:Nat});return e.jsx(nn.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":t.disabled?"":void 0,...o,ref:s,onClick:Ir(t.onClick,()=>{t.disabled||i(!l)})})});nSe.displayName=Nat;var kat=nSe,Uw="ToggleGroup",[Sat]=ad(Uw,[Tw]),Cat=Tw(),aSe=ht.forwardRef((t,s)=>{const{type:r,...n}=t;if(r==="single"){const a=n;return e.jsx(dbs,{...a,ref:s})}if(r==="multiple"){const a=n;return e.jsx(ubs,{...a,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${Uw}\``)});aSe.displayName=Uw;var[Mat,Tat]=Sat(Uw),dbs=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=ah({prop:r,defaultProp:n??"",onChange:a,caller:Uw});return e.jsx(Mat,{scope:t.__scopeToggleGroup,type:"single",value:ht.useMemo(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:ht.useCallback(()=>i(""),[i]),children:e.jsx(Aat,{...o,ref:s})})}),ubs=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=ah({prop:r,defaultProp:n??[],onChange:a,caller:Uw}),c=ht.useCallback(p=>i((f=[])=>[...f,p]),[i]),u=ht.useCallback(p=>i((f=[])=>f.filter(g=>g!==p)),[i]);return e.jsx(Mat,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:c,onItemDeactivate:u,children:e.jsx(Aat,{...o,ref:s})})});aSe.displayName=Uw;var[hbs,mbs]=Sat(Uw),Aat=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:o,dir:l,loop:i=!0,...c}=t,u=Cat(r),p=Mw(l),f={role:"group",dir:p,...c};return e.jsx(hbs,{scope:r,rovingFocus:a,disabled:n,children:a?e.jsx(Lde,{asChild:!0,...u,orientation:o,dir:p,loop:i,children:e.jsx(nn.div,{...f,ref:s})}):e.jsx(nn.div,{...f,ref:s})})}),Wce="ToggleGroupItem",Eat=ht.forwardRef((t,s)=>{const r=Tat(Wce,t.__scopeToggleGroup),n=mbs(Wce,t.__scopeToggleGroup),a=Cat(t.__scopeToggleGroup),o=r.value.includes(t.value),l=n.disabled||t.disabled,i={...t,pressed:o,disabled:l},c=ht.useRef(null);return n.rovingFocus?e.jsx(Dde,{asChild:!0,...a,focusable:!l,active:o,ref:c,children:e.jsx(WFe,{...i,ref:s})}):e.jsx(WFe,{...i,ref:s})});Eat.displayName=Wce;var WFe=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,value:n,...a}=t,o=Tat(Wce,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=o.type==="single"?l:void 0;return e.jsx(nSe,{...i,...a,ref:s,onPressedChange:c=>{c?o.onItemActivate(n):o.onItemDeactivate(n)}})}),Pat=aSe,Iat=Eat;const Lat=mC("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"}}),pbs=N.forwardRef(({className:t,variant:s,size:r,...n},a)=>e.jsx(kat,{ref:a,className:It(Lat({variant:s,size:r,className:t})),...n}));pbs.displayName=kat.displayName;const Dat=N.createContext({size:"default",variant:"default"}),Oat=N.forwardRef(({className:t,variant:s,size:r,children:n,...a},o)=>e.jsx(Pat,{ref:o,className:It("flex items-center justify-center gap-1",t),...a,children:e.jsx(Dat.Provider,{value:{variant:s,size:r},children:n})}));Oat.displayName=Pat.displayName;const Rat=N.forwardRef(({className:t,children:s,variant:r,size:n,...a},o)=>{const l=N.useContext(Dat);return e.jsx(Iat,{ref:o,className:It(Lat({variant:l.variant||r,size:l.size||n}),t),...a,children:s})});Rat.displayName=Iat.displayName;const fbs=[{value:"bidirectional",label:"Two-Way",icon:vd,tooltip:"Sync contacts in both directions"},{value:"push_only",label:"Push Only",icon:ku,tooltip:"Only push Agent OS → BoldTrail"},{value:"pull_only",label:"Pull Only",icon:Wh,tooltip:"Only pull BoldTrail → Agent OS"}];function z_e({value:t,onChange:s,size:r="default"}){const n=r==="sm"?"text-xs":"text-sm";return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:`font-medium ${n} text-muted-foreground`,children:"Sync Direction"}),e.jsx(Oat,{type:"single",value:t,onValueChange:a=>{a&&s(a)},className:"justify-start",children:fbs.map(a=>e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsxs(Rat,{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(Yl,{children:a.tooltip})]},a.value))})]})}function xbs(){const t=Qt(),[s,r]=N.useState(!1),[n,a]=N.useState(null),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState(null),[f,g]=N.useState(null),[b,_]=N.useState(0),j=N.useRef(!1),{data:w}=mt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:B,error:V}=await H.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(V)throw V;return B}}),k=(w==null?void 0:w.sync_direction)||"bidirectional",S=u??k,M=Dt({mutationFn:async()=>{const{data:B,error:V}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(V)throw V;if(B!=null&&B.error)throw new Error(B.error);return B},onSuccess:B=>{p(null),a(B),r(!0)},onError:B=>{me.error(B.message||"Failed to generate sync preview")}}),L=Dt({mutationFn:async()=>{j.current=!1,g("Initializing sync..."),_(5);const{data:B,error:V}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:S}});if(V)throw V;if(B!=null&&B.error)throw new Error(B.error);const Z=B;let X=Z.sync_log_id,ee=Z.next_phase,Q=Z.next_offset;const ie=Z.push_total||0,re=Z.pull_total||0,oe=Z.update_total||0,ce=ie+re+oe;let xe=0,ge=0,ue=0;for(;ee!=="finalize"&&!j.current;){ee==="push"?(g(`Pushing contacts to BoldTrail... (${xe}/${ie})`),_(ce>0?xe/ce*90:0)):ee==="pull"?(g(`Pulling contacts from BoldTrail... (${ge}/${re})`),_(ce>0?(ie+ge)/ce*90:0)):ee==="update"&&(g(`Updating existing contacts... (${ue}/${oe})`),_(ce>0?(ie+re+ue)/ce*90:0));const{data:Me,error:Ne}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:ee,offset:Q,sync_log_id:X,sync_direction:S}});if(Ne)throw Ne;if(Me!=null&&Me.error)throw new Error(Me.error);const Pe=Me;xe+=Pe.chunk_pushed||0,ge+=Pe.chunk_pulled||0,ue+=Pe.chunk_updated||0,Pe.progress&&g(Pe.progress),ee=Pe.next_phase,Q=Pe.next_offset}g("Finalizing sync..."),_(95);const{data:pe,error:be}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:X,sync_direction:S}});if(be)throw be;return _(100),pe},onSuccess:B=>{g(null),_(0),r(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]});const V=[`Pushed ${B.contacts_pushed||0}`,`pulled ${B.contacts_pulled||0}`,`updated ${B.contacts_updated||0}`,`skipped ${B.contacts_skipped||0} duplicates`];me.success(`Sync complete! ${V.join(", ")}.`)},onError:B=>{g(null),_(0),me.error(B.message||"Sync failed")}});if(!(w!=null&&w.connected))return null;const I=S==="pull_only"?0:(n==null?void 0:n.to_push)??0,O=S==="push_only"?0:(n==null?void 0:n.to_pull)??0,q=(n==null?void 0:n.to_update)??0,U=I>0||O>0||q>0;return e.jsxs(e.Fragment,{children:[e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"icon",onClick:()=>M.mutate(),disabled:M.isPending,className:"shrink-0",children:M.isPending?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx(vd,{className:"h-4 w-4 text-emerald-600"})})}),e.jsx(Yl,{children:"Sync with BoldTrail"})]}),e.jsx(fs,{open:s,onOpenChange:B=>{L.isPending||r(B)},children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(vd,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Gr,{children:"Review what will happen when you sync your contacts."})]}),n&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(z_e,{value:S,onChange:p,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${S==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:I}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(ku,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${S==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:O}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Wh,{className:"h-3 w-3"})," Pull to Agent OS"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-amber-600",children:q}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(zM,{className:"h-3 w-3"})," To update"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-muted-foreground",children:n.already_synced}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(pr,{className:"h-3 w-3"})," Already synced"]})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["Agent OS: ",n.agent_os_total," contacts · BoldTrail: ",n.boldtrail_total," contacts"]}),q>0&&e.jsxs("div",{className:"text-xs text-muted-foreground text-center bg-amber-50 dark:bg-amber-950/30 rounded-md p-2",children:[e.jsx(zM,{className:"h-3 w-3 inline mr-1"}),q," contacts have missing fields that will be filled from the other system"]}),I>0&&e.jsxs(gf,{open:o,onOpenChange:l,children:[e.jsx(yf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ku,{className:"h-3 w-3 text-emerald-600"}),I," contacts to push to BoldTrail"]}),e.jsx(Eo,{className:`h-3 w-3 transition-transform ${o?"rotate-180":""}`})]})}),e.jsx(vf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.push_preview.map((B,V)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:B.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:B.email})]},V)),n.to_push>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",n.to_push-20," more"]})]})})]}),O>0&&e.jsxs(gf,{open:i,onOpenChange:c,children:[e.jsx(yf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Wh,{className:"h-3 w-3 text-blue-600"}),O," contacts to pull from BoldTrail"]}),e.jsx(Eo,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})}),e.jsx(vf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.pull_preview.map((B,V)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:B.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:B.email})]},V)),n.to_pull>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",n.to_pull-20," more"]})]})})]}),!U&&!L.isPending&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer or update."}),L.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(Bi,{value:b||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:f||"Sync in progress..."})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),disabled:L.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>L.mutate(),disabled:L.isPending||!U,className:"gap-2",children:[L.isPending?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx(vd,{className:"h-4 w-4"}),L.isPending?"Syncing...":"Sync Now"]})]})]})]})})]})}const gbs=()=>{const{user:t}=Ds();return mt({queryKey:["popby-items",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("popby_items").select("*").or(`owner_user_id.is.null,owner_user_id.eq.${t==null?void 0:t.id}`).eq("is_active",!0).order("name");if(r)throw r;return s},enabled:!!t})},Uhe=t=>{const{user:s}=Ds();return mt({queryKey:["popby-logs",s==null?void 0:s.id,t],queryFn:async()=>{let r=H.from("popby_logs").select("*").order("completed_at",{ascending:!1});if(t){const o=new Date;o.setDate(o.getDate()-t),r=r.gte("completed_at",o.toISOString())}const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!s})},iSe=()=>{const{user:t}=Ds();return mt({queryKey:["relationship-type-popby-defaults",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("relationship_type_popby_defaults").select("*");if(r)throw r;return s},enabled:!!t})},Fat=()=>{const{user:t}=Ds();return mt({queryKey:["contact-popby-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_popby_settings").select("*");if(r)throw r;return s},enabled:!!t})},ybs=()=>{const{data:t}=Gm(),{data:s}=Ux(),{data:r}=Uhe(),{data:n}=Fat(),{data:a}=iSe(),o=new Map;r==null||r.forEach(p=>{const f=o.get(p.contact_id);(!f||new Date(p.completed_at)>new Date(f))&&o.set(p.contact_id,p.completed_at)});const l=new Map;a==null||a.forEach(p=>l.set(p.relationship_type_id,p.frequency_days));const i=new Map;n==null||n.filter(p=>p.is_active).forEach(p=>{i.set(p.contact_id,p.frequency_days)});const c=$m(new Date);return(t||[]).map(p=>{let f=90;if(i.has(p.id))f=i.get(p.id);else if(p.tags&&p.tags.length>0){const w=p.tags.map(k=>l.get(k.relationship_type_id)).filter(k=>k!==void 0);w.length>0&&(f=Math.min(...w))}const g=o.get(p.id)||null,b=g?oy(c,$m(new Date(g))):null,_=b===null||b>=f,j=_&&b!==null?b-f:0;return{...p,lastPopby:g,daysSinceLastPopby:b,frequencyDays:f,isDue:_,daysOverdue:j}}).sort((p,f)=>f.daysOverdue-p.daysOverdue)},zat=()=>ybs().filter(s=>s.isDue),vbs=()=>{const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async r=>{const{error:n}=await H.from("popby_items").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-items"]}),wn({title:"Popby item created!"})},onError:r=>{wn({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},bbs=()=>{const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async r=>{const{error:n}=await H.from("popby_logs").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-logs"]}),wn({title:"Popby logged!"})},onError:r=>{wn({title:"Error logging popby",description:r.message,variant:"destructive"})}})},_bs=()=>{const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async r=>{const{error:n}=await H.from("relationship_type_popby_defaults").upsert({...r,owner_user_id:s==null?void 0:s.id},{onConflict:"relationship_type_id,owner_user_id"});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["relationship-type-popby-defaults"]}),wn({title:"Frequency updated!"})},onError:r=>{wn({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},wbs=()=>{const{data:t}=Uhe(30),s=zat(),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 jbs(){const{user:t}=Ds();return mt({queryKey:["contact-touch-logs",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_touch_logs").select("*").order("completed_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Bat(t){const{data:s}=jbs(),{data:r}=Fat(),{data:n}=iSe(),{data:a}=K1s();return N.useMemo(()=>{const o=a==null?void 0:a.find(w=>w.contact_id===t.id),l=o?new Date(o.snoozed_until):null,i=$m(new Date);if(l&&!US(l,i))return{nextTouchDate:l,daysUntil:oy(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,k)=>new Date(k.completed_at).getTime()-new Date(w.completed_at).getTime())[0],p=u?new Date(u.completed_at):null;let f=90;const g=r==null?void 0:r.find(w=>w.contact_id===t.id&&w.is_active);if(g)f=g.frequency_days;else if(t.tags&&t.tags.length>0){const w=t.tags.map(k=>{const S=n==null?void 0:n.find(M=>M.relationship_type_id===k.relationship_type_id);return S==null?void 0:S.frequency_days}).filter(k=>k!==void 0);w.length>0&&(f=Math.min(...w))}if(!p)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:f,lastTouchDate:null,snoozedUntil:null};const b=El($m(p),f),_=oy(b,i);let j;return _<0?j="overdue":_<=7?j="due-soon":j="on-track",{nextTouchDate:b,daysUntil:_,status:j,frequencyDays:f,lastTouchDate:p,snoozedUntil:null}},[t,s,r,n,a])}function B_e({contact:t}){const s=Bat(t),n=(()=>{switch(s.status){case"overdue":return{variant:"destructive",icon:kl,text:`${Math.abs(s.daysUntil)} days overdue`,className:""};case"due-soon":return{variant:"secondary",icon:un,text:s.daysUntil===0?"Due today":`Due in ${s.daysUntil} days`,className:"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400"};case"on-track":return{variant:"secondary",icon:sa,text:`Next touch in ${s.daysUntil} days`,className:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-400"};case"snoozed":return{variant:"secondary",icon:Rm,text:`Snoozed until ${ms(s.snoozedUntil,"MMM d")}`,className:"bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300"};case"never-touched":return{variant:"outline",icon:hn,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return e.jsxs(tt,{variant:n.variant,className:It("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function Nbs({contact:t,onLogTouch:s,onSnooze:r}){const n=Bat(t),a=Y1s(),[o,l]=N.useState(!1),i=()=>{switch(n.status){case"overdue":return"text-destructive";case"due-soon":return"text-amber-600 dark:text-amber-400";case"on-track":return"text-emerald-600 dark:text-emerald-400";case"snoozed":return"text-slate-600 dark:text-slate-400";case"never-touched":return"text-muted-foreground"}},c=()=>{switch(n.status){case"overdue":return e.jsx(kl,{className:"h-5 w-5 text-destructive"});case"due-soon":return e.jsx(un,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"});case"on-track":return e.jsx(sa,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"});case"snoozed":return e.jsx(Rm,{className:"h-5 w-5 text-slate-600 dark:text-slate-400"});case"never-touched":return e.jsx(hn,{className:"h-5 w-5 text-muted-foreground"})}},u=()=>{switch(n.status){case"overdue":return`${Math.abs(n.daysUntil)} days overdue`;case"due-soon":return n.daysUntil===0?"Due today!":`Due in ${n.daysUntil} days`;case"on-track":return`On track - ${n.daysUntil} days remaining`;case"snoozed":return`Snoozed for ${n.daysUntil} more days`;case"never-touched":return"No touches logged yet"}},p=async()=>{await a.mutateAsync(t.id)};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"Next Touch"]})}),e.jsxs(De,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c(),e.jsx("span",{className:It("font-medium",i()),children:u()})]}),n.status==="snoozed"&&n.snoozedUntil&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Snoozed until:"})," ",ms(n.snoozedUntil,"MMMM d, yyyy")]}),n.status!=="snoozed"&&n.nextTouchDate&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Scheduled:"})," ",ms(n.nextTouchDate,"MMMM d, yyyy")]}),n.lastTouchDate&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Last touch:"})," ",ms(n.lastTouchDate,"MMM d, yyyy")]}),n.status!=="snoozed"&&e.jsxs("div",{className:"text-xs text-muted-foreground border-t pt-2",children:["Touch frequency: Every ",n.frequencyDays," days"]}),n.status==="snoozed"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:p,disabled:a.isPending,children:[e.jsx(Rr,{className:"h-4 w-4 mr-1"}),"Cancel Snooze"]}),s&&e.jsx(K,{size:"sm",className:"flex-1",onClick:s,children:"Log Touch"})]}),n.status!=="snoozed"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>l(!0),children:[e.jsx(Rm,{className:"h-4 w-4 mr-1"}),"Snooze"]}),(n.status==="overdue"||n.status==="due-soon"||n.status==="never-touched")&&s&&e.jsx(K,{size:"sm",className:"flex-1",variant:n.status==="overdue"?"default":"outline",onClick:s,children:"Log Touch"})]})]})]}),e.jsx(qhe,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const fye=768;function NE(){const[t,s]=N.useState(void 0);return N.useEffect(()=>{const r=window.matchMedia(`(max-width: ${fye-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}function kbs(){const{user:t}=Ds(),{hasLeadSite:s,leadSite:r}=zO(),{data:n,isLoading:a}=mt({queryKey:["website-active-contacts",t==null?void 0:t.id,r==null?void 0:r.id],queryFn:async()=>{if(!r)return new Set;const{data:o}=await H.from("lead_site_visitors").select("contact_id").eq("lead_site_id",r.id).not("contact_id","is",null),{data:l}=await H.from("lead_site_consumer_profiles").select("contact_id").eq("lead_site_id",r.id).not("contact_id","is",null),i=new Set;return(o||[]).forEach(c=>{c.contact_id&&i.add(c.contact_id)}),(l||[]).forEach(c=>{c.contact_id&&i.add(c.contact_id)}),i},enabled:!!t&&s,staleTime:5*60*1e3});return{activeContactIds:n??new Set,hasLeadSite:s,isLoading:a}}const Sbs={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"}},Cbs={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 y8({score:t,showScore:s=!1,showTooltip:r=!0,size:n="sm",className:a}){const o=Sbs[t.status],l=Cbs[n],i=e.jsxs("div",{className:It("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[e.jsx("span",{className:It("rounded-full",o.bgClass,l.dot)}),s?e.jsx("span",{children:t.score}):e.jsx("span",{children:o.label})]});return r?e.jsx(z1,{children:e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:i}),e.jsx(Yl,{side:"top",className:"w-64 p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-semibold",children:"Relationship Score"}),e.jsxs("span",{className:It("font-bold",o.textClass),children:[t.score,"/100"]})]}),e.jsx(Bi,{value:t.score,className:"h-2"}),e.jsxs("div",{className:"space-y-1.5 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Recency"}),e.jsxs("span",{children:[t.breakdown.recency,"/40"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Touchpoints (12mo)"}),e.jsxs("span",{children:[t.breakdown.touchpoints,"/30"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Transactions"}),e.jsxs("span",{children:[t.breakdown.transactions,"/20"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Referrals"}),e.jsxs("span",{children:[t.breakdown.referrals,"/10"]})]})]}),t.daysSinceTouch!==null&&e.jsxs("p",{className:"text-xs text-muted-foreground pt-1 border-t",children:["Last contact: ",t.daysSinceTouch===0?"Today":`${t.daysSinceTouch} days ago`]}),t.daysSinceTouch===null&&e.jsx("p",{className:"text-xs text-muted-foreground pt-1 border-t italic",children:"Never contacted"})]})})]})}):i}const Mbs=[{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}],Vz=t=>{if(!t||!t.trim())return null;const s=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(s))return s;const r=s.match(/^(\d{1,2})[\/\-](\d{1,2})(?:[\/\-](\d{2,4}))?$/);if(r){const a=r[1].padStart(2,"0"),o=r[2].padStart(2,"0");let l="2000";r[3]&&(l=r[3].length===2?(parseInt(r[3])>50?"19":"20")+r[3]:r[3]);const i=parseInt(a),c=parseInt(o);if(i>=1&&i<=12&&c>=1&&c<=31)return`${l}-${a}-${o}`}const n=new Date(s);return isNaN(n.getTime())?null:n.toISOString().split("T")[0]},Tbs=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=Ds(),{toast:o}=Ua(),l=N.useRef(null),[i,c]=N.useState("upload"),[u,p]=N.useState([]),[f,g]=N.useState([]),[b,_]=N.useState({}),[j,w]=N.useState([]),[k,S]=N.useState([]),[M,L]=N.useState(!1),[I,O]=N.useState(null),q=()=>{c("upload"),p([]),g([]),_({}),w([]),S([]),O(null),l.current&&(l.current.value="")},U=()=>{q(),s(!1)},B=ge=>{const ue=ge.split(` `).map(Ne=>Ne.trim()).filter(Ne=>Ne);if(ue.length===0)return{headers:[],data:[]};const pe=Ne=>{const Pe=[];let Oe="",Te=!1;for(let ke=0;ke{var be;const ue=(be=ge.target.files)==null?void 0:be[0];if(!ue)return;const pe=new FileReader;pe.onload=Me=>{var ke;const Ne=(ke=Me.target)==null?void 0:ke.result,{headers:Pe,data:Oe}=B(Ne);if(Pe.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}p(Pe),g(Oe);const Te={};Pe.forEach(Be=>{const nt=Be.toLowerCase().replace(/[_\s-]/g,"");nt.includes("firstname")||nt==="first"?Te.first_name=Be:nt.includes("lastname")||nt==="last"?Te.last_name=Be:nt.includes("spouse")&&nt.includes("email")?Te.spouse_email=Be:nt.includes("spouse")||nt.includes("partner")?Te.spouse_name=Be:nt.includes("email")?Te.email=Be:nt.includes("phone")||nt.includes("mobile")||nt.includes("cell")?Te.phone=Be:nt.includes("address")||nt.includes("street")?Te.address=Be:nt==="city"?Te.city=Be:nt==="state"||nt==="province"?Te.state=Be:nt==="zip"||nt==="zipcode"||nt==="postalcode"?Te.zip=Be:nt.includes("company")||nt.includes("organization")||nt.includes("business")?Te.company_name=Be:nt.includes("jobtitle")||nt.includes("title")&&!nt.includes("spouse")?Te.job_title=Be:nt.includes("birthday")||nt.includes("dob")||nt.includes("birthdate")?Te.birthday=Be:nt.includes("anniversary")||nt.includes("homeanniversary")?Te.home_anniversary=Be:(nt.includes("notes")||nt.includes("comment"))&&(Te.notes=Be)}),_(Te),c("mapping")},pe.readAsText(ue)},Z=(ge,ue)=>{_(pe=>{if(ue==="none"){const{[ge]:be,...Me}=pe;return Me}return{...pe,[ge]:ue}})},X=ge=>{w(ue=>ue.includes(ge)?ue.filter(pe=>pe!==ge):[...ue,ge])},ee=async()=>{if(!(a!=null&&a.id))return;const{data:ge}=await H.from("innercircle_contacts").select("id, email, phone").eq("owner_user_id",a.id),ue=new Set((ge||[]).filter(Me=>Me.email).map(Me=>Me.email.toLowerCase())),pe=new Set((ge||[]).filter(Me=>Me.phone).map(Me=>Me.phone.replace(/[^0-9]/g,""))),be=f.map(Me=>{const Ne=nt=>{const Ae=b[nt];if(!Ae)return"";const ft=u.indexOf(Ae);return ft>=0?(Me[ft]||"").trim():""},Pe=Ne("first_name"),Oe=Ne("email"),Te=Ne("phone"),ke=Pe.length>0,Be=!!(Oe&&ue.has(Oe.toLowerCase())||Te&&pe.has(Te.replace(/[^0-9]/g,"")));return{first_name:Pe,last_name:Ne("last_name"),email:Oe,phone:Te,address:Ne("address"),city:Ne("city"),state:Ne("state"),zip:Ne("zip"),spouse_name:Ne("spouse_name"),spouse_email:Ne("spouse_email"),company_name:Ne("company_name"),job_title:Ne("job_title"),birthday:Ne("birthday"),home_anniversary:Ne("home_anniversary"),notes:Ne("notes"),isValid:ke,isDuplicate:Be,error:ke?void 0:"First name is required"}});S(be),c("preview")},Q=ge=>{const ue=ge.trim().split(/\s+/);return{first_name:ue[0],last_name:ue.length>1?ue.slice(1).join(" "):null}},ie=async()=>{if(!(a!=null&&a.id))return;const ge=k.filter(Me=>Me.isValid);if(ge.length===0){o({title:"No valid contacts",description:"There are no valid contacts to import.",variant:"destructive"});return}L(!0);let ue=0,pe=0,be=0;try{for(const Me of ge)try{let Ne=null;if(Me.email){const{data:Te}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Me.email).maybeSingle();Ne=Te}if(!Ne&&Me.phone){const Te=Me.phone.replace(/[^0-9]/g,""),{data:ke}=await H.from("innercircle_contacts").select("id, phone").eq("owner_user_id",a.id).not("phone","is",null);if(ke){const Be=ke.find(nt=>nt.phone&&nt.phone.replace(/[^0-9]/g,"")===Te);Be&&(Ne={id:Be.id})}}const Pe={owner_user_id:a.id,first_name:Me.first_name,last_name:Me.last_name||null,email:Me.email||null,phone:Me.phone||null,address:Me.address||null,city:Me.city||null,state:Me.state||null,zip:Me.zip||null,spouse_name:Me.spouse_name||null,spouse_email:Me.spouse_email||null,company_name:Me.company_name||null,job_title:Me.job_title||null,birthday:Vz(Me.birthday),home_anniversary:Vz(Me.home_anniversary),notes:Me.notes||null};let Oe=null;if(Ne){const{data:Te}=await H.from("innercircle_contacts").select("*").eq("id",Ne.id).single();if(Te){const ke={},Be=["last_name","email","phone","address","city","state","zip","spouse_name","spouse_email","company_name","job_title","birthday","home_anniversary","notes"];for(const nt of Be){const Ae=Te[nt],ft=Pe[nt];(!Ae||Ae==="")&&ft&&(ke[nt]=ft)}Object.keys(ke).length>0&&await H.from("innercircle_contacts").update(ke).eq("id",Ne.id)}Oe=Ne.id,pe++}else{const{data:Te,error:ke}=await H.from("innercircle_contacts").insert(Pe).select("id").single();ke?(console.error("Insert error for contact:",Me.first_name,ke),be++):Te?(Oe=Te.id,j.length>0&&await H.from("innercircle_contact_tags").insert(j.map(Be=>({contact_id:Te.id,relationship_type_id:Be}))),ue++):be++}if(Oe&&Me.spouse_name){const Te=Q(Me.spouse_name);let ke=null;if(Me.spouse_email){const{data:nt}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Me.spouse_email).maybeSingle();ke=nt}if(!ke){const{data:nt}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("first_name",Te.first_name).eq("last_name",Te.last_name||Me.last_name||"").maybeSingle();ke=nt}let Be=null;if(ke){Be=ke.id;const nt=Vz(Me.home_anniversary);nt&&await H.from("innercircle_contacts").update({home_anniversary:nt}).eq("id",ke.id).is("home_anniversary",null)}else{const{data:nt}=await H.from("innercircle_contacts").insert({owner_user_id:a.id,first_name:Te.first_name,last_name:Te.last_name||Me.last_name||null,email:Me.spouse_email||null,address:Me.address||null,city:Me.city||null,state:Me.state||null,zip:Me.zip||null,home_anniversary:Vz(Me.home_anniversary),spouse_name:`${Me.first_name}${Me.last_name?" "+Me.last_name:""}`,spouse_email:Me.email||null,notes:`Spouse of ${Me.first_name} ${Me.last_name||""} (imported via CSV)`.trim()}).select("id").single();nt&&(Be=nt.id,ue++)}Be&&(await H.from("innercircle_contacts").update({spouse_contact_id:Be}).eq("id",Oe),await H.from("innercircle_contacts").update({spouse_contact_id:Oe}).eq("id",Be))}}catch(Ne){console.error("Error importing contact:",Ne),be++}O({created:ue,updated:pe,failed:be}),c("result"),(ue>0||pe>0)&&n(),o({title:"Import Complete",description:`${ue} created, ${pe} updated${be>0?`, ${be} failed`:""}.`})}catch(Me){console.error("Import error:",Me),o({title:"Import Failed",description:Me.message||"Failed to import contacts",variant:"destructive"})}finally{L(!1)}},re=k.filter(ge=>ge.isValid).length,oe=k.filter(ge=>!ge.isValid).length,ce=k.filter(ge=>ge.isValid&&ge.isDuplicate).length,xe=re-ce;return e.jsx(fs,{open:t,onOpenChange:U,children:e.jsxs(ps,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(r1,{className:"h-5 w-5"}),"Import Contacts from CSV"]}),e.jsx(Gr,{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(li,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click to upload or drag and drop a CSV file"}),e.jsx(K,{onClick:()=>{var ge;return(ge=l.current)==null?void 0:ge.click()},children:"Select CSV File"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm",children:[e.jsx("p",{className:"font-medium mb-2",children:"Supported Fields:"}),e.jsx("p",{className:"text-muted-foreground text-xs mb-3",children:"First Name, Last Name, Email, Phone, Street Address, City, State, Zip, Spouse Name, Spouse Email, Company, Job Title, Birthday, Home Anniversary, Notes"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{const ge=`First Name,Last Name,Email,Phone,Street Address,City,State,Zip,Spouse Name,Spouse Email,Company,Job Title,Birthday,Home Anniversary,Notes John,Doe,john@example.com,555-123-4567,123 Main St,Austin,TX,78701,Jane Doe,jane@example.com,ABC Realty,Real Estate Agent,1985-06-15,2020-03-22,Met at open house`,ue=new Blob([ge],{type:"text/csv"}),pe=URL.createObjectURL(ue),be=document.createElement("a");be.href=pe,be.download="contact_import_template.csv",be.click(),URL.revokeObjectURL(pe)},children:[e.jsx(yi,{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:Mbs.map(ge=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(ve,{className:"w-40 text-sm",children:[ge.label,ge.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Zs,{value:b[ge.key]||"none",onValueChange:ue=>Z(ge.key,ue),children:[e.jsx(Ws,{className:"w-48",children:e.jsx(Xs,{placeholder:"Select column..."})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:"-- Not mapped --"}),u.map(ue=>e.jsx(Mt,{value:ue,children:ue},ue))]})]})]},ge.key))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{className:"text-base font-medium",children:"Apply Relationship Types (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(ge=>e.jsx(tt,{variant:j.includes(ge.id)?"default":"outline",className:"cursor-pointer",onClick:()=>X(ge.id),children:ge.name},ge.id))})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-sm",children:e.jsxs("p",{className:"text-muted-foreground",children:["Preview: ",f.length," row(s) found in CSV"]})})]}),i==="preview"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{children:[xe," new"]})]}),ce>0&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(kl,{className:"h-4 w-4"}),e.jsxs("span",{children:[ce," existing (will merge gaps)"]})]}),oe>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(kl,{className:"h-4 w-4"}),e.jsxs("span",{children:[oe," invalid"]})]})]}),ce>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(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/30",children:[e.jsx(St,{children:"First Name"}),e.jsx(St,{children:"Last Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Phone"}),e.jsx(St,{children:"Status"})]})}),e.jsx(zn,{children:k.slice(0,100).map((ge,ue)=>e.jsxs(Ss,{children:[e.jsx(dt,{children:ge.first_name}),e.jsx(dt,{children:ge.last_name}),e.jsx(dt,{children:ge.email}),e.jsx(dt,{children:ge.phone}),e.jsx(dt,{children:ge.isValid?ge.isDuplicate?e.jsx(tt,{variant:"outline",className:"bg-accent text-accent-foreground",children:"Merge"}):e.jsx(tt,{variant:"secondary",className:"bg-primary/10 text-primary",children:"New"}):e.jsx(tt,{variant:"destructive",children:ge.error||"Invalid"})})]},ue))})]}),k.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",k.length," contacts"]})]})]}),i==="result"&&I&&e.jsxs("div",{className:"space-y-4 py-4 text-center",children:[e.jsx(sa,{className:"h-12 w-12 mx-auto text-primary"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground",children:[I.created," created, ",I.updated," merged"]}),I.failed>0&&e.jsxs("p",{className:"text-destructive",children:[I.failed," failed to import"]})]}),e.jsxs(qn,{children:[i==="upload"&&e.jsx(K,{variant:"outline",onClick:U,children:"Cancel"}),i==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:q,children:"Back"}),e.jsx(K,{onClick:ee,disabled:!b.first_name,children:"Continue"})]}),i==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>c("mapping"),children:"Back"}),e.jsx(K,{onClick:ie,disabled:M||re===0,children:M?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${re} Contact${re!==1?"s":""}`})]}),i==="result"&&e.jsx(K,{onClick:U,children:"Done"})]})]})})};function Abs(){return"contacts"in navigator&&"ContactsManager"in window}function Ebs(t){const s=[],r=t.split("BEGIN:VCARD").filter(n=>n.trim());for(const n of r){const a=n.split(/\r?\n/);let o="",l="",i="",c="",u="";for(const p of a){const f=p.replace(/^\s+/,"");if(f.startsWith("N:")||f.startsWith("N;")){const b=f.substring(f.indexOf(":")+1).split(";");l=(b[0]||"").trim(),o=(b[1]||"").trim()}if((f.startsWith("FN:")||f.startsWith("FN;"))&&!o){const b=f.substring(f.indexOf(":")+1).trim().split(" ");o=b[0]||"",l=b.slice(1).join(" ")}(f.startsWith("EMAIL")||f.match(/^item\d+\.EMAIL/i))&&!i&&(i=f.substring(f.indexOf(":")+1).trim()),(f.startsWith("TEL")||f.match(/^item\d+\.TEL/i))&&!c&&(c=f.substring(f.indexOf(":")+1).trim()),(f.startsWith("ADR")||f.match(/^item\d+\.ADR/i))&&!u&&(u=f.substring(f.indexOf(":")+1).split(";").map(_=>_.trim()).filter(Boolean).join(", "))}(o||l)&&s.push({first_name:o,last_name:l,email:i,phone:c,address:u})}return s}function Pbs({open:t,onOpenChange:s,onComplete:r}){const{user:n}=Ds(),{data:a}=Gm(),o=_ue(),l=N.useRef(null),[i,c]=N.useState("choose"),[u,p]=N.useState([]),[f,g]=N.useState(new Set),[b,_]=N.useState(0),[j,w]=N.useState(0),k=Abs(),S=N.useCallback(Z=>{if(!a)return Z;const X=new Set(a.filter(Q=>Q.email).map(Q=>Q.email.toLowerCase())),ee=new Set(a.filter(Q=>Q.phone).map(Q=>Q.phone.replace(/\D/g,"")));return Z.map(Q=>{var oe,ce;const ie=(oe=Q.email)==null?void 0:oe.toLowerCase(),re=(ce=Q.phone)==null?void 0:ce.replace(/\D/g,"");return ie&&X.has(ie)?{...Q,isDuplicate:!0,duplicateField:"email"}:re&&re.length>=7&&ee.has(re)?{...Q,isDuplicate:!0,duplicateField:"phone"}:Q})},[a]),M=async()=>{try{const Z=["name","email","tel","address"],X=await navigator.contacts.select(Z,{multiple:!0});if(!X||X.length===0)return;const ee=X.map(re=>{var xe,ge,ue,pe;const ce=(((xe=re.name)==null?void 0:xe[0])||"").split(" ");return{first_name:ce[0]||"",last_name:ce.slice(1).join(" "),email:((ge=re.email)==null?void 0:ge[0])||"",phone:((ue=re.tel)==null?void 0:ue[0])||"",address:(pe=re.address)!=null&&pe[0]?[re.address[0].streetAddress,re.address[0].city,re.address[0].region,re.address[0].postalCode].filter(Boolean).join(", "):""}}),Q=S(ee);p(Q);const ie=new Set;Q.forEach((re,oe)=>{re.isDuplicate||ie.add(oe)}),g(ie),c("preview")}catch(Z){console.error("Contact Picker error:",Z),wn({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},L=Z=>{var Q;const X=(Q=Z.target.files)==null?void 0:Q[0];if(!X)return;const ee=new FileReader;ee.onload=ie=>{var ge;const re=(ge=ie.target)==null?void 0:ge.result,oe=Ebs(re);if(oe.length===0){wn({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const ce=S(oe);p(ce);const xe=new Set;ce.forEach((ue,pe)=>{ue.isDuplicate||xe.add(pe)}),g(xe),c("preview")},ee.readAsText(X),l.current&&(l.current.value="")},I=async()=>{const Z=u.filter((ee,Q)=>f.has(Q));if(Z.length===0)return;c("importing");let X=0;for(const ee of Z)try{await o.mutateAsync({first_name:ee.first_name,last_name:ee.last_name||void 0,email:ee.email||void 0,phone:ee.phone||void 0,address:ee.address||void 0}),X++,w(Math.round(X/Z.length*100))}catch(Q){console.error(`Failed to import ${ee.first_name} ${ee.last_name}:`,Q)}_(X),c("done")},O=Z=>{g(X=>{const ee=new Set(X);return ee.has(Z)?ee.delete(Z):ee.add(Z),ee})},q=()=>{f.size===u.length?g(new Set):g(new Set(u.map((Z,X)=>X)))},U=Z=>{Z||(c("choose"),p([]),g(new Set),_(0),w(0),i==="done"&&r()),s(Z)},B=u.filter(Z=>Z.isDuplicate).length,V=f.size;return e.jsx(fs,{open:t,onOpenChange:U,children:e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh]",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(h1,{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(Gr,{children:"Add contacts from your phone directly into Agent OS."})]}),i==="choose"&&e.jsxs("div",{className:"space-y-4 pt-2",children:[k&&e.jsxs(K,{onClick:M,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(h1,{className:"h-6 w-6"}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"font-semibold",children:"Select from Phone"}),e.jsx("div",{className:"text-xs opacity-80",children:"Pick contacts directly from your device"})]})]}),e.jsxs("div",{className:"relative",children:[k&&e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),k&&e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"or"})})]}),e.jsxs(K,{variant:k?"outline":"default",onClick:()=>{var Z;return(Z=l.current)==null?void 0:Z.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(li,{className:"h-6 w-6"}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"font-semibold",children:"Upload Contact File"}),e.jsx("div",{className:"text-xs opacity-80",children:k?"Import a .vcf file exported from your Contacts app":"Export contacts from your phone as a .vcf file, then upload here"})]})]}),e.jsx("input",{ref:l,type:"file",accept:".vcf,.vcard",onChange:L,className:"hidden"}),!k&&e.jsxs("div",{className:"rounded-lg bg-muted p-3 text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"How to export contacts:"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-xs",children:"iPhone:"}),e.jsx("p",{className:"text-xs",children:'Open Contacts → select contacts → Share → choose "Export vCard"'})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-xs",children:"Android:"}),e.jsx("p",{className:"text-xs",children:"Open Contacts → Menu → Export → save as .vcf file"})]})]})]}),i==="preview"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{children:[u.length," contact",u.length!==1?"s":""," found",B>0&&e.jsxs("span",{className:"text-amber-600 ml-1",children:["(",B," already exist)"]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:q,children:f.size===u.length?"Deselect All":"Select All"})]}),e.jsx(Gi,{className:"h-[350px] rounded-md border",children:e.jsx("div",{className:"divide-y",children:u.map((Z,X)=>e.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${Z.isDuplicate?"opacity-60":""}`,onClick:()=>O(X),children:[e.jsx(Oo,{checked:f.has(X),onCheckedChange:()=>O(X),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:[Z.first_name," ",Z.last_name]}),Z.isDuplicate&&e.jsxs(tt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",Z.duplicateField,")"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[Z.phone&&e.jsx("div",{children:Z.phone}),Z.email&&e.jsx("div",{className:"truncate",children:Z.email})]})]})]},X))})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c("choose"),children:"Back"}),e.jsxs(K,{onClick:I,disabled:V===0,children:["Import ",V," Contact",V!==1?"s":""]})]})]}),i==="importing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(ws,{className:"h-8 w-8 animate-spin text-primary"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Importing contacts..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[j,"% complete"]})]}),e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${j}%`}})})]}),i==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx(va,{className:"h-6 w-6 text-emerald-600"})}),e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"font-semibold text-lg",children:[b," contact",b!==1?"s":""," imported!"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Your contacts are now in Agent OS and ready for touchpoint plans."})]}),e.jsx(K,{onClick:()=>U(!1),className:"mt-2",children:"Done"})]})]})})}function Vhe(){const t=ci();return mt({queryKey:["custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_custom_tags").select("*").eq("owner_user_id",t).order("name");if(r)throw r;return s},enabled:!!t})}function Ibs(t){return mt({queryKey:["contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_custom_tag_assignments").select("*, tag:contact_custom_tags(*)").eq("contact_id",t);if(r)throw r;return s},enabled:!!t})}function oSe(){const t=Qt(),s=ci();return Dt({mutationFn:async({name:r,color:n})=>{const{data:a,error:o}=await H.from("contact_custom_tags").insert({owner_user_id:s,name:r.trim(),color:n||"#6366F1"}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]})}})}function Lbs(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("contact_custom_tags").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]}),t.invalidateQueries({queryKey:["contact-custom-tags"]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function Dbs(){const t=Qt();return Dt({mutationFn:async({id:s,name:r,color:n})=>{const a={};r!==void 0&&(a.name=r.trim()),n!==void 0&&(a.color=n);const{error:o}=await H.from("contact_custom_tags").update(a).eq("id",s);if(o)throw o},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]}),t.invalidateQueries({queryKey:["contact-custom-tags"]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function $at(){const t=Qt();return Dt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await H.from("contact_custom_tag_assignments").insert({contact_id:s,tag_id:r});if(n)throw n},onSuccess:(s,{contactId:r})=>{t.invalidateQueries({queryKey:["contact-custom-tags",r]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function Obs(){const t=Qt();return Dt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await H.from("contact_custom_tag_assignments").delete().eq("contact_id",s).eq("tag_id",r);if(n)throw n},onSuccess:(s,{contactId:r})=>{t.invalidateQueries({queryKey:["contact-custom-tags",r]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function Rbs(){const t=ci();return mt({queryKey:["all-contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_custom_tag_assignments").select("contact_id, tag_id, tag:contact_custom_tags(id, name, color)");if(r)throw r;return s},enabled:!!t})}function Fbs({selectedIds:t,contacts:s,onClearSelection:r,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const i=fr(),{data:c}=Ux(),u=wNe(),p=Qt(),{isGmailConnected:f}=Wx(),{isReady:g}=rSe(),{data:b}=Vhe(),_=oSe(),j=$at(),[w,k]=N.useState(!1),[S,M]=N.useState(!1),[L,I]=N.useState(!1),[O,q]=N.useState(""),U=t.size;if(U===0)return null;const B=async re=>{k(!0);try{const ce=Array.from(t).map(ge=>({contact_id:ge,relationship_type_id:re})),{error:xe}=await H.from("innercircle_contact_tags").upsert(ce,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(xe)throw xe;p.invalidateQueries({queryKey:["innercircle-contacts"]}),p.invalidateQueries({queryKey:["innercircle-contact-counts"]}),wn({title:`Assigned type to ${U} contacts`}),r()}catch(oe){wn({title:"Error assigning type",description:oe.message,variant:"destructive"})}finally{k(!1)}},V=async re=>{k(!0);try{const oe=Array.from(t);for(const ce of oe)try{await j.mutateAsync({contactId:ce,tagId:re})}catch{}p.invalidateQueries({queryKey:["all-contact-custom-tags"]}),wn({title:`Tagged ${U} contacts`}),I(!1),q("")}catch(oe){wn({title:"Error adding tags",description:oe.message,variant:"destructive"})}finally{k(!1)}},Z=async()=>{if(O.trim()){k(!0);try{const re=await _.mutateAsync({name:O.trim()});await V(re.id)}catch(re){wn({title:"Error creating tag",description:re.message,variant:"destructive"}),k(!1)}}},X=(b==null?void 0:b.filter(re=>re.name.toLowerCase().includes(O.toLowerCase())))||[],ee=b==null?void 0:b.find(re=>re.name.toLowerCase()===O.trim().toLowerCase()),Q=()=>{const re=s.filter(be=>t.has(be.id)),oe=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],ce=re.map(be=>{var Me;return[be.first_name,be.last_name||"",be.email||"",be.phone||"",be.address||"",be.birthday||"",be.home_anniversary||"",be.notes||"",((Me=be.tags)==null?void 0:Me.map(Ne=>{var Pe;return(Pe=Ne.relationship_type)==null?void 0:Pe.name}).join("; "))||""]}),xe=[oe.join(","),...ce.map(be=>be.map(Me=>`"${(Me||"").replace(/"/g,'""')}"`).join(","))].join(` `),ge=new Blob([xe],{type:"text/csv"}),ue=URL.createObjectURL(ge),pe=document.createElement("a");pe.href=ue,pe.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,pe.click(),URL.revokeObjectURL(ue),wn({title:`Exported ${U} contacts`})},ie=async()=>{if(confirm(`Are you sure you want to delete ${U} contacts? This cannot be undone.`)){k(!0);try{const re=Array.from(t);for(const oe of re)await u.mutateAsync(oe);r()}catch(re){wn({title:"Error deleting contacts",description:re.message,variant:"destructive"})}finally{k(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 border border-primary/20 rounded-lg",children:[e.jsxs(tt,{variant:"secondary",className:"font-semibold",children:[U," selected"]}),e.jsxs(Zs,{onValueChange:B,disabled:w,children:[e.jsx(Ws,{className:"w-[180px] h-8",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Fm,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:"Assign Type"})]})}),e.jsx(Gs,{children:c==null?void 0:c.filter(re=>re.active).map(re=>e.jsx(Mt,{value:re.id,children:re.name},re.id))})]}),e.jsxs($o,{open:L,onOpenChange:I,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",disabled:w,children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs(Ro,{className:"w-56 p-2",align:"start",children:[e.jsx(ze,{placeholder:"Search or create tag...",value:O,onChange:re=>q(re.target.value),onKeyDown:re=>{re.key==="Enter"&&O.trim()&&!ee?(re.preventDefault(),Z()):re.key==="Enter"&&ee&&(re.preventDefault(),V(ee.id))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[X.map(re=>e.jsxs("button",{onClick:()=>V(re.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:re.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:re.name})]},re.id)),O.trim()&&!ee&&e.jsxs("button",{onClick:Z,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($s,{className:"h-3.5 w-3.5"}),'Create "',O.trim(),'"']}),X.length===0&&!O.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create a tag"})]})]})]}),f&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>M(!0),disabled:w,children:[e.jsx(cr,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),g&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{const re=Array.from(t).join(",");i(`/admin/email-campaigns/new?contactIds=${re}`)},disabled:w,children:[e.jsx(Ah,{className:"h-3.5 w-3.5 mr-1"}),"Mass Email"]}),a&&n&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>n(Array.from(t)),disabled:w,children:[e.jsx(Yg,{className:"h-3.5 w-3.5 mr-1"}),"Send to Lead Pond"]}),l&&o&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>o(Array.from(t)),disabled:w,children:[e.jsx(e1,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:Q,disabled:w,children:[e.jsx(yi,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,disabled:w,className:"text-destructive hover:text-destructive",children:[e.jsx(Nr,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:r,className:"ml-auto",children:[e.jsx(Rr,{className:"h-3.5 w-3.5 mr-1"}),"Clear"]})]}),e.jsx(qw,{open:S,onOpenChange:M,bulkContacts:Array.from(t).map(re=>{const oe=s.find(ce=>ce.id===re);return oe?{id:oe.id,first_name:oe.first_name,last_name:oe.last_name,email:oe.email||""}:null}).filter(re=>re!==null&&re.email!==""),onSendComplete:()=>{M(!1),r()}})]})}function GFe({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const c=fr(),{isReady:u}=rSe(),p=`${t.first_name} ${t.last_name||""}`.trim();return e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:f=>f.stopPropagation(),children:e.jsx(px,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",onClick:f=>f.stopPropagation(),children:[e.jsxs(Ma,{onClick:()=>c(`/mission-control/contacts/${t.id}?tab=activity&action=log`),children:[e.jsx(Un,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),e.jsxs(Ma,{onClick:()=>c(`/mission-control/video?contactId=${t.id}`),children:[e.jsx(An,{className:"h-4 w-4 mr-2"}),"Send Video"]}),e.jsxs(Ma,{onClick:()=>c(`/mission-control/popbys?contactId=${t.id}`),children:[e.jsx(ma,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),u&&t.email&&e.jsxs(Ma,{onClick:()=>c(`/admin/email-campaigns/new?contactIds=${t.id}`),children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Mass Email"]}),e.jsxs(Ma,{onClick:()=>n(t.id,p),children:[e.jsx(Rm,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&e.jsxs(Ma,{onClick:()=>a(t.id),children:[e.jsx(Yg,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&e.jsxs(Ma,{onClick:()=>l(t.id),children:[e.jsx(e1,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),e.jsxs(Ma,{onClick:()=>s(t),children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ma,{onClick:()=>r(t.id),className:"text-destructive focus:text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function zbs(){const{user:t}=Ds();return mt({queryKey:["contact-smart-lists",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_smart_lists").select("*").order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Bbs(){const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async({name:r,filters:n,sort_by:a})=>{const{data:o,error:l}=await H.from("contact_smart_lists").insert({owner_user_id:s.id,name:r,filters:n,sort_by:a}).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),wn({title:"Smart filter saved"})},onError:r=>{wn({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function $bs(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("contact_smart_lists").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),wn({title:"Smart filter deleted"})}})}function qbs({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=zbs(),a=Bbs(),o=$bs(),[l,i]=N.useState(!1),[c,u]=N.useState(""),p=t.search||t.type&&t.type!=="all"||t.status&&t.status!=="all",f=async()=>{c.trim()&&(await a.mutateAsync({name:c.trim(),filters:t,sort_by:s}),u(""),i(!1))};return e.jsxs(e.Fragment,{children:[e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Xg,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&e.jsx(tt,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),e.jsx(Eo,{className:"h-3.5 w-3.5"})]})}),e.jsxs(Bd,{align:"start",className:"w-56",children:[n&&n.length>0?e.jsxs(e.Fragment,{children:[n.map(g=>e.jsxs(Ma,{className:"flex items-center justify-between group",children:[e.jsx("span",{className:"flex-1 cursor-pointer",onClick:()=>r(g.filters,g.sort_by),children:g.name}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",onClick:b=>{b.stopPropagation(),o.mutate(g.id)},children:e.jsx(Nr,{className:"h-3 w-3 text-destructive"})})]},g.id)),e.jsx(dw,{})]}):e.jsx(Ma,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),p&&e.jsxs(Ma,{onClick:()=>i(!0),children:[e.jsx(KI,{className:"h-4 w-4 mr-2"}),"Save Current Filter"]})]})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{className:"max-w-sm",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Save Smart Filter"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ze,{placeholder:"e.g. Buyers in 40205",value:c,onChange:g=>u(g.target.value),onKeyDown:g=>g.key==="Enter"&&f(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{onClick:f,disabled:!c.trim()||a.isPending,children:"Save"})]})]})]})})]})}function MI(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 ZFe({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=fr(),i=KFe(t,"birthday",7),c=KFe(s,"anniversary",7);if(!i&&!c)return null;const u=(p,f)=>{f.stopPropagation();const g=new URLSearchParams;n&&g.set("contactId",n),a&&g.set("name",a),o&&g.set("address",o),p==="home_anniversary"&&s&&g.set("date",s),g.set("cardType",p),l(`/mission-control/card-studio?${g.toString()}`)};return e.jsxs("div",{className:It("flex flex-wrap gap-1",r),children:[i&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(tt,{variant:"secondary",className:It("text-[10px] gap-0.5 font-medium",i.daysUntil===0?"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-400 animate-pulse":"bg-pink-50 text-pink-600 dark:bg-pink-900/20 dark:text-pink-400"),children:i.label}),n&&e.jsxs("button",{onClick:p=>u("birthday",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-pink-500/15 text-pink-600 dark:text-pink-400 hover:bg-pink-500/25 transition-colors",title:"Send a birthday card",children:[e.jsx(cr,{className:"h-2.5 w-2.5"}),"Send Card"]})]}),c&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(tt,{variant:"secondary",className:It("text-[10px] gap-0.5 font-medium",c.daysUntil===0?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400 animate-pulse":"bg-blue-50 text-blue-600 dark:bg-blue-900/20 dark:text-blue-400"),children:c.label}),n&&e.jsxs("button",{onClick:p=>u("home_anniversary",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors",title:"Send an anniversary card",children:[e.jsx(cr,{className:"h-2.5 w-2.5"}),"Send Card"]})]})]})}function YFe({deal:t}){if(!t||!t.stage)return null;const{stage:s}=t;return e.jsxs(tt,{variant:"outline",className:"text-[10px] gap-1 font-medium whitespace-nowrap",style:{borderColor:s.color,color:s.color,backgroundColor:`${s.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:s.color}}),s.name]})}function Ubs(){const t=ci();return mt({queryKey:["contact-deals-map",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_pipeline").select(` id, deal_name, contact_id, stage:deal_pipeline_stages(id, name, color, icon, is_won_stage, is_lost_stage) `).not("contact_id","is",null);if(r)throw r;const n={};return(s||[]).forEach(a=>{a.contact_id&&!n[a.contact_id]&&(n[a.contact_id]=a)}),n},enabled:!!t})}function Vbs({contactId:t,compact:s=!1}){const{data:r}=Vhe(),{data:n}=Ibs(t),a=oSe(),o=$at(),l=Obs(),[i,c]=N.useState(!1),[u,p]=N.useState(""),f=N.useRef(null),g=new Set((n==null?void 0:n.map(k=>k.tag_id))||[]),b=(r==null?void 0:r.filter(k=>k.name.toLowerCase().includes(u.toLowerCase())))||[],_=r==null?void 0:r.find(k=>k.name.toLowerCase()===u.trim().toLowerCase()),j=async k=>{g.has(k.id)?await l.mutateAsync({contactId:t,tagId:k.id}):await o.mutateAsync({contactId:t,tagId:k.id})},w=async()=>{if(!(!u.trim()||_))try{const k=await a.mutateAsync({name:u.trim()});await o.mutateAsync({contactId:t,tagId:k.id}),p("")}catch{}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n==null?void 0:n.map(k=>{var S,M,L;return e.jsxs(tt,{variant:"outline",className:"text-xs gap-1 pr-1",style:{borderColor:((S=k.tag)==null?void 0:S.color)||"#6366F1",color:((M=k.tag)==null?void 0:M.color)||"#6366F1"},children:[e.jsx(Fm,{className:"h-2.5 w-2.5"}),(L=k.tag)==null?void 0:L.name,e.jsx("button",{onClick:I=>{I.stopPropagation(),l.mutate({contactId:t,tagId:k.tag_id})},className:"ml-0.5 rounded-full hover:bg-accent p-0.5",children:e.jsx(Rr,{className:"h-2.5 w-2.5"})})]},k.id)}),e.jsxs($o,{open:i,onOpenChange:c,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:s?"h-6 w-6 p-0":"h-6 px-2 text-xs",onClick:k=>k.stopPropagation(),children:[e.jsx($s,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs(Ro,{className:"w-56 p-2",align:"start",onClick:k=>k.stopPropagation(),children:[e.jsx(ze,{ref:f,placeholder:"Search or create tag...",value:u,onChange:k=>p(k.target.value),onKeyDown:k=>{k.key==="Enter"&&u.trim()&&!_?(k.preventDefault(),w()):k.key==="Enter"&&_&&!g.has(_.id)&&(k.preventDefault(),j(_))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[b.map(k=>e.jsxs("button",{onClick:()=>j(k),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors",children:[e.jsx("div",{className:"h-3 w-3 rounded-full shrink-0",style:{backgroundColor:k.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:k.name}),g.has(k.id)&&e.jsx(va,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},k.id)),u.trim()&&!_&&e.jsxs("button",{onClick:w,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx($s,{className:"h-3.5 w-3.5"}),'Create "',u.trim(),'"']}),b.length===0&&!u.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create your first tag"})]})]})]})]})}function XFe({contactId:t,tags:s}){return!s||s.length===0?null:e.jsx(e.Fragment,{children:s.map(r=>{var n,a,o;return e.jsx(tt,{variant:"outline",className:"text-[10px] gap-0.5",style:{borderColor:((n=r.tag)==null?void 0:n.color)||"#6366F1",color:((a=r.tag)==null?void 0:a.color)||"#6366F1"},children:(o=r.tag)==null?void 0:o.name},r.tag_id)})})}const Hz=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function Hbs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Vhe(),a=oSe(),o=Dbs(),l=Lbs(),[i,c]=N.useState(""),[u,p]=N.useState(Hz[0]),[f,g]=N.useState(null),[b,_]=N.useState(""),[j,w]=N.useState(""),k=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:u}),c(""),p(Hz[0]),wn({title:"Tag created"})}catch(I){wn({title:"Error",description:I.message,variant:"destructive"})}},S=async I=>{if(b.trim())try{await o.mutateAsync({id:I,name:b.trim(),color:j}),g(null),wn({title:"Tag updated"})}catch(O){wn({title:"Error",description:O.message,variant:"destructive"})}},M=async(I,O)=>{if(confirm(`Delete tag "${O}"? It will be removed from all contacts.`))try{await l.mutateAsync(I),wn({title:"Tag deleted"})}catch(q){wn({title:"Error",description:q.message,variant:"destructive"})}},L=I=>{g(I.id),_(I.name),w(I.color)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Manage Tags"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"New tag name...",value:i,onChange:I=>c(I.target.value),onKeyDown:I=>I.key==="Enter"&&k(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:k,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Hz.map(I=>e.jsx("button",{onClick:()=>p(I),className:`h-6 w-6 rounded-full border-2 transition-transform ${u===I?"border-foreground scale-110":"border-transparent hover:scale-105"}`,style:{backgroundColor:I}},I))})]}),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(I=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:f===I.id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:Hz.map(O=>e.jsx("button",{onClick:()=>w(O),className:`h-5 w-5 rounded-full border-2 ${j===O?"border-foreground":"border-transparent"}`,style:{backgroundColor:O}},O))}),e.jsx(ze,{value:b,onChange:O=>_(O.target.value),onKeyDown:O=>O.key==="Enter"&&S(I.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>S(I.id),children:e.jsx(va,{className:"h-4 w-4 text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>g(null),children:e.jsx(Rr,{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:I.color}}),e.jsx("span",{className:"flex-1 text-sm",children:I.name}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>L(I),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:()=>M(I.id,I.name),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})},I.id))]})]})})}function Wbs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=sE(),a=kNe(),o=ZLt(),l=YLt(),[i,c]=N.useState(""),[u,p]=N.useState(null),[f,g]=N.useState(""),b=async()=>{if(i.trim())try{await a.mutateAsync(i.trim()),c("")}catch(k){me.error(k.message||"Failed to add lead source")}},_=async k=>{if(f.trim())try{await o.mutateAsync({id:k,name:f.trim()}),p(null)}catch(S){me.error(S.message||"Failed to update")}},j=async(k,S)=>{if(confirm(`Remove lead source "${S}"? Contacts using it will keep the label but it won't appear in new dropdowns.`))try{await l.mutateAsync(k)}catch(M){me.error(M.message||"Failed to remove")}},w=k=>{p(k.id),g(k.name)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Manage Lead Sources"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"New lead source name...",value:i,onChange:k=>c(k.target.value),onKeyDown:k=>k.key==="Enter"&&b(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:b,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsxs("div",{className:"mt-2 space-y-1 max-h-[360px] overflow-y-auto",children:[n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading..."}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No lead sources yet. Create one above!"}),r==null?void 0:r.map(k=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:u===k.id?e.jsxs(e.Fragment,{children:[e.jsx(ze,{value:f,onChange:S=>g(S.target.value),onKeyDown:S=>S.key==="Enter"&&_(k.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>_(k.id),children:e.jsx(va,{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(Rr,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-sm",children:k.name}),k.owner_user_id&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>w(k),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(k.id,k.name),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]}),!k.owner_user_id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default"})]})},k.id))]})]})})}function qat({value:t,onChange:s,label:r="Lead Source"}){const{data:n}=sE(),a=kNe(),[o,l]=N.useState(!1),[i,c]=N.useState(""),u=async()=>{if(i.trim())try{const p=await a.mutateAsync(i.trim());p&&(s(p.id),c(""),l(!1))}catch{}};return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:r}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Zs,{value:t||"_none",onValueChange:p=>s(p==="_none"?"":p),children:[e.jsx(Ws,{className:"flex-1",children:e.jsx(Xs,{placeholder:"Select lead source"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"_none",children:"No source"}),n==null?void 0:n.map(p=>e.jsx(Mt,{value:p.id,children:p.name},p.id))]})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",className:"shrink-0",onClick:()=>l(!o),children:o?e.jsx(Rr,{className:"h-4 w-4"}):e.jsx($s,{className:"h-4 w-4"})})]}),o&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"New lead source name...",value:i,onChange:p=>c(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),u())},className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:u,disabled:!i.trim()||a.isPending,children:"Add"})]})]})}function $_e({contactId:t,currentSpouseContactId:s,currentSpouseName:r,currentSpouseEmail:n,onLink:a,onUnlink:o,isEditing:l}){const i=fr(),[c,u]=N.useState(!1),[p,f]=N.useState(""),{data:g}=mt({queryKey:["innercircle-contact-spouse",s],queryFn:async()=>{const{data:_,error:j}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone, birthday").eq("id",s).maybeSingle();if(j)throw j;return _},enabled:!!s}),{data:b}=mt({queryKey:["spouse-search",p],queryFn:async()=>{let _=H.from("innercircle_contacts").select("id, first_name, last_name, email, phone").neq("id",t).order("first_name").limit(20);p.trim()&&(_=_.or(`first_name.ilike.%${p}%,last_name.ilike.%${p}%,email.ilike.%${p}%,phone.ilike.%${p}%`));const{data:j,error:w}=await _;if(w)throw w;return j},enabled:c});if(s&&g){const _=`${g.first_name} ${g.last_name||""}`.trim();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(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(to,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("button",{onClick:()=>i(`/mission-control/contacts/${g.id}`),className:"text-sm font-medium text-primary hover:underline truncate block",children:_}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[g.phone,g.email].filter(Boolean).join(" · ")||"No contact info"})]}),l&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:o,className:"shrink-0 h-7 px-2",children:[e.jsx(xS,{className:"h-3.5 w-3.5 mr-1"}),"Unlink"]}),!l&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>i(`/mission-control/contacts/${g.id}`),className:"shrink-0 h-7 px-2",children:e.jsx(Qa,{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(to,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm",children:r}),n&&e.jsx("span",{className:"text-xs text-muted-foreground block truncate",children:n})]}),l&&e.jsxs($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"shrink-0 h-7 px-2",children:[e.jsx(dl,{className:"h-3.5 w-3.5 mr-1"}),"Link Contact"]})}),e.jsx(Ro,{className:"w-72 p-2",align:"end",children:e.jsx(QFe,{search:p,setSearch:f,results:b,onSelect:_=>{a(_),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($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full justify-start text-muted-foreground font-normal h-10",children:[e.jsx(dl,{className:"h-4 w-4 mr-2"}),"Link an existing contact as spouse..."]})}),e.jsx(Ro,{className:"w-72 p-2",align:"start",children:e.jsx(QFe,{search:p,setSearch:f,results:b,onSelect:_=>{a(_),u(!1),f("")}})})]})]}):null}function QFe({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(cn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{value:t,onChange:a=>s(a.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Gi,{className:"max-h-48",children:r&&r.length>0?e.jsx("div",{className:"space-y-0.5",children:r.map(a=>e.jsxs("button",{onClick:()=>n(a.id),className:"w-full text-left px-2 py-1.5 rounded hover:bg-accent transition-colors",children:[e.jsxs("div",{className:"text-sm font-medium truncate",children:[a.first_name," ",a.last_name]}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[a.phone,a.email].filter(Boolean).join(" · ")||"No contact info"})]},a.id))}):e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:t?"No contacts found":"Type to search contacts"})})]})}function Gbs(){var vi;const t=fr(),[s]=Cc(),{user:r}=Ds(),n=NE(),a=Qt(),o=s.get("type"),l=s.get("filter")??s.get("status"),i=s.get("new")==="true",{contactsWithScores:c,isLoading:u}=Nue(),{activeContactIds:p,hasLeadSite:f}=kbs(),{data:g}=Ux(),{data:b}=Ubs(),{data:_}=Vhe(),{data:j}=Rbs(),[w,k]=N.useState(new Set),[S,M]=N.useState("any"),L=_ue(),I=_Ne(),O=wNe(),q=GYe(),[U,B]=N.useState(""),[V,Z]=N.useState(o||"all"),[X,ee]=N.useState(l||"all"),[Q,ie]=N.useState("date-added"),[re,oe]=N.useState(i),[ce,xe]=N.useState(null),[ge,ue]=N.useState(!1),[pe,be]=N.useState(!1),[Me,Ne]=N.useState(null),[Pe,Oe]=N.useState(""),[Te,ke]=N.useState(new Set),[Be,nt]=N.useState(!1),[Ae,ft]=N.useState(1),[fe,Ve]=N.useState(50),[at,et]=N.useState("my"),[Ce,rt]=N.useState(!1),[Ge,ct]=N.useState(!1),{data:qe}=Bx(),{addToLeadPond:Ze}=ntt(qe==null?void 0:qe.teamId),Qe=!!((vi=qe==null?void 0:qe.team)!=null&&vi.lead_pond_enabled&&(qe!=null&&qe.teamId)),He=!!(qe!=null&&qe.teamId),[Je,it]=N.useState([]),[Lt,Vt]=N.useState(!1),hs=pt=>{it([pt]),Vt(!0)},Ts=pt=>{it(pt),Vt(!0)},Cs=pt=>{qe!=null&&qe.teamId&&Ze.mutate({contact_id:pt,team_id:qe.teamId})},cs=pt=>{qe!=null&&qe.teamId&&pt.forEach(ir=>{Ze.mutate({contact_id:ir,team_id:qe.teamId})})},er=N.useCallback(pt=>{nt(!1),ke(ir=>{const Vn=new Set(ir);return Vn.has(pt)?Vn.delete(pt):Vn.add(pt),Vn})},[]);N.useEffect(()=>{if(!(r!=null&&r.id))return;const pt=H.channel(`innercircle_contacts_inserts_${r.id}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"innercircle_contacts",filter:`owner_user_id=eq.${r.id}`},()=>{a.invalidateQueries({queryKey:["innercircle-contacts"]}),a.invalidateQueries({queryKey:["innercircle-contact-counts"]})}).subscribe();return()=>{H.removeChannel(pt)}},[a,r==null?void 0:r.id]),N.useEffect(()=>{l&&ee(l)},[l]);const[xt,Es]=N.useState({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]});N.useEffect(()=>{i&&oe(!0)},[i]),N.useEffect(()=>{var pt;ce&&Es({first_name:ce.first_name||"",last_name:ce.last_name||"",email:ce.email||"",phone:ce.phone||"",address:ce.address||"",city:ce.city||"",state:ce.state||"",zip_code:ce.zip_code||"",birthday:ce.birthday||"",home_anniversary:ce.home_anniversary||"",spouse_name:ce.spouse_name||"",spouse_email:ce.spouse_email||"",lead_source_id:ce.lead_source_id||"",notes:ce.notes||"",tagIds:((pt=ce.tags)==null?void 0:pt.map(ir=>ir.relationship_type_id))||[]})},[ce]);const ur=N.useMemo(()=>{if(!c)return[];let pt=c.filter(ir=>{var ea,Pa,Ii;const Vn=U===""||`${ir.first_name} ${ir.last_name}`.toLowerCase().includes(U.toLowerCase())||((ea=ir.email)==null?void 0:ea.toLowerCase().includes(U.toLowerCase()))||((Pa=ir.phone)==null?void 0:Pa.includes(U)),Sr=V==="all"||((Ii=ir.tags)==null?void 0:Ii.some(Fo=>Fo.relationship_type_id===V)),jr=w.size===0||(()=>{const Fo=(j==null?void 0:j.filter($t=>$t.contact_id===ir.id).map($t=>$t.tag_id))||[];return S==="any"?Fo.some($t=>w.has($t)):Array.from(w).every($t=>Fo.includes($t))})();return Vn&&Sr&&jr});return X==="not-touched-90"?pt=pt.filter(ir=>{const Vn=ir.relationshipScore.daysSinceTouch;return Vn===null||Vn>90}):X==="at-risk"?pt=pt.filter(ir=>ir.relationshipScore.status==="at-risk"):X==="cooling"?pt=pt.filter(ir=>ir.relationshipScore.status==="cooling"):X==="warm"?pt=pt.filter(ir=>ir.relationshipScore.status==="warm"):X==="has-deal"?pt=pt.filter(ir=>b&&b[ir.id]):X==="no-deal"?pt=pt.filter(ir=>!b||!b[ir.id]):X==="open-house"?pt=pt.filter(ir=>{var Sr;return(((Sr=ir.lead_source_ref)==null?void 0:Sr.name)||ir.lead_source)==="Open House"}):X==="website-active"&&(pt=pt.filter(ir=>p.has(ir.id))),pt=[...pt].sort((ir,Vn)=>{switch(Q){case"important-dates":{const Sr=MI(ir.birthday),jr=MI(Vn.birthday),ea=MI(ir.home_anniversary),Pa=MI(Vn.home_anniversary),Ii=[Sr,ea].filter($t=>$t!==null).sort(($t,je)=>($t??1/0)-(je??1/0))[0]??1/0,Fo=[jr,Pa].filter($t=>$t!==null).sort(($t,je)=>($t??1/0)-(je??1/0))[0]??1/0;return Ii-Fo}case"last-touched":{const Sr=ir.relationshipScore.lastTouchDate,jr=Vn.relationshipScore.lastTouchDate;return!Sr&&!jr?0:Sr?jr?new Date(Sr).getTime()-new Date(jr).getTime():1:-1}case"next-touch":{const Sr=ir.relationshipScore.daysSinceTouch,jr=Vn.relationshipScore.daysSinceTouch;return Sr===null&&jr===null?0:Sr===null?-1:jr===null?1:jr-Sr}case"score":return ir.relationshipScore.score-Vn.relationshipScore.score;case"date-added":{const Sr=ir.created_at,jr=Vn.created_at;return!Sr&&!jr?0:Sr?jr?new Date(jr).getTime()-new Date(Sr).getTime():-1:1}case"name":default:{const Sr=`${ir.first_name||""} ${ir.last_name||""}`.toLowerCase(),jr=`${Vn.first_name||""} ${Vn.last_name||""}`.toLowerCase();return Sr.localeCompare(jr)}}}),pt},[c,U,V,w,S,X,Q,b,j,p]),Mr=ur.length,Lr=Math.max(1,Math.ceil(Mr/fe)),fn=Math.min(Ae,Lr),ki=N.useMemo(()=>{const pt=(fn-1)*fe;return ur.slice(pt,pt+fe)},[ur,fn,fe]);N.useEffect(()=>{ft(1)},[U,V,w,S,X,Q]);const Ea=N.useCallback(()=>{nt(!1),ke(pt=>pt.size>0?new Set:new Set(ki.map(ir=>ir.id)))},[ki]),dr=N.useCallback(()=>{nt(!0),ke(new Set(ur.map(pt=>pt.id)))},[ur]),Jr=N.useCallback((pt,ir)=>{B(pt.search||""),Z(pt.type||"all"),ee(pt.status||"all"),ie(ir||"name")},[]),Wr=()=>{Es({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]})},dn=async pt=>{pt.preventDefault();const ir={...xt,lead_source_id:xt.lead_source_id||null};ce?(await I.mutateAsync({id:ce.id,...ir}),xe(null)):(await L.mutateAsync(ir),oe(!1)),Wr()},Yr=async pt=>{confirm("Are you sure you want to delete this contact?")&&await O.mutateAsync(pt)};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:()=>et("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${at==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),(qe.team.contact_visibility==="full_team"||qe.team.contact_visibility==="leader_only"&&qe.role==="team_leader")&&e.jsxs("button",{onClick:()=>et("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${at==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(pr,{className:"h-3.5 w-3.5"}),"Team"]}),qe.team.lead_pond_enabled&&e.jsxs("button",{onClick:()=>et("lead-pond"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${at==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Yg,{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(cl,{className:"h-4 w-4 mr-1"}),"Back"]})}),at==="team"?e.jsx(Dke,{}):at==="lead-pond"&&qe?e.jsx(Oke,{teamId:qe.teamId}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{children:e.jsx(De,{className:"p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or phone...",value:U,onChange:pt=>B(pt.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto pb-1",children:[e.jsxs(K,{onClick:()=>oe(!0),className:"shrink-0",children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Contact"]}),e.jsxs(K,{variant:"outline",onClick:()=>ue(!0),className:"shrink-0",children:[e.jsx(li,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(K,{variant:"outline",onClick:()=>be(!0),className:"shrink-0",children:[e.jsx(h1,{className:"h-4 w-4 mr-1"}),"Import from Phone"]}),e.jsx(xbs,{})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(Zs,{value:V,onValueChange:Z,children:[e.jsx(Ws,{className:"w-[145px] h-9 text-sm",children:e.jsx(Xs,{placeholder:"Filter by type"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),g==null?void 0:g.filter(pt=>pt.active).map(pt=>e.jsx(Mt,{value:pt.id,children:pt.name},pt.id))]})]}),_&&_.length>0&&e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"h-9 justify-start text-sm",children:[e.jsx(Fm,{className:"h-3.5 w-3.5 mr-1.5 shrink-0 text-muted-foreground"}),w.size===0?"Filter by Tags":`${w.size} tag${w.size>1?"s":""}`]})}),e.jsx(Ro,{className:"w-60 p-3",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Tags"}),e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-md p-0.5",children:[e.jsx("button",{onClick:()=>M("any"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${S==="any"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"Any"}),e.jsx("button",{onClick:()=>M("all"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${S==="all"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"All"})]})]}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:_.map(pt=>{const ir=w.has(pt.id);return e.jsxs("button",{onClick:()=>{k(Vn=>{const Sr=new Set(Vn);return Sr.has(pt.id)?Sr.delete(pt.id):Sr.add(pt.id),Sr})},className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors",children:[e.jsx(Oo,{checked:ir,className:"pointer-events-none"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:pt.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:pt.name})]},pt.id)})}),w.size>0&&e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>k(new Set),children:"Clear tags"})]})})]}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",title:"Settings",children:e.jsx(Xo,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs(Bd,{align:"end",children:[e.jsxs(Ma,{onClick:()=>rt(!0),children:[e.jsx(Fm,{className:"h-4 w-4 mr-2"}),"Manage Tags"]}),e.jsxs(Ma,{onClick:()=>ct(!0),children:[e.jsx(Yg,{className:"h-4 w-4 mr-2"}),"Manage Lead Sources"]})]})]}),e.jsxs(Zs,{value:X,onValueChange:ee,children:[e.jsx(Ws,{className:"w-[145px] h-9 text-sm",children:e.jsx(Xs,{placeholder:"Filter by status"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Status"}),e.jsx(Mt,{value:"warm",children:"🟢 Warm"}),e.jsx(Mt,{value:"cooling",children:"🟡 Cooling Off"}),e.jsx(Mt,{value:"at-risk",children:"🔴 At Risk"}),e.jsx(Mt,{value:"has-deal",children:"📋 Has Deal"}),e.jsx(Mt,{value:"no-deal",children:"📭 No Deal"}),e.jsx(Mt,{value:"open-house",children:"🏠 Open House"}),f&&e.jsx(Mt,{value:"website-active",children:"🌐 Website Active"})]})]}),e.jsxs(Zs,{value:Q,onValueChange:ie,children:[e.jsx(Ws,{className:"w-[165px] h-9 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vd,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Xs,{placeholder:"Sort by"})]})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"name",children:"Name (A-Z)"}),e.jsx(Mt,{value:"important-dates",children:"Important Dates"}),e.jsx(Mt,{value:"last-touched",children:"Last Touched"}),e.jsx(Mt,{value:"next-touch",children:"Next Touch Due"}),e.jsx(Mt,{value:"score",children:"Relationship Score"}),e.jsx(Mt,{value:"date-added",children:"Date Added"})]})]}),e.jsx(qbs,{currentFilters:{search:U,type:V,status:X},currentSortBy:Q,onApplySmartList:Jr})]})]})})}),e.jsx(Fbs,{selectedIds:Te,contacts:ur,onClearSelection:()=>{ke(new Set),nt(!1)},showLeadPondAction:Qe,onSendToLeadPond:cs,showTransferAction:He,onTransfer:Ts}),Te.size>0&&Te.size===ki.length&&!Be&&Mr>fe&&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 ",ki.length," contacts on this page are selected."]}),e.jsxs(K,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:dr,children:["Select all ",Mr.toLocaleString()," matching contacts"]})]}),Be&&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 ",Mr.toLocaleString()," matching contacts are selected.",e.jsx(K,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{ke(new Set),nt(!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..."}):ur.length===0?e.jsx(Ee,{className:"p-6 text-center text-muted-foreground",children:U||V!=="all"||X!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):ki.map(pt=>{var Vn,Sr,jr;const{relationshipScore:ir}=pt;return e.jsx(Ee,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const ea=new URLSearchParams;U&&ea.set("search",U),V!=="all"&&ea.set("type",V),X!=="all"&&ea.set("filter",X);const Pa=ea.toString();t(`/mission-control/contacts/${pt.id}${Pa?`?${Pa}`:""}`)},children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("h3",{className:"font-semibold text-base truncate",children:[pt.first_name," ",pt.last_name]}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground shrink-0"})]}),e.jsxs("div",{className:"space-y-1 text-sm mb-3",children:[pt.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(cr,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:pt.email})]}),pt.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Un,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:pt.phone})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-2",children:[e.jsx(y8,{score:ir,size:"sm"}),e.jsx(B_e,{contact:pt}),(((Vn=pt.lead_source_ref)==null?void 0:Vn.name)||pt.lead_source)&&e.jsx(tt,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:((Sr=pt.lead_source_ref)==null?void 0:Sr.name)||pt.lead_source}),(jr=pt.tags)==null?void 0:jr.map(ea=>{var Pa;return e.jsx(tt,{variant:"secondary",className:"text-xs",children:(Pa=ea.relationship_type)==null?void 0:Pa.name},ea.id)}),e.jsx(XFe,{contactId:pt.id,tags:j==null?void 0:j.filter(ea=>ea.contact_id===pt.id)}),e.jsx(YFe,{deal:b==null?void 0:b[pt.id]})]}),e.jsx(ZFe,{birthday:pt.birthday,homeAnniversary:pt.home_anniversary,className:"mb-2",contactId:pt.id,contactName:`${pt.first_name}${pt.last_name?" "+pt.last_name:""}`,contactAddress:[pt.address,pt.city,pt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[ir.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(ir.lastTouchDate),"MMM d")]}):e.jsx("span",{className:"italic",children:"Never contacted"}),pt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(Dl(pt.birthday),"MMM d")]}),pt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(bn,{className:"h-3 w-3"}),ms(Dl(pt.home_anniversary),"MMM d")]}),pt.created_at&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx($s,{className:"h-3 w-3"}),"Added ",ms(new Date(pt.created_at),"MMM d, yyyy")]})]})]}),e.jsx("div",{className:"ml-2",onClick:ea=>ea.stopPropagation(),children:e.jsx(GFe,{contact:pt,onEdit:xe,onDelete:Yr,onSnooze:(ea,Pa)=>{Ne(ea),Oe(Pa)},showLeadPondAction:Qe,onSendToLeadPond:Cs,showTransferAction:He,onTransfer:hs})})]})})},pt.id)})}):e.jsx(Ee,{children:e.jsx(De,{className:"p-0 overflow-x-auto",children:e.jsxs(Rn,{className:"min-w-[800px]",children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Oo,{checked:ki.length>0&&ki.every(pt=>Te.has(pt.id)),onCheckedChange:()=>Ea()})}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Score"}),e.jsx(St,{children:"Contact Info"}),e.jsx(St,{children:"Types / Pipeline"}),e.jsx(St,{children:"Last Contact"}),e.jsx(St,{className:"cursor-pointer select-none",onClick:()=>ie(Q==="date-added"?"name":"date-added"),children:e.jsxs("div",{className:"flex items-center gap-1",children:["Date Added",Q==="date-added"&&e.jsx(vd,{className:"h-3 w-3"})]})}),e.jsx(St,{children:"Important Dates"}),e.jsx(St,{className:"w-[50px]",children:"Actions"})]})}),e.jsx(zn,{children:u?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8",children:"Loading contacts..."})}):ur.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:U||V!=="all"||X!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):ki.map(pt=>{var Sr,jr,ea;const{relationshipScore:ir}=pt,Vn=b==null?void 0:b[pt.id];return e.jsxs(Ss,{className:`cursor-pointer hover:bg-accent/50 ${Te.has(pt.id)?"bg-accent/30":""}`,onClick:()=>{const Pa=new URLSearchParams;U&&Pa.set("search",U),V!=="all"&&Pa.set("type",V),X!=="all"&&Pa.set("status",X);const Ii=Pa.toString();t(`/mission-control/contacts/${pt.id}${Ii?`?${Ii}`:""}`)},children:[e.jsx(dt,{onClick:Pa=>Pa.stopPropagation(),children:e.jsx(Oo,{checked:Te.has(pt.id),onCheckedChange:()=>er(pt.id)})}),e.jsxs(dt,{className:"font-medium",children:[pt.first_name," ",pt.last_name]}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(y8,{score:ir,size:"sm"}),e.jsx(B_e,{contact:pt})]})}),e.jsx(dt,{children:e.jsx(y8,{score:ir,size:"sm",showScore:!0})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[pt.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(cr,{className:"h-3 w-3"}),pt.email]}),pt.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Un,{className:"h-3 w-3"}),pt.phone]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(((Sr=pt.lead_source_ref)==null?void 0:Sr.name)||pt.lead_source)&&e.jsx(tt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((jr=pt.lead_source_ref)==null?void 0:jr.name)||pt.lead_source}),(ea=pt.tags)==null?void 0:ea.map(Pa=>{var Ii;return e.jsx(tt,{variant:"secondary",className:"text-xs",children:(Ii=Pa.relationship_type)==null?void 0:Ii.name},Pa.id)}),e.jsx(XFe,{contactId:pt.id,tags:j==null?void 0:j.filter(Pa=>Pa.contact_id===pt.id)}),e.jsx(YFe,{deal:Vn})]})}),e.jsx(dt,{children:e.jsx("div",{className:"text-sm",children:ir.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(ir.lastTouchDate),"MMM d, yyyy")]}):e.jsx("span",{className:"text-muted-foreground text-xs italic",children:"Never contacted"})})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:pt.created_at?ms(new Date(pt.created_at),"MMM d, yyyy"):"—"})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(ZFe,{birthday:pt.birthday,homeAnniversary:pt.home_anniversary,contactId:pt.id,contactName:`${pt.first_name}${pt.last_name?" "+pt.last_name:""}`,contactAddress:[pt.address,pt.city,pt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[pt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(Dl(pt.birthday),"MMM d")]}),pt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(bn,{className:"h-3 w-3"}),ms(Dl(pt.home_anniversary),"MMM d")]})]})]})}),e.jsx(dt,{children:e.jsx(GFe,{contact:pt,onEdit:xe,onDelete:Yr,onSnooze:(Pa,Ii)=>{Ne(Pa),Oe(Ii)},showLeadPondAction:Qe,onSendToLeadPond:Cs,showTransferAction:He,onTransfer:hs})})]},pt.id)})})]})})}),Mr>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 ",(fn-1)*fe+1,"–",Math.min(fn*fe,Mr)," of ",Mr.toLocaleString()," contacts"]}),e.jsxs(Zs,{value:String(fe),onValueChange:pt=>{Ve(Number(pt)),ft(1)},children:[e.jsx(Ws,{className:"w-[80px] h-8",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"50",children:"50"}),e.jsx(Mt,{value:"100",children:"100"}),e.jsx(Mt,{value:"250",children:"250"})]})]}),e.jsx("span",{className:"text-xs",children:"per page"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",disabled:fn<=1,onClick:()=>ft(1),children:"First"}),e.jsx(K,{variant:"outline",size:"sm",disabled:fn<=1,onClick:()=>ft(pt=>pt-1),children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",fn," of ",Lr]}),e.jsx(K,{variant:"outline",size:"sm",disabled:fn>=Lr,onClick:()=>ft(pt=>pt+1),children:e.jsx(da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",disabled:fn>=Lr,onClick:()=>ft(Lr),children:"Last"})]})]}),e.jsx(fs,{open:re||!!ce,onOpenChange:pt=>{pt||(oe(!1),xe(null),Wr())},children:e.jsxs(ps,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:ce?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:dn,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(ze,{id:"first_name",value:xt.first_name,onChange:pt=>Es({...xt,first_name:pt.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"last_name",children:"Last Name"}),e.jsx(ze,{id:"last_name",value:xt.last_name,onChange:pt=>Es({...xt,last_name:pt.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:xt.email,onChange:pt=>Es({...xt,email:pt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",value:xt.phone,onChange:pt=>Es({...xt,phone:pt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"address",children:"Address"}),e.jsx(ze,{id:"address",value:xt.address,onChange:pt=>Es({...xt,address:pt.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(ze,{id:"city",value:xt.city,onChange:pt=>Es({...xt,city:pt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:xt.state,onChange:pt=>Es({...xt,state:pt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"zip_code",children:"Zip"}),e.jsx(ze,{id:"zip_code",value:xt.zip_code,onChange:pt=>Es({...xt,zip_code:pt.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(ze,{id:"birthday",type:"date",value:xt.birthday,onChange:pt=>Es({...xt,birthday:pt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(ze,{id:"home_anniversary",type:"date",value:xt.home_anniversary,onChange:pt=>Es({...xt,home_anniversary:pt.target.value})})]})]}),ce&&e.jsx($_e,{contactId:ce.id,currentSpouseContactId:(ce==null?void 0:ce.spouse_contact_id)||null,currentSpouseName:(ce==null?void 0:ce.spouse_name)||null,currentSpouseEmail:(ce==null?void 0:ce.spouse_email)||null,onLink:pt=>q.mutate({contactId:ce.id,spouseContactId:pt}),onUnlink:()=>q.mutate({contactId:ce.id,spouseContactId:null}),isEditing:!0}),e.jsx(qat,{value:xt.lead_source_id,onChange:pt=>Es({...xt,lead_source_id:pt})}),e.jsxs("div",{children:[e.jsx(ve,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:g==null?void 0:g.filter(pt=>pt.active).map(pt=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Oo,{checked:xt.tagIds.includes(pt.id),onCheckedChange:ir=>{Es(ir?{...xt,tagIds:[...xt.tagIds,pt.id]}:{...xt,tagIds:xt.tagIds.filter(Vn=>Vn!==pt.id)})}}),e.jsx("span",{className:"text-sm",children:pt.name})]},pt.id))})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"notes",children:"Notes"}),e.jsx(Er,{id:"notes",value:xt.notes,onChange:pt=>Es({...xt,notes:pt.target.value}),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{oe(!1),xe(null),Wr()},children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:L.isPending||I.isPending,children:[ce?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(Tbs,{open:ge,onOpenChange:ue,relationshipTypes:(g==null?void 0:g.filter(pt=>pt.active))||[],onSuccess:()=>{ue(!1)}}),e.jsx(Pbs,{open:pe,onOpenChange:be,onComplete:()=>be(!1)}),e.jsx(qhe,{open:!!Me,onOpenChange:pt=>{pt||Ne(null)},contactId:Me||"",contactName:Pe}),e.jsx(Hbs,{open:Ce,onOpenChange:rt}),e.jsx(Wbs,{open:Ge,onOpenChange:ct}),e.jsx(att,{open:Lt,onOpenChange:Vt,contactIds:Je,contactNames:Je.map(pt=>{const ir=ur.find(Vn=>Vn.id===pt);return ir?`${ir.first_name} ${ir.last_name||""}`.trim():""}),onComplete:()=>{it([]),ke(new Set),nt(!1)}})]})]})})}function Kbs(){return mt({queryKey:["video-script-categories"],queryFn:async()=>{const{data:t,error:s}=await H.from("video_script_categories").select("*").order("sort_order");if(s)throw s;return t}})}function Zbs(t){return mt({queryKey:["video-scripts",t],queryFn:async()=>{let s=H.from("video_scripts").select("*, category:video_script_categories(*)").eq("is_active",!0).order("title");const{data:r,error:n}=await s;if(n)throw n;return r}})}function Ybs(){const{user:t}=Ds();return mt({queryKey:["user-video-scripts",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await H.from("user_video_scripts").select("*, category:video_script_categories(*)").eq("owner_user_id",t.id).order("title");if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function Xbs(){const{user:t}=Ds(),s=Qt();return Dt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await H.from("user_video_scripts").insert([{owner_user_id:t.id,source_script_id:r.id,category_id:r.category_id,title:r.title,script_text:r.script_text,tags:r.tags,is_custom:!1}]).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["user-video-scripts"]})}})}function Qbs(t){const{user:s}=Ds();return mt({queryKey:["agent-videos",s==null?void 0:s.id,t],queryFn:async()=>{if(!(s!=null&&s.id))return[];let r=H.from("agent_videos").select("*, contact:innercircle_contacts(id, first_name, last_name)").eq("owner_user_id",s.id).order("created_at",{ascending:!1});r=r.eq("is_deleted",!1);const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!(s!=null&&s.id)})}function Jbs(t){return mt({queryKey:["agent-video",t],queryFn:async()=>{const{data:s,error:r}=await H.from("agent_videos").select("*, contact:innercircle_contacts(id, first_name, last_name)").eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function SC(){const{user:t}=Ds(),s=Qt();return Dt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await H.from("agent_videos").insert([{owner_user_id:t.id,contact_id:r.contact_id,bunny_video_id:r.bunny_video_id,playback_url:r.playback_url,thumbnail_url:r.thumbnail_url,preview_url:r.preview_url,duration_seconds:r.duration_seconds,file_size_mb:r.file_size_mb||0,title:r.title,notes:r.notes,task_id:r.task_id,status:r.status||"processing",touch_type:r.touch_type||"video",page_template:"default"}]).select("*, share_token").single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["agent-videos"]}),s.invalidateQueries({queryKey:["storage-usage"]})}})}function e_s(){const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("agent_videos").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["agent-videos"]}),t.invalidateQueries({queryKey:["agent-video",s.id]})}})}function t_s(){const t=Qt();return Dt({mutationFn:async({id:s,bunnyVideoId:r,hardDelete:n=!1})=>{if(console.log("Deleting video:",{id:s,bunnyVideoId:r,hardDelete:n}),r){console.log("Calling bunny-upload delete for videoId:",r);const{data:a,error:o}=await H.functions.invoke("bunny-upload",{body:{action:"delete",videoId:r,isAgentVideo:!0}});o?console.error("Failed to delete from Bunny:",o):console.log("Bunny delete response:",a)}else console.warn("No bunnyVideoId provided, skipping Bunny.net deletion");if(n){console.log("Hard deleting from database:",s);const{error:a}=await H.from("agent_videos").delete().eq("id",s);if(a)throw a}else{console.log("Soft deleting from database:",s);const{error:a}=await H.from("agent_videos").update({is_deleted:!0}).eq("id",s);if(a)throw a}console.log("Video deletion complete")},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-videos"]}),t.invalidateQueries({queryKey:["storage-usage"]})}})}function Hhe(){const{user:t}=Ds();return mt({queryKey:["storage-usage",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await H.from("agent_storage_usage").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s||{user_id:t.id,total_storage_mb:0,storage_tier:"basic",max_storage_mb:1024}},enabled:!!(t!=null&&t.id)})}function Uat(){const{data:t,isLoading:s}=Hhe(),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 pR(t){const{data:s,error:r}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:t,isAgentVideo:!0}});if(r)throw r;return s}async function fR(t){const{data:s,error:r}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}async function _A(t){const{data:s,error:r}=await H.functions.invoke("bunny-upload",{body:{action:"status",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}function s_s(){const{user:t}=Ds(),s=Qt();return Dt({mutationFn:async({contactId:r,videoId:n,notes:a})=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:o}=await H.from("action_types").select("id").eq("name","Video").single();if(!o)throw new Error("Video action type not found");const{data:l,error:i}=await H.from("contact_touch_logs").insert([{owner_user_id:t.id,contact_id:r,action_type_id:o.id,notes:a||`Quick Video Touch - Video ID: ${n}`}]).select().single();if(i)throw i;return l},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-touch-logs"]}),s.invalidateQueries({queryKey:["contacts"]})}})}function r_s(t){return mt({queryKey:["contact-video-replies",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("video_replies").select(` *, video:agent_videos(id, title, thumbnail_url, playback_url) `).eq("contact_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function n_s(t){return mt({queryKey:["client-portal",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("client_portals").select("*").eq("deal_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function lSe(){const t=ci(),s=Qt();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("client_portals").insert({deal_id:r.deal_id,owner_user_id:t,slug:"",is_enabled:r.is_enabled??!0,visibility:r.visibility||"private",require_onboarding:r.require_onboarding??!0,allow_spouse:r.allow_spouse??!1,client_name:r.client_name||null,client_email:r.client_email||null,client_phone:r.client_phone||null,invite_method:r.invite_method||"email"}).select().single();if(a)throw a;return n},onSuccess:(r,n)=>{s.invalidateQueries({queryKey:["client-portal",n.deal_id]})}})}function xR(){const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("client_portals").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function a_s(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("client_portals").update({archived_at:new Date().toISOString(),is_enabled:!1}).eq("id",s).select().single();if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function i_s(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("client_portals").update({archived_at:null}).eq("id",s).select().single();if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function o_s(){const t=Qt();return Dt({mutationFn:async({id:s,dealId:r})=>{await H.from("portal_updates").delete().eq("portal_id",s);const{error:n}=await H.from("client_portals").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function Vat(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("portal_updates").insert({portal_id:s.portal_id,title:s.title,content:s.content||null,video_url:s.video_url||null,is_stage_change:s.is_stage_change||!1}).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["portal-updates",r.portal_id]})}})}function l_s(){const t=ci();return mt({queryKey:["portal-custom-questions",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("portal_custom_questions").select("*").eq("owner_user_id",t).eq("is_active",!0).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function c_s(){const t=ci(),s=Qt();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("portal_custom_questions").insert({owner_user_id:t,question_text:r.question_text,field_type:r.field_type,options:r.options||[],is_required:r.is_required||!1,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function d_s(){const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("portal_custom_questions").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function u_s(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("portal_custom_questions").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function b1(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}`:`https://clients.relevelup.com/${t}`}function h_s({contactId:t}){const s=fr(),r=Qt(),[n,a]=N.useState(null),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState(""),[f,g]=N.useState(""),[b,_]=N.useState(null),j=xR(),w=Vat(),{data:k,isLoading:S}=mt({queryKey:["contact-portals",t],queryFn:async()=>{const{data:U,error:B}=await H.from("deal_pipeline").select("id, deal_name, deal_type").eq("contact_id",t);if(B)throw B;if(!U||U.length===0)return[];const V=U.map(ee=>ee.id),{data:Z,error:X}=await H.from("client_portals").select("*").in("deal_id",V).is("archived_at",null);if(X)throw X;return(Z||[]).map(ee=>({...ee,deal:U.find(Q=>Q.id===ee.deal_id)}))},enabled:!!t}),M=(k==null?void 0:k.map(U=>U.id))||[],{data:L}=mt({queryKey:["contact-portal-updates",M],queryFn:async()=>{if(M.length===0)return{};const{data:U,error:B}=await H.from("portal_updates").select("*").in("portal_id",M).order("created_at",{ascending:!1});if(B)throw B;const V={};return(U||[]).forEach(Z=>{V[Z.portal_id]||(V[Z.portal_id]=Z)}),V},enabled:M.length>0}),I=U=>{navigator.clipboard.writeText(b1(U)),a(U),me.success("Portal link copied!"),setTimeout(()=>a(null),2e3)},O=async U=>{u.trim()&&(await w.mutateAsync({portal_id:U,title:u,content:f||void 0}),c(!1),p(""),g(""),r.invalidateQueries({queryKey:["contact-portal-updates"]}),me.success("Portal update posted!"))},q=async()=>{b&&(await j.mutateAsync({id:b.id,welcome_message:b.welcome_message,next_step_text:b.next_step_text,is_enabled:b.is_enabled,show_post_close_tips:b.show_post_close_tips,review_url:b.review_url}),l(!1),_(null),r.invalidateQueries({queryKey:["contact-portals",t]}),me.success("Portal settings updated!"))};return S||!k||k.length===0?null:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(su,{className:"h-4 w-4"}),"Client Portal"]})}),e.jsx(De,{className:"space-y-3",children:k.map(U=>{var X,ee,Q;const B=((X=U.stage_mapping)==null?void 0:X.length)>0?U.stage_mapping:tNe(((ee=U.deal)==null?void 0:ee.deal_type)||"buyer"),V=B==null?void 0:B[U.current_stage_index??0],Z=L==null?void 0:L[U.id];return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:((Q=U.deal)==null?void 0:Q.deal_name)||"Portal"}),V&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Stage: ",V.label||V.name]})]}),e.jsx(tt,{variant:U.is_enabled?"default":"secondary",className:"text-[10px] flex-shrink-0",children:U.is_enabled?"Active":"Disabled"})]}),Z&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-2",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:Z.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ms(new Date(Z.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:()=>I(U.slug),children:[n===U.slug?e.jsx(va,{className:"h-3 w-3 mr-1"}):e.jsx(gi,{className:"h-3 w-3 mr-1"}),"Copy Link"]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>window.open(b1(U.slug),"_blank"),children:[e.jsx(tn,{className:"h-3 w-3 mr-1"}),"View"]}),e.jsxs(fs,{open:i,onOpenChange:c,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>c(!0),children:[e.jsx(so,{className:"h-3 w-3 mr-1"}),"Post Update"]})}),e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title"}),e.jsx(ze,{value:u,onChange:ie=>p(ie.target.value),placeholder:"e.g. Inspection completed!"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Details (optional)"}),e.jsx(Er,{value:f,onChange:ie=>g(ie.target.value),placeholder:"Add more details...",rows:3})]}),e.jsxs(K,{onClick:()=>O(U.id),disabled:!u.trim()||w.isPending,className:"w-full",children:[e.jsx(Bn,{className:"h-4 w-4 mr-1"}),"Post Update"]})]})]})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{_({...U}),l(!0)},children:[e.jsx(Xo,{className:"h-3 w-3 mr-1"}),"Settings"]})}),e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Portal Settings"})}),b&&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(qr,{checked:b.is_enabled,onCheckedChange:ie=>_({...b,is_enabled:ie})})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Welcome Message"}),e.jsx(Er,{value:b.welcome_message||"",onChange:ie=>_({...b,welcome_message:ie.target.value}),placeholder:"Welcome to your home journey!",rows:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Next Step"}),e.jsx(ze,{value:b.next_step_text||"",onChange:ie=>_({...b,next_step_text:ie.target.value}),placeholder:"What your client should do next..."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Review URL"}),e.jsx(ze,{value:b.review_url||"",onChange:ie=>_({...b,review_url:ie.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Show Post-Close Tips"}),e.jsx(qr,{checked:b.show_post_close_tips,onCheckedChange:ie=>_({...b,show_post_close_tips:ie})})]}),e.jsx(rl,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:q,disabled:j.isPending,className:"flex-1",children:"Save Settings"}),e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/pipeline?deal=${U.deal_id}`),children:[e.jsx(Qa,{className:"h-4 w-4 mr-1"}),"Full Settings"]})]})]})]})]})]}),k.length>1&&e.jsx(rl,{})]},U.id)})})]})}function m_s({contactId:t}){const{data:s}=mt({queryKey:["agent-lead-sites-slugs"],queryFn:async()=>{const{data:l,error:i}=await H.from("lead_sites").select("id, subdomain_slug").eq("is_active",!0);if(i)throw i;return new Map((l||[]).map(c=>[c.id,c.subdomain_slug]))},staleTime:6e5}),r=s&&s.size>0,{data:n,isLoading:a}=mt({queryKey:["contact-property-views",t],queryFn:async()=>{const{data:l,error:i}=await H.rpc("get_contact_property_views",{p_contact_id:t});if(i)throw i;return l||[]},enabled:!!t&&!!r});if(!r||a||!n||n.length===0)return null;const o=l=>{const i=s==null?void 0:s.get(l.lead_site_id);return i?`https://${i}.thelocalmove.com/listing/${l.mls_number}`:null};return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(On,{className:"h-4 w-4 text-primary"})}),"Property Activity",e.jsxs(tt,{variant:"secondary",className:"text-xs ml-auto",children:[n.length," ",n.length===1?"property":"properties"]})]})}),e.jsx(De,{className:"pt-0",children:e.jsx("div",{className:"space-y-1",children:n.map(l=>{const i=o(l),c=l.property_address||`MLS# ${l.mls_number}`;return e.jsxs("a",{href:i||"#",target:"_blank",rel:"noopener noreferrer",onClick:u=>{i||u.preventDefault()},className:"group flex items-center gap-3 p-2.5 rounded-lg hover:bg-muted/60 transition-colors",children:[l.photo_url?e.jsx("div",{className:"h-10 w-10 rounded-lg overflow-hidden flex-shrink-0 bg-muted",children:e.jsx("img",{src:l.photo_url,alt:c,className:"w-full h-full object-cover"})}):e.jsx("div",{className:"h-9 w-9 rounded-lg bg-gradient-to-br from-primary/15 to-primary/5 flex items-center justify-center flex-shrink-0",children:e.jsx(bn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("span",{className:"font-medium text-sm truncate",children:c})}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(un,{className:"h-3 w-3"}),e.jsx("span",{title:ms(new Date(l.viewed_at),"PPp"),children:Uc(new Date(l.viewed_at),{addSuffix:!0})})]})]}),i&&e.jsx(tn,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},l.mls_number)})})})]})}const p_s=["Single Family","Condo","Townhouse","Multi-Family","Land","Commercial"];function JFe({value:t,onChange:s,onAdd:r,suggestions:n,placeholder:a,icon:o}){const[l,i]=N.useState(!1),c=N.useRef(null),u=N.useRef(null);N.useEffect(()=>{const f=g=>{u.current&&!u.current.contains(g.target)&&c.current&&!c.current.contains(g.target)&&i(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const p=n.filter(f=>f.toLowerCase().includes(t.toLowerCase()));return e.jsxs("div",{className:"relative flex-1",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ze,{ref:c,value:t,onChange:f=>{s(f.target.value),i(!0)},onFocus:()=>i(!0),placeholder:a,onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),p.length>0?r(p[0]):r(t))}}),n.length>0&&e.jsx(Eo,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>r(t),children:e.jsx($s,{className:"h-4 w-4"})})]}),l&&p.length>0&&e.jsx("div",{ref:u,className:"absolute z-50 mt-1 w-full max-h-60 overflow-y-auto rounded-md border bg-popover shadow-md",children:p.map(f=>e.jsxs("button",{type:"button",className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors flex items-center gap-2",onClick:()=>{r(f),i(!1)},children:[o||e.jsx(ma,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),f]},f))})]})}function f_s({contactId:t,contactName:s}){var U,B,V;const{user:r}=Ds(),{hasLeadSite:n}=zO(),a=Qt(),[o,l]=N.useState(!1),[i,c]=N.useState(""),[u,p]=N.useState(""),{data:f}=mt({queryKey:["agent-lead-site-config",r==null?void 0:r.id],queryFn:async()=>{const{data:Z,error:X}=await H.from("lead_sites").select("theme_config, mls_market_area").eq("agent_id",r==null?void 0:r.id).eq("is_active",!0).maybeSingle();if(X||!Z)return{cities:[],zipCodes:[]};const ee=Z.theme_config||{},Q=Array.isArray(ee.searchCities)?ee.searchCities:[];Z.mls_market_area&&!Q.includes(Z.mls_market_area)&&Q.unshift(Z.mls_market_area);const ie=Array.isArray(ee.searchZipCodes)?ee.searchZipCodes:[];return{cities:Q,zipCodes:ie}},enabled:!!r}),{data:g,isLoading:b}=mt({queryKey:["contact-property-alert",t],queryFn:async()=>{const{data:Z,error:X}=await H.from("contact_property_alerts").select("*").eq("contact_id",t).maybeSingle();if(X)throw X;return Z},enabled:!!t&&!!r}),[_,j]=N.useState({}),w=()=>{j({is_active:(g==null?void 0:g.is_active)??!0,min_price:(g==null?void 0:g.min_price)??null,max_price:(g==null?void 0:g.max_price)??null,min_beds:(g==null?void 0:g.min_beds)??null,min_baths:(g==null?void 0:g.min_baths)??null,min_sqft:(g==null?void 0:g.min_sqft)??null,max_sqft:(g==null?void 0:g.max_sqft)??null,cities:(g==null?void 0:g.cities)??[],zip_codes:(g==null?void 0:g.zip_codes)??[],property_types:(g==null?void 0:g.property_types)??[],frequency:(g==null?void 0:g.frequency)??"daily"}),l(!0)},k=Dt({mutationFn:async()=>{const Z={contact_id:t,owner_user_id:r.id,is_active:_.is_active??!0,min_price:_.min_price||null,max_price:_.max_price||null,min_beds:_.min_beds||null,min_baths:_.min_baths||null,min_sqft:_.min_sqft||null,max_sqft:_.max_sqft||null,cities:_.cities||[],zip_codes:_.zip_codes||[],property_types:_.property_types||[],frequency:_.frequency||"daily"};if(g!=null&&g.id){const{error:X}=await H.from("contact_property_alerts").update(Z).eq("id",g.id);if(X)throw X}else{const{error:X}=await H.from("contact_property_alerts").insert(Z);if(X)throw X}},onSuccess:()=>{a.invalidateQueries({queryKey:["contact-property-alert",t]}),l(!1),me.success("Property alert saved!")},onError:Z=>{me.error(Z.message||"Failed to save alert")}}),S=Dt({mutationFn:async()=>{if(!(g!=null&&g.id))return;const{error:Z}=await H.from("contact_property_alerts").delete().eq("id",g.id);if(Z)throw Z},onSuccess:()=>{a.invalidateQueries({queryKey:["contact-property-alert",t]}),l(!1),me.success("Property alert removed")}}),M=Z=>{var ee;const X=Z.trim();X&&!((ee=_.cities)!=null&&ee.includes(X))&&j(Q=>({...Q,cities:[...Q.cities||[],X]})),c("")},L=Z=>{var ee;const X=Z.trim();X&&!((ee=_.zip_codes)!=null&&ee.includes(X))&&j(Q=>({...Q,zip_codes:[...Q.zip_codes||[],X]})),p("")},I=Z=>{j(X=>{const ee=X.property_types||[];return{...X,property_types:ee.includes(Z)?ee.filter(Q=>Q!==Z):[...ee,Z]}})};if(!n||b)return null;if(g&&!o)return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:`h-7 w-7 rounded-lg flex items-center justify-center ${g.is_active?"bg-green-500/10":"bg-muted"}`,children:g.is_active?e.jsx(Lm,{className:"h-4 w-4 text-green-600"}):e.jsx(t1,{className:"h-4 w-4 text-muted-foreground"})}),"Property Alerts",e.jsxs(tt,{variant:g.is_active?"default":"secondary",className:"text-xs ml-auto",children:[g.is_active?"Active":"Paused"," · ",g.frequency]})]})}),e.jsxs(De,{className:"pt-0 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5 text-xs",children:[g.min_price||g.max_price?e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(nc,{className:"h-3 w-3"}),g.min_price?`$${(g.min_price/1e3).toFixed(0)}k`:"$0"," - ",g.max_price?`$${(g.max_price/1e3).toFixed(0)}k`:"Any"]}):null,g.min_beds?e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(K4,{className:"h-3 w-3"}),g.min_beds,"+ beds"]}):null,g.min_baths?e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(Ju,{className:"h-3 w-3"}),g.min_baths,"+ baths"]}):null,(U=g.cities)==null?void 0:U.map(Z=>e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(ma,{className:"h-3 w-3"}),Z]},Z)),(B=g.zip_codes)==null?void 0:B.map(Z=>e.jsx(tt,{variant:"outline",children:Z},Z)),(V=g.property_types)==null?void 0:V.map(Z=>e.jsx(tt,{variant:"outline",children:Z},Z))]}),g.last_sent_at&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sent: ",new Date(g.last_sent_at).toLocaleDateString()]}),e.jsx(K,{variant:"outline",size:"sm",onClick:w,className:"w-full",children:"Edit Alert"})]})]});const O=((f==null?void 0:f.cities)||[]).filter(Z=>{var X;return!((X=_.cities)!=null&&X.includes(Z))}),q=((f==null?void 0:f.zipCodes)||[]).filter(Z=>{var X;return!((X=_.zip_codes)!=null&&X.includes(Z))});return o?e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(Lm,{className:"h-4 w-4 text-primary"}),g?"Edit":"Setup"," Property Alert for ",s]})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Alert Active"}),e.jsx(qr,{checked:_.is_active??!0,onCheckedChange:Z=>j(X=>({...X,is_active:Z}))})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(nc,{className:"h-3.5 w-3.5"})," Price Range"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(ze,{type:"number",placeholder:"Min price",value:_.min_price??"",onChange:Z=>j(X=>({...X,min_price:Z.target.value?Number(Z.target.value):null}))}),e.jsx(ze,{type:"number",placeholder:"Max price",value:_.max_price??"",onChange:Z=>j(X=>({...X,max_price:Z.target.value?Number(Z.target.value):null}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(K4,{className:"h-3.5 w-3.5"})," Min Beds"]}),e.jsxs(Zs,{value:_.min_beds?String(_.min_beds):"any",onValueChange:Z=>j(X=>({...X,min_beds:Z==="any"?null:Number(Z)})),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Any"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"any",children:"Any"}),[1,2,3,4,5].map(Z=>e.jsxs(Mt,{value:String(Z),children:[Z,"+"]},Z))]})]})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Ju,{className:"h-3.5 w-3.5"})," Min Baths"]}),e.jsxs(Zs,{value:_.min_baths?String(_.min_baths):"any",onValueChange:Z=>j(X=>({...X,min_baths:Z==="any"?null:Number(Z)})),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Any"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"any",children:"Any"}),[1,1.5,2,2.5,3,4].map(Z=>e.jsxs(Mt,{value:String(Z),children:[Z,"+"]},Z))]})]})]})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(x0,{className:"h-3.5 w-3.5"})," Square Feet"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(ze,{type:"number",placeholder:"Min sqft",value:_.min_sqft??"",onChange:Z=>j(X=>({...X,min_sqft:Z.target.value?Number(Z.target.value):null}))}),e.jsx(ze,{type:"number",placeholder:"Max sqft",value:_.max_sqft??"",onChange:Z=>j(X=>({...X,max_sqft:Z.target.value?Number(Z.target.value):null}))})]})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(ma,{className:"h-3.5 w-3.5"})," Cities"]}),e.jsx(JFe,{value:i,onChange:c,onAdd:M,suggestions:O,placeholder:"Type to search cities..."}),_.cities&&_.cities.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:_.cities.map(Z=>e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[Z,e.jsx("button",{onClick:()=>j(X=>{var ee;return{...X,cities:(ee=X.cities)==null?void 0:ee.filter(Q=>Q!==Z)}}),children:e.jsx(Rr,{className:"h-3 w-3"})})]},Z))})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"mb-1.5",children:"Zip Codes"}),e.jsx(JFe,{value:u,onChange:p,onAdd:L,suggestions:q,placeholder:"Type to search zip codes...",icon:e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:"#"})}),_.zip_codes&&_.zip_codes.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:_.zip_codes.map(Z=>e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[Z,e.jsx("button",{onClick:()=>j(X=>{var ee;return{...X,zip_codes:(ee=X.zip_codes)==null?void 0:ee.filter(Q=>Q!==Z)}}),children:e.jsx(Rr,{className:"h-3 w-3"})})]},Z))})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(bn,{className:"h-3.5 w-3.5"})," Property Types"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:p_s.map(Z=>{var X;return e.jsx(tt,{variant:(X=_.property_types)!=null&&X.includes(Z)?"default":"outline",className:"cursor-pointer",onClick:()=>I(Z),children:Z},Z)})})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"mb-1.5",children:"Frequency"}),e.jsxs(Zs,{value:_.frequency||"daily",onValueChange:Z=>j(X=>({...X,frequency:Z})),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"daily",children:"Daily"}),e.jsx(Mt,{value:"weekly",children:"Weekly"})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>k.mutate(),disabled:k.isPending,className:"flex-1",children:[k.isPending?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(qc,{className:"h-4 w-4 mr-1"}),"Save Alert"]}),e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),g&&e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>S.mutate(),disabled:S.isPending,children:e.jsx(Rr,{className:"h-4 w-4"})})]})]})]}):e.jsx(Ee,{className:"overflow-hidden",children:e.jsx(De,{className:"p-4",children:e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 p-3 rounded-lg border border-dashed border-primary/30 hover:bg-primary/5 transition-colors",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(Lm,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-sm",children:"Set Up Property Alerts"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Automatically email ",s," new listings matching their criteria"]})]})]})})})}function x_s({contactId:t,contactName:s}){var Q;const{user:r}=Ds(),{hasLeadSite:n}=zO(),a=Qt(),[o,l]=N.useState(!1),[i,c]=N.useState(""),[u,p]=N.useState([]),[f,g]=N.useState(!1),[b,_]=N.useState(!1),[j,w]=N.useState(!1),[k,S]=N.useState(""),M=N.useRef(null),L=N.useRef(null),{data:I}=mt({queryKey:["agent-lead-site-cities",r==null?void 0:r.id],queryFn:async()=>{const{data:ie,error:re}=await H.from("lead_sites").select("theme_config, mls_market_area").eq("agent_id",r==null?void 0:r.id).eq("is_active",!0).maybeSingle();if(re||!ie)return[];const oe=ie.theme_config||{},ce=Array.isArray(oe.searchCities)?oe.searchCities:[];return ie.mls_market_area&&!ce.includes(ie.mls_market_area)&&ce.unshift(ie.mls_market_area),ce},enabled:!!r}),{data:O,isLoading:q}=mt({queryKey:["contact-market-report",t],queryFn:async()=>{const{data:ie,error:re}=await H.from("innercircle_contacts").select("market_report_enabled, market_report_cities").eq("id",t).single();if(re)throw re;return ie},enabled:!!t&&!!r});N.useEffect(()=>{const ie=re=>{L.current&&!L.current.contains(re.target)&&M.current&&!M.current.contains(re.target)&&_(!1)};return document.addEventListener("mousedown",ie),()=>document.removeEventListener("mousedown",ie)},[]);const U=()=>{g((O==null?void 0:O.market_report_enabled)??!1),p((O==null?void 0:O.market_report_cities)??[]),l(!0)},B=ie=>{const re=(ie||i).trim();re&&!u.includes(re)&&p([...u,re]),c(""),_(!1)},V=(I||[]).filter(ie=>!u.includes(ie)&&ie.toLowerCase().includes(i.toLowerCase())),Z=Dt({mutationFn:async()=>{const{data:ie,error:re}=await H.functions.invoke("send-market-report",{body:{action:"preview",agentId:r==null?void 0:r.id,cities:(O==null?void 0:O.market_report_cities)??[]}});if(re)throw new Error(re.message||"Failed to generate preview");if(ie&&!ie.ok&&ie.error)throw new Error(ie.error);return ie},onSuccess:ie=>{S(ie.html),w(!0)},onError:ie=>{me.error(ie.message||"Failed to generate preview")}}),X=Dt({mutationFn:async()=>{const{data:ie,error:re}=await H.functions.invoke("send-market-report",{body:{action:"send",agentId:r==null?void 0:r.id,cities:(O==null?void 0:O.market_report_cities)??[],contactIds:[t]}});if(re)throw new Error(re.message||"Failed to send report");if(ie&&!ie.ok&&ie.error)throw new Error(ie.error);return ie},onSuccess:()=>{me.success(`Market report sent to ${s}!`)},onError:ie=>{me.error(ie.message||"Failed to send report")}}),ee=Dt({mutationFn:async()=>{const{error:ie}=await H.from("innercircle_contacts").update({market_report_enabled:f,market_report_cities:u}).eq("id",t);if(ie)throw ie},onSuccess:()=>{a.invalidateQueries({queryKey:["contact-market-report",t]}),l(!1),me.success(f?"Monthly market report enabled!":"Market report disabled")},onError:ie=>{me.error(ie.message||"Failed to save")}});return!n||q?null:O!=null&&O.market_report_enabled&&!o?e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg flex items-center justify-center bg-primary/10",children:e.jsx(No,{className:"h-4 w-4 text-primary"})}),"Monthly Market Report",e.jsx(tt,{variant:"default",className:"text-xs ml-auto",children:"Active"})]})}),e.jsxs(De,{className:"pt-0 space-y-2",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5 text-xs",children:((Q=O.market_report_cities)==null?void 0:Q.length)>0?O.market_report_cities.map(ie=>e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(ma,{className:"h-3 w-3"}),ie]},ie)):e.jsx("span",{className:"text-muted-foreground",children:"Using default market area"})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s," receives a branded market report on the 1st of each month."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Z.mutate(),disabled:Z.isPending,className:"flex-1",children:[Z.isPending?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(On,{className:"h-4 w-4 mr-1"}),"Preview"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>X.mutate(),disabled:X.isPending,className:"flex-1",children:[X.isPending?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4 mr-1"}),"Send Now"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:U,children:"Edit"})]}),e.jsx(fs,{open:j,onOpenChange:w,children:e.jsxs(ps,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsx(_s,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(No,{className:"h-5 w-5 text-primary"}),"Market Report Preview"]})}),e.jsx("div",{className:"flex-1 overflow-y-auto -mx-6 px-6",children:e.jsx("div",{className:"border rounded-lg overflow-hidden",dangerouslySetInnerHTML:{__html:k}})}),e.jsxs("div",{className:"flex gap-2 pt-4 border-t",children:[e.jsxs(K,{onClick:()=>{w(!1),X.mutate()},disabled:X.isPending,className:"flex-1",children:[X.isPending?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4 mr-1"}),"Send to ",s]}),e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Close"})]})]})})]})]}):o?e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(No,{className:"h-4 w-4 text-primary"}),"Market Report for ",s]})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Send Monthly Report"}),e.jsx(qr,{checked:f,onCheckedChange:g})]}),f&&e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(ma,{className:"h-3.5 w-3.5"})," Report Cities"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select cities from your website's configured areas."}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ze,{ref:M,value:i,onChange:ie=>{c(ie.target.value),_(!0)},onFocus:()=>_(!0),placeholder:"Type to search cities...",onKeyDown:ie=>{ie.key==="Enter"&&(ie.preventDefault(),V.length>0?B(V[0]):B())}}),e.jsx(Eo,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>B(),children:e.jsx($s,{className:"h-4 w-4"})})]}),b&&V.length>0&&e.jsx("div",{ref:L,className:"absolute z-50 mt-1 w-full max-h-60 overflow-y-auto rounded-md border bg-popover shadow-md",children:V.map(ie=>e.jsxs("button",{type:"button",className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors flex items-center gap-2",onClick:()=>B(ie),children:[e.jsx(ma,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),ie]},ie))})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:u.map(ie=>e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[ie,e.jsx("button",{onClick:()=>p(u.filter(re=>re!==ie)),children:e.jsx(Rr,{className:"h-3 w-3"})})]},ie))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>ee.mutate(),disabled:ee.isPending,className:"flex-1",children:[ee.isPending?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(qc,{className:"h-4 w-4 mr-1"}),"Save"]}),e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})]}):e.jsx(Ee,{className:"overflow-hidden",children:e.jsx(De,{className:"p-4",children:e.jsxs("button",{onClick:U,className:"w-full flex items-center gap-3 p-3 rounded-lg border border-dashed border-primary/30 hover:bg-primary/5 transition-colors",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(No,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-sm",children:"Enable Monthly Market Report"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Auto-send ",s," a branded market report with real MLS data every month"]})]})]})})})}function g_s({videoId:t}){var l;const{data:s,isLoading:r,error:n}=Jbs(t);if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(ys,{className:"w-full aspect-video rounded-lg"}),e.jsx(ys,{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(Ku,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-medium",children:"Video Unavailable"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"This video has been deleted or is no longer available."})]});const a=i=>{let c=i;return c.includes("iframe.mediadelivery.net/play/")&&(c=c.replace("/play/","/embed/"),c+=(c.includes("?")?"&":"?")+"autoplay=true&responsive=true"),c},o=(l=s.playback_url)==null?void 0:l.includes("iframe.mediadelivery.net");return e.jsxs("div",{className:"space-y-4",children:[s.playback_url?e.jsx("div",{className:"relative w-full aspect-video bg-black rounded-lg overflow-hidden",children:o?e.jsx("iframe",{src:a(s.playback_url),title:s.title||"Video preview",className:"absolute top-0 left-0 w-full h-full",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsx("video",{src:s.playback_url,controls:!0,autoPlay:!0,className:"absolute top-0 left-0 w-full h-full object-contain"})}):e.jsx("div",{className:"w-full aspect-video bg-muted rounded-lg flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Video is still processing..."})}),s.title&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:s.title}),s.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.notes})]})]})}function y_s({contactId:t}){const s=fr(),[r,n]=N.useState(!1),{data:a,isLoading:o}=mt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:f,error:g}=await H.from("deal_tasks").select(` id, title, priority, status, due_date, completed_at, deal:deal_pipeline(id, deal_name) `).eq("contact_id",t).order("status").order("due_date",{ascending:!0,nullsFirst:!1});if(g)throw g;return f},enabled:!!t}),l=async(f,g)=>{const b=g==="done"?"todo":"done";await H.from("deal_tasks").update({status:b,completed_at:b==="done"?new Date().toISOString():null}).eq("id",f),window.dispatchEvent(new CustomEvent("refetch-contact-tasks"))},{refetch:i}=mt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:f,error:g}=await H.from("deal_tasks").select(` id, title, priority, status, due_date, completed_at, deal:deal_pipeline(id, deal_name) `).eq("contact_id",t).order("status").order("due_date",{ascending:!0,nullsFirst:!1});if(g)throw g;return f},enabled:!!t}),c={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"},u=(a==null?void 0:a.filter(f=>f.status!=="done"))||[],p=(a==null?void 0:a.filter(f=>f.status==="done"))||[];return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(va,{className:"h-4 w-4"}),"Tasks",u.length>0&&e.jsx(tt,{variant:"secondary",className:"text-xs",children:u.length})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/tasks"),children:"View All"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>n(!0),children:e.jsx($s,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(De,{className:"space-y-1",children:o?e.jsx(ys,{className:"h-8 w-full"}):u.length===0&&p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tasks yet"}):e.jsxs(e.Fragment,{children:[u.map(f=>e.jsxs("button",{onClick:async()=>{await l(f.id,f.status),i()},className:"w-full text-left flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 transition-colors group",children:[e.jsx("div",{className:"h-4 w-4 rounded-full border-2 border-muted-foreground/30 shrink-0 group-hover:border-primary"}),e.jsxs("span",{className:"text-sm flex-1 truncate",children:[c[f.priority]," ",f.title]}),f.due_date&&e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ms(new Date(f.due_date),"MMM d")})]},f.id)),p.length>0&&e.jsx("div",{className:"pt-1 border-t mt-1",children:e.jsxs("p",{className:"text-[10px] text-muted-foreground px-2 py-1",children:[p.length," completed"]})})]})}),r&&e.jsx(v_s,{contactId:t,open:r,onOpenChange:f=>{n(f),f||i()}})]})}function v_s({contactId:t,open:s,onOpenChange:r}){const[n,a]=N.useState(""),[o,l]=N.useState("medium"),[i,c]=N.useState(),{data:u}=mt({queryKey:["session"],queryFn:async()=>{const{data:f}=await H.auth.getSession();return f.session}}),p=async()=>{var g;if(!n.trim()||!((g=u==null?void 0:u.user)!=null&&g.id))return;const{error:f}=await H.from("deal_tasks").insert([{owner_user_id:u.user.id,contact_id:t,title:n.trim(),priority:o,status:"todo",due_date:i?ms(i,"yyyy-MM-dd"):null}]);if(f){console.error("Task create error:",f);return}r(!1)};return e.jsx(fs,{open:s,onOpenChange:r,children:e.jsxs(ps,{className:"sm:max-w-[400px]",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Add Task"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title"}),e.jsx(ze,{value:n,onChange:f=>a(f.target.value),placeholder:"Task title...",onKeyDown:f=>f.key==="Enter"&&p()})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(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(ze,{type:"date",value:i?ms(i,"yyyy-MM-dd"):"",onChange:f=>c(f.target.value?new Date(f.target.value+"T00:00:00"):void 0)})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{onClick:p,disabled:!n.trim(),children:"Create Task"})]})]})]})})}function b_s({contactId:t}){const s=fr(),{data:r,isLoading:n}=mt({queryKey:["contact-linked-deals",t],queryFn:async()=>{const{data:a,error:o}=await H.from("deal_pipeline").select(` id, deal_name, deal_type, expected_price, property_address, stage:deal_pipeline_stages(id, name, color, icon, is_won_stage, is_lost_stage) `).eq("contact_id",t).order("updated_at",{ascending:!1});if(o)throw o;return a},enabled:!!t});return n||!r||r.length===0?null:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(Gh,{className:"h-4 w-4"}),"Linked Deals"]})}),e.jsx(De,{className:"space-y-2",children:r.map(a=>{const o=a.stage;return e.jsx("button",{onClick:()=>s(`/mission-control/pipeline?deal=${a.id}`),className:"w-full text-left p-3 rounded-lg border hover:bg-accent transition-colors group",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:a.deal_name}),a.property_address&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:a.property_address}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(tt,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&e.jsxs(tt,{variant:"outline",className:"text-[10px] gap-1",style:{borderColor:o.color,color:o.color,backgroundColor:`${o.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:o.color}}),o.name]})]})]}),e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function __s(){var Ge,ct,qe,Ze,Qe;const{contactId:t}=yo(),s=fr(),[r]=Cc(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=eLt(t||""),{data:c}=Ux(),{data:u}=BO(),{data:p}=$O(3650),{data:f}=Uhe(365),{data:g}=r_s(t),{contactsWithScores:b}=Nue(),_=_Ne(),j=wNe(),w=jNe(),k=GYe(),[S,M]=N.useState(!1),[L,I]=N.useState({}),[O,q]=N.useState(!1),[U,B]=N.useState(null),[V,Z]=N.useState(""),[X,ee]=N.useState(void 0),[Q,ie]=N.useState(""),[re,oe]=N.useState(null),[ce,xe]=N.useState(!1),[ge,ue]=N.useState(null),{isGmailConnected:pe,gmailEmail:be}=Wx(),{data:Me}=mt({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:He,error:Je}=await H.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(Je)throw Je;return He},enabled:!!t}),Ne=He=>{if(!He)return null;const Je=He.match(/Video ID:\s*([a-f0-9-]+)/i);return Je?Je[1]:null},Pe=N.useMemo(()=>{if(!b)return[];let He=b.filter(Je=>{var Vt,hs,Ts;const it=n===""||`${Je.first_name} ${Je.last_name}`.toLowerCase().includes(n.toLowerCase())||((Vt=Je.email)==null?void 0:Vt.toLowerCase().includes(n.toLowerCase()))||((hs=Je.phone)==null?void 0:hs.includes(n)),Lt=a==="all"||((Ts=Je.tags)==null?void 0:Ts.some(Cs=>Cs.relationship_type_id===a));return it&&Lt});return o==="not-touched-90"?He=He.filter(Je=>{const it=Je.relationshipScore.daysSinceTouch;return it===null||it>90}):o==="at-risk"?He=He.filter(Je=>Je.relationshipScore.status==="at-risk"):o==="cooling"?He=He.filter(Je=>Je.relationshipScore.status==="cooling"):o==="warm"&&(He=He.filter(Je=>Je.relationshipScore.status==="warm")),He.map(Je=>Je.id)},[b,n,a,o]),Oe=Pe.indexOf(t||""),Te=Oe>0?Pe[Oe-1]:null,ke=Oe1&&Oe!==-1,nt=He=>{const Je=new URLSearchParams;n&&Je.set("search",n),a!=="all"&&Je.set("type",a),o!=="all"&&Je.set("status",o);const it=Je.toString();return`/mission-control/contacts/${He}${it?`?${it}`:""}`},Ae=N.useMemo(()=>{const He=((p==null?void 0:p.filter(it=>it.contact_id===t))||[]).map(it=>{var Ts,Cs,cs;const Lt=Ne(it.notes);let Vt=((Ts=it.action_type)==null?void 0:Ts.name)||"Touch",hs=it.notes;if(Vt==="Other"&&((Cs=it.notes)!=null&&Cs.startsWith("["))){const er=it.notes.indexOf("]");er>0&&(Vt=it.notes.substring(1,er),hs=it.notes.substring(er+1).replace(/^\s*—\s*/,"").trim()||null)}return{id:it.id,type:"touch",completed_at:it.completed_at,name:Vt,color:((cs=it.action_type)==null?void 0:cs.color)||"#3B82F6",notes:hs,videoId:Lt}}),Je=((f==null?void 0:f.filter(it=>it.contact_id===t))||[]).map(it=>({id:it.id,type:"popby",completed_at:it.completed_at,name:"Pop-by",color:"#F97316",notes:it.notes,videoId:null}));return[...He,...Je].sort((it,Lt)=>new Date(Lt.completed_at).getTime()-new Date(it.completed_at).getTime())},[p,f,t]),ft=()=>{var He;l&&(I({first_name:l.first_name||"",last_name:l.last_name||"",email:l.email||"",phone:l.phone||"",address:l.address||"",city:l.city||"",state:l.state||"",zip_code:l.zip_code||"",birthday:l.birthday||"",home_anniversary:l.home_anniversary||"",spouse_name:l.spouse_name||"",spouse_email:l.spouse_email||"",company_name:l.company_name||"",job_title:l.job_title||"",lead_source_id:l.lead_source_id||"",notes:l.notes||"",tagIds:((He=l.tags)==null?void 0:He.map(Je=>Je.relationship_type_id))||[]}),M(!0))},fe=async()=>{await _.mutateAsync({id:t,...L,lead_source_id:L.lead_source_id||null}),M(!1)},Ve=async()=>{confirm("Are you sure you want to delete this contact?")&&(await j.mutateAsync(t),s("/mission-control/contacts"))},et=((Ge=u==null?void 0:u.find(He=>He.id===U))==null?void 0:Ge.name)==="Other",Ce=async()=>{if(!U||et&&!Q.trim())return;const He=X?new Date(X.getFullYear(),X.getMonth(),X.getDate(),12,0,0).toISOString():void 0,Je=et?`[${Q.trim()}]${V?" — "+V:""}`:V;await w.mutateAsync({contactId:t,actionTypeId:U,notes:Je,completedAt:He}),q(!1),B(null),Z(""),ee(void 0),ie("")},rt=(He,Je)=>{pe&&l?(ue({email:He,name:Je||`${l.first_name} ${l.last_name||""}`.trim()}),xe(!0)):window.location.href=`mailto:${He}`};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(cl,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),Be&&e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Te&&s(nt(Te)),disabled:!Te,className:"px-2",children:[e.jsx(cl,{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:[Oe+1," of ",Pe.length]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>ke&&s(nt(ke)),disabled:!ke,className:"px-2",children:[e.jsx("span",{className:"sr-only sm:not-sr-only sm:mr-1",children:"Next"}),e.jsx(da,{className:"h-4 w-4"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end flex-wrap",children:[l.email&&e.jsxs(K,{variant:"outline",onClick:()=>rt(l.email,`${l.first_name} ${l.last_name||""}`.trim()),children:[e.jsx(cr,{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(An,{className:"h-4 w-4 mr-1"}),"Quick Video Touch"]}),e.jsxs(fs,{open:O,onOpenChange:q,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Log Action"]})}),e.jsxs(ps,{className:"max-h-[85vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{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(He=>He.active).map(He=>e.jsxs("button",{onClick:()=>B(He.id),className:` p-3 rounded-lg border text-left transition-all ${U===He.id?"border-primary bg-primary/10":"hover:bg-accent"} `,children:[e.jsx("div",{className:"font-medium",children:He.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:He.description})]},He.id))}),et&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ve,{htmlFor:"custom-action-name",children:"What did you do?"}),e.jsx(ze,{id:"custom-action-name",value:Q,onChange:He=>ie(He.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($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal mt-2",!X&&"text-muted-foreground"),children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),X?ms(X,"PPP"):"Today (default)"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:X,onSelect:ee,disabled:He=>He>new Date,initialFocus:!0,className:It("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(Er,{id:"action-notes",value:V,onChange:He=>Z(He.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(K,{onClick:Ce,disabled:!U||et&&!Q.trim()||w.isPending,className:"w-full",children:[e.jsx(va,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(K,{variant:"outline",onClick:ft,children:[e.jsx(ud,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:Ve,children:e.jsx(Nr,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"bg-card border rounded-lg p-4 sm:p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold",children:[l.first_name," ",l.last_name||""]}),(((ct=l.lead_source_ref)==null?void 0:ct.name)||l.lead_source)&&e.jsx(tt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((qe=l.lead_source_ref)==null?void 0:qe.name)||l.lead_source})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-2 text-muted-foreground",children:[l.email&&e.jsxs("button",{onClick:()=>rt(l.email),className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(cr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:l.email})]}),l.phone&&e.jsxs("a",{href:`tel:${l.phone}`,className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:l.phone})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(B_e,{contact:l}),(Ze=l.tags)==null?void 0:Ze.map(He=>{const Je=c==null?void 0:c.find(it=>it.id===He.relationship_type_id);return Je?e.jsx(tt,{variant:"secondary",className:"text-xs",children:Je.name},He.id):null})]}),e.jsx("div",{className:"mt-2",children:e.jsx(Vbs,{contactId:t})})]})}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs(Ee,{className:"md:col-span-2",children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Contact Information"})}),e.jsx(De,{children:S?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"first_name",children:"First Name"}),e.jsx(ze,{id:"first_name",value:L.first_name,onChange:He=>I({...L,first_name:He.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"last_name",children:"Last Name"}),e.jsx(ze,{id:"last_name",value:L.last_name,onChange:He=>I({...L,last_name:He.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:L.email,onChange:He=>I({...L,email:He.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",value:L.phone,onChange:He=>I({...L,phone:He.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"address",children:"Street Address"}),e.jsx(ze,{id:"address",value:L.address,onChange:He=>I({...L,address:He.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(ve,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:L.city,onChange:He=>I({...L,city:He.target.value}),placeholder:"City"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:L.state,onChange:He=>I({...L,state:He.target.value}),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"zip_code",children:"Zip Code"}),e.jsx(ze,{id:"zip_code",value:L.zip_code,onChange:He=>I({...L,zip_code:He.target.value}),placeholder:"12345"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"birthday",children:"Birthday"}),e.jsx(ze,{id:"birthday",type:"date",value:L.birthday,onChange:He=>I({...L,birthday:He.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(ze,{id:"home_anniversary",type:"date",value:L.home_anniversary,onChange:He=>I({...L,home_anniversary:He.target.value})})]})]}),e.jsx(rl,{}),e.jsx($_e,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:(l==null?void 0:l.spouse_name)||null,currentSpouseEmail:(l==null?void 0:l.spouse_email)||null,onLink:He=>k.mutate({contactId:t,spouseContactId:He}),onUnlink:()=>k.mutate({contactId:t,spouseContactId:null}),isEditing:!0}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"company_name",children:"Company"}),e.jsx(ze,{id:"company_name",value:L.company_name,onChange:He=>I({...L,company_name:He.target.value}),placeholder:"Enter company name"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"job_title",children:"Job Title"}),e.jsx(ze,{id:"job_title",value:L.job_title,onChange:He=>I({...L,job_title:He.target.value}),placeholder:"Enter job title"})]})]}),e.jsx(qat,{value:L.lead_source_id||"",onChange:He=>I({...L,lead_source_id:He})}),e.jsxs("div",{children:[e.jsx(ve,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:c==null?void 0:c.filter(He=>He.active).map(He=>{var Je;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Oo,{checked:(Je=L.tagIds)==null?void 0:Je.includes(He.id),onCheckedChange:it=>{var Lt;I(it?{...L,tagIds:[...L.tagIds||[],He.id]}:{...L,tagIds:(Lt=L.tagIds)==null?void 0:Lt.filter(Vt=>Vt!==He.id)})}}),e.jsx("span",{className:"text-sm",children:He.name})]},He.id)})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"notes",children:"Notes"}),e.jsx(Er,{id:"notes",value:L.notes,onChange:He=>I({...L,notes:He.target.value}),rows:4})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:fe,disabled:_.isPending,children:"Save Changes"}),e.jsx(K,{variant:"outline",onClick:()=>M(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-4",children:[Ae.length>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",ms(new Date(Ae[0].completed_at),"MMM d, yyyy")," ","(",Ae[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(cr,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("button",{onClick:()=>rt(l.email),className:"text-primary hover:underline truncate text-left",children:l.email})]}),l.phone&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Un,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("a",{href:`tel:${l.phone}`,className:"text-primary hover:underline",children:l.phone})]})]}),(l.address||l.city||l.state||l.zip_code)&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ma,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{className:"flex flex-col",children:[l.address&&e.jsx("span",{children:l.address}),(l.city||l.state||l.zip_code)&&e.jsxs("span",{className:"text-muted-foreground",children:[[l.city,l.state].filter(Boolean).join(", "),l.zip_code&&` ${l.zip_code}`]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[l.birthday&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Birthday: ",ms(Dl(l.birthday),"MMMM d")]})]}),l.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Home Anniversary: ",ms(Dl(l.home_anniversary),"MMMM d")]})]}),l.created_at&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($s,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Date Added: ",ms(new Date(l.created_at),"MMMM d, yyyy")]})]})]}),e.jsx(rl,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx($_e,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:l.spouse_name||null,currentSpouseEmail:l.spouse_email||null,onLink:He=>k.mutate({contactId:t,spouseContactId:He}),onUnlink:()=>k.mutate({contactId:t,spouseContactId:null}),isEditing:!1}),(l.company_name||l.job_title)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{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:(Qe=l.tags)!=null&&Qe.length?l.tags.map(He=>{var Je;return e.jsx(tt,{variant:"secondary",children:(Je=He.relationship_type)==null?void 0:Je.name},He.id)}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No relationship types assigned"})})]}),l.notes&&e.jsxs(e.Fragment,{children:[e.jsx(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(Nbs,{contact:l,onLogTouch:()=>q(!0)}),e.jsx(b_s,{contactId:t}),e.jsx(h_s,{contactId:t}),e.jsx(m_s,{contactId:t}),e.jsx(f_s,{contactId:t,contactName:l.first_name}),e.jsx(x_s,{contactId:t,contactName:l.first_name}),e.jsx(y_s,{contactId:t}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Activity Log"})}),e.jsx(De,{children:Ae.length>0?e.jsx("div",{className:"space-y-4",children:Ae.map(He=>{var Je;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[e.jsx("div",{className:"h-8 w-8 rounded-full flex items-center justify-center text-white text-xs",style:{backgroundColor:He.color},children:He.type==="popby"?e.jsx(ko,{className:"h-4 w-4"}):(Je=He.name)==null?void 0:Je.charAt(0)}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:He.name}),He.videoId&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>oe(He.videoId),children:[e.jsx(nl,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ms(new Date(He.completed_at),"MMM d, yyyy h:mm a")}),He.notes&&!He.videoId&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:He.notes})]})]},He.id)})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"})})]}),g&&g.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-4",children:g.map(He=>{var Je,it;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(Je=He.video)!=null&&Je.thumbnail_url?e.jsx("img",{src:He.video.thumbnail_url,alt:He.video.title||"Video",className:"h-12 w-16 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>oe(He.video_id)}):e.jsx("div",{className:"h-12 w-16 bg-muted rounded flex items-center justify-center cursor-pointer hover:bg-muted/80 transition-colors",onClick:()=>oe(He.video_id),children:e.jsx(An,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:["Replied to: ",((it=He.video)==null?void 0:it.title)||"Untitled Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>oe(He.video_id),children:[e.jsx(nl,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ms(new Date(He.created_at),"MMM d, yyyy h:mm a")}),He.message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:['"',He.message,'"']})]})]},He.id)})})})]}),Me&&Me.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Bn,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-3",children:Me.map(He=>e.jsxs(fs,{children:[e.jsx(qi,{asChild:!0,children:e.jsxs("button",{className:"w-full text-left flex items-start gap-3 p-3 rounded-lg border hover:bg-muted/50 transition-colors cursor-pointer",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-sky-500/10 flex items-center justify-center text-sky-600 flex-shrink-0",children:e.jsx(cr,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:He.subject}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["To: ",He.to_email," · ",ms(new Date(He.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground mt-1 flex-shrink-0"})]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5 text-sky-500"}),He.subject]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["To: ",He.to_email," · ",ms(new Date(He.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden rounded-lg border bg-white",children:e.jsx("iframe",{srcDoc:He.body,className:"w-full h-[400px] border-0",sandbox:"",title:`Email: ${He.subject}`})})]})]},He.id))})})]})]}),e.jsx(fs,{open:!!re,onOpenChange:He=>!He&&oe(null),children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Video Preview"})}),re&&e.jsx(g_s,{videoId:re})]})})]})]})}),pe&&l&&ge&&e.jsx(qw,{open:ce,onOpenChange:xe,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:ge.email},gmailEmail:be})]}):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 e7e={Crown:Dm,FileText:Sn,Users:pr,Globe:su,Star:Jn,Phone:Un,MessageSquare:so,PenTool:q_,Video:An,Gift:ko},xye=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function w_s(){var Qe,He;const t=fr(),{user:s}=Ds(),{data:r}=Ux(),{data:n}=sLt(),{data:a}=cLt(),{data:o}=WYe(),{data:l}=BO(),{data:i}=tLt(),c=dLt(),u=rLt(),p=aLt(),f=iLt(),g=oLt(),b=lLt(),_=nLt(),[j,w]=N.useState(null),[k,S]=N.useState(!1),[M,L]=N.useState(null),[I,O]=N.useState(""),[q,U]=N.useState(""),[B,V]=N.useState([]),[Z,X]=N.useState(null),[ee,Q]=N.useState(null),[ie,re]=N.useState(!1),[oe,ce]=N.useState(""),[xe,ge]=N.useState(""),[ue,pe]=N.useState(""),[be,Me]=N.useState(""),Ne=(Je,it)=>a==null?void 0:a.some(Lt=>Lt.plan_id===Je&&Lt.relationship_type_id===it&&Lt.active),Pe=Je=>a==null?void 0:a.find(it=>it.relationship_type_id===Je&&it.active),Oe=async(Je,it)=>{const Lt=Ne(Je,it);await c.mutateAsync({planId:Je,relationshipTypeId:it,active:!Lt})},Te=(n==null?void 0:n.filter(Je=>Je.active&&!Je.owner_user_id))||[],ke=(n==null?void 0:n.filter(Je=>Je.owner_user_id===(s==null?void 0:s.id)))||[],Be=r==null?void 0:r.find(Je=>Je.id===j),nt=j?Pe(j):null,Ae=n==null?void 0:n.find(Je=>Je.id===(nt==null?void 0:nt.plan_id)),ft=async()=>{if(!I.trim())return;const Je=await u.mutateAsync({name:I,description:q});Je&&B.length>0&&await g.mutateAsync({planId:Je.id,items:B}),at()},fe=async()=>{!I.trim()||!M||(await p.mutateAsync({id:M,name:I,description:q}),await g.mutateAsync({planId:M,items:B}),at())},Ve=Je=>{var it;L(Je.id),O(Je.name),U(Je.description||""),V(((it=Je.items)==null?void 0:it.map(Lt=>({month_number:Lt.month_number,action_type_id:Lt.action_type_id,default_script_id:Lt.default_script_id||void 0,notes:Lt.notes||void 0})))||[]),S(!0)},at=()=>{S(!1),L(null),O(""),U(""),V([])},et=(Je,it)=>{Q(it)},Ce=(Je,it,Lt)=>{V(Vt=>[...Vt.filter(Ts=>Ts.month_number!==Je),{month_number:Je,action_type_id:it,default_script_id:Lt}]),X(null),Q(null)},rt=Je=>{V(it=>it.filter(Lt=>Lt.month_number!==Je))},Ge=async()=>{if(!oe.trim()||!xe.trim()||!ee)return;const Je=await b.mutateAsync({actionTypeId:ee,title:oe,scriptBody:xe,emailSubject:ue||void 0,tone:be||void 0});Je&&Z!==null&&Ce(Z,ee,Je.id),re(!1),ce(""),ge(""),pe(""),Me("")},ct=ee?i==null?void 0:i.filter(Je=>Je.action_type_id===ee&&Je.active):[],qe=Je=>e7e[Je||"Phone"]||Un,Ze=Je=>e7e[Je||"Users"]||pr;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(cl,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(K,{onClick:()=>S(!0),className:"w-full sm:w-auto",children:[e.jsx($s,{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(Je=>Je.active).map(Je=>{const it=Ze(Je.icon),Lt=(o==null?void 0:o[Je.id])||0,Vt=Pe(Je.id),hs=n==null?void 0:n.find(Cs=>Cs.id===(Vt==null?void 0:Vt.plan_id)),Ts=j===Je.id;return e.jsxs("button",{onClick:()=>w(Je.id),className:` w-full flex items-center gap-3 p-4 rounded-lg border text-left transition-all ${Ts?"border-primary bg-primary/5 ring-2 ring-primary":"hover:bg-accent"} `,children:[e.jsx(it,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium",children:Je.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Lt," contacts"]})]}),hs?e.jsxs(tt,{variant:"secondary",className:"text-xs",children:[e.jsx(xi,{className:"h-3 w-3 mr-1"}),hs.name.split(" ")[0]]}):e.jsx(tt,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},Je.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:j&&Be?e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[(()=>{const Je=Ze(Be.icon);return e.jsx(Je,{className:"h-5 w-5"})})(),Be.name," Touchpoint Plan"]}),e.jsxs(gr,{children:["Choose a plan for your ",Be.name," contacts"]})]}),e.jsxs(De,{className:"space-y-6",children:[Ae&&e.jsxs("div",{className:"p-4 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(xi,{className:"h-4 w-4 text-green-500"}),"Currently using: ",Ae.name]}),Ae.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ae.description})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>Oe(Ae.id,j),children:"Disable"})]}),Ae.items&&Ae.items.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"12-Month Schedule"]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:xye.map((Je,it)=>{var Ts,Cs;const Lt=((Ts=Ae.items)==null?void 0:Ts.filter(cs=>cs.month_number===it+1))||[],Vt=(Cs=Lt[0])==null?void 0:Cs.action_type,hs=Vt?qe(Vt.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${Lt.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:Je}),hs&&e.jsx(hs,{className:"h-4 w-4 mx-auto mt-1",style:{color:(Vt==null?void 0:Vt.color)||"#3B82F6"}})]},it)})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:Ae?"Switch to a Different Plan":"Choose a Plan"}),Te.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"}),Te.map(Je=>{var Lt;const it=(Ae==null?void 0:Ae.id)===Je.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${it?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Je.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Lt=Je.items)==null?void 0:Lt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Duplicate as my own plan",disabled:_.isPending,onClick:()=>{const Vt=`${Je.name} (Copy)`;_.mutate({sourcePlanId:Je.id,newName:Vt})},children:e.jsx(gi,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:it?"outline":"default",disabled:it||c.isPending,onClick:()=>Oe(Je.id,j),children:it?"Active":"Use This"})]})]},Je.id)})]}),ke.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),ke.map(Je=>{var Lt;const it=(Ae==null?void 0:Ae.id)===Je.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${it?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Je.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Lt=Je.items)==null?void 0:Lt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>Ve(Je),children:e.jsx(Jy,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>f.mutate(Je.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})}),e.jsx(K,{size:"sm",variant:it?"outline":"default",disabled:it||c.isPending,onClick:()=>Oe(Je.id,j),children:it?"Active":"Use This"})]})]},Je.id)})]}),Te.length===0&&ke.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(De,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(hn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"Select a contact group to view and assign plans"})]})})})]}),e.jsx(Ee,{className:"bg-muted/50",children:e.jsx(De,{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(fs,{open:k,onOpenChange:Je=>{Je?S(!0):at()},children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:M?"Edit Touchpoint Plan":"Create Custom Touchpoint Plan"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"plan-name",children:"Plan Name"}),e.jsx(ze,{id:"plan-name",value:I,onChange:Je=>O(Je.target.value),placeholder:"e.g., My VIP Plan"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"plan-description",children:"Description (optional)"}),e.jsx(Er,{id:"plan-description",value:q,onChange:Je=>U(Je.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:xye.map((Je,it)=>{const Lt=it+1,Vt=B.find(Cs=>Cs.month_number===Lt),hs=Vt?l==null?void 0:l.find(Cs=>Cs.id===Vt.action_type_id):null,Ts=hs?qe(hs.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>X(Z===Lt?null:Lt),className:` w-full p-3 rounded-lg border text-center transition-all ${Vt?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${Z===Lt?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:Je}),Ts?e.jsx(Ts,{className:"h-5 w-5 mx-auto mt-1",style:{color:(hs==null?void 0:hs.color)||"#3B82F6"}}):e.jsx($s,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),Vt&&e.jsx("button",{type:"button",onClick:Cs=>{Cs.stopPropagation(),rt(Lt)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:e.jsx(Rr,{className:"h-3 w-3"})})]},it)})}),Z!==null&&!ee&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[e.jsxs("div",{className:"text-sm font-medium mb-2",children:["Step 1: Select action for ",xye[Z-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(Je=>Je.active).map(Je=>{const it=qe(Je.icon);return e.jsxs("button",{type:"button",onClick:()=>et(Z,Je.id),className:"flex items-center gap-2 px-3 py-2 rounded-lg border bg-background hover:bg-accent transition-colors",children:[e.jsx(it,{className:"h-4 w-4",style:{color:Je.color||"#3B82F6"}}),e.jsx("span",{className:"text-sm",children:Je.name})]},Je.id)})})]}),Z!==null&&ee&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm font-medium",children:"Step 2: Select a script (optional)"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Q(null),children:[e.jsx(cl,{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:()=>Ce(Z,ee),className:"w-full flex items-center gap-3 p-3 rounded-lg border bg-background hover:bg-accent transition-colors text-left",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:"No Script"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Use without a predefined script"})]})}),ct==null?void 0:ct.map(Je=>e.jsx("button",{type:"button",onClick:()=>Ce(Z,ee,Je.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:Je.title}),Je.tone&&e.jsx(tt,{variant:"secondary",className:"text-xs mt-1",children:Je.tone}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:[Je.script_body.substring(0,100),"..."]})]})},Je.id)),e.jsxs("button",{type:"button",onClick:()=>re(!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($s,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:"Create Custom Script"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Write your own script for this action"})]})]})]})]})]}),B.length>0&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[B.length," touchpoint",B.length!==1?"s":""," per year"]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:at,children:"Cancel"}),e.jsxs(K,{onClick:M?fe:ft,disabled:!I.trim()||u.isPending||p.isPending,children:[e.jsx(qc,{className:"h-4 w-4 mr-2"}),M?"Save Changes":"Create Plan"]})]})]})}),e.jsx(fs,{open:ie,onOpenChange:re,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{id:"script-title",value:oe,onChange:Je=>ce(Je.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script-tone",children:"Tone (optional)"}),e.jsxs(Zs,{value:be,onValueChange:Me,children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select tone..."})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"friendly",children:"Friendly"}),e.jsx(Mt,{value:"professional",children:"Professional"}),e.jsx(Mt,{value:"casual",children:"Casual"}),e.jsx(Mt,{value:"formal",children:"Formal"})]})]})]}),((He=(Qe=l==null?void 0:l.find(Je=>Je.id===ee))==null?void 0:Qe.name)==null?void 0:He.toLowerCase().includes("email"))&&e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script-email-subject",children:"Email Subject"}),e.jsx(ze,{id:"script-email-subject",value:ue,onChange:Je=>pe(Je.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script-body",children:"Script Content"}),e.jsx(Er,{id:"script-body",value:xe,onChange:Je=>ge(Je.target.value),placeholder:"Write your script here... You can use {{FirstName}} and {{LastName}} as placeholders.",rows:6}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Tip: Use ","{{FirstName}}"," and ","{{LastName}}"," as placeholders"]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>re(!1),children:"Cancel"}),e.jsxs(K,{onClick:Ge,disabled:!oe.trim()||!xe.trim()||b.isPending,children:[e.jsx(qc,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}const j_s="0dde5abb-0005-4c8c-a471-30d0cbc9e280",N_s=[{value:"30",label:"Monthly (30 days)"},{value:"60",label:"Bi-Monthly (60 days)"},{value:"90",label:"Quarterly (90 days)"},{value:"180",label:"Twice a Year (180 days)"},{value:"365",label:"Yearly (365 days)"}];function k_s(){const t=fr(),s=zat(),{data:r}=gbs(),{data:n}=Ux(),{data:a}=iSe(),{data:o}=Uhe(90),{data:l}=Gm(),i=wbs(),c=bbs(),u=vbs(),p=_bs(),{data:f=[],isLoading:g}=mt({queryKey:["popby-templates"],queryFn:async()=>{const{data:ie,error:re}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("category_id",j_s).order("publish_date",{ascending:!1});if(re)throw re;const{data:oe}=await H.from("template_likes").select("template_id"),{data:ce}=await H.from("template_comments").select("template_id"),xe=new Map;oe==null||oe.forEach(ue=>{xe.set(ue.template_id,(xe.get(ue.template_id)||0)+1)});const ge=new Map;return ce==null||ce.forEach(ue=>{ge.set(ue.template_id,(ge.get(ue.template_id)||0)+1)}),(ie||[]).map(ue=>({...ue,likesCount:xe.get(ue.id)||0,commentsCount:ge.get(ue.id)||0}))}}),b=ie=>{const re=l==null?void 0:l.find(oe=>oe.id===ie);return re?`${re.first_name} ${re.last_name||""}`.trim():"Unknown"},_=ie=>{if(!ie)return null;const re=r==null?void 0:r.find(oe=>oe.id===ie);return(re==null?void 0:re.name)||null},[j,w]=N.useState(null),[k,S]=N.useState(!1),[M,L]=N.useState(!1),[I,O]=N.useState(!1),[q,U]=N.useState({popby_item_id:"",notes:""}),[B,V]=N.useState({name:"",description:""}),Z=async()=>{j&&(await c.mutateAsync({contact_id:j.id,popby_item_id:q.popby_item_id||void 0,notes:q.notes||void 0}),S(!1),w(null),U({popby_item_id:"",notes:""}))},X=async()=>{B.name.trim()&&(await u.mutateAsync({name:B.name.trim(),description:B.description.trim()||void 0}),O(!1),V({name:"",description:""}))},ee=async(ie,re)=>{await p.mutateAsync({relationship_type_id:ie,frequency_days:parseInt(re)})},Q=ie=>{var oe;const re=a==null?void 0:a.find(ce=>ce.relationship_type_id===ie);return((oe=re==null?void 0:re.frequency_days)==null?void 0:oe.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(De,{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(De,{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(De,{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(ma,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(K,{variant:"outline",onClick:()=>L(!0),children:[e.jsx(Xo,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),e.jsxs(K,{variant:"outline",onClick:()=>O(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsxs(ba,{defaultValue:"due",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"due",children:"Due for Popby"}),e.jsx(ns,{value:"activity",children:"Recent Activity"}),e.jsx(ns,{value:"library",children:"Popby Library"}),e.jsx(ns,{value:"templates",children:"Popby Templates"})]}),e.jsx(bs,{value:"due",className:"space-y-4 mt-4",children:!s||s.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(ko,{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(ie=>e.jsx(Ee,{className:"hover:shadow-md transition-shadow",children:e.jsx(De,{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:[ie.first_name," ",ie.last_name]}),ie.daysOverdue>0&&e.jsxs(tt,{variant:"destructive",className:"text-xs",children:[ie.daysOverdue,"+ days overdue"]}),ie.daysSinceLastPopby===null&&e.jsx(tt,{variant:"outline",className:"text-xs",children:"Never visited"})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-1 text-sm text-muted-foreground",children:[ie.address&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"}),ie.city||ie.address]}),ie.tags&&ie.tags.length>0&&e.jsx("span",{children:ie.tags.map(re=>{var oe;return(oe=re.relationship_type)==null?void 0:oe.name}).join(", ")})]}),ie.lastPopby&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",ms(new Date(ie.lastPopby),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ie.phone&&e.jsx(K,{size:"sm",variant:"ghost",asChild:!0,children:e.jsx("a",{href:`tel:${ie.phone}`,children:e.jsx(Un,{className:"h-4 w-4"})})}),e.jsxs(K,{size:"sm",onClick:()=>{w(ie),S(!0)},children:[e.jsx(xi,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})},ie.id))})}),e.jsx(bs,{value:"activity",className:"space-y-4 mt-4",children:!o||o.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(un,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No popby activity yet!"}),e.jsx("p",{className:"text-sm mt-1",children:"Start logging popbys to see your history here."})]})}):e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Recent Popby Log"})}),e.jsx(De,{className:"space-y-3",children:o.map(ie=>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(ko,{className:"h-5 w-5 text-orange-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium",children:b(ie.contact_id)}),_(ie.popby_item_id)&&e.jsx(tt,{variant:"secondary",className:"text-xs",children:_(ie.popby_item_id)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ms(new Date(ie.completed_at),"MMM d, yyyy h:mm a")}),ie.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:ie.notes})]})]},ie.id))})]})}),e.jsx(bs,{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(ie=>e.jsx(Ee,{children:e.jsx(De,{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(ko,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-medium",children:ie.name}),ie.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:ie.description}),!ie.owner_user_id&&e.jsx(tt,{variant:"secondary",className:"mt-2 text-xs",children:"Shared"})]})]})})},ie.id)),e.jsx(Ee,{className:"border-dashed cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>O(!0),children:e.jsx(De,{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($s,{className:"h-8 w-8 mx-auto mb-2"}),e.jsx("p",{children:"Add New Popby Idea"})]})})})]})}),e.jsxs(bs,{value:"templates",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[f.length," template",f.length!==1?"s":""," found"]}),g&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(4)].map((ie,re)=>e.jsx(Ee,{children:e.jsxs(De,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ys,{className:"h-5 w-16"}),e.jsx(ys,{className:"h-5 w-20"})]})]})},re))}),!g&&f.length===0&&e.jsx(Ee,{children:e.jsxs(De,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(Ml,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No popby templates available yet!"}),e.jsx("p",{className:"text-sm mt-1",children:"Check back soon for new templates."})]})}),!g&&f.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:f.map(ie=>e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer",onClick:()=>t(`/templates/${ie.id}`),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:ie.preview_image_url?e.jsx("img",{src:ie.preview_image_url,alt:ie.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(De,{className:"p-4 flex flex-col",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:ie.name}),ie.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:wde(ie.description)}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:e.jsx(tt,{variant:"secondary",className:"text-xs",children:"PopBys"})}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:"h-3.5 w-3.5"}),ie.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($c,{className:"h-3.5 w-3.5"}),ie.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:re=>{re.stopPropagation(),t(`/templates/${ie.id}`)},children:[e.jsx(tn,{className:"h-4 w-4"}),"View Template"]})]})]},ie.id))})]})]}),e.jsx(fs,{open:k,onOpenChange:S,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsxs(vs,{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(Zs,{value:q.popby_item_id,onValueChange:ie=>U(re=>({...re,popby_item_id:ie})),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select a popby item..."})}),e.jsx(Gs,{children:r==null?void 0:r.map(ie=>e.jsx(Mt,{value:ie.id,children:ie.name},ie.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Notes (optional)"}),e.jsx(Er,{placeholder:"Any notes about this popby...",value:q.notes,onChange:ie=>U(re=>({...re,notes:ie.target.value}))})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(K,{onClick:Z,disabled:c.isPending,children:"Log Popby"})]})]})}),e.jsx(fs,{open:M,onOpenChange:L,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{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(ie=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx(ve,{className:"font-medium",children:ie.name}),e.jsxs(Zs,{value:Q(ie.id),onValueChange:re=>ee(ie.id,re),children:[e.jsx(Ws,{className:"w-[180px]",children:e.jsx(Xs,{})}),e.jsx(Gs,{children:N_s.map(re=>e.jsx(Mt,{value:re.value,children:re.label},re.value))})]})]},ie.id))]}),e.jsx(qn,{children:e.jsx(K,{onClick:()=>L(!1),children:"Done"})})]})}),e.jsx(fs,{open:I,onOpenChange:O,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{placeholder:"e.g., Homemade cookies",value:B.name,onChange:ie=>V(re=>({...re,name:ie.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Er,{placeholder:"Optional description...",value:B.description,onChange:ie=>V(re=>({...re,description:ie.target.value}))})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(K,{onClick:X,disabled:!B.name.trim()||u.isPending,children:"Add Item"})]})]})})]})})}const S_s=gC({property_address:gc().min(1,"Property address is required"),city:gc().optional(),state:gc().optional(),zip:gc().optional(),transaction_type:LGe(["buyer","seller"]),close_date:gc().min(1,"Close date is required"),sale_price:VL().min(0,"Sale price must be positive"),commission_amount:VL().optional(),lead_source_id:gc().optional(),client_type_id:gc().optional(),contact_id:gc().optional(),notes:gc().optional(),is_win:t3t()});function Hat({open:t,onOpenChange:s,transaction:r}){const[n,a]=N.useState(!1),[o,l]=N.useState(""),[i,c]=N.useState(!1),[u,p]=N.useState(""),f=wue(),g=XLt(),{data:b}=sE(),{data:_}=Ux(),{data:j}=Gm(),w=_ue(),k=kNe(),{data:S}=jue(),M=(S==null?void 0:S.show_commission)??!0,L=mue({resolver:pue(S_s),defaultValues:{property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:new Date().toISOString().split("T")[0],sale_price:0,commission_amount:void 0,lead_source_id:void 0,client_type_id:void 0,contact_id:void 0,notes:"",is_win:!1}});N.useEffect(()=>{r?L.reset({property_address:r.property_address,city:r.city||"",state:r.state||"",zip:r.zip||"",transaction_type:r.transaction_type,close_date:r.close_date,sale_price:Number(r.sale_price),commission_amount:r.commission_amount?Number(r.commission_amount):void 0,lead_source_id:r.lead_source_id||void 0,client_type_id:r.client_type_id||void 0,contact_id:r.contact_id||void 0,notes:r.notes||"",is_win:r.is_win}):L.reset({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:new Date().toISOString().split("T")[0],sale_price:0,commission_amount:void 0,lead_source_id:void 0,client_type_id:void 0,contact_id:void 0,notes:"",is_win:!1})},[r,L]);const I=async B=>{const V={property_address:B.property_address,transaction_type:B.transaction_type,close_date:B.close_date,sale_price:B.sale_price,is_win:B.is_win,commission_amount:B.commission_amount||null,lead_source_id:B.lead_source_id||null,client_type_id:B.client_type_id||null,contact_id:B.contact_id||null,city:B.city||null,state:B.state||null,zip:B.zip||null,notes:B.notes||null};r?await g.mutateAsync({id:r.id,...V}):await f.mutateAsync(V),s(!1)},O=async()=>{if(!o.trim())return;const[B,...V]=o.trim().split(" "),Z=V.join(" ")||null,X=await w.mutateAsync({first_name:B,last_name:Z,tagIds:[]});X&&(L.setValue("contact_id",X.id),l(""),c(!1),a(!1))},q=async()=>{if(!u.trim())return;const B=await k.mutateAsync(u.trim());B&&(L.setValue("lead_source_id",B.id),p(""))},U=j==null?void 0:j.find(B=>B.id===L.watch("contact_id"));return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-lg max-h-[90vh]",children:[e.jsx(_s,{children:e.jsx(vs,{children:r?"Edit Transaction":"Add Transaction"})}),e.jsx(Gi,{className:"max-h-[70vh] pr-4",children:e.jsx(fue,{...L,children:e.jsxs("form",{onSubmit:L.handleSubmit(I),className:"space-y-4",children:[e.jsx(Zc,{control:L.control,name:"property_address",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Property Address *"}),e.jsx(Oc,{children:e.jsx(ze,{placeholder:"123 Main St",...B})}),e.jsx(Sm,{})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(Zc,{control:L.control,name:"city",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"City"}),e.jsx(Oc,{children:e.jsx(ze,{placeholder:"City",...B})})]})}),e.jsx(Zc,{control:L.control,name:"state",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"State"}),e.jsx(Oc,{children:e.jsx(ze,{placeholder:"TX",...B})})]})}),e.jsx(Zc,{control:L.control,name:"zip",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Zip"}),e.jsx(Oc,{children:e.jsx(ze,{placeholder:"75001",...B})})]})})]}),e.jsx(Zc,{control:L.control,name:"transaction_type",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Transaction Type *"}),e.jsxs(Zs,{onValueChange:B.onChange,value:B.value,children:[e.jsx(Oc,{children:e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select type"})})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"})]})]}),e.jsx(Sm,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Zc,{control:L.control,name:"close_date",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Close Date *"}),e.jsx(Oc,{children:e.jsx(ze,{type:"date",...B})}),e.jsx(Sm,{})]})}),e.jsx(Zc,{control:L.control,name:"sale_price",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Sale Price *"}),e.jsx(Oc,{children:e.jsx(ze,{type:"number",placeholder:"0",...B,onChange:V=>B.onChange(Number(V.target.value))})}),e.jsx(Sm,{})]})})]}),M&&e.jsx(Zc,{control:L.control,name:"commission_amount",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Commission"}),e.jsx(Oc,{children:e.jsx(ze,{type:"number",placeholder:"0",...B,value:B.value??"",onChange:V=>B.onChange(V.target.value?Number(V.target.value):void 0)})})]})}),e.jsx(Zc,{control:L.control,name:"lead_source_id",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Lead Source"}),e.jsxs(Zs,{onValueChange:B.onChange,value:B.value||"",children:[e.jsx(Oc,{children:e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select source"})})}),e.jsx(Gs,{children:b==null?void 0:b.map(V=>e.jsx(Mt,{value:V.id,children:V.name},V.id))})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Add custom source...",value:u,onChange:B=>p(B.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:q,disabled:!u.trim(),children:e.jsx($s,{className:"h-4 w-4"})})]}),e.jsx(Zc,{control:L.control,name:"client_type_id",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Client Type"}),e.jsxs(Zs,{onValueChange:B.onChange,value:B.value||"",children:[e.jsx(Oc,{children:e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select client type"})})}),e.jsx(Gs,{children:_==null?void 0:_.map(V=>e.jsx(Mt,{value:V.id,children:V.name},V.id))})]})]})}),e.jsx(Zc,{control:L.control,name:"contact_id",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Client Contact"}),e.jsxs($o,{open:n,onOpenChange:a,children:[e.jsx(qo,{asChild:!0,children:e.jsx(Oc,{children:e.jsxs(K,{variant:"outline",role:"combobox",className:It("w-full justify-between",!B.value&&"text-muted-foreground"),children:[U?`${U.first_name} ${U.last_name||""}`.trim():"Select contact",e.jsx(Sx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsxs(Ro,{className:"w-full p-0",align:"start",children:[e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search contacts..."}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:e.jsxs("div",{className:"p-2 space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"No contact found."}),!i&&e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>c(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add New Contact"]})]})}),e.jsx(Fx,{children:j==null?void 0:j.map(V=>e.jsxs(bp,{value:`${V.first_name} ${V.last_name||""}`,onSelect:()=>{B.onChange(V.id),a(!1)},children:[e.jsx(va,{className:It("mr-2 h-4 w-4",V.id===B.value?"opacity-100":"opacity-0")}),V.first_name," ",V.last_name||""]},V.id))})]})]}),i&&e.jsxs("div",{className:"p-2 border-t space-y-2",children:[e.jsx(ze,{placeholder:"Enter contact name...",value:o,onChange:V=>l(V.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",onClick:O,disabled:!o.trim()||w.isPending,children:"Add Contact"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{c(!1),l("")},children:"Cancel"})]})]})]})]})]})}),e.jsx(Zc,{control:L.control,name:"notes",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Notes"}),e.jsx(Oc,{children:e.jsx(Er,{placeholder:"Any notes about this transaction...",...B})})]})}),e.jsx(Zc,{control:L.control,name:"is_win",render:({field:B})=>e.jsxs(Lc,{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Dc,{children:"Mark as Win 🏆"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Highlight this as a notable success"})]}),e.jsx(Oc,{children:e.jsx(qr,{checked:B.value,onCheckedChange:B.onChange})})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:f.isPending||g.isPending,children:[r?"Update":"Add"," Transaction"]})]})]})})})]})})}function cSe({transactions:t,showCommission:s,isLoading:r,agentNameMap:n,readOnly:a}){const[o,l]=N.useState(null),[i,c]=N.useState(null),[u,p]=N.useState(""),[f,g]=N.useState("all"),[b,_]=N.useState("all"),[j,w]=N.useState("all"),[k,S]=N.useState(!1),M=QLt(),L=wue(),{data:I}=sE(),{data:O}=Ux(),q=NE(),U=Z=>{const{id:X,created_at:ee,updated_at:Q,lead_source:ie,client_type:re,contact:oe,...ce}=Z;L.mutate(ce)},B=()=>{i&&(M.mutate(i),c(null))},V=t.filter(Z=>{var oe,ce,xe,ge;const X=u===""||Z.property_address.toLowerCase().includes(u.toLowerCase())||((ce=(oe=Z.contact)==null?void 0:oe.first_name)==null?void 0:ce.toLowerCase().includes(u.toLowerCase()))||((ge=(xe=Z.contact)==null?void 0:xe.last_name)==null?void 0:ge.toLowerCase().includes(u.toLowerCase())),ee=f==="all"||Z.transaction_type===f,Q=b==="all"||Z.lead_source_id===b,ie=j==="all"||Z.client_type_id===j,re=!k||Z.is_win;return X&&ee&&Q&&ie&&re});return r?e.jsx(Ee,{children:e.jsx(De,{className:"p-6 space-y-4",children:[1,2,3].map(Z=>e.jsx(ys,{className:"h-16 w-full"},Z))})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs(Rt,{children:["Transactions (",V.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search...",value:u,onChange:Z=>p(Z.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs(Zs,{value:f,onValueChange:g,children:[e.jsx(Ws,{className:"w-[100px]",children:e.jsx(Xs,{placeholder:"Type"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"})]})]}),e.jsxs(Zs,{value:b,onValueChange:_,children:[e.jsx(Ws,{className:"w-[130px]",children:e.jsx(Xs,{placeholder:"Lead Source"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Sources"}),I==null?void 0:I.map(Z=>e.jsx(Mt,{value:Z.id,children:Z.name},Z.id))]})]}),e.jsxs(K,{variant:k?"default":"outline",size:"sm",onClick:()=>S(!k),children:[e.jsx(Nc,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx(De,{children:V.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No transactions found"}):q?e.jsx("div",{className:"space-y-3",children:V.map(Z=>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:Z.property_address}),Z.is_win&&e.jsx(Nc,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Z.city,Z.state?`, ${Z.state}`:""]})]}),e.jsx(tt,{variant:Z.transaction_type==="buyer"?"default":"secondary",children:Z.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: "}),IAe(Z.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),Kl(Z.sale_price)]}),s&&Z.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),Kl(Z.commission_amount)]}),Z.lead_source&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Source: "}),Z.lead_source.name]}),Z.contact&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Client: "}),Z.contact.first_name," ",Z.contact.last_name]}),n&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Agent: "}),n[Z.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(Z),children:e.jsx(ud,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>U(Z),children:e.jsx(gi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(Z.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})]},Z.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[n&&e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Property"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Close Date"}),e.jsx(St,{children:"Sale Price"}),s&&e.jsx(St,{children:"Commission"}),e.jsx(St,{children:"Lead Source"}),e.jsx(St,{children:"Client"}),!a&&e.jsx(St,{className:"w-[50px]"})]})}),e.jsx(zn,{children:V.map(Z=>{var X;return e.jsxs(Ss,{children:[n&&e.jsx(dt,{className:"font-medium text-sm",children:n[Z.owner_user_id]||"Unknown"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[Z.is_win&&e.jsx(Nc,{className:"h-4 w-4 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Z.property_address}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Z.city,Z.state?`, ${Z.state}`:""]})]})]})}),e.jsx(dt,{children:e.jsx(tt,{variant:Z.transaction_type==="buyer"?"default":"secondary",children:Z.transaction_type})}),e.jsx(dt,{children:IAe(Z.close_date)}),e.jsx(dt,{children:Kl(Z.sale_price)}),s&&e.jsx(dt,{children:Z.commission_amount?Kl(Z.commission_amount):"-"}),e.jsx(dt,{children:((X=Z.lead_source)==null?void 0:X.name)||"-"}),e.jsx(dt,{children:Z.contact?`${Z.contact.first_name} ${Z.contact.last_name||""}`.trim():"-"}),!a&&e.jsx(dt,{children:e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(mx,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[e.jsxs(Ma,{onClick:()=>l(Z),children:[e.jsx(ud,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ma,{onClick:()=>U(Z),children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(Ma,{onClick:()=>c(Z.id),className:"text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},Z.id)})})]})})})]}),e.jsx(Hat,{open:!!o,onOpenChange:Z=>!Z&&l(null),transaction:o||void 0}),e.jsx(kc,{open:!!i,onOpenChange:Z=>!Z&&c(null),children:e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Delete Transaction?"}),e.jsx(tc,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:B,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function Wat({goals:t,stats:s,year:r,showCommission:n}){const a=new Date().getMonth()+1,o=new Date().getFullYear()===r?a:12,l=12-o,i=(g,b)=>{if(!b||b===0)return null;const _=Math.min(g/b*100,100),j=Math.max(b-g,0),w=l>0?j/l:0,k=o/12*100,S=_>=k?"ahead":_>=k*.8?"on-track":"behind";return{percent:_,remaining:j,pace:w,status:S}},c=i(s.totalTransactions,t.transactions_goal),u=i(s.totalVolume,t.volume_goal),p=n?i(s.totalCommission,t.gci_goal):null,f=g=>{switch(g){case"ahead":return e.jsxs(tt,{className:"bg-green-500 text-white",children:[e.jsx(ul,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return e.jsxs(tt,{variant:"secondary",children:[e.jsx(p0,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return e.jsxs(tt,{variant:"destructive",children:[e.jsx(pS,{className:"h-3 w-3 mr-1"}),"Behind"]});default:return null}};return!t.transactions_goal&&!t.volume_goal&&!t.gci_goal?null:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zm,{className:"h-5 w-5 text-primary"}),e.jsxs(Rt,{children:[r," Goals Progress"]})]})}),e.jsx(De,{children:e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[t.transactions_goal&&c&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Transactions"}),f(c.status)]}),e.jsx(Bi,{value:c.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[s.totalTransactions," of ",t.transactions_goal]}),e.jsxs("span",{children:[Math.round(c.percent),"%"]})]}),c.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Math.ceil(c.pace),"/month to hit goal"]})]}),t.volume_goal&&u&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Volume"}),f(u.status)]}),e.jsx(Bi,{value:u.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Kl(s.totalVolume,!0)," of ",Kl(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 ",Kl(u.pace,!0),"/month"]})]}),n&&t.gci_goal&&p&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"GCI"}),f(p.status)]}),e.jsx(Bi,{value:p.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Kl(s.totalCommission,!0)," of ",Kl(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 ",Kl(p.pace,!0),"/month"]})]})]})})]})}const C_s={light:"",dark:".dark"},Gat=N.createContext(null);function Kat(){const t=N.useContext(Gat);if(!t)throw new Error("useChart must be used within a ");return t}const Zat=N.forwardRef(({id:t,className:s,children:r,config:n,...a},o)=>{const l=N.useId(),i=`chart-${t||l.replace(/:/g,"")}`;return e.jsx(Gat.Provider,{value:{config:n},children:e.jsxs("div",{"data-chart":i,ref:o,className:It("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",s),...a,children:[e.jsx(M_s,{id:i,config:n}),e.jsx(aT,{children:r})]})})});Zat.displayName="Chart";const M_s=({id:t,config:s})=>{const r=Object.entries(s).filter(([n,a])=>a.theme||a.color);return r.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(C_s).map(([n,a])=>` ${a} [data-chart=${t}] { ${r.map(([o,l])=>{var c;const i=((c=l.theme)==null?void 0:c[n])||l.color;return i?` --color-${o}: ${i};`:null}).join(` `)} } `).join(` `)}}):null},Yat=N.forwardRef(({active:t,payload:s,className:r,indicator:n="dot",hideLabel:a=!1,hideIndicator:o=!1,label:l,labelFormatter:i,labelClassName:c,formatter:u,color:p,nameKey:f,labelKey:g},b)=>{const{config:_}=Kat(),j=N.useMemo(()=>{var I;if(a||!(s!=null&&s.length))return null;const[k]=s,S=`${g||k.dataKey||k.name||"value"}`,M=q_e(_,k,S),L=!g&&typeof l=="string"?((I=_[l])==null?void 0:I.label)||l:M==null?void 0:M.label;return i?e.jsx("div",{className:It("font-medium",c),children:i(L,s)}):L?e.jsx("div",{className:It("font-medium",c),children:L}):null},[l,i,s,a,c,_,g]);if(!t||!(s!=null&&s.length))return null;const w=s.length===1&&n!=="dot";return e.jsxs("div",{ref:b,className:It("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[w?null:j,e.jsx("div",{className:"grid gap-1.5",children:s.map((k,S)=>{const M=`${f||k.name||k.dataKey||"value"}`,L=q_e(_,k,M),I=p||k.payload.fill||k.color;return e.jsx("div",{className:It("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",n==="dot"&&"items-center"),children:u&&(k==null?void 0:k.value)!==void 0&&k.name?u(k.value,k.name,k,S,k.payload):e.jsxs(e.Fragment,{children:[L!=null&&L.icon?e.jsx(L.icon,{}):!o&&e.jsx("div",{className:It("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":w&&n==="dashed"}),style:{"--color-bg":I,"--color-border":I}}),e.jsxs("div",{className:It("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:(L==null?void 0:L.label)||k.name})]}),k.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:k.value.toLocaleString()})]})]})},k.dataKey)})})]})});Yat.displayName="ChartTooltip";const T_s=N.forwardRef(({className:t,hideIcon:s=!1,payload:r,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=Kat();return r!=null&&r.length?e.jsx("div",{ref:o,className:It("flex items-center justify-center gap-4",n==="top"?"pb-3":"pt-3",t),children:r.map(i=>{const c=`${a||i.dataKey||"value"}`,u=q_e(l,i,c);return e.jsxs("div",{className:It("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[u!=null&&u.icon&&!s?e.jsx(u.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:i.color}}),u==null?void 0:u.label]},i.value)})}):null});T_s.displayName="ChartLegend";function q_e(t,s,r){if(typeof s!="object"||s===null)return;const n="payload"in s&&typeof s.payload=="object"&&s.payload!==null?s.payload:void 0;let a=r;return r in s&&typeof s[r]=="string"?a=s[r]:n&&r in n&&typeof n[r]=="string"&&(a=n[r]),a in t?t[a]:t[r]}const Wz=["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 dSe({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(De,{className:"py-12 text-center text-muted-foreground",children:"Add transactions to see your performance charts"})}):e.jsxs("div",{className:"grid gap-6",children:[r&&e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Transactions by Month"})}),e.jsx(De,{className:"overflow-hidden",children:e.jsx(Zat,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:e.jsx(aT,{width:"100%",height:"100%",children:e.jsxs(bat,{data:t.transactionsByMonth,margin:{top:5,right:10,left:0,bottom:5},children:[e.jsx(rat,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(aC,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),e.jsx(iC,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),e.jsx(hp,{content:e.jsx(Yat,{})}),e.jsx(I1,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(De,{children:[e.jsx("div",{className:"h-[250px]",children:e.jsx(aT,{width:"100%",height:"100%",children:e.jsxs(_at,{children:[e.jsx(q0,{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(iR,{fill:Wz[o%Wz.length]},`cell-${o}`))}),e.jsx(hp,{formatter:(a,o)=>[`${a} deals`,o]})]})})}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2 justify-center",children:t.leadSourceBreakdown.slice(0,6).map((a,o)=>e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:Wz[o%Wz.length]}}),e.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function A_s(t){if(!t||!t.trim())return null;const s=t.trim(),r=["yyyy-MM-dd","M/d/yyyy","MM/dd/yyyy","M-d-yyyy","MM-dd-yyyy","MM/dd/yy","M/d/yy"];for(const n of r)try{const a=vje(s,n,new Date);if(Pve(a))return ms(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(Pve(n))return ms(n,"yyyy-MM-dd")}catch{}return null}const E_s=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function P_s({open:t,onOpenChange:s}){const[r,n]=N.useState([]),[a,o]=N.useState(!1),[l,i]=N.useState(0),{data:c}=sE(),{data:u}=Ux(),p=wue(),f=()=>{const k=E_s.join(","),S=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),M=`${k} ${S}`,L=new Blob([M],{type:"text/csv"}),I=URL.createObjectURL(L),O=document.createElement("a");O.href=I,O.download="transaction-import-template.csv",O.click(),URL.revokeObjectURL(I)},g=k=>{const S=k.split(` `).filter(L=>L.trim());if(S.length<2)return[];const M=S[0].split(",").map(L=>L.trim().toLowerCase().replace(/['"]/g,""));return S.slice(1).map((L,I)=>{var oe,ce,xe,ge;const O=[];let q="",U=!1;for(const ue of L)ue==='"'?U=!U:ue===","&&!U?(O.push(q.trim()),q=""):q+=ue;O.push(q.trim());const B=ue=>{var be;const pe=M.indexOf(ue);return pe>=0?(be=O[pe])==null?void 0:be.replace(/^["']|["']$/g,"").trim():""},V=(oe=B("transaction_type"))==null?void 0:oe.toLowerCase(),Z=(ce=B("sale_price"))==null?void 0:ce.replace(/[$,]/g,""),X=(xe=B("commission_amount"))==null?void 0:xe.replace(/[$,]/g,""),ee=(ge=B("is_win"))==null?void 0:ge.toLowerCase(),Q=B("close_date"),ie=A_s(Q);let re;return B("property_address")?["buyer","seller"].includes(V)?ie?(!Z||isNaN(Number(Z)))&&(re="Invalid sale price"):re=`Invalid date format: "${Q}" - use MM/DD/YYYY or YYYY-MM-DD`:re='Transaction type must be "buyer" or "seller"':re="Missing property address",{property_address:B("property_address"),city:B("city"),state:B("state"),zip:B("zip"),transaction_type:V==="seller"?"seller":"buyer",close_date:ie||"",sale_price:Number(Z)||0,commission_amount:X?Number(X):null,lead_source_name:B("lead_source"),client_type_name:B("client_type"),is_win:["yes","true","1"].includes(ee),notes:B("notes"),error:re}})},b=k=>{var L;const S=(L=k.target.files)==null?void 0:L[0];if(!S)return;const M=new FileReader;M.onload=I=>{var U;const O=(U=I.target)==null?void 0:U.result,q=g(O);n(q)},M.readAsText(S)},_=async()=>{const k=r.filter(L=>!L.error);if(k.length===0){me.error("No valid transactions to import");return}o(!0),i(0);let S=0,M=0;for(let L=0;LU.name.toLowerCase()===I.lead_source_name.toLowerCase()),q=u==null?void 0:u.find(U=>U.name.toLowerCase()===I.client_type_name.toLowerCase());await p.mutateAsync({property_address:I.property_address,city:I.city||null,state:I.state||null,zip:I.zip||null,transaction_type:I.transaction_type,close_date:I.close_date,sale_price:I.sale_price,commission_amount:I.commission_amount,lead_source_id:(O==null?void 0:O.id)||null,client_type_id:(q==null?void 0:q.id)||null,contact_id:null,notes:I.notes||null,is_win:I.is_win}),S++}catch(O){M++,console.error("Failed to import transaction:",O)}i(Math.round((L+1)/k.length*100))}o(!1),S>0&&me.success(`Imported ${S} transaction${S>1?"s":""}`),M>0&&me.error(`Failed to import ${M} transaction${M>1?"s":""}`),n([]),s(!1)},j=r.filter(k=>!k.error).length,w=r.filter(k=>k.error).length;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Import Transactions"}),e.jsx(Gr,{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(yi,{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(ze,{id:"csv-file",type:"file",accept:".csv",onChange:b})]}),r.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(tt,{variant:"outline",children:[r.length," rows found"]}),j>0&&e.jsxs(tt,{className:"bg-green-500 text-white",children:[e.jsx(va,{className:"h-3 w-3 mr-1"}),j," valid"]}),w>0&&e.jsxs(tt,{variant:"destructive",children:[e.jsx(kl,{className:"h-3 w-3 mr-1"}),w," errors"]})]}),e.jsx(Gi,{className:"h-[200px] border rounded-lg",children:e.jsxs("div",{className:"p-2 space-y-2",children:[r.slice(0,10).map((k,S)=>e.jsxs("div",{className:`p-2 rounded text-sm ${k.error?"bg-destructive/10":"bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:k.property_address||"(no address)"}),e.jsx(tt,{variant:k.transaction_type==="buyer"?"default":"secondary",children:k.transaction_type})]}),e.jsxs("div",{className:"text-muted-foreground",children:[k.close_date," • $",k.sale_price.toLocaleString()]}),k.error&&e.jsx(Eke,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(Pke,{className:"text-xs",children:k.error})})]},S)),r.length>10&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["...and ",r.length-10," more"]})]})}),a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${l}%`}})}),e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:["Importing... ",l,"%"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:_,disabled:j===0||a,children:[e.jsx(li,{className:"h-4 w-4 mr-2"}),"Import ",j," Transaction",j!==1?"s":""]})]})]})]})})}const I_s=gC({transactions_goal:VL().min(0).optional(),volume_goal:VL().min(0).optional(),gci_goal:VL().min(0).optional()});function L_s({open:t,onOpenChange:s,year:r,existingGoals:n}){const a=JLt(),{data:o}=jue(),l=(o==null?void 0:o.show_commission)??!0,i=mue({resolver:pue(I_s),defaultValues:{transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0}});N.useEffect(()=>{n?i.reset({transactions_goal:n.transactions_goal??void 0,volume_goal:n.volume_goal?Number(n.volume_goal):void 0,gci_goal:n.gci_goal?Number(n.gci_goal):void 0}):i.reset({transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0})},[n,i,t]);const c=async u=>{await a.mutateAsync({year:r,transactions_goal:u.transactions_goal??null,volume_goal:u.volume_goal??null,gci_goal:l?u.gci_goal??null:null}),s(!1)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{children:[r," Goals"]}),e.jsx(Gr,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(fue,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(c),className:"space-y-4",children:[e.jsx(Zc,{control:i.control,name:"transactions_goal",render:({field:u})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Transactions Goal"}),e.jsx(Oc,{children:e.jsx(ze,{type:"number",placeholder:"e.g., 24",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(wie,{children:"Total number of deals you want to close"}),e.jsx(Sm,{})]})}),e.jsx(Zc,{control:i.control,name:"volume_goal",render:({field:u})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Volume Goal ($)"}),e.jsx(Oc,{children:e.jsx(ze,{type:"number",placeholder:"e.g., 5000000",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(wie,{children:"Total sales volume you want to achieve"}),e.jsx(Sm,{})]})}),l&&e.jsx(Zc,{control:i.control,name:"gci_goal",render:({field:u})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"GCI Goal ($)"}),e.jsx(Oc,{children:e.jsx(ze,{type:"number",placeholder:"e.g., 150000",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(wie,{children:"Gross commission income target"}),e.jsx(Sm,{})]})}),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 uSe({transactions:t,isLoading:s}){const r=N.useRef(null),n=N.useRef(null),a=N.useRef([]),o=N.useRef(null),{isAdmin:l}=Ds(),[i,c]=N.useState(""),[u,p]=N.useState(!0),[f,g]=N.useState(0),[b,_]=N.useState(!1),j=t.filter(k=>k.latitude!=null&&k.longitude!=null),w=t.filter(k=>k.latitude==null||k.longitude==null);return N.useEffect(()=>{(async()=>{p(!0);try{const{data:S}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();S!=null&&S.value&&c(S.value)}catch(S){console.error("Error fetching mapbox token:",S)}p(!1)})()},[]),N.useEffect(()=>{if(!i||w.length===0||b)return;(async()=>{var M;_(!0);let S=0;for(const L of w){const I=[L.property_address,L.city,L.state,L.zip].filter(Boolean).join(", ");if(I)try{const q=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(I)}.json?access_token=${i}&limit=1`)).json();if((M=q.features)!=null&&M[0]){const[U,B]=q.features[0].center;await H.from("scorecard_transactions").update({latitude:B,longitude:U}).eq("id",L.id),L.latitude=B,L.longitude=U,S++}}catch(O){console.error("Geocode error:",O)}}g(S),_(!1)})()},[i,t]),N.useEffect(()=>{if(!r.current||!i||n.current)return;Ao.accessToken=i;const k=t.filter(L=>L.latitude!=null&&L.longitude!=null);let S=[-98.5795,39.8283],M=4;if(k.length>0){const L=k.reduce((O,q)=>O+q.longitude,0)/k.length,I=k.reduce((O,q)=>O+q.latitude,0)/k.length;S=[L,I],M=k.length===1?12:10}return n.current=new Ao.Map({container:r.current,style:"mapbox://styles/mapbox/light-v11",zoom:M,center:S}),n.current.addControl(new Ao.NavigationControl,"top-right"),()=>{var L;(L=n.current)==null||L.remove(),n.current=null}},[i]),N.useEffect(()=>{var S;if(!n.current||!i)return;a.current.forEach(M=>M.remove()),a.current=[],(S=o.current)==null||S.remove();const k=t.filter(M=>M.latitude!=null&&M.longitude!=null);if(k.forEach(M=>{var B;const L=M.transaction_type==="buyer",I=L?"#3B82F6":"#10B981",O=document.createElement("div");O.className="cursor-pointer",O.innerHTML=`
${L?'':''}
`;const q=new Ao.Popup({offset:25,closeButton:!0}).setHTML(`
${M.property_address}
${M.city?`
${M.city}${M.state?", "+M.state:""} ${M.zip||""}
`:""}
${L?"Buyer":"Seller"} $${Number(M.sale_price).toLocaleString()}
Closed: ${Dl(M.close_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${(B=M.lead_source)!=null&&B.name?" · "+M.lead_source.name:""}
${M.contact?`
Client: ${M.contact.first_name} ${M.contact.last_name||""}
`:""}
`),U=new Ao.Marker(O).setLngLat([M.longitude,M.latitude]).setPopup(q).addTo(n.current);a.current.push(U)}),k.length>1){const M=new Ao.LngLatBounds;k.forEach(L=>M.extend([L.longitude,L.latitude])),n.current.fitBounds(M,{padding:60,maxZoom:13})}else k.length===1&&n.current.flyTo({center:[k[0].longitude,k[0].latitude],zoom:12})},[t,i,b]),u||s?e.jsx(Ee,{children:e.jsx(De,{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(De,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(ma,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"No Transactions Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add transactions to see them plotted on the map."})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#3B82F6"}}),e.jsx("span",{children:"Buyer"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#10B981"}}),e.jsx("span",{children:"Seller"})]}),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[j.length," of ",t.length," mapped",b&&" · Geocoding..."]})]}),e.jsx("div",{ref:r,className:"w-full h-[55vh] rounded-lg shadow-lg border"})]}):e.jsx(Ee,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(kl,{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 Xat=()=>{const{data:t}=Bx();return mt({queryKey:["team-scorecard-members",t==null?void 0:t.teamId],queryFn:async()=>{const{data:s,error:r}=await H.from("team_members").select("user_id").eq("team_id",t.teamId);if(r)throw r;const n=s.map(l=>l.user_id),{data:a,error:o}=await H.from("profiles").select("id, name, email, avatar_url").in("id",n);if(o)throw o;return a||[]},enabled:!!(t!=null&&t.teamId)&&(t==null?void 0:t.role)==="team_leader"})},D_s=t=>{const{data:s}=Bx(),{data:r}=Xat();return mt({queryKey:["team-scorecard-transactions",s==null?void 0:s.teamId,t],queryFn:async()=>{const n=r.map(l=>l.id),{data:a,error:o}=await H.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).in("owner_user_id",n).gte("close_date",`${t}-01-01`).lte("close_date",`${t}-12-31`).order("close_date",{ascending:!1});if(o)throw o;return a},enabled:!!r&&r.length>0})};function O_s(t,s){const r=s.filter(o=>o.owner_user_id===t.id),n=r.reduce((o,l)=>o+Number(l.sale_price),0),a=r.reduce((o,l)=>o+(Number(l.commission_amount)||0),0);return{member:t,totalTransactions:r.length,buyerCount:r.filter(o=>o.transaction_type==="buyer").length,sellerCount:r.filter(o=>o.transaction_type==="seller").length,totalVolume:n,averagePrice:r.length>0?n/r.length:0,totalGCI:a}}function R_s(t,s){return t?t.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2):s[0].toUpperCase()}function F_s({year:t}){var g;const{data:s,isLoading:r}=Xat(),{data:n,isLoading:a}=D_s(t),o=fr(),l=r||a,{aggregate:i,memberStats:c,topPerformer:u,agentNameMap:p,teamChartStats:f}=N.useMemo(()=>{if(!s||!n)return{aggregate:null,memberStats:[],topPerformer:null,agentNameMap:{},teamChartStats:null};const b=s.map(V=>O_s(V,n));b.sort((V,Z)=>Z.totalVolume-V.totalVolume);const _={};s.forEach(V=>{_[V.id]=V.name||V.email});const j=n.length,w=n.reduce((V,Z)=>V+Number(Z.sale_price),0),k=n.reduce((V,Z)=>V+(Number(Z.commission_amount)||0),0),S=n.filter(V=>V.transaction_type==="buyer").length,M=n.filter(V=>V.transaction_type==="seller").length,L={};n.forEach(V=>{var X;const Z=((X=V.lead_source)==null?void 0:X.name)||"Unknown";L[Z]=(L[Z]||0)+1});const I=Object.entries(L).sort((V,Z)=>Z[1]-V[1])[0],O={};n.forEach(V=>{const Z=Dl(V.close_date).toLocaleString("default",{month:"short"});O[Z]=(O[Z]||0)+1});const U=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(V=>({month:V,count:O[V]||0})),B=Object.entries(L).map(([V,Z])=>({name:V,count:Z})).sort((V,Z)=>Z.count-V.count);return{aggregate:{totalTxns:j,buyerCount:S,sellerCount:M,totalVolume:w,avgPrice:j>0?w/j:0,totalGCI:k,topSource:I?{name:I[0],count:I[1]}:null,memberCount:s.length},memberStats:b,topPerformer:b[0]||null,agentNameMap:_,teamChartStats:{transactionsByMonth:U,leadSourceBreakdown:B}}},[s,n]);return l?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[1,2,3,4].map(b=>e.jsx(ys,{className:"h-24"},b))}),e.jsx(ys,{className:"h-64"})]}):!i||c.length===0?e.jsx(Ee,{className:"py-12",children:e.jsxs(De,{className:"text-center space-y-2",children:[e.jsx(pr,{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(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(pr,{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(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(bn,{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(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(nc,{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:Kl(i.totalVolume,!0)})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ul,{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:Kl(i.avgPrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(nc,{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:Kl(i.totalGCI,!0)})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Nc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((g=i.topSource)==null?void 0:g.name)||"-"}),i.topSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.topSource.count," deals"]})]})})]}),u&&u.totalTransactions>0&&e.jsx(Ee,{className:"border-primary/30 bg-primary/5",children:e.jsxs(De,{className:"pt-4 flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center justify-center h-10 w-10 rounded-full bg-primary/10",children:e.jsx(xo,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground",children:["Top Performer — ",t]}),e.jsx("p",{className:"text-lg font-bold",children:u.member.name||u.member.email})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.totalTransactions," deals"]}),e.jsx("p",{className:"font-semibold",children:Kl(u.totalVolume,!0)})]})]})}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Member Performance"})}),e.jsx(De,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"Transactions"}),e.jsx(St,{className:"text-center",children:"B / S"}),e.jsx(St,{className:"text-right",children:"Volume"}),e.jsx(St,{className:"text-right",children:"Avg Price"}),e.jsx(St,{className:"text-right",children:"GCI"}),e.jsx(St,{className:"text-right"})]})}),e.jsx(zn,{children:c.map((b,_)=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[_===0&&b.totalTransactions>0&&e.jsx(xo,{className:"absolute -top-2 -right-2 h-3.5 w-3.5 text-amber-500"}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:b.member.avatar_url||void 0}),e.jsx(kn,{className:"text-xs",children:R_s(b.member.name,b.member.email)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:b.member.name||b.member.email}),b.member.name&&e.jsx("p",{className:"text-xs text-muted-foreground",children:b.member.email})]})]})}),e.jsx(dt,{className:"text-center font-semibold",children:b.totalTransactions}),e.jsxs(dt,{className:"text-center text-sm",children:[b.buyerCount," / ",b.sellerCount]}),e.jsx(dt,{className:"text-right font-medium",children:Kl(b.totalVolume,!0)}),e.jsx(dt,{className:"text-right text-sm",children:Kl(b.averagePrice,!0)}),e.jsx(dt,{className:"text-right font-medium",children:Kl(b.totalGCI,!0)}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>o(`/mission-control/scorecard/${b.member.id}`),children:e.jsx(On,{className:"h-4 w-4"})})})]},b.member.id))})]})})})]}),e.jsxs(ba,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"transactions",children:[e.jsx(Mh,{className:"h-4 w-4 mr-1"}),"All Transactions"]}),e.jsxs(ns,{value:"charts",children:[e.jsx(No,{className:"h-4 w-4 mr-1"}),"Charts"]}),e.jsxs(ns,{value:"map",children:[e.jsx(ma,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(bs,{value:"transactions",children:e.jsx(cSe,{transactions:n||[],showCommission:!0,isLoading:a,agentNameMap:p,readOnly:!0})}),e.jsx(bs,{value:"charts",children:f&&e.jsx(dSe,{stats:f,year:t})}),e.jsx(bs,{value:"map",children:e.jsx(uSe,{transactions:n||[],isLoading:a})})]})]})}const Qat=new Date().getFullYear(),t7e=Array.from({length:10},(t,s)=>Qat-s);function z_s(){var B;const[t,s]=N.useState(Qat),[r,n]=N.useState(!1),[a,o]=N.useState(!1),[l,i]=N.useState(!1),[c,u]=N.useState(!1),[p,f]=N.useState("my"),{data:g}=Bx(),b=(g==null?void 0:g.role)==="team_leader",{data:_,isLoading:j}=SNe(t),{yearStats:w,lifetimeStats:k,showCommission:S}=uXe(t),{data:M,isLoading:L}=dXe(t),{data:I}=jue(),O=e8t(),q=()=>{if(!_||_.length===0)return;const V=["Property Address","City","State","Zip","Transaction Type","Close Date","Sale Price",...S?["Commission"]:[],"Lead Source","Client Type","Contact Name","Is Win","Notes"],Z=_.map(re=>{var oe,ce;return[re.property_address,re.city||"",re.state||"",re.zip||"",re.transaction_type,re.close_date,re.sale_price,...S?[re.commission_amount||""]:[],((oe=re.lead_source)==null?void 0:oe.name)||"",((ce=re.client_type)==null?void 0:ce.name)||"",re.contact?`${re.contact.first_name} ${re.contact.last_name||""}`.trim():"",re.is_win?"Yes":"No",re.notes||""]}),X=[V,...Z].map(re=>re.map(oe=>`"${String(oe).replace(/"/g,'""')}"`).join(",")).join(` `),ee=new Blob([X],{type:"text/csv"}),Q=URL.createObjectURL(ee),ie=document.createElement("a");ie.href=Q,ie.download=`transactions-${t}.csv`,ie.click(),URL.revokeObjectURL(Q)},U=!_||_.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"})]}),b&&e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 w-fit",children:[e.jsx(K,{variant:p==="my"?"default":"ghost",size:"sm",onClick:()=>f("my"),className:"h-8",children:"My Scorecard"}),e.jsxs(K,{variant:p==="team"?"default":"ghost",size:"sm",onClick:()=>f("team"),className:"h-8",children:[e.jsx(pr,{className:"h-4 w-4 mr-1.5"}),"Team"]})]}),p==="team"&&b?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Team Performance"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Aggregate stats and member comparison"})]}),e.jsxs(Zs,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(Ws,{className:"w-[120px]",children:e.jsx(Xs,{})}),e.jsx(Gs,{children:t7e.map(V=>e.jsx(Mt,{value:String(V),children:V},V))})]})]}),e.jsx(F_s,{year:t})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Business Scorecard"}),e.jsx("p",{className:"text-muted-foreground",children:"Track your transactions, goals, and performance"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(Zs,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(Ws,{className:"w-[120px]",children:e.jsx(Xs,{})}),e.jsx(Gs,{children:t7e.map(V=>e.jsx(Mt,{value:String(V),children:V},V))})]}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(!c),children:e.jsx(Xo,{className:"h-4 w-4"})})]})]}),c&&e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsx(Rt,{className:"text-lg",children:"Settings"})}),e.jsx(De,{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(qr,{checked:(I==null?void 0:I.show_commission)??!0,onCheckedChange:V=>O.mutate({show_commission:V})})]})})]}),U&&!j?e.jsx(Ee,{className:"py-12",children:e.jsxs(De,{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(No,{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($s,{className:"h-4 w-4 mr-2"}),"Add Your First Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(li,{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(yi,{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($s,{className:"h-4 w-4 mr-2"}),"Add Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!0),children:[e.jsx(zm,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(li,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(K,{variant:"outline",onClick:q,disabled:U,children:[e.jsx(yi,{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(yi,{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(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(bn,{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:[k.totalTransactions," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(pr,{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(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(nc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Kl(w.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Kl(k.totalVolume,!0)," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ul,{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:Kl(w.averagePrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Nc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((B=w.topLeadSource)==null?void 0:B.name)||"-"}),w.topLeadSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w.topLeadSource.count," deals"]})]})}),S&&e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(nc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Kl(w.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Kl(k.totalCommission,!0)," lifetime"]})]})}),S&&w.totalNetToAgent>0&&w.totalNetToAgent!==w.totalCommission&&e.jsx(Ee,{children:e.jsxs(De,{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(nc,{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:Kl(w.totalNetToAgent,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Kl(k.totalNetToAgent,!0)," lifetime"]})]})})]}),M&&e.jsx(Wat,{goals:M,stats:w,year:t,showCommission:S}),e.jsxs(ba,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"transactions",children:"Transactions"}),e.jsx(ns,{value:"charts",children:"Charts"}),e.jsxs(ns,{value:"map",children:[e.jsx(ma,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(bs,{value:"transactions",children:e.jsx(cSe,{transactions:_||[],showCommission:S,isLoading:j})}),e.jsx(bs,{value:"charts",children:e.jsx(dSe,{stats:w,year:t})}),e.jsx(bs,{value:"map",children:e.jsx(uSe,{transactions:_||[],isLoading:j})})]})]})]})]}),e.jsx(Hat,{open:r,onOpenChange:n}),e.jsx(P_s,{open:a,onOpenChange:o}),e.jsx(L_s,{open:l,onOpenChange:i,year:t,existingGoals:M})]})}function Jat({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=Ds(),[l,i]=N.useState(null),[c,u]=N.useState(!1),[p,f]=N.useState(!1);N.useEffect(()=>{(async()=>{if(!(!t||!o)){u(!0);try{const{data:w,error:k}=await H.from("listing_shares").select("id, share_token, click_count, lead_count").eq("listing_id",r).eq("sharing_agent_id",o.id).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(k)throw k;if(w&&w.share_token)i(w);else if(w&&!w.share_token){const{data:S,error:M}=await H.from("listing_shares").update({share_type:"referral_link"}).eq("id",w.id).select("id, share_token, click_count, lead_count").single();if(M)throw M;i(S)}else{const{data:S,error:M}=await H.from("listing_shares").insert({listing_id:r,sharing_agent_id:o.id,share_type:"referral_link"}).select("id, share_token, click_count, lead_count").single();if(M)throw M;i(S)}}catch(w){console.error("Error creating share link:",w),me.error("Failed to generate share link")}finally{u(!1)}}})()},[t,o,r]);const g=l!=null&&l.share_token?`https://listings.relevelup.com/${n||r}?ref=${l.share_token}`:"",b=async()=>{try{await navigator.clipboard.writeText(g),f(!0),me.success("Link copied to clipboard!"),setTimeout(()=>f(!1),2e3)}catch{me.error("Failed to copy link")}},_=j=>{const w=encodeURIComponent(g),k=encodeURIComponent(`Check out this listing: ${a}`);switch(j){case"email":window.open(`mailto:?subject=${k}&body=${w}`);break;case"text":window.open(`sms:?body=${k}%20${w}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${w}`,"_blank");break}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(pn,{className:"h-5 w-5 text-amber-500"}),"Share & Earn Leads"]}),e.jsx(Gr,{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(ze,{value:c?"Generating...":g,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:b,disabled:c||!g,variant:p?"default":"outline",children:p?e.jsx(va,{className:"h-4 w-4"}):e.jsx(gi,{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:()=>_("email"),disabled:c,children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Email"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>_("text"),disabled:c,children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>_("facebook"),disabled:c,children:[e.jsx(Su,{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(On,{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(pr,{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 B_s={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},$_s={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},q_s={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Gz({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var j,w;const{user:o}=Ds(),{data:l}=nXe(t.id),i=rXe(),[c,u]=N.useState(!1),p=k=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(k),f=((j=t.photos)==null?void 0:j.find(k=>k.is_primary))||((w=t.photos)==null?void 0:w[0]),g=(o==null?void 0:o.id)===t.agent_id,b=async k=>{k.stopPropagation();try{const S=await i.mutateAsync(t.id);me.success(S.saved?"Listing saved!":"Listing removed from saved")}catch{me.error("Failed to save listing")}},_=k=>{if(k.stopPropagation(),o)u(!0);else{const S=`https://listings.relevelup.com/${t.slug||t.id}`;navigator.clipboard.writeText(S),me.success("Link copied to clipboard!")}};return e.jsxs(Ee,{className:"overflow-hidden hover:shadow-lg transition-shadow cursor-pointer group",onClick:s,children:[e.jsxs("div",{className:"relative aspect-[4/3] bg-muted",children:[f?e.jsx("img",{src:f.photo_url,alt:t.property_address||t.city,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(y0,{className:"h-12 w-12"})}),e.jsx(tt,{className:`absolute top-2 left-2 ${B_s[t.status]} text-white border-0`,children:$_s[t.status]}),t.is_featured&&e.jsx("div",{className:"absolute top-2 right-2 p-1.5 bg-amber-500 rounded-full",children:e.jsx(Jn,{className:"h-4 w-4 text-white fill-white"})}),e.jsxs("div",{className:"absolute bottom-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(K,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:b,children:e.jsx(ni,{className:`h-4 w-4 ${l?"fill-pink-500 text-pink-500":""}`})}),e.jsx(K,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:_,title:g?"Copy link":"Share & earn leads",children:g?e.jsx(_d,{className:"h-4 w-4"}):e.jsx(pn,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(Jat,{open:c,onOpenChange:u,listingId:t.id,listingSlug:t.slug||null,listingTitle:t.property_address||`${t.city}, ${t.state}`}),e.jsxs(De,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xl font-bold text-primary",children:p(t.price)}),t.open_to_referrals&&e.jsxs(tt,{variant:"outline",className:"text-xs",children:[e.jsx(pr,{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(ma,{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(Im,{className:"h-4 w-4"}),t.bedrooms," bd"]}),t.bathrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ju,{className:"h-4 w-4"}),t.bathrooms," ba"]}),t.square_footage&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(y0,{className:"h-4 w-4"}),t.square_footage.toLocaleString()," sqft"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsx(tt,{variant:"secondary",className:"text-xs",children:q_s[t.property_type]}),t.agent&&e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[120px]",children:t.agent.name})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(On,{className:"h-3 w-3"}),t.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(_d,{className:"h-3 w-3"}),t.share_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ni,{className:"h-3 w-3"}),t.save_count]})]}),a&&(r||n)&&e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1",onClick:k=>{k.stopPropagation(),r()},children:[e.jsx(ud,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(K,{variant:"destructive",size:"sm",onClick:k=>{k.stopPropagation(),n()},children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})]})}const U_s=[{value:"active",label:"Active"},{value:"coming_soon",label:"Coming Soon"},{value:"price_improvement",label:"Price Improvement"},{value:"under_contract",label:"Under Contract"},{value:"sold",label:"Sold"}],V_s=[{value:"single_family",label:"Single Family"},{value:"condo",label:"Condo"},{value:"townhouse",label:"Townhouse"},{value:"land",label:"Land"},{value:"multi_family",label:"Multi-Family"},{value:"luxury",label:"Luxury"},{value:"commercial",label:"Commercial"},{value:"other",label:"Other"}];function H_s({filters:t,onFiltersChange:s,onClose:r}){const n=()=>{s({sortBy:"newest"})};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(Rt,{className:"text-lg",children:"Filters"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Clear All"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Rr,{className:"h-4 w-4"})})]})]}),e.jsxs(De,{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(Zs,{value:t.status||"all",onValueChange:a=>s({...t,status:a==="all"?void 0:a}),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"All statuses"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Statuses"}),U_s.map(a=>e.jsx(Mt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Property Type"}),e.jsxs(Zs,{value:t.propertyType||"all",onValueChange:a=>s({...t,propertyType:a==="all"?void 0:a}),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"All types"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),V_s.map(a=>e.jsx(Mt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Min Price"}),e.jsx(ze,{type:"number",placeholder:"No minimum",value:t.minPrice||"",onChange:a=>s({...t,minPrice:a.target.value?Number(a.target.value):void 0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Max Price"}),e.jsx(ze,{type:"number",placeholder:"No maximum",value:t.maxPrice||"",onChange:a=>s({...t,maxPrice:a.target.value?Number(a.target.value):void 0})})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Open to Referrals Only"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show only listings accepting buyer referrals"})]}),e.jsx(qr,{checked:t.openToReferrals||!1,onCheckedChange:a=>s({...t,openToReferrals:a||void 0})})]})]})]})}function W_s({leaderboard:t}){const s=n=>{switch(n){case 0:return e.jsx(xo,{className:"h-5 w-5 text-amber-500"});case 1:return e.jsx(o1,{className:"h-5 w-5 text-gray-400"});case 2:return e.jsx(Nc,{className:"h-5 w-5 text-amber-700"});default:return e.jsx("span",{className:"text-sm font-medium text-muted-foreground w-5 text-center",children:n+1})}},r=(n,a)=>!n||n.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"No data yet. Start sharing to climb the leaderboard!"}):e.jsx("div",{className:"space-y-2",children:n.map((o,l)=>e.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${l===0?"bg-gradient-to-r from-amber-500/10 to-amber-500/5 border border-amber-500/20":"bg-muted/50"}`,children:[e.jsx("div",{className:"flex items-center justify-center w-8",children:s(l)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-medium truncate",children:o.name})}),e.jsxs(tt,{variant:l===0?"default":"secondary",children:[o.count," ",a]})]},o.agentId))});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5 text-amber-500"}),"Community Badges"]})}),e.jsx(De,{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(_d,{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(bn,{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(o1,{className:"h-6 w-6 text-purple-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Referral Connector"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Send 3+ referrals"})]}),e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-amber-500/10 to-amber-500/5 border border-amber-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-amber-500/20 flex items-center justify-center",children:e.jsx(xo,{className:"h-6 w-6 text-amber-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Community MVP"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Top performer"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Community Leaderboard"})}),e.jsx(De,{children:e.jsxs(ba,{defaultValue:"sharers",children:[e.jsxs(pa,{className:"w-full",children:[e.jsxs(ns,{value:"sharers",className:"flex-1",children:[e.jsx(_d,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),e.jsxs(ns,{value:"listers",className:"flex-1",children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"Top Contributors"]})]}),e.jsx(bs,{value:"sharers",className:"mt-4",children:r(t==null?void 0:t.topSharers,"shares")}),e.jsx(bs,{value:"listers",className:"mt-4",children:r(t==null?void 0:t.topListers,"listings")})]})})]})]})}const s7e={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},r7e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function G_s(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function K_s({listings:t,isLoading:s}){const r=fr(),n=N.useRef(null),a=N.useRef(null),o=N.useRef([]),{isAdmin:l}=Ds(),[i,c]=N.useState(""),[u,p]=N.useState(!0),[f,g]=N.useState(!1),b=t.filter(j=>j.latitude!=null&&j.longitude!=null),_=t.filter(j=>(j.latitude==null||j.longitude==null)&&(j.property_address||j.city));return N.useEffect(()=>{(async()=>{p(!0);try{const{data:w}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();w!=null&&w.value&&c(w.value)}catch(w){console.error("Error fetching mapbox token:",w)}p(!1)})()},[]),N.useEffect(()=>{if(!i||_.length===0||f)return;(async()=>{var w;g(!0);for(const k of _){const S=[k.property_address,k.city,k.state].filter(Boolean).join(", ");if(S)try{const L=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(S)}.json?access_token=${i}&limit=1`)).json();if((w=L.features)!=null&&w[0]){const[I,O]=L.features[0].center;await H.from("listings").update({latitude:O,longitude:I}).eq("id",k.id),k.latitude=O,k.longitude=I}}catch(M){console.error("Geocode error:",M)}}g(!1)})()},[i,t]),N.useEffect(()=>{if(!n.current||!i||a.current)return;Ao.accessToken=i;const j=t.filter(S=>S.latitude!=null&&S.longitude!=null);let w=[-98.5795,39.8283],k=4;if(j.length>0){const S=j.reduce((L,I)=>L+I.longitude,0)/j.length,M=j.reduce((L,I)=>L+I.latitude,0)/j.length;w=[S,M],k=j.length===1?12:10}return a.current=new Ao.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:k,center:w}),a.current.addControl(new Ao.NavigationControl,"top-right"),()=>{var S;(S=a.current)==null||S.remove(),a.current=null}},[i]),N.useEffect(()=>{if(!a.current||!i)return;o.current.forEach(w=>w.remove()),o.current=[];const j=t.filter(w=>w.latitude!=null&&w.longitude!=null);if(j.forEach(w=>{var O,q,U;const k=s7e[w.status]||"#10B981",S=((O=w.photos)==null?void 0:O.find(B=>B.is_primary))||((q=w.photos)==null?void 0:q[0]),M=document.createElement("div");M.className="cursor-pointer",M.innerHTML=`
`;const L=new Ao.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${S!=null&&S.photo_url?``:""}
${G_s(w.price)}
${w.property_address||""}
${w.city}, ${w.state}
${r7e[w.status]||w.status} ${w.bedrooms?`${w.bedrooms} bed`:""} ${w.bathrooms?`${w.bathrooms} bath`:""}
${(U=w.agent)!=null&&U.name?`
Listed by ${w.agent.name}
`:""}
Click to view details →
`),I=new Ao.Marker(M).setLngLat([w.longitude,w.latitude]).setPopup(L).addTo(a.current);o.current.push(I)}),j.length>1){const w=new Ao.LngLatBounds;j.forEach(k=>w.extend([k.longitude,k.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]),N.useEffect(()=>(window.__navigateToListing__=j=>{r(`/mission-control/listings/${j}`)},()=>{delete window.__navigateToListing__}),[r]),u||s?e.jsx(Ee,{children:e.jsx(De,{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(De,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(ma,{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(s7e).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:r7e[j]})]},j)),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[b.length," of ",t.length," mapped",f&&" · Geocoding..."]})]}),e.jsx("div",{ref:n,className:"w-full h-[60vh] rounded-lg shadow-lg border"})]}):e.jsx(Ee,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(kl,{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 Z_s(){var B,V,Z,X,ee,Q,ie,re;const t=fr(),{brokerageId:s}=Ds(),{data:r,isLoading:n}=QYe(),[a,o]=N.useState("feed"),[l,i]=N.useState(!1),[c,u]=N.useState(""),[p,f]=N.useState({sortBy:"newest"}),{data:g,isLoading:b}=JYe({...p,city:c||p.city}),{data:_,isLoading:j}=OLt(),{data:w,isLoading:k}=eXe(),{data:S,isLoading:M}=BLt(),{data:L,isLoading:I}=ULt(),{data:O}=qLt(),q=sXe(),U=async oe=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await q.mutateAsync(oe),me.success("Listing deleted successfully")}catch{me.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($s,{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(De,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(bn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(g==null?void 0:g.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Listings"})]})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-pink-500/10 rounded-lg",children:e.jsx(ni,{className:"h-5 w-5 text-pink-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(_==null?void 0:_.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved"})]})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-emerald-500/10 rounded-lg",children:e.jsx(Y4,{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(De,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:e.jsx(pr,{className:"h-5 w-5 text-sky-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(((B=S==null?void 0:S.sent)==null?void 0:B.length)||0)+(((V=S==null?void 0:S.received)==null?void 0:V.length)||0)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Referrals"})]})]})})]}),e.jsxs(ba,{value:a,onValueChange:o,children:[e.jsxs(pa,{className:"w-full justify-start overflow-x-auto",children:[e.jsx(ns,{value:"feed",children:"Community Feed"}),s&&e.jsx(ns,{value:"brokerage",children:"Brokerage"}),e.jsx(ns,{value:"my-listings",children:"My Listings"}),e.jsx(ns,{value:"saved",children:"Saved"}),e.jsx(ns,{value:"referrals",children:"Referrals"}),e.jsx(ns,{value:"map",children:"Map"}),e.jsx(ns,{value:"leaderboard",children:"Leaderboard"})]}),e.jsxs(bs,{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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by city or neighborhood...",value:c,onChange:oe=>u(oe.target.value),className:"pl-9"})]}),e.jsxs(Zs,{value:p.sortBy,onValueChange:oe=>f({...p,sortBy:oe}),children:[e.jsx(Ws,{className:"w-[180px]",children:e.jsx(Xs,{placeholder:"Sort by"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"newest",children:"Newest First"}),e.jsx(Mt,{value:"updated",children:"Recently Updated"}),e.jsx(Mt,{value:"price_asc",children:"Price: Low to High"}),e.jsx(Mt,{value:"price_desc",children:"Price: High to Low"})]})]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!l),children:[e.jsx(Xg,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&e.jsx(H_s,{filters:p,onFiltersChange:f,onClose:()=>i(!1)}),b?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((oe,ce)=>e.jsxs(Ee,{children:[e.jsx(ys,{className:"h-48 w-full"}),e.jsxs(De,{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-1/2"}),e.jsx(ys,{className:"h-4 w-1/4"})]})]},ce))}):(g==null?void 0:g.length)===0?e.jsx(Ee,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(bn,{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($s,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:g==null?void 0:g.map(oe=>e.jsx(Gz,{listing:oe,onClick:()=>t(`/mission-control/listings/${oe.id}`)},oe.id))})]}),e.jsx(bs,{value:"my-listings",className:"space-y-4",children:k?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((oe,ce)=>e.jsxs(Ee,{children:[e.jsx(ys,{className:"h-48 w-full"}),e.jsxs(De,{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-1/2"})]})]},ce))}):(w==null?void 0:w.length)===0?e.jsx(Ee,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(Y4,{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($s,{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(oe=>e.jsx(Gz,{listing:oe,showActions:!0,onClick:()=>t(`/mission-control/listings/${oe.id}`),onEdit:()=>t(`/mission-control/listings/${oe.id}/edit`),onDelete:()=>U(oe.id)},oe.id))})}),e.jsx(bs,{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((oe,ce)=>e.jsxs(Ee,{children:[e.jsx(ys,{className:"h-48 w-full"}),e.jsxs(De,{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-1/2"})]})]},ce))}):(_==null?void 0:_.length)===0?e.jsx(Ee,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(ni,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No saved listings"}),e.jsx("p",{className:"text-muted-foreground",children:"Save listings to quickly access them later"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:_==null?void 0:_.map(oe=>e.jsx(Gz,{listing:oe.listing,onClick:()=>t(`/mission-control/listings/${oe.listing.id}`)},oe.id))})}),e.jsx(bs,{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(_d,{className:"h-4 w-4"}),"Referrals Sent (",((Z=S==null?void 0:S.sent)==null?void 0:Z.length)||0,")"]}),((X=S==null?void 0:S.sent)==null?void 0:X.length)===0?e.jsx(Ee,{children:e.jsx(De,{className:"py-8 text-center text-muted-foreground",children:"No referrals sent yet"})}):e.jsx("div",{className:"space-y-3",children:(ee=S==null?void 0:S.sent)==null?void 0:ee.map(oe=>{var ce,xe;return e.jsx(Ee,{children:e.jsx(De,{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:oe.buyer_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((ce=oe.listing)==null?void 0:ce.property_address)||((xe=oe.listing)==null?void 0:xe.city)})]}),e.jsx(tt,{variant:oe.status==="closed"?"default":"secondary",children:oe.status.replace("_"," ")})]})})},oe.id)})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),"Referrals Received (",((Q=S==null?void 0:S.received)==null?void 0:Q.length)||0,")"]}),((ie=S==null?void 0:S.received)==null?void 0:ie.length)===0?e.jsx(Ee,{children:e.jsx(De,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):e.jsx("div",{className:"space-y-3",children:(re=S==null?void 0:S.received)==null?void 0:re.map(oe=>{var ce;return e.jsx(Ee,{children:e.jsxs(De,{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:oe.buyer_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["From: ",(ce=oe.sender)==null?void 0:ce.name]})]}),e.jsx(tt,{variant:oe.status==="closed"?"default":"secondary",children:oe.status.replace("_"," ")})]}),e.jsx(K,{size:"sm",variant:"outline",className:"w-full mt-2",onClick:()=>t(`/mission-control/listings/${oe.listing_id}`),children:"View Listing"})]})},oe.id)})})]})]})}),s&&e.jsx(bs,{value:"brokerage",className:"space-y-4",children:I?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((oe,ce)=>e.jsxs(Ee,{children:[e.jsx(ys,{className:"h-48 w-full"}),e.jsxs(De,{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-1/2"})]})]},ce))}):(L==null?void 0:L.length)===0?e.jsx(Ee,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(Y4,{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($s,{className:"h-4 w-4 mr-2"}),"Add a Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:L==null?void 0:L.map(oe=>e.jsx(Gz,{listing:oe,onClick:()=>t(`/mission-control/listings/${oe.id}`)},oe.id))})}),e.jsx(bs,{value:"map",children:e.jsx(K_s,{listings:g||[],isLoading:b})}),e.jsx(bs,{value:"leaderboard",children:e.jsx(W_s,{leaderboard:O})})]})]})}):e.jsx(Ms,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(Ee,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(bn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Coming Soon"}),e.jsx("p",{className:"text-muted-foreground",children:"Listing Exchange is currently in development. Check back soon!"})]})})})}function yx(t){const s=t.expected_commission;if(!s)return null;if((t.commission_calc_method||"standard")==="referral_first"){let a=s;t.referral_fee_pct&&(a-=s*(t.referral_fee_pct/100));let o=a;return t.brokerage_split_pct&&(o-=a*(t.brokerage_split_pct/100)),t.team_split_pct&&(o-=s*(t.team_split_pct/100)),t.franchise_fee_pct&&(o-=s*(t.franchise_fee_pct/100)),t.transaction_fee&&(o-=t.transaction_fee),Math.max(0,o)}let n=s;return t.brokerage_split_pct&&(n-=s*(t.brokerage_split_pct/100)),t.team_split_pct&&(n-=s*(t.team_split_pct/100)),t.franchise_fee_pct&&(n-=s*(t.franchise_fee_pct/100)),t.referral_fee_pct&&(n-=s*(t.referral_fee_pct/100)),t.transaction_fee&&(n-=t.transaction_fee),Math.max(0,n)}function Whe(){const t=ci();return mt({queryKey:["deal-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function eit(){const t=ci(),s=Qt();return Dt({mutationFn:async()=>{if(!t)throw new Error("Not authenticated");const{error:r}=await H.rpc("initialize_deal_pipeline_stages",{p_user_id:t});if(r)throw r},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-stages"]})}})}function Ghe(){const t=ci();return mt({queryKey:["deal-pipeline-deals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("deal_pipeline").select(` *, contact:innercircle_contacts(id, first_name, last_name, email, phone), listing:listings(id, property_address, city, state, price, status, created_at) `).eq("owner_user_id",t).order("updated_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function tit(){const t=ci(),s=Qt();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("deal_pipeline").insert({deal_name:r.deal_name,deal_type:r.deal_type,stage_id:r.stage_id||null,contact_id:r.contact_id||null,listing_id:r.listing_id||null,property_address:r.property_address||null,city:r.city||null,state:r.state||null,zip_code:r.zip_code||null,expected_price:r.expected_price||null,expected_commission:r.expected_commission||null,commission_percentage:r.commission_percentage||3,target_close_date:r.target_close_date||null,contract_date:r.contract_date||null,listing_date:r.listing_date||null,priority:r.priority||"medium",probability:r.probability||50,notes:r.notes||null,owner_user_id:t}).select().single();if(a)throw a;return await H.from("deal_activities").insert([{deal_id:n.id,activity_type:"system",title:"Deal created",description:`Deal "${r.deal_name}" was created`}]),n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-deals"]}),s.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function sit(){const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("deal_pipeline").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function Y_s(){const t=Qt();return Dt({mutationFn:async({dealId:s,stageId:r,stageName:n})=>{const{data:a,error:o}=await H.from("deal_pipeline").update({stage_id:r}).eq("id",s).select().single();if(o)throw o;return await H.from("deal_activities").insert({deal_id:s,activity_type:"stage_change",title:`Moved to ${n}`,metadata:{new_stage_id:r,new_stage_name:n}}),a},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-activities"]})}})}function X_s(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("deal_pipeline").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function Q_s(t){return mt({queryKey:["deal-activities",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_activities").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function J_s(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("deal_activities").insert([{deal_id:s.deal_id,activity_type:s.activity_type,title:s.title,description:s.description||null}]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-activities",r.deal_id]})}})}function ews(t){return mt({queryKey:["deal-checklist",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_checklist_items").select("*").eq("deal_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function tws(){const t=Qt();return Dt({mutationFn:async({id:s,is_completed:r,deal_id:n})=>{const{data:a,error:o}=await H.from("deal_checklist_items").update({is_completed:r,completed_at:r?new Date().toISOString():null}).eq("id",s).select().single();if(o)throw o;return a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-checklist",r.deal_id]})}})}function sws(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("deal_checklist_items").insert([{deal_id:s.deal_id,title:s.title,description:s.description||null,due_date:s.due_date||null,sort_order:s.sort_order||0}]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-checklist",r.deal_id]})}})}function rws(){const t=ci();return mt({queryKey:["deal-pipeline-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("deal_pipeline").select("*, deal_pipeline_stages(name, is_won_stage, is_lost_stage)").eq("owner_user_id",t);if(r)throw r;const n=(s==null?void 0:s.filter(i=>{var c,u,p;return!((c=i.deal_pipeline_stages)!=null&&c.is_won_stage)&&!((u=i.deal_pipeline_stages)!=null&&u.is_lost_stage)&&((p=i.deal_pipeline_stages)==null?void 0:p.name)!=="Cancelled"}))||[],a=(s==null?void 0:s.filter(i=>{var c;return(c=i.deal_pipeline_stages)==null?void 0:c.is_won_stage}))||[],o=new Date().getFullYear(),l=a.filter(i=>{const c=i.actual_close_date;return c?new Date(c).getFullYear()===o:!0});return{totalDeals:(s==null?void 0:s.length)||0,activeDeals:n.length,wonDeals:a.length,pipelineValue:n.reduce((i,c)=>i+(c.expected_price||0),0),expectedCommission:n.reduce((i,c)=>i+(c.expected_commission||0),0),expectedNetToAgent:n.reduce((i,c)=>i+(yx(c)||0),0),wonValue:a.reduce((i,c)=>i+(c.expected_price||0),0),weightedGCI:n.reduce((i,c)=>{const u=(c.probability??50)/100;return i+(c.expected_commission||0)*u},0),weightedNet:n.reduce((i,c)=>{const u=(c.probability??50)/100;return i+(yx(c)||0)*u},0),ytdWonDeals:l.length,ytdWonGCI:l.reduce((i,c)=>i+(c.expected_commission||0),0),ytdWonNet:l.reduce((i,c)=>i+(yx(c)||0),0),projectedAnnualNet:l.reduce((i,c)=>i+(yx(c)||0),0)+n.reduce((i,c)=>{const u=(c.probability??50)/100;return i+(yx(c)||0)*u},0)}},enabled:!!t})}function nws(t){const s=ci();return mt({queryKey:["deal-by-listing",t,s],queryFn:async()=>{if(!s||!t)return null;const{data:r,error:n}=await H.from("deal_pipeline").select(` *, deal_pipeline_stages(id, name, color) `).eq("owner_user_id",s).eq("listing_id",t).maybeSingle();if(n)throw n;return r},enabled:!!s&&!!t})}function aws(){const t=Qt();return Dt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await H.from("deal_pipeline").update({listing_id:r}).eq("id",s).select().single();if(a)throw a;return await H.from("deal_activities").insert({deal_id:s,activity_type:"system",title:"Linked to Listing Exchange",description:"This deal is now synced with Listing Exchange",metadata:{listing_id:r}}),n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-by-listing",r.listingId]})}})}function iws(){const t=Qt();return Dt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await H.from("deal_pipeline").update({listing_id:null}).eq("id",s).select().single();if(a)throw a;return{data:n,listingId:r}},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-by-listing",s.listingId]})}})}function ows({listing:t}){const s=fr(),[r,n]=N.useState(""),[a,o]=N.useState(!1),{data:l,isLoading:i}=nws(t.id),{data:c,isLoading:u}=Whe(),{data:p,isLoading:f}=Ghe(),g=eit(),b=aws(),_=iws(),j=tit(),w=(p==null?void 0:p.filter(I=>!I.listing_id))||[],k=I=>{if(!(c!=null&&c.length))return null;switch(I){case"coming_soon":case"active":case"price_improvement":return c.find(O=>O.name==="Active");case"under_contract":return c.find(O=>O.name==="Under Contract");case"sold":return c.find(O=>O.is_won_stage);default:return c.find(O=>O.name==="Active")}},S=async()=>{o(!0);try{c!=null&&c.length||await g.mutateAsync();const I=k(t.status);await j.mutateAsync({deal_name:t.property_address?`${t.property_address}, ${t.city}`:`${t.city}, ${t.state}`,deal_type:"seller",stage_id:(I==null?void 0:I.id)||null,listing_id:t.id,property_address:t.property_address,city:t.city,state:t.state,expected_price:t.price,expected_commission:t.price*.03,commission_percentage:3,priority:"medium",probability:50}),me.success("Deal created and linked to listing!")}catch(I){console.error("Failed to create deal:",I),me.error("Failed to create deal")}finally{o(!1)}},M=async()=>{if(!r){me.error("Please select a deal");return}try{await b.mutateAsync({dealId:r,listingId:t.id}),me.success("Listing linked to deal!"),n("")}catch{me.error("Failed to link listing")}},L=async()=>{if(l)try{await _.mutateAsync({dealId:l.id,listingId:t.id}),me.success("Listing unlinked from deal")}catch{me.error("Failed to unlink listing")}};return i||u?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2 text-base",children:[e.jsx(h0,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsx(De,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?e.jsxs(Ee,{className:"border-primary/20 bg-primary/5",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"flex items-center gap-2 text-base",children:[e.jsx(dl,{className:"h-4 w-4 text-primary"}),"Linked to Pipeline"]})}),e.jsxs(De,{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:l.deal_name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:l.deal_pipeline_stages&&e.jsx(tt,{variant:"secondary",className:"text-xs",style:{backgroundColor:`${l.deal_pipeline_stages.color}20`,color:l.deal_pipeline_stages.color},children:l.deal_pipeline_stages.name})})]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Status changes sync automatically between the listing and pipeline."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>s("/mission-control/pipeline"),children:["View Pipeline",e.jsx(Qa,{className:"h-3 w-3 ml-1"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:L,disabled:_.isPending,children:_.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(xS,{className:"h-4 w-4"})})]})]})]}):e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"flex items-center gap-2 text-base",children:[e.jsx(h0,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsxs(De,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link this listing to your pipeline to track the deal and sync status changes."}),e.jsxs(K,{onClick:S,disabled:a||j.isPending,className:"w-full",size:"sm",children:[a||j.isPending?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx($s,{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(Zs,{value:r,onValueChange:n,children:[e.jsx(Ws,{className:"flex-1 text-sm",children:e.jsx(Xs,{placeholder:"Link to existing deal..."})}),e.jsx(Gs,{children:w.map(I=>e.jsx(Mt,{value:I.id,children:I.deal_name},I.id))})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:M,disabled:!r||b.isPending,children:b.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(dl,{className:"h-4 w-4"})})]})]})]})]})}const lws={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},cws={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},n7e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function dws(){var ee,Q,ie,re,oe,ce,xe,ge,ue;const{listingId:t}=yo(),s=fr(),{user:r}=Ds(),{data:n,isLoading:a}=tXe(t||""),{data:o}=nXe(t||""),{data:l}=FLt(t||""),i=rXe(),c=RLt(),u=zLt(),p=sXe(),f=$Lt(),[g,b]=N.useState(!1),[_,j]=N.useState(!1),[w,k]=N.useState(!1),[S,M]=N.useState(null),[L,I]=N.useState({buyerName:"",buyerType:"",notes:""}),O=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),q=pe=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(pe),U=async pe=>{const be=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,Me=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;u.mutate({listingId:n.id,shareType:pe});try{switch(pe){case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(be)}`,"_blank");break;case"copy":await navigator.clipboard.writeText(be),me.success("Link copied to clipboard!");break;case"text":window.open(`sms:?body=${encodeURIComponent(`${Me} ${be}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent(Me)}&body=${encodeURIComponent(`Check out this listing: ${be}`)}`);break}}catch(Ne){console.error("Share error:",Ne),me.error("Failed to share")}},B=async()=>{try{await p.mutateAsync(n.id),me.success("Listing deleted"),s("/mission-control/listings")}catch{me.error("Failed to delete listing")}},V=async()=>{if(!L.buyerName.trim()){me.error("Please enter buyer name");return}try{await f.mutateAsync({listingId:n.id,listingAgentId:n.agent_id,buyerName:L.buyerName,buyerType:L.buyerType||void 0,notes:L.notes||void 0}),me.success("Referral sent successfully!"),j(!1),I({buyerName:"",buyerType:"",notes:""})}catch{me.error("Failed to send referral")}},Z=pe=>{var ke,Be;const be=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,Me=q((n==null?void 0:n.price)||0),Ne=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",Pe=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",Oe=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",Te=[Ne,Pe,Oe].filter(Boolean).join(" | ");switch(pe){case"just_listed":return`🏡 JUST LISTED! ${be} ${Me} ${Te} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(ke=n==null?void 0:n.city)==null?void 0:ke.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${be} Now ${Me}! ${Te} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${n7e[(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! ${Te} DM me for details! 📩 #ComingSoon #RealEstate #${(Be=n==null?void 0:n.city)==null?void 0:Be.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(ys,{className:"h-10 w-32"}),e.jsx(ys,{className:"h-[400px] w-full"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsx(ys,{className:"h-48"}),e.jsx(ys,{className:"h-48"}),e.jsx(ys,{className:"h-48"})]})]})});if(!n)return e.jsx(Ms,{title:"Listing Not Found",description:"",children:e.jsx(Ee,{children:e.jsxs(De,{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 X=((ee=n.photos)==null?void 0:ee.find(pe=>pe.is_primary))||((Q=n.photos)==null?void 0:Q[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(Ja,{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:()=>X&&M(X.photo_url),children:X?e.jsx("img",{src:X.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:(ie=n.photos)==null?void 0:ie.slice(1,5).map((pe,be)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>M(pe.photo_url),children:e.jsx("img",{src:pe.photo_url,alt:`Photo ${be+2}`,className:"w-full h-full object-cover"})},pe.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(De,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(tt,{className:`${lws[n.status]} text-white border-0`,children:cws[n.status]}),n.is_featured&&e.jsxs(tt,{variant:"outline",className:"border-amber-500 text-amber-500",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1 fill-amber-500"}),"Featured"]}),n.open_to_referrals&&e.jsxs(tt,{variant:"outline",children:[e.jsx(pr,{className:"h-3 w-3 mr-1"}),"Open to Referrals"]})]}),e.jsx("h1",{className:"text-3xl font-bold text-primary mb-2",children:q(n.price)}),n.property_address&&e.jsx("p",{className:"text-xl font-medium",children:n.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ma,{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(ni,{className:`h-4 w-4 ${o?"fill-pink-500 text-pink-500":""}`})}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>c.mutate(n.id),children:l?e.jsx(t1,{className:"h-4 w-4"}):e.jsx(Lm,{className:"h-4 w-4"})}),!O&&e.jsxs(K,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>k(!0),children:[e.jsx(pn,{className:"h-4 w-4 mr-2"}),"Share & Earn Leads"]}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(_d,{className:"h-4 w-4 mr-2"}),"Share"]})}),e.jsxs(Bd,{children:[e.jsxs(Ma,{onClick:()=>U("copy"),children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),e.jsxs(Ma,{onClick:()=>U("facebook"),children:[e.jsx(Su,{className:"h-4 w-4 mr-2"}),"Facebook"]}),e.jsxs(Ma,{onClick:()=>U("text"),children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(Ma,{onClick:()=>U("email"),children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Email"]})]})]}),O&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/listings/${n.id}/edit`),children:[e.jsx(ud,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>b(!0),children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 py-4 border-y",children:[n.bedrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(Im,{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(Ju,{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(y0,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.square_footage.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sq Ft"})]}),n.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.year_built}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"pt-4 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(tt,{variant:"secondary",children:[e.jsx(ka,{className:"h-3 w-3 mr-1"}),n7e[n.property_type]]}),n.lot_size&&e.jsxs(tt,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&e.jsx(tt,{variant:"secondary",children:"HOA"})]}),n.description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium mb-2",children:"Description"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.description})]}),n.agent_notes&&n.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.agent_notes})]}),n.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:n.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{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(On,{className:"h-4 w-4"}),n.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(_d,{className:"h-4 w-4"}),n.share_count," shares"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ni,{className:"h-4 w-4"}),n.save_count," saves"]})]})]})}),n.allow_sharing&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Share Content"})}),e.jsx(De,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(pe=>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:[pe.replace("_"," ")," Caption"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(Z(pe)),me.success("Caption copied!")},children:e.jsx(gi,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:Z(pe)})]},pe))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Listing Agent"})}),e.jsxs(De,{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:((oe=(re=n.agent)==null?void 0:re.name)==null?void 0:oe.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((ce=n.agent)==null?void 0:ce.name)||"Unknown"}),((ge=(xe=n.agent)==null?void 0:xe.brokerage)==null?void 0:ge.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:n.agent.brokerage.name})]})]}),!O&&e.jsx("div",{className:"space-y-2",children:((ue=n.agent)==null?void 0:ue.email)&&e.jsx(K,{variant:"outline",className:"w-full",asChild:!0,children:e.jsxs("a",{href:`mailto:${n.agent.email}`,children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Email Agent"]})})})]})]}),O&&e.jsx(ows,{listing:n}),!O&&n.open_to_referrals&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"Send a Buyer"]})}),e.jsxs(De,{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(fs,{open:!!S,onOpenChange:()=>M(null),children:e.jsx(ps,{className:"max-w-4xl",children:e.jsx("img",{src:S||"",alt:"Full size",className:"w-full h-auto"})})}),e.jsx(fs,{open:g,onOpenChange:b,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Delete Listing"}),e.jsx(Gr,{children:"Are you sure you want to delete this listing? This action cannot be undone."})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:B,disabled:p.isPending,children:p.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(fs,{open:_,onOpenChange:j,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Send Buyer Referral"}),e.jsx(Gr,{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(ze,{value:L.buyerName,onChange:pe=>I({...L,buyerName:pe.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Buyer Type"}),e.jsxs(Zs,{value:L.buyerType,onValueChange:pe=>I({...L,buyerType:pe}),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select type"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"first_time",children:"First-Time Buyer"}),e.jsx(Mt,{value:"investor",children:"Investor"}),e.jsx(Mt,{value:"relocating",children:"Relocating"}),e.jsx(Mt,{value:"upgrade",children:"Upgrading"}),e.jsx(Mt,{value:"downsize",children:"Downsizing"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Notes"}),e.jsx(Er,{value:L.notes,onChange:pe=>I({...L,notes:pe.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(qn,{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(Jat,{open:w,onOpenChange:k,listingId:(n==null?void 0:n.id)||"",listingSlug:(n==null?void 0:n.slug)||null,listingTitle:(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`})]})}function uws({onImport:t}){const[s,r]=N.useState(""),[n,a]=N.useState([]),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState(null),f=N.useRef(),g=N.useRef(null);N.useEffect(()=>{const S=M=>{g.current&&!g.current.contains(M.target)&&c(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[]);const b=async S=>{if(S.trim().length<3){a([]),c(!1);return}l(!0);try{const{data:M,error:L}=await H.functions.invoke("mls-listing-search",{body:{query:S}});if(L)throw L;a((M==null?void 0:M.listings)||[]),c(!0)}catch(M){console.error("MLS search error:",M),a([])}finally{l(!1)}},_=S=>{r(S),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>b(S),400)},j=S=>{p(S.mlsNumber),t(S),c(!1),r(`${S.address}, ${S.city}`),me.success(`Imported: ${S.address}`,{description:"Property details and photos have been auto-filled."}),p(null)},w=S=>S?`$${S.toLocaleString()}`:"",k=S=>{const M=(S||"").toLowerCase();return M.includes("single")||M.includes("detached")?"Single Family":M.includes("condo")?"Condo":M.includes("town")?"Townhouse":M.includes("land")||M.includes("lot")?"Land":M.includes("multi")?"Multi-Family":M.includes("commercial")?"Commercial":S||"Other"};return e.jsxs(Ee,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(yi,{className:"h-4 w-4 text-primary"}),"Import from MLS"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Search by address to auto-fill property details and photos from MLS"})]}),e.jsx(De,{children:e.jsxs("div",{ref:g,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:s,onChange:S=>_(S.target.value),onFocus:()=>n.length>0&&c(!0),placeholder:"Start typing a property address...",className:"pl-9 pr-9"}),o&&e.jsx(ws,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 animate-spin text-muted-foreground"}),s&&!o&&e.jsx("button",{type:"button",onClick:()=>{r(""),a([]),c(!1)},className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Rr,{className:"h-4 w-4"})})]}),i&&e.jsx("div",{className:"absolute z-50 w-full mt-1 bg-popover border rounded-lg shadow-lg max-h-[400px] overflow-y-auto",children:n.length===0&&!o?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No properties found. Try a different address."}):n.map(S=>e.jsxs("button",{type:"button",onClick:()=>j(S),disabled:u===S.mlsNumber,className:"w-full text-left p-3 hover:bg-accent/50 transition-colors border-b last:border-0 flex items-start gap-3",children:[S.photos[0]?e.jsx("img",{src:S.photos[0],alt:"",className:"w-16 h-12 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-16 h-12 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(ma,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:S.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[S.city,", ",S.state," ",S.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:w(S.price)}),S.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Im,{className:"h-3 w-3"})," ",S.bedrooms]}),S.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Ju,{className:"h-3 w-3"})," ",S.bathrooms]}),S.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(x0,{className:"h-3 w-3"})," ",S.sqft.toLocaleString()]})]})]}),e.jsxs("div",{className:"flex-shrink-0 flex flex-col items-end gap-1",children:[e.jsx(tt,{variant:"outline",className:"text-[10px]",children:k(S.propertyType)}),S.photos.length>0&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[S.photos.length," photos"]})]})]},S.mlsNumber))})]})})]})}function hws({photo:t,onRemove:s,onSetPrimary:r}){const{attributes:n,listeners:a,setNodeRef:o,transform:l,transition:i,isDragging:c}=Zke({id:t.id}),u={transform:QS.Transform.toString(l),transition:i};return e.jsxs("div",{ref:o,style:u,className:It("relative aspect-square rounded-lg overflow-hidden bg-muted group",c&&"opacity-50 ring-2 ring-primary z-50"),children:[e.jsx("img",{src:t.photo_url,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",...n,...a,className:"absolute top-1 left-1 p-1 bg-black/60 text-white rounded cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Cu,{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(Rr,{className:"h-3 w-3"})}),t.is_primary?e.jsxs("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded flex items-center gap-0.5",children:[e.jsx(Jn,{className:"h-2.5 w-2.5 fill-current"})," Primary"]}):e.jsx("button",{type:"button",onClick:()=>r(t.id),className:"absolute bottom-1 left-1 text-[10px] bg-black/60 text-white px-1.5 py-0.5 rounded opacity-0 group-hover:opacity-100 transition-opacity hover:bg-black/80",children:"Set as Primary"})]})}function mws({photos:t,uploading:s,onUpload:r,onRemove:n,onReorder:a,onSetPrimary:o}){const l=$ke(qle(tR,{activationConstraint:{distance:5}})),i=[...t].sort((u,p)=>(u.sort_order??0)-(p.sort_order??0)),c=u=>{const{active:p,over:f}=u;if(!f||p.id===f.id)return;const g=i.findIndex(k=>k.id===p.id),b=i.findIndex(k=>k.id===f.id),_=[...i],[j]=_.splice(g,1);_.splice(b,0,j);const w=_.map((k,S)=>({...k,sort_order:S}));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(Wke,{sensors:l,collisionDetection:qke,onDragEnd:c,children:e.jsx(Kke,{items:i.map(u=>u.id),strategy:sR,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[i.map(u=>e.jsx(hws,{photo:u,onRemove:n,onSetPrimary:o},u.id)),e.jsxs("label",{className:"aspect-square rounded-lg border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 cursor-pointer flex flex-col items-center justify-center gap-2 text-muted-foreground",children:[s?e.jsx(ws,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(li,{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 pws({selectedVideoId:t,onVideoSelect:s,listingId:r}){const n=fr(),{user:a}=Ds(),[o,l]=N.useState(!1),[i,c]=N.useState([]),[u,p]=N.useState(!1),[f,g]=N.useState(null),[b,_]=N.useState({});N.useEffect(()=>{t&&a?j():g(null)},[t,a]);const j=async()=>{if(!t)return;const{data:B,error:V}=await H.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("id",t).eq("is_deleted",!1).single();!V&&B&&(g(B),w(B))},w=async B=>{try{const{data:V,error:Z}=await H.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:B.bunny_video_id,isAgentVideo:!0}});!Z&&(V!=null&&V.thumbnailUrl)&&_(X=>({...X,[B.id]:{thumbnailUrl:V.thumbnailUrl}}))}catch(V){console.warn("Failed to get signed URL",V)}},k=async()=>{if(a){p(!0);try{const{data:B,error:V}=await H.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("owner_user_id",a.id).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(V)throw V;c(B||[]),B!=null&&B.length&&S(B)}catch(B){console.error("Error fetching videos:",B),me.error("Failed to load videos")}finally{p(!1)}}},S=async B=>{var V;try{const Z=B.map(re=>re.bunny_video_id),{data:X,error:ee}=await H.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Z,isAgentVideo:!0}});if(ee)throw ee;const Q=(X==null?void 0:X.assets)||{},ie={};for(const re of B)(V=Q[re.bunny_video_id])!=null&&V.thumbnailUrl&&(ie[re.id]={thumbnailUrl:Q[re.bunny_video_id].thumbnailUrl});_(re=>({...re,...ie}))}catch(Z){console.warn("Failed to bulk-fetch signed URLs",Z)}},M=()=>{l(!0),k()},L=B=>{s(B.id),g(B),l(!1),me.success("Video selected")},I=()=>{s(null),g(null)},O=()=>{const B=r?`/mission-control/listings/${r}/edit`:"/mission-control/listings/new";n(`/mission-control/video?returnUrl=${encodeURIComponent(B)}`)},q=B=>{if(!B)return"0:00";const V=Math.floor(B/60),Z=B%60;return`${V}:${Z.toString().padStart(2,"0")}`},U=B=>{var V;return((V=b[B.id])==null?void 0:V.thumbnailUrl)||B.thumbnail_url};return e.jsxs("div",{className:"space-y-3",children:[f?e.jsx(Ee,{className:"overflow-hidden",children:e.jsx(De,{className:"p-0",children:e.jsxs("div",{className:"flex items-start gap-4 p-4",children:[e.jsxs("div",{className:"relative w-32 h-20 bg-muted rounded-lg overflow-hidden flex-shrink-0",children:[U(f)?e.jsx("img",{src:U(f),alt:f.title||"Video thumbnail",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(An,{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(nl,{className:"h-6 w-6 text-white fill-white"})}),f.duration_seconds&&e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1.5 py-0.5 rounded",children:q(f.duration_seconds)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:f.title||"Untitled Video"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Property Video Tour"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:M,children:"Change"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:I,className:"text-destructive hover:text-destructive",children:e.jsx(Rr,{className:"h-4 w-4"})})]})]})})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(De,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(An,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add a video walkthrough to showcase this property"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 justify-center",children:[e.jsxs(K,{type:"button",variant:"outline",onClick:M,className:"gap-2",children:[e.jsx(LM,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(K,{type:"button",variant:"outline",onClick:O,className:"gap-2",children:[e.jsx(kx,{className:"h-4 w-4"}),"Record New Video"]})]})]})})}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(_s,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(LM,{className:"h-5 w-5"}),"Select a Video"]})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:u?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(An,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No videos in your library yet"}),e.jsxs(K,{onClick:O,className:"gap-2",children:[e.jsx(kx,{className:"h-4 w-4"}),"Record Your First Video"]})]}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 p-1",children:i.map(B=>e.jsxs("button",{type:"button",onClick:()=>L(B),className:`group relative rounded-lg overflow-hidden border-2 transition-all text-left ${t===B.id?"border-primary ring-2 ring-primary/20":"border-transparent hover:border-muted-foreground/30"}`,children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[U(B)?e.jsx("img",{src:U(B),alt:B.title||"Video",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(An,{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(nl,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity"})}),B.duration_seconds&&e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1.5 py-0.5 rounded",children:q(B.duration_seconds)})]}),e.jsx("div",{className:"p-2 bg-card",children:e.jsx("p",{className:"text-xs font-medium truncate",children:B.title||"Untitled Video"})})]},B.id))})}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs(K,{type:"button",variant:"ghost",onClick:O,className:"gap-2",children:[e.jsx(kx,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const fws=[{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"}],xws=[{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 gws({id:t,url:s,index:r,onRemove:n}){const{attributes:a,listeners:o,setNodeRef:l,transform:i,transition:c,isDragging:u}=Zke({id:t}),p={transform:QS.Transform.toString(i),transition:c};return e.jsxs("div",{ref:l,style:p,className:`relative aspect-square rounded-lg overflow-hidden bg-muted group ${u?"opacity-50 ring-2 ring-primary z-50":""}`,children:[e.jsx("img",{src:s,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",...a,...o,className:"absolute top-1 left-1 p-1 bg-black/60 text-white rounded cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Cu,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>n(r),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Rr,{className:"h-3 w-3"})}),r===0&&e.jsxs("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded flex items-center gap-0.5",children:[e.jsx(Jn,{className:"h-2.5 w-2.5 fill-current"})," Primary"]})]})}function yws({photoUrls:t,pendingPhotos:s,onRemove:r,onReorder:n,uploading:a,onUpload:o}){const l=$ke(qle(tR,{activationConstraint:{distance:5}})),i=t.map((u,p)=>`pending-${p}`),c=u=>{const{active:p,over:f}=u;if(!f||p.id===f.id)return;const g=i.indexOf(p.id),b=i.indexOf(f.id),_=[...t],j=[...s],[w]=_.splice(g,1),[k]=j.splice(g,1);_.splice(b,0,w),j.splice(b,0,k),n(_,j)};return e.jsxs("div",{className:"space-y-2",children:[t.length>1&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag photos to reorder. First photo will be primary."}),e.jsx(Wke,{sensors:l,collisionDetection:qke,onDragEnd:c,children:e.jsx(Kke,{items:i,strategy:sR,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[t.map((u,p)=>e.jsx(gws,{id:i[p],url:u,index:p,onRemove:r},i[p])),e.jsxs("label",{className:"aspect-square rounded-lg border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 cursor-pointer flex flex-col items-center justify-center gap-2 text-muted-foreground",children:[a?e.jsx(ws,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-8 w-8"}),e.jsx("span",{className:"text-xs",children:"Upload"})]}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:u=>o(u.target.files),disabled:a})]})]})})}),s.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-4",children:[s.length," photo",s.length!==1?"s":""," will be uploaded when you save."]})]})}function a7e(){const{listingId:t}=yo(),[s]=Cc(),r=s.get("brokerage"),n=fr(),{user:a}=Ds(),{hasLeadSite:o}=zO(),l=!!t&&t!=="new",i=!!r&&!l,[c,u]=N.useState([]),{data:p,isLoading:f}=tXe(l?t:""),g=TLt(),b=ALt(),_=ELt(),j=PLt(),w=ILt(),k=LLt(),S=DLt(),{data:M=[]}=mt({queryKey:["brokerage-agents",r],queryFn:async()=>{if(!r)return[];const{data:ue,error:pe}=await H.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name");if(pe)throw pe;return ue||[]},enabled:i}),[L,I]=N.useState(""),[O,q]=N.useState(!1),[U,B]=N.useState([]),[V,Z]=N.useState([]),[X,ee]=N.useState({property_address:"",city:"",state:"",neighborhood:"",price:"",property_type:"single_family",status:"active",bedrooms:"",bathrooms:"",square_footage:"",lot_size:"",year_built:"",has_hoa:!1,description:"",agent_notes:"",agent_notes_public:!1,mls_link:"",video_link:"",video_id:null,allow_sharing:!0,open_to_referrals:!0,open_to_social_promotion:!0,share_with_brokerage:!1,is_public:!0});N.useEffect(()=>{var ue,pe,be,Me,Ne;p&&l&&ee({property_address:p.property_address||"",city:p.city||"",state:p.state||"",neighborhood:p.neighborhood||"",price:((ue=p.price)==null?void 0:ue.toString())||"",property_type:p.property_type,status:p.status,bedrooms:((pe=p.bedrooms)==null?void 0:pe.toString())||"",bathrooms:((be=p.bathrooms)==null?void 0:be.toString())||"",square_footage:((Me=p.square_footage)==null?void 0:Me.toString())||"",lot_size:p.lot_size||"",year_built:((Ne=p.year_built)==null?void 0:Ne.toString())||"",has_hoa:p.has_hoa,description:p.description||"",agent_notes:p.agent_notes||"",agent_notes_public:p.agent_notes_public,mls_link:p.mls_link||"",video_link:p.video_link||"",video_id:p.video_id||null,allow_sharing:p.allow_sharing,open_to_referrals:p.open_to_referrals,open_to_social_promotion:p.open_to_social_promotion,share_with_brokerage:p.share_with_brokerage??!1,is_public:p.is_public})},[p,l]);const Q=ue=>{var Ne,Pe;const pe={"single family":"single_family",detached:"single_family",residential:"single_family",condo:"condo",condominium:"condo",apartment:"condo",townhouse:"townhouse",townhome:"townhouse",land:"land",lot:"land","lots and land":"land","multi-family":"multi_family","multi family":"multi_family",duplex:"multi_family",commercial:"commercial"},be=(ue.propertyType||"").toLowerCase(),Me=((Ne=Object.entries(pe).find(([Oe])=>be.includes(Oe)))==null?void 0:Ne[1])||"other";ee(Oe=>({...Oe,property_address:ue.address||Oe.property_address,city:ue.city||Oe.city,state:ue.state||Oe.state,price:ue.price?String(ue.price):Oe.price,property_type:Me,bedrooms:ue.bedrooms?String(ue.bedrooms):Oe.bedrooms,bathrooms:ue.bathrooms?String(ue.bathrooms):Oe.bathrooms,square_footage:ue.sqft?String(ue.sqft):Oe.square_footage,lot_size:ue.lotSize?String(ue.lotSize):Oe.lot_size,year_built:ue.yearBuilt?String(ue.yearBuilt):Oe.year_built,description:ue.description||Oe.description})),((Pe=ue.photos)==null?void 0:Pe.length)>0&&(u(ue.photos),V.forEach(Oe=>URL.revokeObjectURL(Oe)),B([]),Z([]))},ie=ue=>{if(!ue)return;const pe=Array.from(ue);B(Me=>[...Me,...pe]);const be=pe.map(Me=>URL.createObjectURL(Me));Z(Me=>[...Me,...be])},re=ue=>{URL.revokeObjectURL(V[ue]),B(pe=>pe.filter((be,Me)=>Me!==ue)),Z(pe=>pe.filter((be,Me)=>Me!==ue))},oe=async ue=>{var pe;if(!(!ue||!p)){q(!0);try{for(const be of Array.from(ue)){const Me=be.name.split(".").pop(),Ne=`${a==null?void 0:a.id}/${p.id}/${Date.now()}.${Me}`,{error:Pe}=await H.storage.from("listing-photos").upload(Ne,be);if(Pe)throw Pe;const{data:{publicUrl:Oe}}=H.storage.from("listing-photos").getPublicUrl(Ne);await j.mutateAsync({listingId:p.id,photoUrl:Oe,isPrimary:!((pe=p.photos)!=null&&pe.length)})}me.success("Photos uploaded!")}catch(be){console.error("Upload error:",be),me.error("Failed to upload photos")}finally{q(!1)}}},ce=async ue=>{for(let pe=0;pe{if(p)try{await w.mutateAsync({photoId:ue,listingId:p.id}),me.success("Photo removed")}catch{me.error("Failed to remove photo")}},ge=async ue=>{if(ue.preventDefault(),!X.city.trim()||!X.state.trim()||!X.price){me.error("Please fill in required fields (City, State, Price)");return}if(i&&!L){me.error("Please select an agent to assign this listing to");return}try{const pe={property_address:X.property_address||null,city:X.city,state:X.state,neighborhood:X.neighborhood||null,price:Number(X.price),property_type:X.property_type,status:X.status,bedrooms:X.bedrooms?Number(X.bedrooms):null,bathrooms:X.bathrooms?Number(X.bathrooms):null,square_footage:X.square_footage?Number(X.square_footage):null,lot_size:X.lot_size||null,year_built:X.year_built?Number(X.year_built):null,has_hoa:X.has_hoa,description:X.description||null,agent_notes:X.agent_notes||null,agent_notes_public:X.agent_notes_public,mls_link:X.mls_link||null,video_link:X.video_link||null,video_id:X.video_id||null,allow_sharing:X.allow_sharing,open_to_referrals:X.open_to_referrals,open_to_social_promotion:X.open_to_social_promotion,share_with_brokerage:X.share_with_brokerage,is_public:X.is_public};if(l)await _.mutateAsync({id:t,...pe}),me.success("Listing updated!"),n(`/mission-control/listings/${t}`);else{q(!0);let be;if(i&&L?be=await b.mutateAsync({agentId:L,...pe}):be=await g.mutateAsync(pe),U.length>0)try{await ce(be.id),V.forEach(Me=>URL.revokeObjectURL(Me)),B([]),Z([])}catch(Me){console.error("Photo upload error:",Me),me.error("Listing created but some photos failed to upload")}if(c.length>0)try{for(let Me=0;Men(i?"/my-brokerage":"/mission-control/listings"),children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"}),i?"Back to Brokerage":"Back to Listings"]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[i&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Assign to Agent *"})}),e.jsxs(De,{children:[e.jsxs(Zs,{value:L,onValueChange:I,children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select an agent..."})}),e.jsx(Gs,{children:M.map(ue=>e.jsx(Mt,{value:ue.id,children:ue.name||ue.email},ue.id))})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"This listing will appear on the selected agent's Listing Exchange."})]})]}),!l&&o&&!i&&e.jsx(uws,{onImport:Q}),c.length>0&&e.jsxs(Ee,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(yi,{className:"h-4 w-4 text-primary"}),"MLS Photos (",c.length,")"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"These photos will be imported when you save the listing."})]}),e.jsxs(De,{children:[e.jsxs("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:[c.slice(0,12).map((ue,pe)=>e.jsx("div",{className:"aspect-square rounded overflow-hidden bg-muted",children:e.jsx("img",{src:ue,alt:"",className:"w-full h-full object-cover"})},pe)),c.length>12&&e.jsxs("div",{className:"aspect-square rounded bg-muted flex items-center justify-center text-sm text-muted-foreground font-medium",children:["+",c.length-12]})]}),e.jsxs(K,{type:"button",variant:"ghost",size:"sm",className:"mt-2 text-destructive",onClick:()=>u([]),children:[e.jsx(Rr,{className:"h-3 w-3 mr-1"})," Clear MLS photos"]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Property Details"})}),e.jsx(De,{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(ze,{value:X.property_address,onChange:ue=>ee({...X,property_address:ue.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"City *"}),e.jsx(ze,{value:X.city,onChange:ue=>ee({...X,city:ue.target.value}),placeholder:"City",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"State *"}),e.jsx(ze,{value:X.state,onChange:ue=>ee({...X,state:ue.target.value}),placeholder:"State",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Neighborhood"}),e.jsx(ze,{value:X.neighborhood,onChange:ue=>ee({...X,neighborhood:ue.target.value}),placeholder:"Neighborhood"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Price *"}),e.jsx(ze,{type:"number",value:X.price,onChange:ue=>ee({...X,price:ue.target.value}),placeholder:"500000",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Property Type"}),e.jsxs(Zs,{value:X.property_type,onValueChange:ue=>ee({...X,property_type:ue}),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:xws.map(ue=>e.jsx(Mt,{value:ue.value,children:ue.label},ue.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Status"}),e.jsxs(Zs,{value:X.status,onValueChange:ue=>ee({...X,status:ue}),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:fws.map(ue=>e.jsx(Mt,{value:ue.value,children:ue.label},ue.value))})]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Property Specs (Optional)"})}),e.jsx(De,{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(ze,{type:"number",value:X.bedrooms,onChange:ue=>ee({...X,bedrooms:ue.target.value}),placeholder:"3"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Bathrooms"}),e.jsx(ze,{type:"number",step:"0.5",value:X.bathrooms,onChange:ue=>ee({...X,bathrooms:ue.target.value}),placeholder:"2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Sq Ft"}),e.jsx(ze,{type:"number",value:X.square_footage,onChange:ue=>ee({...X,square_footage:ue.target.value}),placeholder:"2000"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Lot Size"}),e.jsx(ze,{value:X.lot_size,onChange:ue=>ee({...X,lot_size:ue.target.value}),placeholder:"0.25 acres"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Year Built"}),e.jsx(ze,{type:"number",value:X.year_built,onChange:ue=>ee({...X,year_built:ue.target.value}),placeholder:"2005"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(qr,{checked:X.has_hoa,onCheckedChange:ue=>ee({...X,has_hoa:ue})}),e.jsx(ve,{children:"Has HOA"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Description & Links"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Er,{value:X.description,onChange:ue=>ee({...X,description:ue.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(Er,{value:X.agent_notes,onChange:ue=>ee({...X,agent_notes:ue.target.value}),placeholder:"Notes for other agents...",rows:2}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:X.agent_notes_public,onCheckedChange:ue=>ee({...X,agent_notes_public:ue})}),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(ze,{value:X.mls_link,onChange:ue=>ee({...X,mls_link:ue.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Video Link"}),e.jsx(ze,{value:X.video_link,onChange:ue=>ee({...X,video_link:ue.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(An,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx(De,{children:e.jsx(pws,{selectedVideoId:X.video_id,onVideoSelect:ue=>ee({...X,video_id:ue}),listingId:l?t:void 0})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Photos"})}),e.jsx(De,{children:l&&(p!=null&&p.photos)?e.jsx(mws,{photos:p.photos,uploading:O,onUpload:ue=>oe(ue),onRemove:ue=>xe(ue),onReorder:ue=>{k.mutate({photos:ue.map(pe=>({id:pe.id,sort_order:pe.sort_order,is_primary:pe.is_primary}))})},onSetPrimary:ue=>{p&&S.mutate({photoId:ue,listingId:p.id})}}):e.jsx(yws,{photoUrls:V,onRemove:re,onReorder:(ue,pe)=>{Z(ue),B(pe)},pendingPhotos:U,uploading:O,onUpload:ie})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Sharing & Collaboration"})}),e.jsxs(De,{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(qr,{checked:X.allow_sharing,onCheckedChange:ue=>ee({...X,allow_sharing:ue})})]}),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(qr,{checked:X.open_to_referrals,onCheckedChange:ue=>ee({...X,open_to_referrals:ue})})]}),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(qr,{checked:X.open_to_social_promotion,onCheckedChange:ue=>ee({...X,open_to_social_promotion:ue})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Share with Brokerage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visible to agents in your brokerage"})]}),e.jsx(qr,{checked:X.share_with_brokerage,onCheckedChange:ue=>ee({...X,share_with_brokerage:ue})})]}),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(qr,{checked:X.is_public,onCheckedChange:ue=>ee({...X,is_public:ue})})]})]})]}),e.jsx(K,{type:"submit",className:"w-full",size:"lg",disabled:g.isPending||_.isPending,children:g.isPending||_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):l?"Update Listing":"Create Listing"})]})]})]})})}let op=null;function vws(){if(op)return op;try{const t=document.createElement("canvas"),s=t.getContext("webgl2")||t.getContext("webgl");if(!s)return op={canRunVirtualBg:!1,reason:"WebGL is not supported on this device"},op;const r=s.getExtension("WEBGL_debug_renderer_info"),n=r?s.getParameter(r.UNMASKED_RENDERER_WEBGL):"Unknown",a=["swiftshader","llvmpipe","software","microsoft basic render"],o=(n||"").toLowerCase();if(a.some(c=>o.includes(c)))return op={canRunVirtualBg:!1,reason:"Your device uses a software renderer which may cause lag",renderer:n},op;const i=performance;return i.memory&&i.memory.jsHeapSizeLimit<256*1024*1024?(op={canRunVirtualBg:!1,reason:"Limited device memory detected",renderer:n},op):navigator.hardwareConcurrency&&navigator.hardwareConcurrency<2?(op={canRunVirtualBg:!1,reason:"Single-core device detected — virtual backgrounds may cause lag",renderer:n},op):(op={canRunVirtualBg:!0,renderer:n},op)}catch{return op={canRunVirtualBg:!0},op}}const bws=[{type:"none",label:"Off"},{type:"blur",label:"Blur"}];function _ws({value:t,onChange:s,isLoading:r=!1,disabled:n=!1,className:a}){const o=N.useRef(null),[l,i]=N.useState(!1),[c]=N.useState(()=>vws()),u=!c.canRunVirtualBg,{data:p=[],refetch:f}=mt({queryKey:["video-backgrounds"],queryFn:async()=>{const{data:{user:w}}=await H.auth.getUser();if(!w)return[];const{data:k,error:S}=await H.from("video_backgrounds").select("*").eq("is_active",!0).order("sort_order",{ascending:!0});return S?(console.error("Failed to load backgrounds:",S),[]):k||[]}}),g=p.map(w=>({type:"image",label:w.name,imageUrl:w.image_url,thumbnail:w.thumbnail_url||w.image_url})),b=[...bws,...g],_=w=>w.type!==t.type?!1:w.type==="image"?w.imageUrl===t.imageUrl:!0,j=async w=>{var S;const k=(S=w.target.files)==null?void 0:S[0];if(k){if(!k.type.startsWith("image/")){me.error("Please select an image file");return}if(k.size>5*1024*1024){me.error("Image must be under 5MB");return}i(!0);try{const{data:{user:M}}=await H.auth.getUser();if(!M)throw new Error("Not authenticated");const L=k.name.split(".").pop()||"jpg",I=`${M.id}/${crypto.randomUUID()}.${L}`,{error:O}=await H.storage.from("video-backgrounds").upload(I,k,{contentType:k.type});if(O)throw O;const{data:q}=H.storage.from("video-backgrounds").getPublicUrl(I),U=q.publicUrl,{error:B}=await H.from("video_backgrounds").insert({name:k.name.replace(/\.[^.]+$/,""),image_url:U,thumbnail_url:U,category:"custom",is_stock:!1,user_id:M.id});if(B)throw B;await f(),s({type:"image",imageUrl:U,blurRadius:15}),me.success("Background uploaded!")}catch(M){console.error("Upload error:",M),me.error("Failed to upload background")}finally{i(!1),o.current&&(o.current.value="")}}};return e.jsxs("div",{className:It("flex flex-col gap-1",a),children:[u&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-600 bg-amber-50 dark:bg-amber-950/30 dark:text-amber-400 rounded px-2 py-1",children:[e.jsx(Ku,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{children:c.reason||"Virtual backgrounds may cause lag on this device"})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto py-2 px-1 scrollbar-none",children:[e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap mr-1 font-medium",children:"Background:"}),r&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ws,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"Loading…"})]}),b.map((w,k)=>{const S=_(w);return e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({type:w.type,imageUrl:w.imageUrl,blurRadius:15}),className:It("flex-shrink-0 flex flex-col items-center gap-0.5 rounded-lg border-2 p-1 transition-all","hover:border-primary/50 focus:outline-none focus:ring-2 focus:ring-primary/30",S?"border-primary bg-primary/10":"border-transparent bg-muted/50",n&&"opacity-50 cursor-not-allowed"),children:[e.jsxs("div",{className:"w-12 h-8 rounded flex items-center justify-center overflow-hidden bg-muted",children:[w.type==="none"&&e.jsx(GI,{className:"h-4 w-4 text-muted-foreground"}),w.type==="blur"&&e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-primary/20 to-primary/40 flex items-center justify-center",children:e.jsx("span",{className:"text-[10px] font-medium text-primary",children:"Blur"})}),w.type==="image"&&w.thumbnail&&e.jsx("img",{src:w.thumbnail,alt:w.label,className:"w-full h-full object-cover"})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-14",children:w.label})]},`${w.type}-${w.imageUrl||k}`)}),e.jsxs("button",{type:"button",disabled:n||l,onClick:()=>{var w;return(w=o.current)==null?void 0:w.click()},className:It("flex-shrink-0 flex flex-col items-center gap-0.5 rounded-lg border-2 border-dashed p-1 transition-all","hover:border-primary/50 focus:outline-none focus:ring-2 focus:ring-primary/30","border-muted-foreground/30 bg-muted/30",(n||l)&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"w-12 h-8 rounded flex items-center justify-center",children:l?e.jsx(ws,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx($s,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:l?"Uploading":"Custom"})]}),e.jsx("input",{ref:o,type:"file",accept:"image/*",className:"hidden",onChange:j}),e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({...t,mirror:!t.mirror}),className:It("flex-shrink-0 flex flex-col items-center gap-0.5 rounded-lg border-2 p-1 transition-all ml-1","hover:border-primary/50 focus:outline-none focus:ring-2 focus:ring-primary/30",t.mirror?"border-primary bg-primary/10":"border-transparent bg-muted/50",n&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"w-12 h-8 rounded flex items-center justify-center",children:e.jsx(nL,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Mirror"})]})]})]})}var wA=typeof self<"u"?self:{};function rit(t,s){e:{for(var r=["CLOSURE_FLAGS"],n=wA,a=0;a>6|192;else{if(s>=55296&&s<=57343){if(s<=56319&&a=56320&&o<=57343){s=1024*(s-55296)+o-56320+65536,n[r++]=s>>18|240,n[r++]=s>>12&63|128,n[r++]=s>>6&63|128,n[r++]=63&s|128;continue}a--}s=65533}n[r++]=s>>12|224,n[r++]=s>>6&63|128}n[r++]=63&s|128}}t=r===n.length?n:n.subarray(0,r)}return t}function ait(t){wA.setTimeout(()=>{throw t},0)}var U_e,kws=rit(610401301,!1),o7e=rit(748402147,!0);function l7e(){var t=wA.navigator;return t&&(t=t.userAgent)?t:""}const c7e=wA.navigator;function Khe(t){return Khe[" "](t),t}U_e=c7e&&c7e.userAgentData||null,Khe[" "]=function(){};const iit={};let TI=null;function Sws(t){const s=t.length;let r=3*s/4;r%3?r=Math.floor(r):"=.".indexOf(t[s-1])!=-1&&(r="=.".indexOf(t[s-2])!=-1?r-2:r-1);const n=new Uint8Array(r);let a=0;return function(o,l){function i(u){for(;c>4),f!=64&&(l(p<<4&240|f>>2),g!=64&&l(f<<6&192|g))}}(t,function(o){n[a++]=o}),a!==r?n.subarray(0,a):n}function oit(){if(!TI){TI={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),s=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){const n=t.concat(s[r].split(""));iit[r]=n;for(let a=0;a0)&&(l7e().indexOf("Trident")!=-1||l7e().indexOf("MSIE")!=-1))&&typeof btoa=="function";const d7e=/[-_.]/g,Mws={"-":"+",_:"/",".":"="};function Tws(t){return Mws[t]||""}function cit(t){if(!lit)return Sws(t);t=d7e.test(t)?t.replace(d7e,Tws):t,t=atob(t);const s=new Uint8Array(t.length);for(let r=0;r=s||(r[t]=n+1,uit(t=Error(),"incident"),ait(t))}}function kE(){return typeof BigInt=="function"}var SE=typeof Symbol=="function"&&typeof Symbol()=="symbol";function U0(t,s,r=!1){return typeof Symbol=="function"&&typeof Symbol()=="symbol"?r&&Symbol.for&&t?Symbol.for(t):t!=null?Symbol(t):Symbol():s}var Pws=U0("jas",void 0,!0),u7e=U0(void 0,"0di"),lI=U0(void 0,"1oa"),Nf=U0(void 0,Symbol()),Iws=U0(void 0,"0ub"),Lws=U0(void 0,"0ubs"),H_e=U0(void 0,"0ubsb"),Dws=U0(void 0,"0actk"),kA=U0("m_m","Pa",!0),h7e=U0();const hit={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},mit=Object.defineProperties,Ta=SE?Pws:"Ga";var CC;const m7e=[];function gR(t,s){SE||Ta in t||mit(t,hit),t[Ta]|=s}function Pu(t,s){SE||Ta in t||mit(t,hit),t[Ta]=s}function yR(t){return gR(t,34),t}function sO(t){return gR(t,8192),t}Pu(m7e,7),CC=Object.freeze(m7e);var SA={};function Mf(t,s){return s===void 0?t.h!==lC&&!!(2&(0|t.v[Ta])):!!(2&s)&&t.h!==lC}const lC={};function pSe(t,s){if(t!=null){if(typeof t=="string")t=t?new k0(t,jA):oC();else if(t.constructor!==k0)if(hSe(t))t=t.length?new k0(new Uint8Array(t),jA):oC();else{if(!s)throw Error();t=void 0}}return t}class p7e{constructor(s,r,n){this.g=s,this.h=r,this.l=n}next(){const s=this.g.next();return s.done||(s.value=this.h.call(this.l,s.value)),s}[Symbol.iterator](){return this}}var Ows=Object.freeze({});function pit(t,s,r){const n=128&s?0:-1,a=t.length;var o;(o=!!a)&&(o=(o=t[a-1])!=null&&typeof o=="object"&&o.constructor===Object);const l=a+(o?-1:0);for(s=128&s?1:0;stypeof t=="number"),f7e=Zhe(t=>typeof t=="string"),Fws=Zhe(t=>typeof t=="boolean"),Yhe=typeof wA.BigInt=="function"&&typeof wA.BigInt(0)=="bigint";function kf(t){var s=t;if(f7e(s)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(s))throw Error(String(s))}else if(Rws(s)&&!Number.isSafeInteger(s))throw Error(String(s));return Yhe?BigInt(t):t=Fws(t)?t?"1":"0":f7e(t)?t.trim()||"0":String(t)}var W_e=Zhe(t=>Yhe?t>=Bws&&t<=qws:t[0]==="-"?x7e(t,zws):x7e(t,$ws));const zws=Number.MIN_SAFE_INTEGER.toString(),Bws=Yhe?BigInt(Number.MIN_SAFE_INTEGER):void 0,$ws=Number.MAX_SAFE_INTEGER.toString(),qws=Yhe?BigInt(Number.MAX_SAFE_INTEGER):void 0;function x7e(t,s){if(t.length>s.length)return!1;if(t.lengtha)return!1;if(n>>0;Xc=s,Qd=(t-s)/4294967296>>>0}function CA(t){if(t<0){g7e(-t);const[s,r]=gSe(Xc,Qd);Xc=s>>>0,Qd=r>>>0}else g7e(t)}function fSe(t){const s=Vws||(Vws=new DataView(new ArrayBuffer(8)));s.setFloat32(0,+t,!0),Qd=0,Xc=s.getUint32(0,!0)}function xit(t,s){const r=4294967296*s+(t>>>0);return Number.isSafeInteger(r)?r:rO(t,s)}function Hws(t,s){return kf(kE()?BigInt.asUintN(64,(BigInt(s>>>0)<>>0)):rO(t,s))}function git(t,s){return kE()?kf(BigInt.asIntN(64,(BigInt.asUintN(32,BigInt(s))<>>=0,(s>>>=0)<=2097151)var r=""+(4294967296*s+t);else kE()?r=""+(BigInt(s)<>>24|s<<8))+6710656*(s=s>>16&65535),r+=8147497*s,s*=2,t>=1e7&&(r+=t/1e7>>>0,t%=1e7),r>=1e7&&(s+=r/1e7>>>0,r%=1e7),r=s+y7e(r)+y7e(t));return r}function y7e(t){return t=String(t),"0000000".slice(t.length)+t}function xSe(t,s){if(2147483648&s)if(kE())t=""+(BigInt(0|s)<>>0));else{const[r,n]=gSe(t,s);t="-"+rO(r,n)}else t=rO(t,s);return t}function Xhe(t){if(t.length<16)CA(Number(t));else if(kE())t=BigInt(t),Xc=Number(t&BigInt(4294967295))>>>0,Qd=Number(t>>BigInt(32)&BigInt(4294967295));else{const s=+(t[0]==="-");Qd=Xc=0;const r=t.length;for(let n=s,a=(r-s)%6+s;a<=r;n=a,a+=6){const o=Number(t.slice(n,a));Qd*=1e6,Xc=1e6*Xc+o,Xc>=4294967296&&(Qd+=Math.trunc(Xc/4294967296),Qd>>>=0,Xc>>>=0)}if(s){const[n,a]=gSe(Xc,Qd);Xc=n,Qd=a}}}function gSe(t,s){return s=~s,t?t=1+~t:s+=1,[t,s]}function ry(t){return Array.prototype.slice.call(t)}const vR=typeof BigInt=="function"?BigInt.asIntN:void 0,Wws=typeof BigInt=="function"?BigInt.asUintN:void 0,cC=Number.isSafeInteger,Qhe=Number.isFinite,MA=Math.trunc,Gws=kf(0);function AI(t){if(t!=null&&typeof t!="number")throw Error(`Value of float/double field must be a number, found ${typeof t}: ${t}`);return t}function c0(t){return t==null||typeof t=="number"?t:t==="NaN"||t==="Infinity"||t==="-Infinity"?Number(t):void 0}function nO(t){if(t!=null&&typeof t!="boolean"){var s=typeof t;throw Error(`Expected boolean but got ${s!="object"?s:t?Array.isArray(t)?"array":s:"null"}: ${t}`)}return t}function yit(t){return t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0}const Kws=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function bR(t){switch(typeof t){case"bigint":return!0;case"number":return Qhe(t);case"string":return Kws.test(t);default:return!1}}function ME(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Qhe(t)?0|t:void 0}function vit(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Qhe(t)?t>>>0:void 0}function bit(t){const s=t.length;return(t[0]==="-"?s<20||s===20&&t<="-9223372036854775808":s<19||s===19&&t<="9223372036854775807")?t:(Xhe(t),xSe(Xc,Qd))}function ySe(t){if(t=MA(t),!cC(t)){CA(t);var s=Xc,r=Qd;(t=2147483648&r)&&(r=~r>>>0,(s=1+~s>>>0)==0&&(r=r+1>>>0)),t=typeof(s=xit(s,r))=="number"?t?-s:s:t?"-"+s:s}return t}function _it(t){var s=MA(Number(t));return cC(s)?String(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),bit(t))}function wit(t){var s=MA(Number(t));return cC(s)?kf(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),kE()?kf(vR(64,BigInt(t))):kf(bit(t)))}function jit(t){return cC(t)?t=kf(ySe(t)):(t=MA(t),cC(t)?t=String(t):(CA(t),t=xSe(Xc,Qd)),t=kf(t)),t}function Gce(t){const s=typeof t;return t==null?t:s==="bigint"?kf(vR(64,t)):bR(t)?s==="string"?wit(t):jit(t):void 0}function Nit(t){if(typeof t!="string")throw Error();return t}function _R(t){if(t!=null&&typeof t!="string")throw Error();return t}function Eh(t){return t==null||typeof t=="string"?t:void 0}function vSe(t,s,r,n){return t!=null&&t[kA]===SA?t:Array.isArray(t)?((n=(r=0|t[Ta])|32&n|2&n)!==r&&Pu(t,n),new s(t)):(r?2&n?((t=s[u7e])||(yR((t=new s).v),t=s[u7e]=t),s=t):s=new s:s=void 0,s)}function Zws(t,s,r){if(s)e:{if(!bR(s=t))throw V_e("int64");switch(typeof s){case"string":s=wit(s);break e;case"bigint":s=kf(vR(64,s));break e;default:s=jit(s)}}else s=Gce(t);return(t=s)==null?r?Gws:void 0:t}const Yws={};let Xws=function(){try{return Khe(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class yye{constructor(){this.g=new Map}get(s){return this.g.get(s)}set(s,r){return this.g.set(s,r),this.size=this.g.size,this}delete(s){return s=this.g.delete(s),this.size=this.g.size,s}clear(){this.g.clear(),this.size=this.g.size}has(s){return this.g.has(s)}entries(){return this.g.entries()}keys(){return this.g.keys()}values(){return this.g.values()}forEach(s,r){return this.g.forEach(s,r)}[Symbol.iterator](){return this.entries()}}const Qws=Xws?(Object.setPrototypeOf(yye.prototype,Map.prototype),Object.defineProperties(yye.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),yye):class extends Map{constructor(){super()}};function v7e(t){return t}function vye(t){if(2&t.J)throw Error("Cannot mutate an immutable Map")}var L1=class extends Qws{constructor(t,s,r=v7e,n=v7e){super(),this.J=0|t[Ta],this.K=s,this.S=r,this.fa=this.K?Jws:n;for(let a=0;a{t.call(s,a.get(n),n,a)}):super.forEach(t,s)}set(t,s){return vye(this),(t=this.S(t,!0,!1))==null?this:s==null?(super.delete(t),this):super.set(t,this.fa(s,!0,!0,this.K,!1,this.J))}Ma(t){const s=this.S(t[0],!1,!0);t=t[1],t=this.K?t===void 0?null:t:this.fa(t,!1,!0,void 0,!1,this.J),super.set(s,t)}has(t){return super.has(this.S(t,!1,!1))}get(t){t=this.S(t,!1,!1);const s=super.get(t);if(s!==void 0){var r=this.K;return r?((r=this.fa(s,!1,!0,r,this.ra,this.J))!==s&&super.set(t,r),r):s}}[Symbol.iterator](){return this.entries()}};function Jws(t,s,r,n,a,o){return t=vSe(t,n,r,o),a&&(t=_Se(t)),t}function e2s(t){return[t,this.get(t)]}let t2s;function b7e(){return t2s||(t2s=new L1(yR([]),void 0,void 0,void 0,Yws))}function Jhe(t){return Nf?t[Nf]:void 0}function Kce(t,s){for(const r in t)!isNaN(r)&&s(t,+r,t[r])}L1.prototype.toJSON=void 0;var G_e=class{};const s2s={Ka:!0};function r2s(t,s){s<100||NA(Lws,1)}function eme(t,s,r,n){const a=n!==void 0;n=!!n;var o,l=Nf;!a&&SE&&l&&(o=t[l])&&Kce(o,r2s),l=[];var i=t.length;let c;o=4294967295;let u=!1;const p=!!(64&s),f=p?128&s?0:-1:void 0;1&s||(c=i&&t[i-1],c!=null&&typeof c=="object"&&c.constructor===Object?o=--i:c=void 0,!p||128&s||a||(u=!0,o=o-f+f)),s=void 0;for(var g=0;g=o){const _=g-f;(s??(s={}))[_]=b}else l[g]=b}if(c)for(let b in c){if((i=c[b])==null||(i=r(i,n))==null)continue;let _;g=+b,p&&!Number.isNaN(g)&&(_=g+f){_[w]=ry(k)}),_.da=b.da,_}(t)),l}function n2s(t){return t[0]=aO(t[0]),t[1]=aO(t[1]),t}function aO(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return W_e(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var s=0|t[Ta];return t.length===0&&1&s?void 0:eme(t,s,aO)}if(t!=null&&t[kA]===SA)return kit(t);if(t instanceof k0){if((s=t.g)==null)t="";else if(typeof s=="string")t=s;else{if(lit){for(var r="",n=0,a=s.length-10240;n>2];o=r[(3&o)<<4|l>>4],l=r[(15&l)<<2|i>>6],i=r[63&i],n[p++]=c+o+l+i}switch(c=0,i=a,s.length-u){case 2:i=r[(15&(c=s[u+1]))<<2]||a;case 1:s=s[u],n[p]=r[s>>2]+r[(3&s)<<4|c>>4]+i+a}s=n.join("")}t=t.g=s}return t}return t instanceof L1?t=t.size!==0?t.V(n2s):void 0:void 0}return t}let a2s,i2s;function kit(t){return eme(t=t.v,0|t[Ta],aO)}function SS(t,s){return Sit(t,s[0],s[1])}function Sit(t,s,r,n=0){if(t==null){var a=32;r?(t=[r],a|=128):t=[],s&&(a=-16760833&a|(1023&s)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(a=0|t[Ta],o7e&&1&a)throw Error("rfarr");if(2048&a&&!(2&a)&&function(){if(o7e)throw Error("carr");NA(Dws,5)}(),256&a)throw Error("farr");if(64&a)return(a|n)!==a&&Pu(t,a|n),t;if(r&&(a|=128,r!==t[0]))throw Error("mid");e:{a|=64;var o=(r=t).length;if(o){var l=o-1;const c=r[l];if(c!=null&&typeof c=="object"&&c.constructor===Object){if((l-=s=128&a?0:-1)>=1024)throw Error("pvtlmt");for(var i in c)(o=+i)1024)throw Error("spvt");a=-16760833&a|(1023&i)<<14}}}return Pu(t,64|a|n),t}function o2s(t,s){if(typeof t!="object")return t;if(Array.isArray(t)){var r=0|t[Ta];return t.length===0&&1&r?void 0:_7e(t,r,s)}if(t!=null&&t[kA]===SA)return w7e(t);if(t instanceof L1){if(2&(s=t.J))return t;if(!t.size)return;if(r=yR(t.V()),t.K)for(t=0;t=o)if(l=t[o],l!=null&&typeof l=="object"&&l.constructor===Object)r=l[s],i=!0;else{if(a!==o)return;r=l}else r=t[a];if(n&&r!=null){if((n=n(r))==null)return n;if(!Object.is(n,r))return i?l[s]=n:t[a]=n,n}return r}}function Sl(t,s,r,n){EE(t),Au(t=t.v,0|t[Ta],s,r,n)}function Au(t,s,r,n,a){const o=r+(a?0:-1);var l=t.length-1;if(l>=1+(a?0:-1)&&o>=l){const i=t[l];if(i!=null&&typeof i=="object"&&i.constructor===Object)return i[r]=n,s}return o<=l?(t[o]=n,s):(n!==void 0&&(r>=(l=(s??(s=0|t[Ta]))>>14&1023||536870912)?n!=null&&(t[l+(a?0:-1)]={[r]:n}):t[o]=n),s)}function A4(){return Ows===void 0?2:4}function E4(t,s,r,n,a){let o=t.v,l=0|o[Ta];n=Mf(t,l)?1:n,a=!!a||n===3,n===2&&AE(t)&&(o=t.v,l=0|o[Ta]);let i=(t=jSe(o,s))===CC?7:0|t[Ta],c=NSe(i,l);var u=!(4&c);if(u){4&c&&(t=ry(t),i=0,c=MS(c,l),l=Au(o,l,s,t));let p=0,f=0;for(;p{const i=vSe(l,r,!1,s);return o=i!==l&&i!=null,i}))!=null)return o&&!Mf(n)&&MC(t,s),n}function Yo(t,s,r,n){let a=t.v,o=0|a[Ta];if((s=Pit(a,o,s,r,n))==null)return s;if(o=0|a[Ta],!Mf(t,o)){const l=_Se(s);l!==s&&(AE(t)&&(a=t.v,o=0|a[Ta]),o=Au(a,o,r,s=l,n),MC(a,o))}return s}function Iit(t,s,r,n,a,o,l,i){var c=Mf(t,r);o=c?1:o,l=!!l||o===3,c=i&&!c,(o===2||c)&&AE(t)&&(r=0|(s=t.v)[Ta]);var u=(t=jSe(s,a))===CC?7:0|t[Ta],p=NSe(u,r);if(i=!(4&p)){var f=t,g=r;const b=!!(2&p);b&&(g|=2);let _=!b,j=!0,w=0,k=0;for(;w32)for(a|=(127&r)>>4,o=3;o<32&&128&r;o+=7)r=l[i++],a|=(127&r)<>>0,a>>>0);throw Error()}function ESe(t){let s=0,r=t.g;const n=r+10,a=t.h;for(;r>>0}function Yce(t){var s=t.h;const r=t.g;var n=s[r],a=s[r+1];const o=s[r+2];return s=s[r+3],TS(t,t.g+4),t=2*((a=(n<<0|a<<8|o<<16|s<<24)>>>0)>>31)+1,n=a>>>23&255,a&=8388607,n==255?a?NaN:t*(1/0):n==0?1401298464324817e-60*t*a:t*Math.pow(2,n-150)*(a+8388608)}function l2s(t){return yw(t)}function TS(t,s){if(t.g=s,s>t.l)throw Error()}function Dit(t,s){if(s<0)throw Error();const r=t.g;if((s=r+s)>t.l)throw Error();return t.g=s,r}function Oit(t,s){if(s==0)return oC();var r=Dit(t,s);return t.Y&&t.j?r=t.h.subarray(r,r+s):(t=t.h,r=r===(s=r+s)?new Uint8Array(0):Uws?t.slice(r,s):new Uint8Array(t.subarray(r,s))),r.length==0?oC():new k0(r,jA)}var j7e=[];function Rit(t,s,r,n){if(Xce.length){const a=Xce.pop();return a.o(n),a.g.init(t,s,r,n),a}return new c2s(t,s,r,n)}function Fit(t){t.g.clear(),t.l=-1,t.h=-1,Xce.length<100&&Xce.push(t)}function zit(t){var s=t.g;if(s.g==s.l)return!1;t.m=t.g.g;var r=L0(t.g);if(s=r>>>3,!((r&=7)>=0&&r<=5)||s<1)throw Error();return t.l=s,t.h=r,!0}function Iie(t){switch(t.h){case 0:t.h!=0?Iie(t):ESe(t.g);break;case 1:TS(t=t.g,t.g+8);break;case 2:if(t.h!=2)Iie(t);else{var s=L0(t.g);TS(t=t.g,t.g+s)}break;case 5:TS(t=t.g,t.g+4);break;case 3:for(s=t.l;;){if(!zit(t))throw Error();if(t.h==4){if(t.l!=s)throw Error();break}Iie(t)}break;default:throw Error()}}function wR(t,s,r){const n=t.g.l;var a=L0(t.g);let o=(a=t.g.g+a)-n;if(o<=0&&(t.g.l=a,r(s,t,void 0,void 0,void 0),o=a-t.g.g),o)throw Error();return t.g.g=a,t.g.l=n,s}function PSe(t){var s=L0(t.g),r=Dit(t=t.g,s);if(t=t.h,wws){var n,a=t;(n=gye)||(n=gye=new TextDecoder("utf-8",{fatal:!0})),s=r+s,a=r===0&&s===a.length?a:a.subarray(r,s);try{var o=n.decode(a)}catch(i){if(Kz===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),Kz=!0}catch{Kz=!1}}throw!Kz&&(gye=void 0),i}}else{s=(o=r)+s,r=[];let i,c=null;for(;o=s?U2():(i=t[o++],l<194||(192&i)!=128?(o--,U2()):r.push((31&l)<<6|63&i)):l<240?o>=s-1?U2():(i=t[o++],(192&i)!=128||l===224&&i<160||l===237&&i>=160||(192&(n=t[o++]))!=128?(o--,U2()):r.push((15&l)<<12|(63&i)<<6|63&n)):l<=244?o>=s-2?U2():(i=t[o++],(192&i)!=128||i-144+(l<<28)>>30||(192&(n=t[o++]))!=128||(192&(a=t[o++]))!=128?(o--,U2()):(l=(7&l)<<18|(63&i)<<12|(63&n)<<6|63&a,l-=65536,r.push(55296+(l>>10&1023),56320+(1023&l)))):U2(),r.length>=8192&&(c=i7e(c,r),r.length=0)}o=i7e(c,r)}return o}function Bit(t){const s=L0(t.g);return Oit(t.g,s)}function sme(t,s,r){var n=L0(t.g);for(n=t.g.g+n;t.g.g>>0,this.g=s>>>0}};let d2s;function k7e(t){return t?/^-?\d+$/.test(t)?(Xhe(t),new Z_e(Xc,Qd)):null:u2s||(u2s=new Z_e(0,0))}var Z_e=class{constructor(t,s){this.h=t>>>0,this.g=s>>>0}};let u2s;function lT(t,s,r){for(;r>0||s>127;)t.g.push(127&s|128),s=(s>>>7|r<<25)>>>0,r>>>=7;t.g.push(s)}function IE(t,s){for(;s>127;)t.g.push(127&s|128),s>>>=7;t.g.push(s)}function rme(t,s){if(s>=0)IE(t,s);else{for(let r=0;r<9;r++)t.g.push(127&s|128),s>>=7;t.g.push(1)}}function ISe(t){var s=Xc;t.g.push(s>>>0&255),t.g.push(s>>>8&255),t.g.push(s>>>16&255),t.g.push(s>>>24&255)}function TA(t,s){s.length!==0&&(t.l.push(s),t.h+=s.length)}function Gx(t,s,r){IE(t.g,8*s+r)}function LSe(t,s){return Gx(t,s,2),s=t.g.end(),TA(t,s),s.push(t.h),s}function DSe(t,s){var r=s.pop();for(r=t.h+t.g.length()-r;r>127;)s.push(127&r|128),r>>>=7,t.h++;s.push(r),t.h++}function nme(t,s,r){Gx(t,s,2),IE(t.g,r.length),TA(t,t.g.end()),TA(t,r)}function Qce(t,s,r,n){r!=null&&(s=LSe(t,s),n(r,t),DSe(t,s))}function V0(){const t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var OSe=V0(),$it=V0(),RSe=V0(),FSe=V0(),zSe=V0(),qit=V0(),h2s=V0(),ame=V0(),Uit=V0(),Vit=V0();function H0(t,s,r){var n=t.v;Nf&&Nf in n&&(n=n[Nf])&&delete n[s.g],s.h?s.j(t,s.h,s.g,r,s.l):s.j(t,s.g,r,s.l)}var Aa=class{constructor(t,s){this.v=Sit(t,s,void 0,2048)}toJSON(){return kit(this)}j(){var a;var t=G2s,s=this.v,r=t.g,n=Nf;if(SE&&n&&((a=s[n])==null?void 0:a[r])!=null&&NA(Iws,3),s=t.g,h7e&&Nf&&h7e===void 0&&(n=(r=this.v)[Nf])&&(n=n.da))try{n(r,s,s2s)}catch(o){ait(o)}return t.h?t.m(this,t.h,t.g,t.l):t.m(this,t.g,t.defaultValue,t.l)}clone(){const t=this.v,s=0|t[Ta];return wSe(this,t,s)?bSe(this,t,!0):new this.constructor(TE(t,s,!1))}};Aa.prototype[kA]=SA,Aa.prototype.toString=function(){return this.v.toString()};var LE=class{constructor(t,s,r){this.g=t,this.h=s,t=OSe,this.l=!!t&&r===t||!1}};function ime(t,s){return new LE(t,s,OSe)}function Hit(t,s,r,n,a){Qce(t,r,Zit(s,n),a)}const m2s=ime(function(t,s,r,n,a){return t.h===2&&(wR(t,CSe(s,n,r),a),!0)},Hit),p2s=ime(function(t,s,r,n,a){return t.h===2&&(wR(t,CSe(s,n,r),a),!0)},Hit);var ome=Symbol(),lme=Symbol(),Y_e=Symbol(),S7e=Symbol(),C7e=Symbol();let Wit,Git;function TC(t,s,r,n){var a=n[t];if(a)return a;(a={}).qa=n,a.T=function(f){switch(typeof f){case"boolean":return a2s||(a2s=[0,void 0,!0]);case"number":return f>0?void 0:f===0?i2s||(i2s=[0,void 0]):[-f,void 0];case"string":return[0,f];case"object":return f}}(n[0]);var o=n[1];let l=1;o&&o.constructor===Object&&(a.ba=o,typeof(o=n[++l])=="function"&&(a.ma=!0,Wit??(Wit=o),Git??(Git=n[l+1]),o=n[l+=2]));const i={};for(;o&&Array.isArray(o)&&o.length&&typeof o[0]=="number"&&o[0]>0;){for(var c=0;ca(o,l,i,n):a}function $Se(t,s,r,n,a){const o=r.g;let l,i;t[s]=(c,u,p)=>o(c,u,p,i||(i=TC(lme,BSe,$Se,n).T),l||(l=qSe(n)),a)}function qSe(t){let s=t[Y_e];if(s!=null)return s;const r=TC(lme,BSe,$Se,t);return s=r.ma?(n,a)=>Wit(n,a,r):(n,a)=>{for(;zit(a)&&a.h!=4;){var o=a.l,l=r[o];if(l==null){var i=r.ba;i&&(i=i[o])&&(i=x2s(i))!=null&&(l=r[o]=i)}if(l==null||!l(a,n,o)){if(l=(i=a).m,Iie(i),i.ha)var c=void 0;else c=i.g.g-l,i.g.g=l,c=Oit(i.g,c);l=void 0,i=n,c&&((l=i[Nf]??(i[Nf]=new G_e))[o]??(l[o]=[])).push(c)}}return(n=Jhe(n))&&(n.da=r.qa[C7e]),!0},t[Y_e]=s,t[C7e]=f2s.bind(t),s}function f2s(t,s,r,n){var a=this[lme];const o=this[Y_e],l=SS(void 0,a.T),i=Jhe(t);if(i){var c=!1,u=a.ba;if(u){if(a=(p,f,g)=>{if(g.length!==0)if(u[f])for(const b of g){p=Rit(b);try{c=!0,o(l,p)}finally{Fit(p)}}else n==null||n(t,f,g)},s==null)Kce(i,a);else if(i!=null){const p=i[s];p&&a(i,s,p)}if(c){let p=0|t[Ta];if(2&p&&2048&p&&!(r!=null&&r.Ka))throw Error();const f=CE(p),g=(b,_)=>{if(D1(t,b,f)!=null){if((r==null?void 0:r.Qa)===1)return;throw Error()}_!=null&&(p=Au(t,p,b,_,f)),delete i[b]};s==null?pit(l,0|l[Ta],(b,_)=>{g(b,_)}):g(s,D1(l,s,f))}}}}function x2s(t){const s=(t=Kit(t))[0].g;if(t=t[1]){const r=qSe(t),n=TC(lme,BSe,$Se,t).T;return(a,o,l)=>s(a,o,l,n,r)}return s}function cme(t,s,r){t[s]=r.h}function dme(t,s,r,n){let a,o;const l=r.h;t[s]=(i,c,u)=>l(i,c,u,o||(o=TC(ome,cme,dme,n).T),a||(a=Yit(n)))}function Yit(t){let s=t[S7e];if(!s){const r=TC(ome,cme,dme,t);s=(n,a)=>Xit(n,a,r),t[S7e]=s}return s}function Xit(t,s,r){pit(t,0|t[Ta],(n,a)=>{if(a!=null){var o=function(l,i){var c=l[i];if(c)return c;if((c=l.ba)&&(c=c[i])){var u=(c=Kit(c))[0].h;if(c=c[1]){const p=Yit(c),f=TC(ome,cme,dme,c).T;c=l.ma?Git(f,p):(g,b,_)=>u(g,b,_,f,p)}else c=u;return l[i]=c}}(r,n);o?o(s,a,n):n<500||NA(H_e,3)}}),(t=Jhe(t))&&Kce(t,(n,a,o)=>{for(TA(s,s.g.end()),n=0;n{Qce(t,r,SS([l,o],n),a)});else if(Array.isArray(s)){for(let o=0;o>BigInt(32))),lT(t.g,r.h,r.g);break;default:r=k7e(s),lT(t.g,r.h,r.g)}}function eot(t,s,r){(s=ME(s))!=null&&s!=null&&(Gx(t,r,0),rme(t.g,s))}function tot(t,s,r){(s=yit(s))!=null&&(Gx(t,r,0),t.g.g.push(s?1:0))}function sot(t,s,r){(s=Eh(s))!=null&&nme(t,r,nit(s))}function rot(t,s,r,n,a){Qce(t,r,Zit(s,n),a)}function not(t,s,r){(s=s==null||typeof s=="string"||s instanceof k0?s:void 0)!=null&&nme(t,r,TSe(s,!0).buffer)}function aot(t,s,r){(s=vit(s))!=null&&s!=null&&(Gx(t,r,0),IE(t.g,s))}function iot(t,s,r){return(t.h===5||t.h===2)&&(s=PE(s,0|s[Ta],r),t.h==2?sme(t,Yce,s):s.push(Yce(t.g)),!0)}var tu=rm(function(t,s,r){return t.h===5&&(nm(s,r,Yce(t.g)),!0)},Qit,ame),v2s=OE(iot,function(t,s,r){if((s=DE(c0,s))!=null)for(let l=0;l=0?n=String(a):((a=n.indexOf("."))!==-1&&(n=n.substring(0,a)),(a=n[0]!=="-"&&((a=n.length)<20||a===20&&n<="18446744073709551615"))||(Xhe(n),n=rO(Xc,Qd))),n;if(a==="number")return(n=MA(n))>=0&&cC(n)||(CA(n),n=xit(Xc,Qd)),n}}(s),s!=null&&(typeof s=="string"&&N7e(s),s!=null))switch(Gx(t,r,0),typeof s){case"number":t=t.g,CA(s),lT(t,Xc,Qd);break;case"bigint":r=BigInt.asUintN(64,s),r=new K_e(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),lT(t.g,r.h,r.g);break;default:r=N7e(s),lT(t.g,r.h,r.g)}},h2s),Nu=rm(function(t,s,r){return t.h===0&&(nm(s,r,yw(t.g)),!0)},eot,FSe),jR=OE(function(t,s,r){return(t.h===0||t.h===2)&&(s=PE(s,0|s[Ta],r),t.h==2?sme(t,yw,s):s.push(yw(t.g)),!0)},function(t,s,r){if((s=DE(ME,s))!=null&&s.length){r=LSe(t,r);for(let n=0;n{{const o={ea:!0};n&&Object.assign(o,n),r=Rit(r,void 0,void 0,o);try{const l=new t,i=l.v;qSe(s)(i,r);var a=l}finally{Fit(r)}}return a}}function ume(t){return function(){const s=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const l=this.g;return this.g=[],l}}}};Xit(this.v,s,TC(ome,cme,dme,t)),TA(s,s.g.end());const r=new Uint8Array(s.h),n=s.l,a=n.length;let o=0;for(let l=0;la;r=A7e.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r}()),t=(s=wye)?s.createScriptURL(t):t,new class{constructor(r){this.g=r}toString(){return this.g+""}}(t)}function Zz(t,...s){if(s.length===0)return E7e(t[0]);let r=t[0];for(let n=0;n({index:wx(n,1)??0??-1,score:Ed(n,2)??0,categoryName:Eh(ed(n,3))??""??"",displayName:Eh(ed(n,4))??""??""})),headIndex:s,headName:r}}function X2s(t){const s={classifications:O1(t,P2s,1).map(r=>{var n;return XSe(((n=Yo(r,fot,4))==null?void 0:n.g())??[],wx(r,2)??0,Eh(ed(r,3))??"")})};return function(r){return r==null?r:typeof r=="bigint"?(W_e(r)?r=Number(r):(r=vR(64,r),r=W_e(r)?Number(r):String(r)),r):bR(r)?typeof r=="number"?ySe(r):_it(r):void 0}(ed(t,2,void 0,void 0,Gce))!=null&&(s.timestampMs=qot(ed(t,2,void 0,void 0,Gce)??Cit)),s}function Uot(t){var l,i;var s=E4(t,3,c0,A4()),r=E4(t,2,ME,A4()),n=E4(t,1,Eh,A4()),a=E4(t,9,Eh,A4());const o={categories:[],keypoints:[]};for(let c=0;cs>127?s-256:s)}function U7e(t,s){if(t.length!==s.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${t.length} vs. ${s.length}).`);let r=0,n=0,a=0;for(let o=0;o=1&&Number(t[1])>=17))}async function V7e(t){if(typeof importScripts!="function"){const s=document.createElement("script");return s.src=t.toString(),s.crossOrigin="anonymous",new Promise((r,n)=>{s.addEventListener("load",()=>{r()},!1),s.addEventListener("error",a=>{n(a)},!1),document.body.appendChild(s)})}try{importScripts(t.toString())}catch(s){if(!(s instanceof TypeError))throw s;await self.import(t.toString())}}function Wot(t){return t.videoWidth!==void 0?[t.videoWidth,t.videoHeight]:t.naturalWidth!==void 0?[t.naturalWidth,t.naturalHeight]:t.displayWidth!==void 0?[t.displayWidth,t.displayHeight]:[t.width,t.height]}function Oa(t,s,r){t.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(s=t.i.stringToNewUTF8(s)),t.i._free(s)}function H7e(t,s,r){if(!t.i.canvas)throw Error("No OpenGL canvas configured.");if(r?t.i._bindTextureToStream(r):t.i._bindTextureToCanvas(),!(r=t.i.canvas.getContext("webgl2")||t.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");t.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!0),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,s),t.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1);const[n,a]=Wot(s);return!t.l||n===t.i.canvas.width&&a===t.i.canvas.height||(t.i.canvas.width=n,t.i.canvas.height=a),[n,a]}function W7e(t,s,r){t.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const n=new Uint32Array(s.length);for(let a=0;a>2),r(s);for(const a of n)t.i._free(a);t.i._free(s)}function $y(t,s,r){t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[s]=r}function Rb(t,s,r){let n=[];t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[s]=(a,o,l)=>{o?(r(n,l),n=[]):n.push(a)}}H5.forVisionTasks=function(t,s=!1){return Xz("vision",t??Zz``,s)},H5.forTextTasks=function(t,s=!1){return Xz("text",t??Zz``,s)},H5.forGenAiTasks=function(t,s=!1){return Xz("genai",t??Zz``,s)},H5.forAudioTasks=function(t,s=!1){return Xz("audio",t??Zz``,s)},H5.isSimdSupported=function(t=!1){return Vot(t)};async function J2s(t,s,r,n){return t=await(async(a,o,l,i,c)=>{if(o&&await V7e(o),!self.ModuleFactory||l&&(await V7e(l),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&c&&((o=self.Module).locateFile=c.locateFile,c.mainScriptUrlOrBlob&&(o.mainScriptUrlOrBlob=c.mainScriptUrlOrBlob)),c=await self.ModuleFactory(self.Module||c),self.ModuleFactory=self.Module=void 0,new a(c,i)})(t,r.wasmLoaderPath,r.assetLoaderPath,s,{locateFile:a=>a.endsWith(".wasm")?r.wasmBinaryPath.toString():r.assetBinaryPath&&a.endsWith(".data")?r.assetBinaryPath.toString():a}),await t.o(n),t}function kye(t,s){const r=Yo(t.baseOptions,Jce,1)||new Jce;typeof s=="string"?(Sl(r,2,_R(s)),Sl(r,1)):s instanceof Uint8Array&&(Sl(r,1,pSe(s,!1)),Sl(r,2)),oi(t.baseOptions,0,1,r)}function G7e(t){try{const s=t.H.length;if(s===1)throw Error(t.H[0].message);if(s>1)throw Error("Encountered multiple errors: "+t.H.map(r=>r.message).join(", "))}finally{t.H=[]}}function la(t,s){t.C=Math.max(t.C,s)}function fme(t,s){t.B=new Lp,Tf(t.B,2,"PassThroughCalculator"),Vc(t.B,"free_memory"),Do(t.B,"free_memory_unused_out"),rd(s,"free_memory"),Kx(s,t.B)}function AA(t,s){Vc(t.B,s),Do(t.B,s+"_unused_out")}function xme(t){t.g.addBoolToStream(!0,"free_memory",t.C)}var twe=class{constructor(t){this.g=t,this.H=[],this.C=0,this.g.setAutoRenderToScreen(!1)}l(t,s=!0){var r,n,a,o,l,i;if(s){const c=t.baseOptions||{};if((r=t.baseOptions)!=null&&r.modelAssetBuffer&&((n=t.baseOptions)!=null&&n.modelAssetPath))throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!((a=Yo(this.baseOptions,Jce,1))!=null&&a.g()||(o=Yo(this.baseOptions,Jce,1))!=null&&o.l()||(l=t.baseOptions)!=null&&l.modelAssetBuffer||(i=t.baseOptions)!=null&&i.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(u,p){let f=Yo(u.baseOptions,F7e,3);if(!f){var g=f=new F7e,b=new P7e;v8(g,4,Lie,b)}"delegate"in p&&(p.delegate==="GPU"?(p=f,g=new k2s,v8(p,2,Lie,g)):(p=f,g=new P7e,v8(p,4,Lie,g))),oi(u.baseOptions,0,3,f)}(this,c),c.modelAssetPath)return fetch(c.modelAssetPath.toString()).then(u=>{if(u.ok)return u.arrayBuffer();throw Error(`Failed to fetch model: ${c.modelAssetPath} (${u.status})`)}).then(u=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(u),!0,!1,!1),kye(this,"/model.dat"),this.m(),this.L()});if(c.modelAssetBuffer instanceof Uint8Array)kye(this,c.modelAssetBuffer);else if(c.modelAssetBuffer)return async function(u){const p=[];for(var f=0;;){const{done:g,value:b}=await u.read();if(g)break;p.push(b),f+=b.length}if(p.length===0)return new Uint8Array(0);if(p.length===1)return p[0];u=new Uint8Array(f),f=0;for(const g of p)u.set(g,f),f+=g.length;return u}(c.modelAssetBuffer).then(u=>{kye(this,u),this.m(),this.L()})}return this.m(),this.L(),Promise.resolve()}L(){}ca(){let t;if(this.g.ca(s=>{t=S2s(s)}),!t)throw Error("Failed to retrieve CalculatorGraphConfig");return t}setGraph(t,s){this.g.attachErrorListener((r,n)=>{this.H.push(Error(n))}),this.g.Ja(),this.g.setGraph(t,s),this.B=void 0,G7e(this)}finishProcessing(){this.g.finishProcessing(),G7e(this)}close(){this.B=void 0,this.g.closeGraph()}};function rw(t,s){if(!t)throw Error(`Unable to obtain required WebGL resource: ${s}`);return t}twe.prototype.close=twe.prototype.close;class ejs{constructor(s,r,n,a){this.g=s,this.h=r,this.m=n,this.l=a}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function K7e(t,s,r){const n=t.g;if(r=rw(n.createShader(r),"Failed to create WebGL shader"),n.shaderSource(r,s),n.compileShader(r),!n.getShaderParameter(r,n.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${n.getShaderInfoLog(r)}`);return n.attachShader(t.h,r),r}function Z7e(t,s){const r=t.g,n=rw(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(n);const a=rw(r.createBuffer(),"Failed to create buffer");r.bindBuffer(r.ARRAY_BUFFER,a),r.enableVertexAttribArray(t.O),r.vertexAttribPointer(t.O,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW);const o=rw(r.createBuffer(),"Failed to create buffer");return r.bindBuffer(r.ARRAY_BUFFER,o),r.enableVertexAttribArray(t.L),r.vertexAttribPointer(t.L,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array(s?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.bindVertexArray(null),new ejs(r,n,a,o)}function QSe(t,s){if(t.g){if(s!==t.g)throw Error("Cannot change GL context once initialized")}else t.g=s}function tjs(t,s,r,n){return QSe(t,s),t.h||(t.m(),t.D()),r?(t.u||(t.u=Z7e(t,!0)),r=t.u):(t.A||(t.A=Z7e(t,!1)),r=t.A),s.useProgram(t.h),r.bind(),t.l(),t=n(),r.g.bindVertexArray(null),t}function Got(t,s,r){return QSe(t,s),t=rw(s.createTexture(),"Failed to create texture"),s.bindTexture(s.TEXTURE_2D,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,r??s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,r??s.LINEAR),s.bindTexture(s.TEXTURE_2D,null),t}function Kot(t,s,r){QSe(t,s),t.B||(t.B=rw(s.createFramebuffer(),"Failed to create framebuffe.")),s.bindFramebuffer(s.FRAMEBUFFER,t.B),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,r,0)}function sjs(t){var s;(s=t.g)==null||s.bindFramebuffer(t.g.FRAMEBUFFER,null)}var Zot=class{H(){return` precision mediump float; varying vec2 vTex; uniform sampler2D inputTexture; void main() { gl_FragColor = texture2D(inputTexture, vTex); } `}m(){const t=this.g;if(this.h=rw(t.createProgram(),"Failed to create WebGL program"),this.X=K7e(this,` attribute vec2 aVertex; attribute vec2 aTex; varying vec2 vTex; void main(void) { gl_Position = vec4(aVertex, 0.0, 1.0); vTex = aTex; }`,t.VERTEX_SHADER),this.W=K7e(this,this.H(),t.FRAGMENT_SHADER),t.linkProgram(this.h),!t.getProgramParameter(this.h,t.LINK_STATUS))throw Error(`Error during program linking: ${t.getProgramInfoLog(this.h)}`);this.O=t.getAttribLocation(this.h,"aVertex"),this.L=t.getAttribLocation(this.h,"aTex")}D(){}l(){}close(){if(this.h){const t=this.g;t.deleteProgram(this.h),t.deleteShader(this.X),t.deleteShader(this.W)}this.B&&this.g.deleteFramebuffer(this.B),this.A&&this.A.close(),this.u&&this.u.close()}};function Vv(t,s){switch(s){case 0:return t.g.find(r=>r instanceof Uint8Array);case 1:return t.g.find(r=>r instanceof Float32Array);case 2:return t.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${s}`)}}function swe(t){var s=Vv(t,1);if(!s){if(s=Vv(t,0))s=new Float32Array(s).map(n=>n/255);else{s=new Float32Array(t.width*t.height);const n=EA(t);var r=JSe(t);if(Kot(r,n,Yot(t)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){r=new Float32Array(t.width*t.height*4),n.readPixels(0,0,t.width,t.height,n.RGBA,n.FLOAT,r);for(let a=0,o=0;aMath.round(255*r))),t.g.push(s)),s;var t,s}ia(){return swe(this)}N(){return Yot(this)}clone(){const t=[];for(const s of this.g){let r;if(s instanceof Uint8Array)r=new Uint8Array(s);else if(s instanceof Float32Array)r=new Float32Array(s);else{if(!(s instanceof WebGLTexture))throw Error(`Type is not supported: ${s}`);{const n=EA(this),a=JSe(this);n.activeTexture(n.TEXTURE1),r=Got(a,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);const o=Xot(this);n.texImage2D(n.TEXTURE_2D,0,o,this.width,this.height,0,n.RED,n.FLOAT,null),n.bindTexture(n.TEXTURE_2D,null),Kot(a,n,r),tjs(a,n,!1,()=>{Qot(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),rwe(this)}),sjs(a),rwe(this)}}t.push(r)}return new Uu(t,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&EA(this).deleteTexture(Vv(this,2)),Y7e=-1}};Uu.prototype.close=Uu.prototype.close,Uu.prototype.clone=Uu.prototype.clone,Uu.prototype.getAsWebGLTexture=Uu.prototype.N,Uu.prototype.getAsFloat32Array=Uu.prototype.ia,Uu.prototype.getAsUint8Array=Uu.prototype.ja,Uu.prototype.hasWebGLTexture=Uu.prototype.R,Uu.prototype.hasFloat32Array=Uu.prototype.ka,Uu.prototype.hasUint8Array=Uu.prototype.Fa;var Y7e=250;function fy(...t){return t.map(([s,r])=>({start:s,end:r}))}const rjs=function(t){return class extends t{Ja(){this.i._registerModelResourcesGraphService()}}}((X7e=class{constructor(t,s){this.l=!0,this.i=t,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",s!==void 0?this.i.canvas=s:Hot()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(t){const s=await(await fetch(t)).arrayBuffer();t=!(t.endsWith(".pbtxt")||t.endsWith(".textproto")),this.setGraph(new Uint8Array(s),t)}setGraphFromString(t){this.setGraph(new TextEncoder().encode(t),!1)}setGraph(t,s){const r=t.length,n=this.i._malloc(r);this.i.HEAPU8.set(t,n),s?this.i._changeBinaryGraph(r,n):this.i._changeTextGraph(r,n),this.i._free(n)}configureAudio(t,s,r,n,a){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Oa(this,n||"input_audio",o=>{Oa(this,a=a||"audio_header",l=>{this.i._configureAudio(o,l,t,s??0,r)})})}setAutoResizeCanvas(t){this.l=t}setAutoRenderToScreen(t){this.i._setAutoRenderToScreen(t)}setGpuBufferVerticalFlip(t){this.i.gpuOriginForWebTexturesIsBottomLeft=t}ca(t){$y(this,"__graph_config__",s=>{t(s)}),Oa(this,"__graph_config__",s=>{this.i._getGraphConfig(s,void 0)}),delete this.i.simpleListeners.__graph_config__}attachErrorListener(t){this.i.errorListener=t}attachEmptyPacketListener(t,s){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[t]=s}addAudioToStream(t,s,r){this.addAudioToStreamWithShape(t,0,0,s,r)}addAudioToStreamWithShape(t,s,r,n,a){const o=4*t.length;this.h!==o&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(o),this.h=o),this.i.HEAPF32.set(t,this.g/4),Oa(this,n,l=>{this.i._addAudioToInputStream(this.g,s,r,l,a)})}addGpuBufferToStream(t,s,r){Oa(this,s,n=>{const[a,o]=H7e(this,t,n);this.i._addBoundTextureToStream(n,a,o,r)})}addBoolToStream(t,s,r){Oa(this,s,n=>{this.i._addBoolToInputStream(t,n,r)})}addDoubleToStream(t,s,r){Oa(this,s,n=>{this.i._addDoubleToInputStream(t,n,r)})}addFloatToStream(t,s,r){Oa(this,s,n=>{this.i._addFloatToInputStream(t,n,r)})}addIntToStream(t,s,r){Oa(this,s,n=>{this.i._addIntToInputStream(t,n,r)})}addUintToStream(t,s,r){Oa(this,s,n=>{this.i._addUintToInputStream(t,n,r)})}addStringToStream(t,s,r){Oa(this,s,n=>{Oa(this,t,a=>{this.i._addStringToInputStream(a,n,r)})})}addStringRecordToStream(t,s,r){Oa(this,s,n=>{W7e(this,Object.keys(t),a=>{W7e(this,Object.values(t),o=>{this.i._addFlatHashMapToInputStream(a,o,Object.keys(t).length,n,r)})})})}addProtoToStream(t,s,r,n){Oa(this,r,a=>{Oa(this,s,o=>{const l=this.i._malloc(t.length);this.i.HEAPU8.set(t,l),this.i._addProtoToInputStream(l,t.length,o,a,n),this.i._free(l)})})}addEmptyPacketToStream(t,s){Oa(this,t,r=>{this.i._addEmptyPacketToInputStream(r,s)})}addBoolVectorToStream(t,s,r){Oa(this,s,n=>{const a=this.i._allocateBoolVector(t.length);if(!a)throw Error("Unable to allocate new bool vector on heap.");for(const o of t)this.i._addBoolVectorEntry(a,o);this.i._addBoolVectorToInputStream(a,n,r)})}addDoubleVectorToStream(t,s,r){Oa(this,s,n=>{const a=this.i._allocateDoubleVector(t.length);if(!a)throw Error("Unable to allocate new double vector on heap.");for(const o of t)this.i._addDoubleVectorEntry(a,o);this.i._addDoubleVectorToInputStream(a,n,r)})}addFloatVectorToStream(t,s,r){Oa(this,s,n=>{const a=this.i._allocateFloatVector(t.length);if(!a)throw Error("Unable to allocate new float vector on heap.");for(const o of t)this.i._addFloatVectorEntry(a,o);this.i._addFloatVectorToInputStream(a,n,r)})}addIntVectorToStream(t,s,r){Oa(this,s,n=>{const a=this.i._allocateIntVector(t.length);if(!a)throw Error("Unable to allocate new int vector on heap.");for(const o of t)this.i._addIntVectorEntry(a,o);this.i._addIntVectorToInputStream(a,n,r)})}addUintVectorToStream(t,s,r){Oa(this,s,n=>{const a=this.i._allocateUintVector(t.length);if(!a)throw Error("Unable to allocate new unsigned int vector on heap.");for(const o of t)this.i._addUintVectorEntry(a,o);this.i._addUintVectorToInputStream(a,n,r)})}addStringVectorToStream(t,s,r){Oa(this,s,n=>{const a=this.i._allocateStringVector(t.length);if(!a)throw Error("Unable to allocate new string vector on heap.");for(const o of t)Oa(this,o,l=>{this.i._addStringVectorEntry(a,l)});this.i._addStringVectorToInputStream(a,n,r)})}addBoolToInputSidePacket(t,s){Oa(this,s,r=>{this.i._addBoolToInputSidePacket(t,r)})}addDoubleToInputSidePacket(t,s){Oa(this,s,r=>{this.i._addDoubleToInputSidePacket(t,r)})}addFloatToInputSidePacket(t,s){Oa(this,s,r=>{this.i._addFloatToInputSidePacket(t,r)})}addIntToInputSidePacket(t,s){Oa(this,s,r=>{this.i._addIntToInputSidePacket(t,r)})}addUintToInputSidePacket(t,s){Oa(this,s,r=>{this.i._addUintToInputSidePacket(t,r)})}addStringToInputSidePacket(t,s){Oa(this,s,r=>{Oa(this,t,n=>{this.i._addStringToInputSidePacket(n,r)})})}addProtoToInputSidePacket(t,s,r){Oa(this,r,n=>{Oa(this,s,a=>{const o=this.i._malloc(t.length);this.i.HEAPU8.set(t,o),this.i._addProtoToInputSidePacket(o,t.length,a,n),this.i._free(o)})})}addBoolVectorToInputSidePacket(t,s){Oa(this,s,r=>{const n=this.i._allocateBoolVector(t.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(const a of t)this.i._addBoolVectorEntry(n,a);this.i._addBoolVectorToInputSidePacket(n,r)})}addDoubleVectorToInputSidePacket(t,s){Oa(this,s,r=>{const n=this.i._allocateDoubleVector(t.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(const a of t)this.i._addDoubleVectorEntry(n,a);this.i._addDoubleVectorToInputSidePacket(n,r)})}addFloatVectorToInputSidePacket(t,s){Oa(this,s,r=>{const n=this.i._allocateFloatVector(t.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(const a of t)this.i._addFloatVectorEntry(n,a);this.i._addFloatVectorToInputSidePacket(n,r)})}addIntVectorToInputSidePacket(t,s){Oa(this,s,r=>{const n=this.i._allocateIntVector(t.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(const a of t)this.i._addIntVectorEntry(n,a);this.i._addIntVectorToInputSidePacket(n,r)})}addUintVectorToInputSidePacket(t,s){Oa(this,s,r=>{const n=this.i._allocateUintVector(t.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(const a of t)this.i._addUintVectorEntry(n,a);this.i._addUintVectorToInputSidePacket(n,r)})}addStringVectorToInputSidePacket(t,s){Oa(this,s,r=>{const n=this.i._allocateStringVector(t.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(const a of t)Oa(this,a,o=>{this.i._addStringVectorEntry(n,o)});this.i._addStringVectorToInputSidePacket(n,r)})}attachBoolListener(t,s){$y(this,t,s),Oa(this,t,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(t,s){Rb(this,t,s),Oa(this,t,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(t,s){$y(this,t,s),Oa(this,t,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(t,s){Rb(this,t,s),Oa(this,t,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(t,s){$y(this,t,s),Oa(this,t,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(t,s){Rb(this,t,s),Oa(this,t,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(t,s){$y(this,t,s),Oa(this,t,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(t,s){Rb(this,t,s),Oa(this,t,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(t,s){$y(this,t,s),Oa(this,t,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(t,s){Rb(this,t,s),Oa(this,t,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(t,s){$y(this,t,s),Oa(this,t,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(t,s){Rb(this,t,s),Oa(this,t,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(t,s,r){$y(this,t,s),Oa(this,t,n=>{this.i._attachProtoListener(n,r||!1)})}attachProtoVectorListener(t,s,r){Rb(this,t,s),Oa(this,t,n=>{this.i._attachProtoVectorListener(n,r||!1)})}attachAudioListener(t,s,r){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),$y(this,t,(n,a)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),s(n,a)}),Oa(this,t,n=>{this.i._attachAudioListener(n,r||!1)})}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends X7e{get ga(){return this.i}pa(t,s,r){Oa(this,s,n=>{const[a,o]=H7e(this,t,n);this.ga._addBoundTextureAsImageToStream(n,a,o,r)})}Z(t,s){$y(this,t,s),Oa(this,t,r=>{this.ga._attachImageListener(r)})}aa(t,s){Rb(this,t,s),Oa(this,t,r=>{this.ga._attachImageVectorListener(r)})}}));var X7e,xy=class extends rjs{};async function Uo(t,s,r){return async function(n,a,o,l){return J2s(n,a,o,l)}(t,r.canvas??(Hot()?void 0:document.createElement("canvas")),s,r)}function Jot(t,s,r,n){if(t.U){const o=new bot;if(r!=null&&r.regionOfInterest){if(!t.oa)throw Error("This task doesn't support region-of-interest.");var a=r.regionOfInterest;if(a.left>=a.right||a.top>=a.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(a.left<0||a.top<0||a.right>1||a.bottom>1)throw Error("Expected RectF values to be in [0,1].");Ha(o,1,(a.left+a.right)/2),Ha(o,2,(a.top+a.bottom)/2),Ha(o,4,a.right-a.left),Ha(o,3,a.bottom-a.top)}else Ha(o,1,.5),Ha(o,2,.5),Ha(o,4,1),Ha(o,3,1);if(r!=null&&r.rotationDegrees){if((r==null?void 0:r.rotationDegrees)%90!=0)throw Error("Expected rotation to be a multiple of 90°.");if(Ha(o,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[l,i]=Wot(s);r=Ed(o,3)*i/l,a=Ed(o,4)*l/i,Ha(o,4,r),Ha(o,3,a)}}t.g.addProtoToStream(o.g(),"mediapipe.NormalizedRect",t.U,n)}t.g.pa(s,t.X,n??performance.now()),t.finishProcessing()}function gy(t,s,r){var n;if((n=t.baseOptions)!=null&&n.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");Jot(t,s,r,t.C+1)}function G0(t,s,r,n){var a;if(!((a=t.baseOptions)!=null&&a.g()))throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");Jot(t,s,r,n)}function PA(t,s,r,n){var a=s.data;const o=s.width,l=o*(s=s.height);if((a instanceof Uint8Array||a instanceof Float32Array)&&a.length!==l)throw Error("Unsupported channel count: "+a.length/l);return t=new Uu([a],r,!1,t.g.i.canvas,t.P,o,s),n?t.clone():t}var Af=class extends twe{constructor(t,s,r,n){super(t),this.g=t,this.X=s,this.U=r,this.oa=n,this.P=new Zot}l(t,s=!0){if("runningMode"in t&&Sl(this.baseOptions,2,nO(!!t.runningMode&&t.runningMode!=="IMAGE")),t.canvas!==void 0&&this.g.i.canvas!==t.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(t,s)}close(){this.P.close(),super.close()}};Af.prototype.close=Af.prototype.close;var ex=class extends Af{constructor(t,s){super(new xy(t,s),"image_in","norm_rect_in",!1),this.j={detections:[]},oi(t=this.h=new mme,0,1,s=new Nd),Ha(this.h,2,.5),Ha(this.h,3,.3)}get baseOptions(){return Yo(this.h,Nd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return"minDetectionConfidence"in t&&Ha(this.h,2,t.minDetectionConfidence??.5),"minSuppressionThreshold"in t&&Ha(this.h,3,t.minSuppressionThreshold??.3),this.l(t)}F(t,s){return this.j={detections:[]},gy(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},G0(this,t,r,s),this.j}m(){var t=new Lf;rd(t,"image_in"),rd(t,"norm_rect_in"),sl(t,"detections");const s=new If;H0(s,F2s,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),Vc(r,"IMAGE:image_in"),Vc(r,"NORM_RECT:norm_rect_in"),Do(r,"DETECTIONS:detections"),r.o(s),Kx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=got(o),this.j.detections.push(Uot(n));la(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ex.prototype.detectForVideo=ex.prototype.G,ex.prototype.detect=ex.prototype.F,ex.prototype.setOptions=ex.prototype.o,ex.createFromModelPath=async function(t,s){return Uo(ex,t,{baseOptions:{modelAssetPath:s}})},ex.createFromModelBuffer=function(t,s){return Uo(ex,t,{baseOptions:{modelAssetBuffer:s}})},ex.createFromOptions=function(t,s){return Uo(ex,t,s)};var eCe=fy([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),tCe=fy([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),sCe=fy([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),elt=fy([474,475],[475,476],[476,477],[477,474]),rCe=fy([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),nCe=fy([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),tlt=fy([469,470],[470,471],[471,472],[472,469]),aCe=fy([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),slt=[...eCe,...tCe,...sCe,...rCe,...nCe,...aCe],rlt=fy([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function Q7e(t){t.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var ld=class extends Af{constructor(t,s){super(new xy(t,s),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,oi(t=this.h=new kot,0,1,s=new Nd),this.A=new Not,oi(this.h,0,3,this.A),this.u=new mme,oi(this.h,0,2,this.u),R1(this.u,4,1),Ha(this.u,2,.5),Ha(this.A,2,.5),Ha(this.h,4,.5)}get baseOptions(){return Yo(this.h,Nd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return"numFaces"in t&&R1(this.u,4,t.numFaces??1),"minFaceDetectionConfidence"in t&&Ha(this.u,2,t.minFaceDetectionConfidence??.5),"minTrackingConfidence"in t&&Ha(this.h,4,t.minTrackingConfidence??.5),"minFacePresenceConfidence"in t&&Ha(this.A,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in t&&(this.outputFacialTransformationMatrixes=!!t.outputFacialTransformationMatrixes),this.l(t)}F(t,s){return Q7e(this),gy(this,t,s),this.j}G(t,s,r){return Q7e(this),G0(this,t,r,s),this.j}m(){var t=new Lf;rd(t,"image_in"),rd(t,"norm_rect"),sl(t,"face_landmarks");const s=new If;H0(s,B2s,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),Vc(r,"IMAGE:image_in"),Vc(r,"NORM_RECT:norm_rect"),Do(r,"NORM_LANDMARKS:face_landmarks"),r.o(s),Kx(t,r),this.g.attachProtoVectorListener("face_landmarks",(n,a)=>{for(const o of n)n=NR(o),this.j.faceLandmarks.push(pme(n));la(this,a)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{la(this,n)}),this.outputFaceBlendshapes&&(sl(t,"blendshapes"),Do(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,a)=>{if(this.outputFaceBlendshapes)for(const o of n)n=hme(o),this.j.faceBlendshapes.push(XSe(n.g()??[]));la(this,a)}),this.g.attachEmptyPacketListener("blendshapes",n=>{la(this,n)})),this.outputFacialTransformationMatrixes&&(sl(t,"face_geometry"),Do(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(n,a)=>{if(this.outputFacialTransformationMatrixes)for(const o of n)(n=Yo(n=z2s(o),A2s,2))&&this.j.facialTransformationMatrixes.push({rows:wx(n,1)??0??0,columns:wx(n,2)??0??0,data:E4(n,3,c0,A4()).slice()??[]});la(this,a)}),this.g.attachEmptyPacketListener("face_geometry",n=>{la(this,n)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ld.prototype.detectForVideo=ld.prototype.G,ld.prototype.detect=ld.prototype.F,ld.prototype.setOptions=ld.prototype.o,ld.createFromModelPath=function(t,s){return Uo(ld,t,{baseOptions:{modelAssetPath:s}})},ld.createFromModelBuffer=function(t,s){return Uo(ld,t,{baseOptions:{modelAssetBuffer:s}})},ld.createFromOptions=function(t,s){return Uo(ld,t,s)},ld.FACE_LANDMARKS_LIPS=eCe,ld.FACE_LANDMARKS_LEFT_EYE=tCe,ld.FACE_LANDMARKS_LEFT_EYEBROW=sCe,ld.FACE_LANDMARKS_LEFT_IRIS=elt,ld.FACE_LANDMARKS_RIGHT_EYE=rCe,ld.FACE_LANDMARKS_RIGHT_EYEBROW=nCe,ld.FACE_LANDMARKS_RIGHT_IRIS=tlt,ld.FACE_LANDMARKS_FACE_OVAL=aCe,ld.FACE_LANDMARKS_CONTOURS=slt,ld.FACE_LANDMARKS_TESSELATION=rlt;var iCe=fy([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function J7e(t){t.gestures=[],t.landmarks=[],t.worldLandmarks=[],t.handedness=[]}function eze(t){return t.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:t.gestures,landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handedness:t.handedness,handednesses:t.handedness}}function tze(t,s=!0){const r=[];for(const a of t){var n=hme(a);t=[];for(const o of n.g())n=s&&wx(o,1)!=null?wx(o,1)??0:-1,t.push({score:Ed(o,2)??0,index:n,categoryName:Eh(ed(o,3))??""??"",displayName:Eh(ed(o,4))??""??""});r.push(t)}return r}var Wp=class extends Af{constructor(t,s){super(new xy(t,s),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],oi(t=this.j=new Mot,0,1,s=new Nd),this.u=new GSe,oi(this.j,0,2,this.u),this.D=new WSe,oi(this.u,0,3,this.D),this.A=new Cot,oi(this.u,0,2,this.A),this.h=new $2s,oi(this.j,0,3,this.h),Ha(this.A,2,.5),Ha(this.u,4,.5),Ha(this.D,2,.5)}get baseOptions(){return Yo(this.j,Nd,1)}set baseOptions(t){oi(this.j,0,1,t)}o(t){var a,o,l,i;if(R1(this.A,3,t.numHands??1),"minHandDetectionConfidence"in t&&Ha(this.A,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Ha(this.u,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Ha(this.D,2,t.minHandPresenceConfidence??.5),t.cannedGesturesClassifierOptions){var s=new I5,r=s,n=ewe(t.cannedGesturesClassifierOptions,(a=Yo(this.h,I5,3))==null?void 0:a.l());oi(r,0,2,n),oi(this.h,0,3,s)}else t.cannedGesturesClassifierOptions===void 0&&((o=Yo(this.h,I5,3))==null||o.g());return t.customGesturesClassifierOptions?(oi(r=s=new I5,0,2,n=ewe(t.customGesturesClassifierOptions,(l=Yo(this.h,I5,4))==null?void 0:l.l())),oi(this.h,0,4,s)):t.customGesturesClassifierOptions===void 0&&((i=Yo(this.h,I5,4))==null||i.g()),this.l(t)}Ha(t,s){return J7e(this),gy(this,t,s),eze(this)}Ia(t,s,r){return J7e(this),G0(this,t,r,s),eze(this)}m(){var t=new Lf;rd(t,"image_in"),rd(t,"norm_rect"),sl(t,"hand_gestures"),sl(t,"hand_landmarks"),sl(t,"world_hand_landmarks"),sl(t,"handedness");const s=new If;H0(s,q2s,this.j);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),Vc(r,"IMAGE:image_in"),Vc(r,"NORM_RECT:norm_rect"),Do(r,"HAND_GESTURES:hand_gestures"),Do(r,"LANDMARKS:hand_landmarks"),Do(r,"WORLD_LANDMARKS:world_hand_landmarks"),Do(r,"HANDEDNESS:handedness"),r.o(s),Kx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n){n=NR(o);const l=[];for(const i of O1(n,vot,1))l.push({x:Ed(i,1)??0,y:Ed(i,2)??0,z:Ed(i,3)??0,visibility:Ed(i,4)??0});this.landmarks.push(l)}la(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{la(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n){n=cT(o);const l=[];for(const i of O1(n,yot,1))l.push({x:Ed(i,1)??0,y:Ed(i,2)??0,z:Ed(i,3)??0,visibility:Ed(i,4)??0});this.worldLandmarks.push(l)}la(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{la(this,n)}),this.g.attachProtoVectorListener("hand_gestures",(n,a)=>{this.gestures.push(...tze(n,!1)),la(this,a)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{la(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{this.handedness.push(...tze(n)),la(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function sze(t){return{landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handednesses:t.handedness,handedness:t.handedness}}Wp.prototype.recognizeForVideo=Wp.prototype.Ia,Wp.prototype.recognize=Wp.prototype.Ha,Wp.prototype.setOptions=Wp.prototype.o,Wp.createFromModelPath=function(t,s){return Uo(Wp,t,{baseOptions:{modelAssetPath:s}})},Wp.createFromModelBuffer=function(t,s){return Uo(Wp,t,{baseOptions:{modelAssetBuffer:s}})},Wp.createFromOptions=function(t,s){return Uo(Wp,t,s)},Wp.HAND_CONNECTIONS=iCe;var Gp=class extends Af{constructor(t,s){super(new xy(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],oi(t=this.h=new GSe,0,1,s=new Nd),this.u=new WSe,oi(this.h,0,3,this.u),this.j=new Cot,oi(this.h,0,2,this.j),R1(this.j,3,1),Ha(this.j,2,.5),Ha(this.u,2,.5),Ha(this.h,4,.5)}get baseOptions(){return Yo(this.h,Nd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return"numHands"in t&&R1(this.j,3,t.numHands??1),"minHandDetectionConfidence"in t&&Ha(this.j,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Ha(this.h,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Ha(this.u,2,t.minHandPresenceConfidence??.5),this.l(t)}F(t,s){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],gy(this,t,s),sze(this)}G(t,s,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],G0(this,t,r,s),sze(this)}m(){var t=new Lf;rd(t,"image_in"),rd(t,"norm_rect"),sl(t,"hand_landmarks"),sl(t,"world_hand_landmarks"),sl(t,"handedness");const s=new If;H0(s,U2s,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),Vc(r,"IMAGE:image_in"),Vc(r,"NORM_RECT:norm_rect"),Do(r,"LANDMARKS:hand_landmarks"),Do(r,"WORLD_LANDMARKS:world_hand_landmarks"),Do(r,"HANDEDNESS:handedness"),r.o(s),Kx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n)n=NR(o),this.landmarks.push(pme(n));la(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{la(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n)n=cT(o),this.worldLandmarks.push(_8(n));la(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{la(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{var o=this.handedness,l=o.push;const i=[];for(const c of n){n=hme(c);const u=[];for(const p of n.g())u.push({score:Ed(p,2)??0,index:wx(p,1)??0??-1,categoryName:Eh(ed(p,3))??""??"",displayName:Eh(ed(p,4))??""??""});i.push(u)}l.call(o,...i),la(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Gp.prototype.detectForVideo=Gp.prototype.G,Gp.prototype.detect=Gp.prototype.F,Gp.prototype.setOptions=Gp.prototype.o,Gp.createFromModelPath=function(t,s){return Uo(Gp,t,{baseOptions:{modelAssetPath:s}})},Gp.createFromModelBuffer=function(t,s){return Uo(Gp,t,{baseOptions:{modelAssetBuffer:s}})},Gp.createFromOptions=function(t,s){return Uo(Gp,t,s)},Gp.HAND_CONNECTIONS=iCe;var nlt=fy([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function rze(t){t.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function nze(t){try{if(!t.D)return t.h;t.D(t.h)}finally{xme(t)}}function Jz(t,s){t=NR(t),s.push(pme(t))}var Pc=class extends Af{constructor(t,s){super(new xy(t,s),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,oi(t=this.j=new Iot,0,1,s=new Nd),this.I=new WSe,oi(this.j,0,2,this.I),this.W=new V2s,oi(this.j,0,3,this.W),this.u=new mme,oi(this.j,0,4,this.u),this.O=new Not,oi(this.j,0,5,this.O),this.A=new Eot,oi(this.j,0,6,this.A),this.M=new Pot,oi(this.j,0,7,this.M),Ha(this.u,2,.5),Ha(this.u,3,.3),Ha(this.O,2,.5),Ha(this.A,2,.5),Ha(this.A,3,.3),Ha(this.M,2,.5),Ha(this.I,2,.5)}get baseOptions(){return Yo(this.j,Nd,1)}set baseOptions(t){oi(this.j,0,1,t)}o(t){return"minFaceDetectionConfidence"in t&&Ha(this.u,2,t.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in t&&Ha(this.u,3,t.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in t&&Ha(this.O,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"minPoseDetectionConfidence"in t&&Ha(this.A,2,t.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in t&&Ha(this.A,3,t.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in t&&Ha(this.M,2,t.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in t&&(this.outputPoseSegmentationMasks=!!t.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in t&&Ha(this.I,2,t.minHandLandmarksConfidence??.5),this.l(t)}F(t,s,r){const n=typeof s!="function"?s:{};return this.D=typeof s=="function"?s:r,rze(this),gy(this,t,n),nze(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:n,rze(this),G0(this,t,a,s),nze(this)}m(){var t=new Lf;rd(t,"input_frames_image"),sl(t,"pose_landmarks"),sl(t,"pose_world_landmarks"),sl(t,"face_landmarks"),sl(t,"left_hand_landmarks"),sl(t,"left_hand_world_landmarks"),sl(t,"right_hand_landmarks"),sl(t,"right_hand_world_landmarks");const s=new If,r=new M7e;Tf(r,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),function(a,o){if(o!=null)if(Array.isArray(o))Sl(a,2,eme(o,0,aO));else{if(!(typeof o=="string"||o instanceof k0||hSe(o)))throw Error("invalid value in Any.value field: "+o+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");e_(a,2,pSe(o,!1),oC())}}(r,this.j.g());const n=new Lp;Tf(n,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),MSe(n,8,M7e,r),Vc(n,"IMAGE:input_frames_image"),Do(n,"POSE_LANDMARKS:pose_landmarks"),Do(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),Do(n,"FACE_LANDMARKS:face_landmarks"),Do(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),Do(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),Do(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),Do(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(s),Kx(t,n),fme(this,t),this.g.attachProtoListener("pose_landmarks",(a,o)=>{Jz(a,this.h.poseLandmarks),la(this,o)}),this.g.attachEmptyPacketListener("pose_landmarks",a=>{la(this,a)}),this.g.attachProtoListener("pose_world_landmarks",(a,o)=>{var l=this.h.poseWorldLandmarks;a=cT(a),l.push(_8(a)),la(this,o)}),this.g.attachEmptyPacketListener("pose_world_landmarks",a=>{la(this,a)}),this.outputPoseSegmentationMasks&&(Do(n,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),AA(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",(a,o)=>{this.h.poseSegmentationMasks=[PA(this,a,!0,!this.D)],la(this,o)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",a=>{this.h.poseSegmentationMasks=[],la(this,a)})),this.g.attachProtoListener("face_landmarks",(a,o)=>{Jz(a,this.h.faceLandmarks),la(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",a=>{la(this,a)}),this.outputFaceBlendshapes&&(sl(t,"extra_blendshapes"),Do(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(a,o)=>{var l=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(a=hme(a),l.push(XSe(a.g()??[]))),la(this,o)}),this.g.attachEmptyPacketListener("extra_blendshapes",a=>{la(this,a)})),this.g.attachProtoListener("left_hand_landmarks",(a,o)=>{Jz(a,this.h.leftHandLandmarks),la(this,o)}),this.g.attachEmptyPacketListener("left_hand_landmarks",a=>{la(this,a)}),this.g.attachProtoListener("left_hand_world_landmarks",(a,o)=>{var l=this.h.leftHandWorldLandmarks;a=cT(a),l.push(_8(a)),la(this,o)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",a=>{la(this,a)}),this.g.attachProtoListener("right_hand_landmarks",(a,o)=>{Jz(a,this.h.rightHandLandmarks),la(this,o)}),this.g.attachEmptyPacketListener("right_hand_landmarks",a=>{la(this,a)}),this.g.attachProtoListener("right_hand_world_landmarks",(a,o)=>{var l=this.h.rightHandWorldLandmarks;a=cT(a),l.push(_8(a)),la(this,o)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",a=>{la(this,a)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Pc.prototype.detectForVideo=Pc.prototype.G,Pc.prototype.detect=Pc.prototype.F,Pc.prototype.setOptions=Pc.prototype.o,Pc.createFromModelPath=function(t,s){return Uo(Pc,t,{baseOptions:{modelAssetPath:s}})},Pc.createFromModelBuffer=function(t,s){return Uo(Pc,t,{baseOptions:{modelAssetBuffer:s}})},Pc.createFromOptions=function(t,s){return Uo(Pc,t,s)},Pc.HAND_CONNECTIONS=iCe,Pc.POSE_CONNECTIONS=nlt,Pc.FACE_LANDMARKS_LIPS=eCe,Pc.FACE_LANDMARKS_LEFT_EYE=tCe,Pc.FACE_LANDMARKS_LEFT_EYEBROW=sCe,Pc.FACE_LANDMARKS_LEFT_IRIS=elt,Pc.FACE_LANDMARKS_RIGHT_EYE=rCe,Pc.FACE_LANDMARKS_RIGHT_EYEBROW=nCe,Pc.FACE_LANDMARKS_RIGHT_IRIS=tlt,Pc.FACE_LANDMARKS_FACE_OVAL=aCe,Pc.FACE_LANDMARKS_CONTOURS=slt,Pc.FACE_LANDMARKS_TESSELATION=rlt;var tx=class extends Af{constructor(t,s){super(new xy(t,s),"input_image","norm_rect",!0),this.j={classifications:[]},oi(t=this.h=new Lot,0,1,s=new Nd)}get baseOptions(){return Yo(this.h,Nd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return oi(this.h,0,2,ewe(t,Yo(this.h,VSe,2))),this.l(t)}sa(t,s){return this.j={classifications:[]},gy(this,t,s),this.j}ta(t,s,r){return this.j={classifications:[]},G0(this,t,r,s),this.j}m(){var t=new Lf;rd(t,"input_image"),rd(t,"norm_rect"),sl(t,"classifications");const s=new If;H0(s,H2s,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),Vc(r,"IMAGE:input_image"),Vc(r,"NORM_RECT:norm_rect"),Do(r,"CLASSIFICATIONS:classifications"),r.o(s),Kx(t,r),this.g.attachProtoListener("classifications",(n,a)=>{this.j=X2s(I2s(n)),la(this,a)}),this.g.attachEmptyPacketListener("classifications",n=>{la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};tx.prototype.classifyForVideo=tx.prototype.ta,tx.prototype.classify=tx.prototype.sa,tx.prototype.setOptions=tx.prototype.o,tx.createFromModelPath=function(t,s){return Uo(tx,t,{baseOptions:{modelAssetPath:s}})},tx.createFromModelBuffer=function(t,s){return Uo(tx,t,{baseOptions:{modelAssetBuffer:s}})},tx.createFromOptions=function(t,s){return Uo(tx,t,s)};var Kp=class extends Af{constructor(t,s){super(new xy(t,s),"image_in","norm_rect",!0),this.h=new Dot,this.embeddings={embeddings:[]},oi(t=this.h,0,1,s=new Nd)}get baseOptions(){return Yo(this.h,Nd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){var s=this.h,r=Yo(this.h,R7e,2);return r=r?r.clone():new R7e,t.l2Normalize!==void 0?Sl(r,1,nO(t.l2Normalize)):"l2Normalize"in t&&Sl(r,1),t.quantize!==void 0?Sl(r,2,nO(t.quantize)):"quantize"in t&&Sl(r,2),oi(s,0,2,r),this.l(t)}za(t,s){return gy(this,t,s),this.embeddings}Aa(t,s,r){return G0(this,t,r,s),this.embeddings}m(){var t=new Lf;rd(t,"image_in"),rd(t,"norm_rect"),sl(t,"embeddings_out");const s=new If;H0(s,W2s,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),Vc(r,"IMAGE:image_in"),Vc(r,"NORM_RECT:norm_rect"),Do(r,"EMBEDDINGS:embeddings_out"),r.o(s),Kx(t,r),this.g.attachProtoListener("embeddings_out",(n,a)=>{n=O2s(n),this.embeddings=function(o){return{embeddings:O1(o,D2s,1).map(l=>{var u,p;const i={headIndex:wx(l,3)??0??-1,headName:Eh(ed(l,4))??""??""};var c=l.v;return Pit(c,0|c[Ta],O7e,bye(l,1))!==void 0?(l=E4(l=Yo(l,O7e,bye(l,1),void 0),1,c0,A4()),i.floatEmbedding=l.slice()):(c=new Uint8Array(0),i.quantizedEmbedding=((p=(u=Yo(l,L2s,bye(l,2),void 0))==null?void 0:u.na())==null?void 0:p.h())??c),i}),timestampMs:qot(ed(o,2,void 0,void 0,Gce)??Cit)}}(n),la(this,a)}),this.g.attachEmptyPacketListener("embeddings_out",n=>{la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Kp.cosineSimilarity=function(t,s){if(t.floatEmbedding&&s.floatEmbedding)t=U7e(t.floatEmbedding,s.floatEmbedding);else{if(!t.quantizedEmbedding||!s.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");t=U7e(q7e(t.quantizedEmbedding),q7e(s.quantizedEmbedding))}return t},Kp.prototype.embedForVideo=Kp.prototype.Aa,Kp.prototype.embed=Kp.prototype.za,Kp.prototype.setOptions=Kp.prototype.o,Kp.createFromModelPath=function(t,s){return Uo(Kp,t,{baseOptions:{modelAssetPath:s}})},Kp.createFromModelBuffer=function(t,s){return Uo(Kp,t,{baseOptions:{modelAssetBuffer:s}})},Kp.createFromOptions=function(t,s){return Uo(Kp,t,s)};var nwe=class{constructor(t,s,r){this.confidenceMasks=t,this.categoryMask=s,this.qualityScores=r}close(){var t,s;(t=this.confidenceMasks)==null||t.forEach(r=>{r.close()}),(s=this.categoryMask)==null||s.close()}};function njs(t){var r,n;const s=function(a){return O1(a,Lp,1)}(t.ca()).filter(a=>(Eh(ed(a,1))??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(t.u=[],s.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");s.length===1&&(((n=(r=Yo(s[0],If,7))==null?void 0:r.j())==null?void 0:n.g())??new Map).forEach((a,o)=>{t.u[Number(o)]=Eh(ed(a,1))??""})}function aze(t){t.categoryMask=void 0,t.confidenceMasks=void 0,t.qualityScores=void 0}function ize(t){try{const s=new nwe(t.confidenceMasks,t.categoryMask,t.qualityScores);if(!t.j)return s;t.j(s)}finally{xme(t)}}nwe.prototype.close=nwe.prototype.close;var xm=class extends Af{constructor(t,s){super(new xy(t,s),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new YSe,this.A=new Oot,oi(this.h,0,3,this.A),oi(t=this.h,0,1,s=new Nd)}get baseOptions(){return Yo(this.h,Nd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?Sl(this.h,2,_R(t.displayNamesLocale)):"displayNamesLocale"in t&&Sl(this.h,2),"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}L(){njs(this)}segment(t,s,r){const n=typeof s!="function"?s:{};return this.j=typeof s=="function"?s:r,aze(this),gy(this,t,n),ize(this)}La(t,s,r,n){const a=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,aze(this),G0(this,t,a,s),ize(this)}Da(){return this.u}m(){var t=new Lf;rd(t,"image_in"),rd(t,"norm_rect");const s=new If;H0(s,Fot,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),Vc(r,"IMAGE:image_in"),Vc(r,"NORM_RECT:norm_rect"),r.o(s),Kx(t,r),fme(this,t),this.outputConfidenceMasks&&(sl(t,"confidence_masks"),Do(r,"CONFIDENCE_MASKS:confidence_masks"),AA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>PA(this,o,!0,!this.j)),la(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],la(this,n)})),this.outputCategoryMask&&(sl(t,"category_mask"),Do(r,"CATEGORY_MASK:category_mask"),AA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=PA(this,n,!1,!this.j),la(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,la(this,n)})),sl(t,"quality_scores"),Do(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,la(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};xm.prototype.getLabels=xm.prototype.Da,xm.prototype.segmentForVideo=xm.prototype.La,xm.prototype.segment=xm.prototype.segment,xm.prototype.setOptions=xm.prototype.o,xm.createFromModelPath=function(t,s){return Uo(xm,t,{baseOptions:{modelAssetPath:s}})},xm.createFromModelBuffer=function(t,s){return Uo(xm,t,{baseOptions:{modelAssetBuffer:s}})},xm.createFromOptions=function(t,s){return Uo(xm,t,s)};var awe=class{constructor(t,s,r){this.confidenceMasks=t,this.categoryMask=s,this.qualityScores=r}close(){var t,s;(t=this.confidenceMasks)==null||t.forEach(r=>{r.close()}),(s=this.categoryMask)==null||s.close()}};awe.prototype.close=awe.prototype.close;var qy=class extends Af{constructor(t,s){super(new xy(t,s),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new YSe,this.u=new Oot,oi(this.h,0,3,this.u),oi(t=this.h,0,1,s=new Nd)}get baseOptions(){return Yo(this.h,Nd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}segment(t,s,r,n){const a=typeof r!="function"?r:{};if(this.j=typeof r=="function"?r:n,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,r=this.C+1,n=new zot,s.keypoint&&s.scribble)throw Error("Cannot provide both keypoint and scribble.");if(s.keypoint){var o=new Nye;e_(o,3,nO(!0),!1),e_(o,1,AI(s.keypoint.x),0),e_(o,2,AI(s.keypoint.y),0),v8(n,1,J_e,o)}else{if(!s.scribble)throw Error("Must provide either a keypoint or a scribble.");{const i=new K2s;for(o of s.scribble)e_(s=new Nye,3,nO(!0),!1),e_(s,1,AI(o.x),0),e_(s,2,AI(o.y),0),MSe(i,1,Nye,s);v8(n,2,J_e,i)}}this.g.addProtoToStream(n.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",r),gy(this,t,a);e:{try{const i=new awe(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=i;break e}this.j(i)}finally{xme(this)}l=void 0}return l}m(){var t=new Lf;rd(t,"image_in"),rd(t,"roi_in"),rd(t,"norm_rect_in");const s=new If;H0(s,Fot,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),Vc(r,"IMAGE:image_in"),Vc(r,"ROI:roi_in"),Vc(r,"NORM_RECT:norm_rect_in"),r.o(s),Kx(t,r),fme(this,t),this.outputConfidenceMasks&&(sl(t,"confidence_masks"),Do(r,"CONFIDENCE_MASKS:confidence_masks"),AA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>PA(this,o,!0,!this.j)),la(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],la(this,n)})),this.outputCategoryMask&&(sl(t,"category_mask"),Do(r,"CATEGORY_MASK:category_mask"),AA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=PA(this,n,!1,!this.j),la(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,la(this,n)})),sl(t,"quality_scores"),Do(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,la(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};qy.prototype.segment=qy.prototype.segment,qy.prototype.setOptions=qy.prototype.o,qy.createFromModelPath=function(t,s){return Uo(qy,t,{baseOptions:{modelAssetPath:s}})},qy.createFromModelBuffer=function(t,s){return Uo(qy,t,{baseOptions:{modelAssetBuffer:s}})},qy.createFromOptions=function(t,s){return Uo(qy,t,s)};var sx=class extends Af{constructor(t,s){super(new xy(t,s),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},oi(t=this.h=new Bot,0,1,s=new Nd)}get baseOptions(){return Yo(this.h,Nd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?Sl(this.h,2,_R(t.displayNamesLocale)):"displayNamesLocale"in t&&Sl(this.h,2),t.maxResults!==void 0?R1(this.h,3,t.maxResults):"maxResults"in t&&Sl(this.h,3),t.scoreThreshold!==void 0?Ha(this.h,4,t.scoreThreshold):"scoreThreshold"in t&&Sl(this.h,4),t.categoryAllowlist!==void 0?Zce(this.h,5,t.categoryAllowlist):"categoryAllowlist"in t&&Sl(this.h,5),t.categoryDenylist!==void 0?Zce(this.h,6,t.categoryDenylist):"categoryDenylist"in t&&Sl(this.h,6),this.l(t)}F(t,s){return this.j={detections:[]},gy(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},G0(this,t,r,s),this.j}m(){var t=new Lf;rd(t,"input_frame_gpu"),rd(t,"norm_rect"),sl(t,"detections");const s=new If;H0(s,Z2s,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),Vc(r,"IMAGE:input_frame_gpu"),Vc(r,"NORM_RECT:norm_rect"),Do(r,"DETECTIONS:detections"),r.o(s),Kx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=got(o),this.j.detections.push(Uot(n));la(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};sx.prototype.detectForVideo=sx.prototype.G,sx.prototype.detect=sx.prototype.F,sx.prototype.setOptions=sx.prototype.o,sx.createFromModelPath=async function(t,s){return Uo(sx,t,{baseOptions:{modelAssetPath:s}})},sx.createFromModelBuffer=function(t,s){return Uo(sx,t,{baseOptions:{modelAssetBuffer:s}})},sx.createFromOptions=function(t,s){return Uo(sx,t,s)};var iwe=class{constructor(t,s,r){this.landmarks=t,this.worldLandmarks=s,this.segmentationMasks=r}close(){var t;(t=this.segmentationMasks)==null||t.forEach(s=>{s.close()})}};function oze(t){t.landmarks=[],t.worldLandmarks=[],t.segmentationMasks=void 0}function lze(t){try{const s=new iwe(t.landmarks,t.worldLandmarks,t.segmentationMasks);if(!t.u)return s;t.u(s)}finally{xme(t)}}iwe.prototype.close=iwe.prototype.close;var Zp=class extends Af{constructor(t,s){super(new xy(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,oi(t=this.h=new $ot,0,1,s=new Nd),this.A=new Pot,oi(this.h,0,3,this.A),this.j=new Eot,oi(this.h,0,2,this.j),R1(this.j,4,1),Ha(this.j,2,.5),Ha(this.A,2,.5),Ha(this.h,4,.5)}get baseOptions(){return Yo(this.h,Nd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return"numPoses"in t&&R1(this.j,4,t.numPoses??1),"minPoseDetectionConfidence"in t&&Ha(this.j,2,t.minPoseDetectionConfidence??.5),"minTrackingConfidence"in t&&Ha(this.h,4,t.minTrackingConfidence??.5),"minPosePresenceConfidence"in t&&Ha(this.A,2,t.minPosePresenceConfidence??.5),"outputSegmentationMasks"in t&&(this.outputSegmentationMasks=t.outputSegmentationMasks??!1),this.l(t)}F(t,s,r){const n=typeof s!="function"?s:{};return this.u=typeof s=="function"?s:r,oze(this),gy(this,t,n),lze(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.u=typeof r=="function"?r:n,oze(this),G0(this,t,a,s),lze(this)}m(){var t=new Lf;rd(t,"image_in"),rd(t,"norm_rect"),sl(t,"normalized_landmarks"),sl(t,"world_landmarks"),sl(t,"segmentation_masks");const s=new If;H0(s,Y2s,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),Vc(r,"IMAGE:image_in"),Vc(r,"NORM_RECT:norm_rect"),Do(r,"NORM_LANDMARKS:normalized_landmarks"),Do(r,"WORLD_LANDMARKS:world_landmarks"),r.o(s),Kx(t,r),fme(this,t),this.g.attachProtoVectorListener("normalized_landmarks",(n,a)=>{this.landmarks=[];for(const o of n)n=NR(o),this.landmarks.push(pme(n));la(this,a)}),this.g.attachEmptyPacketListener("normalized_landmarks",n=>{this.landmarks=[],la(this,n)}),this.g.attachProtoVectorListener("world_landmarks",(n,a)=>{this.worldLandmarks=[];for(const o of n)n=cT(o),this.worldLandmarks.push(_8(n));la(this,a)}),this.g.attachEmptyPacketListener("world_landmarks",n=>{this.worldLandmarks=[],la(this,n)}),this.outputSegmentationMasks&&(Do(r,"SEGMENTATION_MASK:segmentation_masks"),AA(this,"segmentation_masks"),this.g.aa("segmentation_masks",(n,a)=>{this.segmentationMasks=n.map(o=>PA(this,o,!0,!this.u)),la(this,a)}),this.g.attachEmptyPacketListener("segmentation_masks",n=>{this.segmentationMasks=[],la(this,n)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Zp.prototype.detectForVideo=Zp.prototype.G,Zp.prototype.detect=Zp.prototype.F,Zp.prototype.setOptions=Zp.prototype.o,Zp.createFromModelPath=function(t,s){return Uo(Zp,t,{baseOptions:{modelAssetPath:s}})},Zp.createFromModelBuffer=function(t,s){return Uo(Zp,t,{baseOptions:{modelAssetBuffer:s}})},Zp.createFromOptions=function(t,s){return Uo(Zp,t,s)},Zp.POSE_CONNECTIONS=nlt;let P4=null,EI=null;async function ajs(){return P4||EI||(EI=(async()=>{const t=await H5.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm");return P4=await xm.createFromOptions(t,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/image_segmenter/selfie_multiclass_256x256/float32/latest/selfie_multiclass_256x256.tflite",delegate:"GPU"},runningMode:"VIDEO",outputCategoryMask:!1,outputConfidenceMasks:!0}),P4})(),EI)}function ijs(t,s,r,n,a){const o=new Float32Array(t.length);for(let l=0;l=0&&(i-=t[c+p]);const g=Math.min(f,r-1)-Math.max(p+1,0)+1;o[c+u]=i/g}}for(let l=0;l=0&&(i-=o[u*r+l]);const f=Math.min(p,n-1)-Math.max(u+1,0)+1;s[c*r+l]=i/f}}}function ojs(){P4&&(P4.close(),P4=null,EI=null)}function ljs(t,s){const r=N.useRef(null),n=N.useRef(null),a=N.useRef(null),o=N.useRef(null),l=N.useRef(0),i=N.useRef(0),[c,u]=N.useState(null),[p,f]=N.useState(!1),[g,b]=N.useState(null),_=s.type!=="none"&&t!==null;return N.useEffect(()=>{if(s.type==="image"&&s.imageUrl){const j=new Image;j.crossOrigin="anonymous",j.src=s.imageUrl,j.onload=()=>{o.current=j}}else o.current=null},[s.type,s.imageUrl]),N.useEffect(()=>{if(!_||!t){a.current&&(a.current.srcObject=null,a.current=null);return}const j=document.createElement("video");return j.srcObject=t,j.muted=!0,j.playsInline=!0,j.autoplay=!0,j.play().catch(()=>{}),a.current=j,()=>{j.srcObject=null,a.current=null}},[_,t]),N.useEffect(()=>{if(!_){u(null),b(null);return}let j=!1;return(async()=>{f(!0),b(null);try{const k=await ajs();if(j)return;f(!1);const S=a.current;if(!S||(await new Promise(pe=>{if(S.videoWidth>0)return pe();S.onloadedmetadata=()=>pe(),setTimeout(pe,2e3)}),j))return;const M=S.videoWidth||640,L=S.videoHeight||480,I=r.current;if(!I)return;I.width=M,I.height=L;const O=I.getContext("2d",{willReadFrequently:!1});n.current||(n.current=document.createElement("canvas"));const q=n.current;q.width=M,q.height=L;const U=q.getContext("2d",{willReadFrequently:!0}),B=document.createElement("canvas");B.width=M,B.height=L;const V=B.getContext("2d"),Z=I.captureStream(30);((t==null?void 0:t.getAudioTracks())||[]).forEach(pe=>Z.addTrack(pe)),j||u(Z);const ee=s.blurRadius??15,Q=s.mirror??!1,ie=new Float32Array(M*L),re=new Float32Array(M*L),oe=new Float32Array(M*L);let ce=!1;const xe=4,ge=.6,ue=()=>{if(j||!a.current)return;const pe=performance.now();if(pe-i.current<30){l.current=requestAnimationFrame(ue);return}i.current=pe;const be=a.current;if(be.readyState<2){l.current=requestAnimationFrame(ue);return}try{const Ne=k.segmentForVideo(be,pe).confidenceMasks;if(Ne&&Ne.length>0){re.fill(0);for(let Te=1;TeBe?(ft=Te.height*Be,nt=(Te.width-ft)/2):(fe=Te.width/Be,Ae=(Te.height-fe)/2),O.drawImage(Te,nt,Ae,ft,fe,0,0,M,L)}U.clearRect(0,0,M,L),U.drawImage(be,0,0,M,L);const Pe=U.getImageData(0,0,M,L),Oe=Pe.data;for(let Te=0;Te{j=!0,l.current&&cancelAnimationFrame(l.current),u(null)}},[_,s.type,s.blurRadius,s.imageUrl,t]),N.useEffect(()=>()=>{ojs()},[]),{canvasRef:r,compositedStream:c,isLoading:p,isActive:_,error:g}}function gme({maxDurationSeconds:t=30,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=N.useRef(null),i=N.useRef(null),c=N.useRef(null),[u,p]=N.useState(null),f=N.useRef([]),g=N.useRef(null),b=N.useRef(null),_=N.useRef(null),j=N.useRef(null),w=NE(),[k,S]=N.useState("camera"),M=N.useRef(null),L=N.useRef(null),I=N.useRef(null),O=N.useRef(null),q=N.useRef(null),[U,B]=N.useState(!0),[V,Z]=N.useState(!0),[X,ee]=N.useState(null),[Q,ie]=N.useState(!1),[re,oe]=N.useState(!1),[ce,xe]=N.useState(null),[ge,ue]=N.useState(null),[pe,be]=N.useState(0),[Me,Ne]=N.useState("user"),[Pe,Oe]=N.useState(0),[Te,ke]=N.useState(!1),[Be,nt]=N.useState(!0),[Ae,ft]=N.useState(null),[fe,Ve]=N.useState(!1),[at,et]=N.useState(null),Ce=N.useRef(null),[rt,Ge]=N.useState(()=>{try{const dr=localStorage.getItem("video-bg-config");if(dr)return JSON.parse(dr)}catch{}return{type:"none"}});N.useEffect(()=>{try{localStorage.setItem("video-bg-config",JSON.stringify(rt))}catch{}},[rt]);const{canvasRef:ct,compositedStream:qe,isLoading:Ze,isActive:Qe}=ljs(u,rt),He=N.useRef(r);He.current=r;const Je=N.useCallback(dr=>{B(dr)},[]),it=N.useRef(U),Lt=N.useCallback(()=>{I.current&&(cancelAnimationFrame(I.current),I.current=null),M.current&&(M.current.getTracks().forEach(dr=>dr.stop()),M.current=null),O.current&&(O.current.getTracks().forEach(dr=>dr.stop()),O.current=null),q.current&&(q.current.srcObject=null,q.current=null)},[]),Vt=N.useCallback(async()=>{var dr;try{const Jr=await navigator.mediaDevices.getDisplayMedia({video:{width:{ideal:1920},height:{ideal:1080}},audio:!0});M.current=Jr;let Wr=null;try{Wr=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:320},height:{ideal:240}},audio:{echoCancellation:!0,noiseSuppression:!0}})}catch{console.warn("[VideoRecorder] No webcam for PiP overlay")}let dn=null;if(!Wr)try{dn=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{console.warn("[VideoRecorder] No mic audio")}const Yr=Jr.getVideoTracks()[0],vi=Yr.getSettings(),pt=vi.width||1920,ir=vi.height||1080,Vn=document.createElement("canvas");Vn.width=pt,Vn.height=ir,L.current=Vn;const Sr=Vn.getContext("2d");let jr=null;Wr&&(jr=document.createElement("video"),jr.srcObject=Wr,jr.muted=!0,jr.playsInline=!0,jr.autoplay=!0,await jr.play(),q.current=jr);const ea=document.createElement("video");ea.srcObject=Jr,ea.muted=!0,ea.playsInline=!0,ea.autoplay=!0,await ea.play();const Pa=()=>{if(Sr.drawImage(ea,0,0,pt,ir),jr&&jr.readyState>=2){const $e=Math.round(pt*.2),Ye=Math.round($e*(jr.videoHeight/jr.videoWidth||.75)),bt=pt-$e-20,gt=ir-Ye-20,Ft=12;Sr.save(),Sr.beginPath(),Sr.moveTo(bt+Ft,gt),Sr.lineTo(bt+$e-Ft,gt),Sr.quadraticCurveTo(bt+$e,gt,bt+$e,gt+Ft),Sr.lineTo(bt+$e,gt+Ye-Ft),Sr.quadraticCurveTo(bt+$e,gt+Ye,bt+$e-Ft,gt+Ye),Sr.lineTo(bt+Ft,gt+Ye),Sr.quadraticCurveTo(bt,gt+Ye,bt,gt+Ye-Ft),Sr.lineTo(bt,gt+Ft),Sr.quadraticCurveTo(bt,gt,bt+Ft,gt),Sr.closePath(),Sr.clip(),Sr.translate(bt+$e,gt),Sr.scale(-1,1),Sr.drawImage(jr,0,0,$e,Ye),Sr.restore(),Sr.strokeStyle="rgba(255,255,255,0.6)",Sr.lineWidth=2,Sr.beginPath(),Sr.moveTo(bt+Ft,gt),Sr.lineTo(bt+$e-Ft,gt),Sr.quadraticCurveTo(bt+$e,gt,bt+$e,gt+Ft),Sr.lineTo(bt+$e,gt+Ye-Ft),Sr.quadraticCurveTo(bt+$e,gt+Ye,bt+$e-Ft,gt+Ye),Sr.lineTo(bt+Ft,gt+Ye),Sr.quadraticCurveTo(bt,gt+Ye,bt,gt+Ye-Ft),Sr.lineTo(bt,gt+Ft),Sr.quadraticCurveTo(bt,gt,bt+Ft,gt),Sr.closePath(),Sr.stroke()}I.current=requestAnimationFrame(Pa)};Pa();const Ii=Vn.captureStream(30),Fo=[],$t=Jr.getAudioTracks();if($t.length&&Fo.push(...$t),Wr){const $e=Wr.getAudioTracks();$e.length&&Fo.push(...$e)}else dn&&Fo.push(...dn.getAudioTracks());const je=new MediaStream([...Ii.getVideoTracks(),...Fo]);return O.current=je,Yr.onended=()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),Lt()},je}catch(Jr){return console.error("[VideoRecorder] Screen capture error:",Jr),Jr.name!=="NotAllowedError"&&((dr=He.current)==null||dr.call(He,"Failed to start screen capture: "+(Jr.message||"Unknown error"))),null}},[Lt]),hs=N.useCallback(async()=>{var Jr,Wr;Z(!0),ft(null);const dr=w&&U;console.log("[VideoRecorder] initCamera start",{isMobile:w,usePortraitMode:U,shouldBePortrait:dr,facingMode:Me});try{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Camera not available in this browser or context. Try opening in a new tab.");c.current&&(console.log("[VideoRecorder] stopping existing stream"),c.current.getTracks().forEach(ir=>ir.stop()));const dn=w&&dr?{facingMode:{ideal:Me},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:Me},width:{ideal:1280},height:{ideal:720}};console.log("[VideoRecorder] requesting getUserMedia",dn);const Yr=await navigator.mediaDevices.getUserMedia({video:dn,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),Yr.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");c.current=Yr,p(Yr),ee(!0);const pt=Yr.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",pt.width,"x",pt.height),l.current){const ir=l.current;ir.srcObject=Yr,ir.muted=!0,ir.playsInline=!0,ir.autoplay=!0,ir.setAttribute("muted",""),ir.setAttribute("playsinline",""),ir.setAttribute("autoplay","");try{(Jr=ir.load)==null||Jr.call(ir)}catch(Sr){console.warn("[VideoRecorder] videoEl.load failed",Sr)}const Vn=async()=>{try{return await ir.play(),console.log("[VideoRecorder] preview play ok"),Ve(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:ir.readyState,videoWidth:ir.videoWidth,videoHeight:ir.videoHeight})},300),!0}catch(Sr){return console.warn("[VideoRecorder] preview play blocked",Sr),Ve(!0),!1}};await new Promise(Sr=>{let jr=!1;const ea=()=>{jr||(jr=!0,Sr())},Pa=()=>{Vn().finally(ea)};ir.onloadedmetadata=Pa,ir.onloadeddata=Pa,setTimeout(ea,1500)})}try{b.current=new AudioContext;const ir=b.current.createMediaStreamSource(Yr);_.current=b.current.createAnalyser(),_.current.fftSize=256,ir.connect(_.current);const Vn=()=>{if(_.current){const Sr=new Uint8Array(_.current.frequencyBinCount);_.current.getByteFrequencyData(Sr);const jr=Sr.reduce((ea,Pa)=>ea+Pa)/Sr.length;Oe(Math.min(100,jr/128*100))}j.current=requestAnimationFrame(Vn)};Vn()}catch(ir){console.warn("Audio context not available:",ir)}}catch(dn){console.error("Camera initialization error:",dn),ee(!1);let Yr="Failed to access camera or microphone.";dn.name==="NotAllowedError"?Yr="Camera permission denied. Please allow camera access in your browser settings.":dn.name==="NotFoundError"?Yr="No camera found. Please connect a camera and try again.":dn.name==="NotReadableError"?Yr="Camera is in use by another application. Please close other apps using the camera.":dn.message&&(Yr=dn.message),ft(Yr),(Wr=He.current)==null||Wr.call(He,Yr)}finally{Z(!1)}},[Me,w,U]);N.useEffect(()=>{it.current!==U&&X&&!Q&&!ge&&(it.current=U,hs())},[U,X,Q,ge,hs]),N.useEffect(()=>(hs(),()=>{c.current&&c.current.getTracks().forEach(dr=>dr.stop()),g.current&&clearInterval(g.current),j.current&&cancelAnimationFrame(j.current),b.current&&b.current.close(),Ce.current&&clearInterval(Ce.current),ge&&URL.revokeObjectURL(ge),Lt()}),[hs,ge]),N.useEffect(()=>{if(V||X!==!0||ge)return;const dr=c.current,Jr=l.current;!dr||!Jr||Qe||(Jr.srcObject!==dr&&(Jr.srcObject=dr,Jr.muted=!0,Jr.playsInline=!0,Jr.autoplay=!0,Jr.setAttribute("muted",""),Jr.setAttribute("playsinline",""),Jr.setAttribute("autoplay","")),Jr.play().then(()=>Ve(!1)).catch(Wr=>{Ve(!0),console.warn("Live preview play blocked on mount:",Wr)}))},[X,V,ge,Qe]),N.useEffect(()=>{n==null||n(Q)},[Q,n]);const Ts=N.useCallback(async()=>{if(ge)return;const dr=l.current;if(dr)try{await dr.play(),Ve(!1)}catch(Jr){Ve(!0),console.warn("Live preview still blocked (needs user gesture):",Jr)}},[ge]),Cs=N.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),g.current&&(clearInterval(g.current),g.current=null),Lt(),ie(!1),oe(!1)},[Lt]),cs=N.useCallback(async()=>{let dr=null;if(k==="screen"){if(dr=await Vt(),!dr)return}else dr=Qe&&qe?qe:c.current;if(!dr)return;Ts(),f.current=[],be(0);const Wr=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"].find(Yr=>MediaRecorder.isTypeSupported(Yr)),dn=new MediaRecorder(dr,Wr?{mimeType:Wr,videoBitsPerSecond:k==="screen"?4e6:25e5}:{videoBitsPerSecond:k==="screen"?4e6:25e5});dn.ondataavailable=Yr=>{Yr.data.size>0&&f.current.push(Yr.data)},dn.onstop=()=>{var ir;const Yr=dn.mimeType||Wr||((ir=f.current[0])==null?void 0:ir.type)||"video/webm",vi=new Blob(f.current,{type:Yr});xe(vi);const pt=URL.createObjectURL(vi);ue(pt)},i.current=dn,dn.start(100),ie(!0),g.current=setInterval(()=>{be(Yr=>Yr>=t-1?(Cs(),t):Yr+1)},1e3)},[Ts,t,Cs,Qe,qe,k,Vt]),er=N.useCallback(()=>{Ce.current&&(clearInterval(Ce.current),Ce.current=null),et(3);let dr=3;Ce.current=setInterval(()=>{dr-=1,dr<=0?(Ce.current&&clearInterval(Ce.current),Ce.current=null,et(null),cs()):et(dr)},1e3)},[cs]),xt=N.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),oe(!0),g.current&&clearInterval(g.current))},[]),Es=N.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),oe(!1),g.current=setInterval(()=>{be(dr=>dr>=t-1?(Cs(),t):dr+1)},1e3))},[t,Cs]),ur=N.useCallback(()=>{ge&&URL.revokeObjectURL(ge),xe(null),ue(null),be(0),ke(!1),nt(!0),l.current&&c.current&&!Qe&&(l.current.srcObject=c.current,l.current.muted=!0,Ts())},[Ts,ge,Qe]),Mr=N.useCallback(()=>{Ne(dr=>dr==="user"?"environment":"user")},[]),Lr=N.useCallback(()=>{ce&&s(ce,pe)},[ce,pe,s]),fn=N.useCallback(()=>{l.current&&ge&&(Te?l.current.pause():(nt(!1),l.current.muted=!1,l.current.play()),ke(!Te))},[ge,Te]);N.useEffect(()=>{if(!ge)return;const dr=l.current;if(!dr)return;nt(!1),dr.pause(),dr.removeAttribute("src"),dr.srcObject=null,dr.load(),dr.src=ge,dr.currentTime=0,dr.playsInline=!0,dr.muted=!1,dr.onended=()=>ke(!1);const Jr=()=>{var Yr;const Wr=dr.error,dn=Wr?`Recorded video failed to play (code ${Wr.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",Wr),(Yr=He.current)==null||Yr.call(He,dn)};return dr.addEventListener("error",Jr),dr.load(),()=>{dr.removeEventListener("error",Jr)}},[ge]);const ki=dr=>{const Jr=Math.floor(dr/60),Wr=dr%60;return`${Jr}:${Wr.toString().padStart(2,"0")}`},Ea=k==="screen"?"aspect-video":w&&U?"aspect-[9/16]":"aspect-video";return V?e.jsx("div",{className:It("flex items-center justify-center bg-black rounded-lg",Ea,a),children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),e.jsx("p",{children:"Initializing camera..."})]})}):X===!1?e.jsx("div",{className:It("flex items-center justify-center bg-black rounded-lg",Ea,a),children:e.jsxs("div",{className:"text-center text-white p-8 max-w-md",children:[e.jsx(kl,{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:Ae||"Please allow camera and microphone access to record videos."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(K,{onClick:()=>hs(),variant:"secondary",className:"w-full",children:[e.jsx(Go,{className:"h-4 w-4 mr-2"}),"Try Again"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-3",children:"💡 Tip: If you're viewing this in an embedded preview, try opening the app in a new browser tab for full camera access."})]})]})}):e.jsxs("div",{className:It("flex flex-col gap-2",a),children:[!Q&&!ge&&e.jsxs("div",{className:"flex items-center justify-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsxs(K,{variant:k==="camera"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>S("camera"),children:[e.jsx(kx,{className:"h-4 w-4"}),"Camera"]}),e.jsxs(K,{variant:k==="screen"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>S("screen"),children:[e.jsx(lS,{className:"h-4 w-4"}),"Screen"]})]}),k==="camera"&&!Q&&!ge&&e.jsx(_ws,{value:rt,onChange:Ge,isLoading:Ze,disabled:Q}),k==="camera"&&w&&!Q&&!ge&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(cS,{className:It("h-4 w-4",U?"text-muted-foreground":"text-primary")}),e.jsx(ve,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Landscape"}),e.jsx(qr,{id:"orientation-toggle",checked:U,onCheckedChange:Je}),e.jsx(ve,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),e.jsx(h1,{className:It("h-4 w-4",U?"text-primary":"text-muted-foreground")})]}),k==="screen"&&!Q&&!ge&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 px-4 bg-muted/50 rounded-lg text-sm text-muted-foreground",children:[e.jsx(lS,{className:"h-4 w-4 text-primary"}),e.jsx("span",{children:"Press record to share your screen. Your webcam will appear as a small overlay."})]}),e.jsxs("div",{className:It("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{Ts()},children:[e.jsx("video",{ref:l,src:ge??void 0,className:It("w-full bg-black",U&&!ge?"object-contain":"object-cover",Ea,!ge&&Me==="user"!==(rt.mirror??!1)&&"scale-x-[-1]",Qe&&!ge&&"hidden"),playsInline:!0,controls:!!ge,muted:ge?Be:!0,autoPlay:!ge},ge??"live"),Qe&&!ge&&e.jsx("canvas",{ref:ct,className:It("w-full bg-black",U?"object-contain":"object-cover",Ea,Me==="user"!==(rt.mirror??!1)&&"scale-x-[-1]")}),Qe&&Ze&&!ge&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/60 z-20",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(ws,{className:"h-8 w-8 animate-spin mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Loading virtual background…"})]})}),!ge&&fe&&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 Ts(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!ge&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),at!==null&&!ge&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-30 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"text-white font-bold drop-shadow-lg animate-scale-in",style:{fontSize:"96px",lineHeight:1,textShadow:"0 4px 16px rgba(0,0,0,0.8)"},children:at},at),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),Q&&e.jsxs("div",{className:"absolute top-4 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[e.jsx("div",{className:It("w-3 h-3 rounded-full",re?"bg-yellow-500":"bg-red-500 animate-pulse")}),e.jsxs("span",{className:"text-white text-sm font-medium",children:[ki(pe)," / ",ki(t)]})]}),Q&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(Bi,{value:pe/t*100,className:"h-1 rounded-none"})}),!ge&&e.jsxs("div",{className:"absolute bottom-20 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[e.jsx(fL,{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:`${Pe}%`}})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:ge?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:ur,children:[e.jsx(Go,{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:fn,children:Te?e.jsx(Rm,{className:"h-5 w-5"}):e.jsx(nl,{className:"h-5 w-5"})}),e.jsxs(K,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:Lr,children:[e.jsx(va,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):e.jsxs(e.Fragment,{children:[k==="camera"?e.jsx(K,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:Mr,disabled:Q||at!==null,children:e.jsx(u1,{className:"h-5 w-5"})}):e.jsx("div",{className:"h-12 w-12"}),!Q&&at===null?e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:k==="screen"?cs:er,children:k==="screen"?e.jsx(lS,{className:"h-6 w-6"}):e.jsx(An,{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:re?Es:xt,children:re?e.jsx(nl,{className:"h-5 w-5"}):e.jsx(Rm,{className:"h-5 w-5"})}),e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:Cs,children:e.jsx(y0,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const alt="teleprompter_settings",Sye={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function cjs(){try{const t=localStorage.getItem(alt);return t?{...Sye,...JSON.parse(t)}:Sye}catch{return Sye}}function djs(t){try{localStorage.setItem(alt,JSON.stringify(t))}catch{}}function ilt({text:t,isVisible:s,onToggleVisibility:r,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=N.useRef(null),c=N.useRef(null),u=N.useRef(0),p=N.useRef(0),[f,g]=N.useState(cjs),{scrollSpeed:b,fontSize:_,lineHeight:j,opacity:w,position:k,isMirrored:S}=f,M=N.useCallback((X,ee)=>{g(Q=>{const ie={...Q,[X]:ee};return djs(ie),ie})},[]),[L,I]=N.useState(!1),[O,q]=N.useState(null),U=N.useCallback(X=>{if(!i.current)return;u.current===0&&(u.current=X);const ee=X-u.current;u.current=X,p.current+=b*ee/1e3;const Q=Math.floor(p.current);Q>0&&(i.current.scrollTop+=Q,p.current-=Q);const{scrollTop:ie,scrollHeight:re,clientHeight:oe}=i.current;if(ie+oe>=re){I(!1);return}c.current=requestAnimationFrame(U)},[b]);N.useEffect(()=>(L?(u.current=0,p.current=0,c.current=requestAnimationFrame(U)):c.current&&cancelAnimationFrame(c.current),()=>{c.current&&cancelAnimationFrame(c.current)}),[L,U]),N.useEffect(()=>{if(n&&s)if(i.current&&(i.current.scrollTop=0),a){q(3);let X=3;const ee=setInterval(()=>{X-=1,X<=0?(clearInterval(ee),q(null),o==null||o(),I(!0)):q(X)},1e3);return()=>clearInterval(ee)}else setTimeout(()=>I(!0),100);else n||(I(!1),q(null))},[n,s,a,o]);const B=N.useCallback(()=>{i.current&&(i.current.scrollTop=0),I(!1)},[]),V=N.useCallback(()=>{I(X=>!X)},[]);if(!s)return e.jsx("div",{className:It("absolute top-4 right-4 pointer-events-auto z-10",l),children:e.jsxs(K,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(On,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const Z={top:"top-0 pt-16",center:"top-1/2 -translate-y-1/2",bottom:"bottom-0 pb-24"};return e.jsxs("div",{className:It("absolute inset-0 pointer-events-none",l),children:[O!==null&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"text-white font-bold drop-shadow-lg animate-scale-in",style:{fontSize:"96px",lineHeight:1,textShadow:"0 4px 16px rgba(0,0,0,0.8)"},children:O},O),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),e.jsx("div",{className:It("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",Z[k],O!==null&&"opacity-30"),style:{opacity:O!==null?.3:w},children:e.jsxs("div",{ref:i,className:It("mx-auto max-w-2xl px-6 overflow-y-auto scrollbar-hide h-full",S&&"scale-x-[-1]"),style:{maskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)",WebkitMaskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)"},children:[e.jsx("div",{className:"h-full",style:{minHeight:"100%"}}),e.jsx("p",{className:"text-white text-center font-medium drop-shadow-lg",style:{fontSize:`${_}px`,lineHeight: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($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsx(K,{variant:"secondary",size:"icon",className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(Xo,{className:"h-4 w-4"})})}),e.jsx(Ro,{className:"w-72",side:"left",align:"start",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium",children:"Teleprompter Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs",children:"Scroll Speed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:b})]}),e.jsx(Gg,{value:[b],onValueChange:([X])=>M("scrollSpeed",X),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:[_,"px"]})]}),e.jsx(Gg,{value:[_],onValueChange:([X])=>M("fontSize",X),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(Gg,{value:[j*10],onValueChange:([X])=>M("lineHeight",X/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(Gg,{value:[w*100],onValueChange:([X])=>M("opacity",X/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:k==="top"?"default":"outline",size:"sm",onClick:()=>M("position","top"),children:e.jsx(pf,{className:"h-4 w-4"})}),e.jsx(K,{variant:k==="center"?"default":"outline",size:"sm",onClick:()=>M("position","center"),children:e.jsx(p0,{className:"h-4 w-4"})}),e.jsx(K,{variant:k==="bottom"?"default":"outline",size:"sm",onClick:()=>M("position","bottom"),children:e.jsx(Eo,{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(qr,{checked:S,onCheckedChange:X=>M("isMirrored",X)})]})]})})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:V,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:L?e.jsx(Rm,{className:"h-4 w-4"}):e.jsx(nl,{className:"h-4 w-4"})}),e.jsx(K,{variant:"secondary",size:"icon",onClick:B,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(u1,{className:"h-4 w-4"})}),e.jsxs(K,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(kp,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function ujs({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=Ua(),[o,l]=N.useState(""),[i,c]=N.useState(null),[u,p]=N.useState("levelup"),{data:f,isLoading:g}=Kbs(),{data:b,isLoading:_}=Zbs(),{data:j,isLoading:w}=Ybs(),k=Xbs(),S=N.useMemo(()=>b?b.filter(q=>{const U=!o||q.title.toLowerCase().includes(o.toLowerCase())||q.script_text.toLowerCase().includes(o.toLowerCase())||q.tags.some(V=>V.toLowerCase().includes(o.toLowerCase())),B=!i||q.category_id===i;return U&&B}):[],[b,o,i]),M=N.useMemo(()=>j?j.filter(q=>!o||q.title.toLowerCase().includes(o.toLowerCase())||q.script_text.toLowerCase().includes(o.toLowerCase())):[],[j,o]),L=q=>{t({title:q.title,text:q.script_text})},I=async q=>{try{await k.mutateAsync(q),a({title:"Script saved to My Scripts"})}catch{a({title:"Failed to save script",variant:"destructive"})}},O=g||_||w;return e.jsxs("div",{className:It("flex flex-col h-full",n),children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search scripts...",value:o,onChange:q=>l(q.target.value),className:"pl-9"})]})}),e.jsxs(ba,{value:u,onValueChange:q=>p(q),className:"flex-1 flex flex-col",children:[e.jsxs(pa,{className:"mx-4 mt-4 grid grid-cols-2",children:[e.jsxs(ns,{value:"levelup",children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(ns,{value:"my-scripts",children:[e.jsx(Nx,{className:"h-4 w-4 mr-2"}),"My Scripts"]})]}),e.jsxs(bs,{value:"levelup",className:"flex-1 flex flex-col mt-0 p-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx(tt,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>c(null),children:"All"}),f==null?void 0:f.map(q=>e.jsx(tt,{variant:i===q.id?"default":"outline",className:"cursor-pointer",onClick:()=>c(q.id),children:q.name},q.id))]}),e.jsx(Gi,{className:"flex-1 max-h-[50vh]",children:O?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Sn,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No scripts found"})]}):e.jsx("div",{className:"space-y-2",children:S.map(q=>e.jsxs(Ee,{className:It("cursor-pointer hover:bg-accent/50 transition-colors",r===q.id&&"ring-2 ring-primary"),onClick:()=>L(q),children:[e.jsx(Pt,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-sm font-medium truncate",children:q.title}),q.category&&e.jsx(tt,{variant:"secondary",className:"mt-1 text-xs",children:q.category.name})]}),e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:U=>{U.stopPropagation(),I(q)},children:e.jsx(Nx,{className:"h-4 w-4"})}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})]})]})}),e.jsx(De,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:q.script_text})})]},q.id))})})]}),e.jsxs(bs,{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($s,{className:"h-4 w-4 mr-2"}),"Create New Script"]}),e.jsx(Gi,{className:"flex-1 max-h-[50vh]",children:w?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):M.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Nx,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No saved scripts"}),e.jsx("p",{className:"text-sm mt-1",children:"Save LevelUp scripts or create your own"})]}):e.jsx("div",{className:"space-y-2",children:M.map(q=>e.jsxs(Ee,{className:It("cursor-pointer hover:bg-accent/50 transition-colors",r===q.id&&"ring-2 ring-primary"),onClick:()=>L(q),children:[e.jsx(Pt,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-sm font-medium truncate",children:q.title}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:q.is_custom?e.jsx(tt,{variant:"outline",className:"text-xs",children:"Custom"}):e.jsx(tt,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground ml-2"})]})}),e.jsx(De,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:q.script_text})})]},q.id))})})]})]})]})}function hjs({selectedTemplate:t,onSelect:s,contactName:r,saving:n=!1}){const[a,o]=N.useState(()=>{const i=XM(t);return new Set([i.category])}),l=i=>{o(c=>{const u=new Set(c);return u.has(i)?u.delete(i):u.add(i),u})};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Share Page Template"}),n&&e.jsx(ws,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"space-y-3",children:IIt.map(i=>{const c=LIt(i.id),u=a.has(i.id),p=c.some(f=>f.id===t);return e.jsxs(gf,{open:u,onOpenChange:()=>l(i.id),children:[e.jsxs(yf,{className:"flex items-center justify-between w-full p-2.5 rounded-lg bg-muted/50 hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:i.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",c.length,")"]}),p&&!u&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:"✓"})]}),e.jsx(Eo,{className:It("h-4 w-4 text-muted-foreground transition-transform",u&&"rotate-180")})]}),e.jsx(vf,{className:"pt-2",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:c.map(f=>{const g=t===f.id;return e.jsxs("button",{type:"button",onClick:()=>s(f.id),disabled:n,className:It("relative rounded-lg border-2 p-2.5 text-left transition-all hover:shadow-sm disabled:opacity-50 disabled:cursor-not-allowed",g?"border-primary ring-1 ring-primary/20 bg-primary/5":"border-muted hover:border-muted-foreground/30"),children:[g&&e.jsx("div",{className:"absolute top-1 right-1 w-4 h-4 rounded-full bg-primary flex items-center justify-center",children:e.jsx(va,{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: "',XM(t).headerText(r),'"']})]})}function olt({open:t,onOpenChange:s,video:r,contactName:n,onTemplateUpdated:a}){const[o,l]=N.useState(r.page_template||"default"),[i,c]=N.useState(!1),[u,p]=N.useState(!1),[f,g]=N.useState(r.page_template||"default"),[b,_]=N.useState([]),[j,w]=N.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[k,S]=N.useState(!1),[M,L]=N.useState(!1),I=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";N.useEffect(()=>{t&&b.length===0&&O()},[t]);const O=async()=>{L(!0);try{const{data:ie,error:re}=await H.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(re)throw re;const oe=(ie||[]).map(ce=>({id:ce.id,name:[ce.first_name,ce.last_name].filter(Boolean).join(" ")||"Unnamed",email:ce.email||null}));_(oe)}catch(ie){console.error("Failed to fetch contacts:",ie)}finally{L(!1)}},q=async ie=>{w(ie),S(!1),c(!0);try{const{error:re}=await H.from("agent_videos").update({contact_id:(ie==null?void 0:ie.id)||null,recipient_name:(ie==null?void 0:ie.name)||null}).eq("id",r.id);if(re)throw re;me.success(ie?`Assigned to ${ie.name}`:"Contact removed"),a==null||a()}catch(re){console.error("Failed to update contact:",re),me.error("Failed to update contact")}finally{c(!1)}},U=async ie=>{l(ie),c(!0);try{const{error:re}=await H.from("agent_videos").update({page_template:ie}).eq("id",r.id);if(re)throw re;g(ie),me.success("Template saved!"),a==null||a()}catch(re){console.error("Failed to save template:",re),me.error("Failed to save template"),l(f)}finally{c(!1)}},B=(j==null?void 0:j.name)||null,V=()=>{const ie=r.title||"Video Message",re=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:r.thumbnail_url||"";return``},Z=async()=>{if(!r.thumbnail_url){me.error("Video thumbnail not available yet");return}const ie=V(),re=`Watch: ${r.title||"Video Message"} ${I}`;try{const oe=new Blob([ie],{type:"text/html"}),ce=new Blob([re],{type:"text/plain"}),xe=new ClipboardItem({"text/html":oe,"text/plain":ce});await navigator.clipboard.write([xe]),me.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(re+` `+ie),me.success("Copied! Paste into your email.")}},X=async()=>{await navigator.clipboard.writeText(I),p(!0),me.success("Share link copied!"),setTimeout(()=>p(!1),2e3)},ee=()=>{const re=XM(o).headerText(B),oe=o==="default"?`Check out this video: ${I}`:`${re} Check out this special video: ${I}`;window.open(`sms:?body=${encodeURIComponent(oe)}`,"_self")},Q=()=>{const ie=XM(o),re=ie.headerText(B),oe=o==="default"?r.title||"Video Message":re,ce=`${ie.subText} Watch the video: ${I}`,xe=j!=null&&j.email?encodeURIComponent(j.email):"";window.open(`mailto:${xe}?subject=${encodeURIComponent(oe)}&body=${encodeURIComponent(ce)}`,"_self")};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-5 w-5"}),"Share Video"]}),e.jsx(Gr,{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($o,{open:k,onOpenChange:S,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":k,className:"flex-1 justify-between",disabled:i,children:[j?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"h-4 w-4 text-muted-foreground"}),j.name]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(Sx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search contacts..."}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:M?"Loading...":"No contacts found."}),e.jsx(Fx,{children:b.map(ie=>e.jsxs(bp,{value:ie.name,onSelect:()=>q(ie),children:[e.jsx(va,{className:It("mr-2 h-4 w-4",(j==null?void 0:j.id)===ie.id?"opacity-100":"opacity-0")}),ie.name]},ie.id))})]})]})})]}),j&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>q(null),disabled:i,className:"shrink-0",children:e.jsx(Rr,{className:"h-4 w-4"})})]}),j&&o!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Page will show: "',XM(o).headerText(j.name),'"']})]}),e.jsx(hjs,{selectedTemplate:o,onSelect:U,contactName:B,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(ze,{value:I,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:X,variant:u?"default":"outline",className:"shrink-0 gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(va,{className:"h-4 w-4"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(gi,{className:"h-4 w-4"}),"Copy"]})})]})]}),r.thumbnail_url&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Share for Email"}),e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:Z,children:[e.jsx(gl,{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:ee,children:[e.jsx(so,{className:"h-4 w-4"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:Q,children:[e.jsx(cr,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(qn,{children:e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function mjs(){var et;const t=fr(),[s]=Cc(),{toast:r}=Ua(),n=s.get("contact_id"),a=s.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:c}=Uat(),{data:u}=Gm(),p=SC(),f=s_s(),[g,b]=N.useState("record"),[_,j]=N.useState(""),[w,k]=N.useState(!1),[S,M]=N.useState(!1),[L,I]=N.useState(!1),[O,q]=N.useState(null),[U,B]=N.useState(0),[V,Z]=N.useState(0),[X,ee]=N.useState(null),[Q,ie]=N.useState(null),[re,oe]=N.useState(n||""),[ce,xe]=N.useState(""),[ge,ue]=N.useState(""),[pe,be]=N.useState(null),[Me,Ne]=N.useState(null),[Pe,Oe]=N.useState(null),[Te,ke]=N.useState(!1),Be=N.useCallback(async(Ce,rt)=>{q(Ce),b("uploading");try{const{videoId:Ge,uploadUrl:ct}=await pR(ce||"Quick Video Touch");ee(Ge);const{apiKey:qe}=await fR(Ge),Ze=new XMLHttpRequest;Ze.upload.onprogress=it=>{it.lengthComputable&&B(it.loaded/it.total*100)},await new Promise((it,Lt)=>{Ze.onload=()=>{Ze.status>=200&&Ze.status<300?it():Lt(new Error(`Upload failed: ${Ze.status}`))},Ze.onerror=()=>Lt(new Error("Upload failed")),Ze.open("PUT",ct),Ze.setRequestHeader("AccessKey",qe),Ze.send(Ce)}),b("processing");let Qe=0;const He=Date.now(),Je=90*1e3;for(;Qe<4;){if(await new Promise(Lt=>setTimeout(Lt,3e3)),Date.now()-He>Je){const Lt=Ce.size/1048576,Vt=`https://iframe.mediadelivery.net/play/${Ge}/${Ge}`;await p.mutateAsync({bunny_video_id:Ge,playback_url:Vt,file_size_mb:Lt,title:ce||"Quick Video Touch",notes:ge||void 0,contact_id:re&&re!=="none"?re:void 0,status:"processing",touch_type:"video_touch"}),r({title:"Video saved — still processing",description:'Your video has been saved and will appear in your library with a "processing" badge. It will be ready to share once encoding completes (usually within a few minutes).',duration:8e3}),t("/mission-control/video-library");return}const it=await _A(Ge);if(Qe=it.status,Z(it.encodeProgress||0),Qe===4)ie({playbackUrl:it.directPlayUrl,thumbnailUrl:it.thumbnailUrl,previewUrl:it.previewUrl||null,duration:it.length||rt,fileSizeMb:(it.storageSize||Ce.size)/(1024*1024)});else if(Qe===5||Qe===6)throw new Error("Video processing failed")}b("details")}catch(Ge){console.error("Upload error:",Ge),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),b("record")}},[ce,r]),nt=async()=>{if(!(!X||!Q))try{const Ce=re&&re!=="none"?re:null,rt=await p.mutateAsync({bunny_video_id:X,contact_id:Ce,playback_url:Q.playbackUrl,thumbnail_url:Q.thumbnailUrl,preview_url:Q.previewUrl,duration_seconds:Q.duration,file_size_mb:Q.fileSizeMb,title:ce||"Quick Video Touch",notes:ge,task_id:a||null,status:"ready"});be(rt.id),Ne(rt.share_token||null),Ce&&await f.mutateAsync({contactId:Ce,videoId:rt.id,notes:ge}),r({title:"Video saved successfully!"}),b("share")}catch(Ce){console.error("Save video error:",Ce),r({title:"Failed to save video",description:(Ce==null?void 0:Ce.message)||"Please try again.",variant:"destructive"})}},Ae=(Ce,rt)=>{navigator.clipboard.writeText(rt),Oe(Ce),setTimeout(()=>Oe(null),2e3),r({title:"Copied to clipboard!"})},ft=()=>Me?`https://video.relevelup.com/${Me}`:(Q==null?void 0:Q.playbackUrl)||"",fe=()=>{const Ce=u==null?void 0:u.find(Ze=>Ze.id===re),rt=Ce?`${Ce.first_name}`:"",Ge=(Ce==null?void 0:Ce.phone)||"",ct=(Ce==null?void 0:Ce.email)||"",qe=ft();return{text:`Hey${rt?` ${rt}`:""}! I recorded a quick video for you: ${qe}`,link:qe,contactPhone:Ge,contactEmail:ct}},Ve=()=>{const{text:Ce,contactPhone:rt}=fe(),Ge=rt?`sms:${rt}?body=${encodeURIComponent(Ce)}`:`sms:?body=${encodeURIComponent(Ce)}`;window.open(Ge,"_self")},at=()=>{const{link:Ce,contactEmail:rt}=fe(),Ge="Check out this video",ct=`I recorded a quick video for you: ${Ce}`,qe=rt?`mailto:${rt}?subject=${encodeURIComponent(Ge)}&body=${encodeURIComponent(ct)}`:`mailto:?subject=${encodeURIComponent(Ge)}&body=${encodeURIComponent(ct)}`;window.open(qe,"_self")};return o?e.jsx(Ms,{title:"QuickVid",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t(-1),children:e.jsx(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"QuickVid"}),e.jsx("p",{className:"text-muted-foreground",children:"Record a personal video message"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>t("/mission-control/video-library"),className:"gap-1.5",children:[e.jsx(Sn,{className:"h-4 w-4"}),"Video Library"]}),c&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm text-warning",children:["Storage: ",i.toFixed(0),"% used"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[l.toFixed(0)," MB remaining"]})]})]})]}),g==="record"&&e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsx(gme,{maxDurationSeconds:60,onRecordingComplete:Be,onRecordingStateChange:I,className:"w-full",teleprompterContent:w&&_&&e.jsx(ilt,{text:_,isVisible:w,onToggleVisibility:()=>k(!1),isRecording:L,startCountdown:!0})}),!w&&_&&e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>k(!0),children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(Ee,{className:"lg:col-span-1",children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsx(Er,{placeholder:"Type or paste your script here...",value:_,onChange:Ce=>j(Ce.target.value),rows:6}),e.jsxs(JA,{open:S,onOpenChange:M,children:[e.jsx(sNe,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full",children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),e.jsxs(yC,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[e.jsx(eE,{className:"p-4 border-b",children:e.jsx(tE,{children:"Select a Script"})}),e.jsx(ujs,{onSelectScript:Ce=>{j(Ce.text),M(!1),k(!0)},className:"h-[calc(100vh-80px)]"})]})]}),_&&e.jsx(K,{className:"w-full",onClick:()=>k(!0),children:"Use Script"})]})]})]}),g==="uploading"&&e.jsx(Ee,{className:"max-w-md mx-auto",children:e.jsxs(De,{className:"pt-6 text-center",children:[e.jsx(li,{className:"h-12 w-12 mx-auto mb-4 text-primary animate-pulse"}),e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Uploading Video..."}),e.jsx(Bi,{value:U,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[U.toFixed(0),"%"]})]})}),g==="processing"&&e.jsx(Ee,{className:"max-w-md mx-auto",children:e.jsxs(De,{className:"pt-6 text-center space-y-4",children:[e.jsx(ws,{className:"h-12 w-12 mx-auto mb-4 text-primary animate-spin"}),e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Processing Video..."}),e.jsx(Bi,{value:V,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[V.toFixed(0),"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:`This usually takes 30-60 seconds. If it takes longer, we'll auto-save your video and you can find it in your Video Library — look for the "processing" badge.`})]})}),g==="details"&&e.jsxs(Ee,{className:"max-w-lg mx-auto",children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Video Details"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title"}),e.jsx(ze,{value:ce,onChange:Ce=>xe(Ce.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Attach to Contact (Optional)"}),e.jsxs(Zs,{value:re,onValueChange:oe,children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"No contact - use anywhere"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Bo,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),u==null?void 0:u.map(Ce=>e.jsx(Mt,{value:Ce.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"h-4 w-4"}),Ce.first_name," ",Ce.last_name]})},Ce.id))]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Notes"}),e.jsx(Er,{value:ge,onChange:Ce=>ue(Ce.target.value),placeholder:"Add notes about this video...",rows:3})]}),e.jsxs(K,{className:"w-full",onClick:nt,disabled:p.isPending,children:[p.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),g==="share"&&e.jsxs(Ee,{className:"max-w-lg mx-auto",children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(va,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),e.jsxs(De,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Share your video with one click:"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs(K,{variant:"outline",className:"justify-start",onClick:Ve,children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:at,children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>Ae("link",fe().link),children:[e.jsx(Bo,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Pe==="link"&&e.jsx(va,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>ke(!0),children:[e.jsx(ac,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),children:"View Library"}),e.jsx(K,{onClick:()=>{b("record"),q(null),ee(null),ie(null)},children:"Record Another"})]})]})]}),pe&&Me&&e.jsx(olt,{open:Te,onOpenChange:ke,video:{id:pe,share_token:Me,title:ce||null,contact_id:re||null,thumbnail_url:(Q==null?void 0:Q.thumbnailUrl)||null},contactName:((et=u==null?void 0:u.find(Ce=>Ce.id===re))==null?void 0:et.first_name)||null})]})}):e.jsx(Ms,{title:"QuickVid",children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center py-12",children:[e.jsx(Ku,{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 pjs({open:t,onOpenChange:s}){const{data:r}=Gm(),{data:n}=Hhe(),a=SC(),o=N.useRef(null),[l,i]=N.useState(null),[c,u]=N.useState(""),[p,f]=N.useState(""),[g,b]=N.useState(""),[_,j]=N.useState(!1),[w,k]=N.useState(0),[S,M]=N.useState("idle"),L=(n==null?void 0:n.total_storage_mb)||0,O=((n==null?void 0:n.max_storage_mb)||1024)-L,q=Z=>{var Q;const X=(Q=Z.target.files)==null?void 0:Q[0];if(!X)return;if(!X.type.startsWith("video/")){me.error("Please select a video file");return}const ee=X.size/(1024*1024);if(ee>500){me.error("Video file must be less than 500MB");return}if(ee>O){me.error(`Not enough storage. You have ${O.toFixed(1)} MB remaining.`);return}i(X),c||u(X.name.replace(/\.[^/.]+$/,""))},U=async()=>{if(!l){me.error("Please select a video file");return}j(!0),k(0),M("creating");try{const{data:Z,error:X}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:c||l.name,isAgentVideo:!0}});if(X)throw new Error(X.message);const{videoId:ee,libraryId:Q}=Z;M("uploading");const{data:ie,error:re}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:ee,isAgentVideo:!0}});if(re)throw new Error(re.message);await new Promise((xe,ge)=>{const ue=new XMLHttpRequest;ue.upload.addEventListener("progress",pe=>{if(pe.lengthComputable){const be=Math.round(pe.loaded/pe.total*100);k(be)}}),ue.addEventListener("load",()=>{ue.status>=200&&ue.status<300?xe():ge(new Error(`Upload failed with status ${ue.status}`))}),ue.addEventListener("error",()=>ge(new Error("Upload failed"))),ue.open("PUT",ie.uploadUrl),ue.setRequestHeader("AccessKey",ie.apiKey),ue.send(l)}),M("processing");const oe=l.size/(1024*1024),ce=`https://iframe.mediadelivery.net/embed/${Q}/${ee}`;await a.mutateAsync({bunny_video_id:ee,playback_url:ce,file_size_mb:oe,title:c||l.name,notes:p||void 0,contact_id:g||void 0,status:"processing",touch_type:"video_upload"}),me.success("Video uploaded successfully! Processing may take a few minutes."),B()}catch(Z){console.error("Upload error:",Z),me.error(Z instanceof Error?Z.message:"Failed to upload video")}finally{j(!1),M("idle")}},B=()=>{_||(i(null),u(""),f(""),b(""),k(0),M("idle"),s(!1))},V=()=>{switch(S){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${w}%`;case"processing":return"Saving video...";default:return""}};return e.jsx(fs,{open:t,onOpenChange:B,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Upload Video"}),e.jsx(Gr,{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(An,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:l.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(l.size/(1024*1024)).toFixed(1)," MB"]})]}),!_&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:Z=>{Z.stopPropagation(),i(null)},children:e.jsx(Rr,{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 Z;return(Z=o.current)==null?void 0:Z.click()},children:[e.jsx(li,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select a video file"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, MOV, WebM (max 500MB)"})]}),e.jsx("input",{ref:o,type:"file",accept:"video/*",className:"hidden",onChange:q,disabled:_})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",value:c,onChange:Z=>u(Z.target.value),placeholder:"Enter video title",disabled:_})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Associate with Contact (optional)"}),e.jsxs(Zs,{value:g||"__none__",onValueChange:Z=>b(Z==="__none__"?"":Z),disabled:_,children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select a contact"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"__none__",children:"No contact"}),r==null?void 0:r.map(Z=>e.jsxs(Mt,{value:Z.id,children:[Z.first_name," ",Z.last_name||""]},Z.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(Er,{id:"notes",value:p,onChange:Z=>f(Z.target.value),placeholder:"Add any notes about this video",rows:2,disabled:_})]}),_&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:V()})]}),e.jsx(Bi,{value:S==="uploading"?w:S==="processing"?100:10})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:B,disabled:_,children:"Cancel"}),e.jsx(K,{onClick:U,disabled:!l||_,children:_?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function fjs(t){return mt({queryKey:["video-share-recipients",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("video_share_recipients").select("*").eq("video_id",t).order("sent_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function xjs(){const{user:t}=Ds();return mt({queryKey:["video-share-stats",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await H.from("video_share_recipients").select("*").eq("owner_user_id",t.id);if(r)throw r;const n=s;return{totalSent:n.length,totalOpened:n.filter(a=>a.opened_at).length,totalClicked:n.filter(a=>a.clicked_at).length,totalWatched:n.filter(a=>a.watched_at).length,openRate:n.length>0?Math.round(n.filter(a=>a.opened_at).length/n.length*100):0,clickRate:n.length>0?Math.round(n.filter(a=>a.clicked_at).length/n.length*100):0,watchRate:n.length>0?Math.round(n.filter(a=>a.watched_at).length/n.length*100):0}},enabled:!!(t!=null&&t.id)})}function gjs(){const{user:t}=Ds();return mt({queryKey:["video-share-history",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await H.from("video_share_recipients").select(` *, agent_videos!inner(id, title, thumbnail_url, share_token, duration_seconds) `).eq("owner_user_id",t.id).order("sent_at",{ascending:!1}).limit(200);if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function yjs(){const{user:t}=Ds(),s=Qt();return Dt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await H.from("video_share_recipients").insert([{video_id:r.video_id,owner_user_id:t.id,recipient_email:r.recipient_email,recipient_name:r.recipient_name||null,contact_id:r.contact_id||null,sent_via:r.sent_via||"gmail",share_token:"placeholder"}]).select().single();if(a)throw a;return n},onSuccess:r=>{s.invalidateQueries({queryKey:["video-share-recipients",r.video_id]}),s.invalidateQueries({queryKey:["video-share-stats"]}),s.invalidateQueries({queryKey:["video-share-history"]})}})}function vjs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=open`}function bjs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=click`}function _js({open:t,onOpenChange:s,video:r,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=N.useState([]),[c,u]=N.useState(null),[p,f]=N.useState(!1),[g,b]=N.useState(!1),[_,j]=N.useState(""),[w,k]=N.useState(""),[S,M]=N.useState(""),[L,I]=N.useState(!1),O=yjs(),q=r.share_token?`https://video.relevelup.com/share/video/${r.share_token}`:"",U=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:a||r.thumbnail_url||"",B=r.title||"Video Message";N.useEffect(()=>{t&&l.length===0&&V()},[t]),N.useEffect(()=>{if(t&&(k(`I recorded a video for you — ${B}`),M("Hey! I recorded a quick video just for you. Click below to watch it:"),u(null),j(""),r.contact_id)){const re=l.find(oe=>oe.id===r.contact_id);re&&(u(re),j(re.email||""))}},[t,r.contact_id,l]);const V=async()=>{b(!0);try{const{data:re,error:oe}=await H.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(oe)throw oe;i(re||[])}catch{console.error("Failed to fetch contacts")}finally{b(!1)}},Z=re=>{u(re),f(!1),j(re.email||""),M(`Hey ${re.first_name}! I recorded a quick video just for you. Click below to watch it:`),k(`I recorded a video for you — ${B}`)},X=()=>{u(null),j(""),M("Hey! I recorded a quick video just for you. Click below to watch it:")},ee=re=>`${re.first_name} ${re.last_name||""}`.trim(),Q=re=>{const oe=S.split(/\n\n+/).map(ge=>`

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

`).join(""),ce=re?bjs(re):q,xe=re?``:"";return`
${oe}

▶ Watch Video

${xe}
`},ie=async()=>{if(!_){me.error("Please enter a recipient email");return}if(!q){me.error("Video does not have a share link");return}I(!0);try{let re;try{const ge=c?ee(c):_.split("@")[0];re=(await O.mutateAsync({video_id:r.id,recipient_email:_,recipient_name:ge,contact_id:(c==null?void 0:c.id)||null,sent_via:"gmail"})).share_token}catch(ge){console.warn("Failed to create tracking record, sending without tracking:",ge)}const oe=Q(re),{data:ce,error:xe}=await H.functions.invoke("gmail-send",{body:{to:_,subject:w,body:oe,contactId:(c==null?void 0:c.id)||null}});if(xe)throw xe;if(!(ce!=null&&ce.success))throw new Error((ce==null?void 0:ce.error)||"Failed to send");me.success("Video email sent!"),s(!1),o==null||o()}catch(re){console.error("Gmail send error:",re),me.error("Failed to send: "+(re instanceof Error?re.message:"Unknown error"))}finally{I(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[560px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(cr,{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($o,{open:p,onOpenChange:f,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"flex-1 justify-between",children:[c?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"h-4 w-4 text-muted-foreground"}),ee(c),c.email&&e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",c.email,")"]})]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(Sx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[350px] p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search contacts..."}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:g?"Loading...":"No contacts found."}),e.jsx(Fx,{children:l.filter(re=>re.email).map(re=>e.jsxs(bp,{value:`${re.first_name} ${re.last_name||""} ${re.email||""}`,onSelect:()=>Z(re),children:[e.jsx(va,{className:It("mr-2 h-4 w-4",(c==null?void 0:c.id)===re.id?"opacity-100":"opacity-0")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ee(re)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:re.email})]})]},re.id))})]})]})})]}),c&&e.jsx(K,{variant:"ghost",size:"icon",onClick:X,className:"shrink-0",children:e.jsx(Rr,{className:"h-4 w-4"})})]})]}),!c&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"video-to",children:"Or type email address"}),e.jsx(ze,{id:"video-to",value:_,onChange:re=>j(re.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(ze,{id:"video-subject",value:w,onChange:re=>k(re.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(Er,{id:"video-message",value:S,onChange:re=>M(re.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:[U?e.jsx("img",{src:U,alt:B,className:"w-full aspect-video object-cover"}):e.jsx("div",{className:"w-full aspect-video flex items-center justify-center bg-muted",children:e.jsx(nl,{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(nl,{className:"h-5 w-5 text-primary ml-0.5"})})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Recipients will see the thumbnail with a play button. Clicking opens the video page."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),disabled:L,children:"Cancel"}),e.jsxs(K,{onClick:ie,disabled:L||!_||!w,className:"gap-2",children:[L?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4"}),L?"Sending...":"Send Video Email"]})]})]})]})})}const wjs=()=>{const{user:t}=Ds();return mt({queryKey:["team-videos",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.rpc("get_team_videos",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})};function jjs({recipient:t}){return t.watched_at?e.jsxs(tt,{className:"bg-emerald-100 text-emerald-800 text-[10px]",children:[e.jsx(nl,{className:"h-2.5 w-2.5 mr-0.5"}),"Watched"]}):t.clicked_at?e.jsxs(tt,{className:"bg-blue-100 text-blue-800 text-[10px]",children:[e.jsx(wh,{className:"h-2.5 w-2.5 mr-0.5"}),"Clicked"]}):t.opened_at?e.jsxs(tt,{className:"bg-amber-100 text-amber-800 text-[10px]",children:[e.jsx(On,{className:"h-2.5 w-2.5 mr-0.5"}),"Opened"]}):e.jsxs(tt,{variant:"outline",className:"text-[10px]",children:[e.jsx(Bn,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]})}function Njs({open:t,onOpenChange:s,videoId:r,videoTitle:n}){const{data:a=[],isLoading:o}=fjs(r);return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-2xl max-h-[80vh]",children:[e.jsx(_s,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(No,{className:"h-5 w-5"}),"Send Analytics: ",n]})}),o?e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((l,i)=>e.jsx(ys,{className:"h-12 w-full"},i))}):a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No recipients tracked for this video yet."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs("div",{className:"text-center p-2 rounded-lg bg-muted/50",children:[e.jsx("div",{className:"text-lg font-bold",children:a.length}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Sent"})]}),e.jsxs("div",{className:"text-center p-2 rounded-lg bg-amber-50",children:[e.jsx("div",{className:"text-lg font-bold text-amber-700",children:a.filter(l=>l.opened_at).length}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Opened"})]}),e.jsxs("div",{className:"text-center p-2 rounded-lg bg-blue-50",children:[e.jsx("div",{className:"text-lg font-bold text-blue-700",children:a.filter(l=>l.clicked_at).length}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Clicked"})]})]}),e.jsx(Gi,{className:"h-[400px]",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Recipient"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Sent"}),e.jsx(St,{children:"Last Activity"})]})}),e.jsx(zn,{children:a.map(l=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:l.recipient_name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.recipient_email})]})}),e.jsx(dt,{children:e.jsx(jjs,{recipient:l})}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:ms(new Date(l.sent_at),"MMM d, h:mm a")}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:l.last_activity_at?Uc(new Date(l.last_activity_at),{addSuffix:!0}):"—"})]},l.id))})]})})]})]})})}function kjs(){const{data:t,isLoading:s}=xjs(),{data:r=[],isLoading:n}=gjs(),[a,o]=N.useState(null),l=s||n,i=r.reduce((c,u)=>{const p=u.agent_videos,f=(p==null?void 0:p.id)||u.video_id;return c[f]||(c[f]={videoId:f,title:(p==null?void 0:p.title)||"Untitled",thumbnailUrl:p==null?void 0:p.thumbnail_url,recipients:[]}),c[f].recipients.push(u),c},{});return l?e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((c,u)=>e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(ys,{className:"h-4 w-20"})}),e.jsx(De,{children:e.jsx(ys,{className:"h-8 w-16"})})]},u))})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Sent"}),e.jsx(Bn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:(t==null?void 0:t.totalSent)||0})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Open Rate"}),e.jsx(On,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(De,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.openRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalOpened)||0," opened"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(wh,{className:"h-4 w-4 text-blue-500"})]}),e.jsxs(De,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.clickRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalClicked)||0," clicked"]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Send History by Video"}),e.jsx(gr,{children:"Click a video to see individual recipient tracking"})]}),e.jsx(De,{children:Object.keys(i).length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No tracked sends yet. Send a video via Gmail to start tracking."}):e.jsx("div",{className:"space-y-2",children:Object.values(i).map(c=>{const u=c.recipients.filter(f=>f.opened_at).length,p=c.recipients.filter(f=>f.clicked_at).length;return e.jsxs("button",{onClick:()=>o({id:c.videoId,title:c.title}),className:"w-full flex items-center gap-3 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-left",children:[e.jsx("div",{className:"h-10 w-16 rounded bg-muted overflow-hidden flex-shrink-0",children:c.thumbnailUrl?e.jsx("img",{src:c.thumbnailUrl,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer",onError:f=>{const g=f.currentTarget;g.style.display="none",g.parentElement.innerHTML='
'}}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(An,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:c.title}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Bn,{className:"h-3 w-3"})," ",c.recipients.length]}),e.jsxs("span",{className:"text-xs text-amber-600 flex items-center gap-1",children:[e.jsx(On,{className:"h-3 w-3"})," ",u]}),e.jsxs("span",{className:"text-xs text-blue-600 flex items-center gap-1",children:[e.jsx(wh,{className:"h-3 w-3"})," ",p]})]})]}),e.jsx(ul,{className:"h-4 w-4 text-muted-foreground"})]},c.videoId)})})})]}),e.jsx(Njs,{open:!!a,onOpenChange:c=>!c&&o(null),videoId:(a==null?void 0:a.id)||null,videoTitle:(a==null?void 0:a.title)||""})]})}function Sjs({previewSrc:t,thumbnailSrc:s,alt:r,isHovered:n}){const[a,o]=N.useState(!1),[l,i]=N.useState(!1),c=n&&t&&!a,u=s&&!l;return!u&&!c?e.jsx("div",{className:"w-full h-full flex items-center justify-center absolute inset-0 bg-muted",children:e.jsx(An,{className:"h-12 w-12 text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[u&&e.jsx("img",{src:s,alt:r,loading:"lazy",className:`w-full h-full object-cover absolute inset-0 transition-opacity duration-200 ${c?"opacity-0":"opacity-100"}`,onError:()=>i(!0)}),c&&e.jsx("img",{src:t,alt:r,className:"w-full h-full object-cover absolute inset-0",onError:()=>o(!0)})]})}function Cjs({video:t,previewSrc:s,thumbnailSrc:r,onOpen:n,onDelete:a,onRename:o,onNavigateToContact:l,onGetEmbedCode:i,onCopyEmailHtml:c,onEmbedToCrm:u,onShareWithTemplate:p,onSendViaGmail:f,isGmailConnected:g,getContactName:b,getShareUrl:_,copyToClipboard:j,formatDuration:w}){const[k,S]=N.useState(!1);return e.jsxs(Ee,{className:"overflow-hidden group cursor-pointer",onClick:n,onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:[e.jsxs("div",{className:"relative aspect-video bg-muted overflow-hidden",children:[e.jsx(Sjs,{previewSrc:s,thumbnailSrc:r,alt:t.title||"Video preview",isHovered:k}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("div",{className:"w-12 h-12 rounded-full bg-white/90 flex items-center justify-center",children:e.jsx(nl,{className:"h-6 w-6 text-primary ml-1"})})}),e.jsx("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:w(t.duration_seconds)}),t.status!=="ready"&&e.jsx(tt,{variant:t.status==="processing"?"secondary":"destructive",className:"absolute top-2 left-2",children:t.status})]}),e.jsx(De,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-medium truncate",children:t.title||"Untitled Video"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsx(to,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:b(t.contact_id)})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),e.jsx("span",{children:ms(new Date(t.created_at),"MMM d, yyyy")})]}),(t.view_count??0)>0&&e.jsxs("div",{className:"flex items-center gap-1 text-primary",children:[e.jsx(On,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]}),g&&t.share_token&&e.jsxs(K,{variant:"outline",size:"sm",className:"mt-2 gap-1.5 text-xs h-7",onClick:M=>{M.stopPropagation(),f==null||f()},children:[e.jsx(cr,{className:"h-3 w-3"}),"Send via Gmail"]}),e.jsx("h3",{className:"font-medium truncate",children:t.title||"Untitled Video"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsx(to,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:b(t.contact_id)})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),e.jsx("span",{children:ms(new Date(t.created_at),"MMM d, yyyy")})]}),(t.view_count??0)>0&&e.jsxs("div",{className:"flex items-center gap-1 text-primary",children:[e.jsx(On,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]})]}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:M=>M.stopPropagation(),children:e.jsx(mx,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",className:"bg-popover",children:[e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),n()},children:[e.jsx(On,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(dw,{}),e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),p()},children:[e.jsx(ac,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),j(_(t),"Share link")},children:[e.jsx(Bo,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),i()},children:[e.jsx(X4,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),c()},children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),u()},children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),g&&t.share_token&&e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),f==null||f()},children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),o()},children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsx(dw,{}),t.contact_id&&e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),l()},children:[e.jsx(to,{className:"h-4 w-4 mr-2"}),"View Contact"]}),e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),a()},className:"text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function Mjs(){var it,Lt;const t=fr(),{data:s,isLoading:r,refetch:n}=Qbs(),{data:a}=Hhe(),{data:o}=Gm(),l=t_s(),i=e_s(),{isGmailConnected:c,gmailEmail:u}=Wx(),{data:p}=Bx(),{data:f=[],isLoading:g}=wjs(),[b,_]=N.useState("my"),[j,w]=N.useState(""),[k,S]=N.useState(null),[M,L]=N.useState(!1),[I,O]=N.useState(!1),[q,U]=N.useState(!1),[B,V]=N.useState(!1),[Z,X]=N.useState(!1),[ee,Q]=N.useState(""),[ie,re]=N.useState(!1),[oe,ce]=N.useState(!1),[xe,ge]=N.useState(!1),[ue,pe]=N.useState(!1),[be,Me]=N.useState(""),[Ne,Pe]=N.useState({}),Oe=Vt=>{if(!Vt)return"Unassigned";const hs=o==null?void 0:o.find(Ts=>Ts.id===Vt);return hs?`${hs.first_name} ${hs.last_name||""}`.trim():"Unknown"},Te=Vt=>{if(!Vt)return"0:00";const hs=Math.floor(Vt/60),Ts=Vt%60;return`${hs}:${Ts.toString().padStart(2,"0")}`},ke=s==null?void 0:s.filter(Vt=>{if(!j)return!0;const hs=Oe(Vt.contact_id).toLowerCase(),Ts=(Vt.title||"").toLowerCase(),Cs=(Vt.notes||"").toLowerCase();return hs.includes(j.toLowerCase())||Ts.includes(j.toLowerCase())||Cs.includes(j.toLowerCase())}),[Be,nt]=N.useState(!1);N.useEffect(()=>{if(Be)return;(async()=>{if(!(s!=null&&s.length))return;const hs=s.filter(Cs=>Cs.status==="processing"&&Cs.bunny_video_id);if(!hs.length)return;let Ts=!1;for(const Cs of hs)try{const{data:cs,error:er}=await H.functions.invoke("bunny-upload",{body:{action:"status",videoId:Cs.bunny_video_id,isAgentVideo:!0}});if(er||!cs)continue;cs.status===4&&(await H.from("agent_videos").update({status:"ready",playback_url:cs.directPlayUrl,thumbnail_url:cs.thumbnailUrl,preview_url:cs.previewUrl,duration_seconds:cs.length||Cs.duration_seconds,updated_at:new Date().toISOString()}).eq("id",Cs.id),Ts=!0)}catch(cs){console.warn("Reconcile check failed for video",Cs.id,cs)}nt(!0),Ts&&n()})()},[s,Be,n]),N.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const hs=s.filter(xt=>(xt==null?void 0:xt.bunny_video_id)&&!Ne[xt.id]);if(!hs.length)return;const Ts=hs.map(xt=>xt.bunny_video_id),{data:Cs,error:cs}=await H.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Ts,isAgentVideo:!0}});if(cs)throw cs;const er=(Cs==null?void 0:Cs.assets)||{};Pe(xt=>{const Es={...xt};for(const ur of hs)er[ur.bunny_video_id]&&(Es[ur.id]={previewUrl:er[ur.bunny_video_id].previewUrl,thumbnailUrl:er[ur.bunny_video_id].thumbnailUrl});return Es})})().catch(hs=>console.warn("Failed to load signed Bunny asset URLs",hs))},[s,Ne]);const Ae=(a==null?void 0:a.total_storage_mb)||0,ft=(a==null?void 0:a.max_storage_mb)||1024,fe=Ae/ft*100,Ve=fe>=80,at=fe>=100,et=async(Vt,hs)=>{await navigator.clipboard.writeText(Vt),me.success(`${hs} copied to clipboard`)},Ce=Vt=>Vt.share_token?`https://video.relevelup.com/${Vt.share_token}`:Vt.playback_url||"",rt=Vt=>{const hs=Ce(Vt),Ts=o==null?void 0:o.find(ur=>ur.id===Vt.contact_id),Cs=Oe(Vt.contact_id),cs=Cs!=="Unassigned"?Cs.split(" ")[0]:"",er=(Ts==null?void 0:Ts.phone)||"",xt=`Hey${cs?` ${cs}`:""}! I recorded a quick video message for you. Check it out: ${hs}`,Es=er?`sms:${er}?body=${encodeURIComponent(xt)}`:`sms:?body=${encodeURIComponent(xt)}`;window.open(Es,"_self")},Ge=Vt=>{const hs=o==null?void 0:o.find(Es=>Es.id===Vt.contact_id),Ts=(hs==null?void 0:hs.email)||"",Cs=Ce(Vt),cs="Check out this video",er=`I recorded a quick video for you: ${Cs}`,xt=Ts?`mailto:${Ts}?subject=${encodeURIComponent(cs)}&body=${encodeURIComponent(er)}`:`mailto:?subject=${encodeURIComponent(cs)}&body=${encodeURIComponent(er)}`;window.open(xt,"_self")},ct=Vt=>{var cs;const hs=Ce(Vt),Ts=Vt.title||"Video Message",Cs=Vt.share_token?`https://video.relevelup.com/thumb/${Vt.share_token}`:((cs=Ne[Vt.id])==null?void 0:cs.thumbnailUrl)||Vt.thumbnail_url||"";return``},qe=async Vt=>{if(!Vt.thumbnail_url&&!Vt.share_token){me.error("Video thumbnail not available yet");return}const hs=ct(Vt),Ts=Ce(Vt),Cs=`Watch: ${Vt.title||"Video Message"} ${Ts}`;try{const cs=new Blob([hs],{type:"text/html"}),er=new Blob([Cs],{type:"text/plain"}),xt=new ClipboardItem({"text/html":cs,"text/plain":er});await navigator.clipboard.write([xt]),me.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(Cs+` `+hs),me.success("Copied! Paste into your email.")}},Ze=async Vt=>{try{me.loading("Preparing download...",{id:"download"});const{data:hs,error:Ts}=await H.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:Vt.bunny_video_id,isAgentVideo:!0}});if(Ts||!(hs!=null&&hs.downloadUrl))throw new Error((Ts==null?void 0:Ts.message)||"Failed to get download URL");const cs=`${((Vt.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,er=await fetch(hs.downloadUrl);if(!er.ok)throw new Error("Failed to fetch video file");const xt=await er.blob(),Es=URL.createObjectURL(xt),ur=document.createElement("a");ur.href=Es,ur.download=cs,ur.rel="noreferrer",document.body.appendChild(ur),ur.click(),ur.remove(),URL.revokeObjectURL(Es),me.success("Download started",{id:"download"})}catch(hs){console.error("Download error:",hs),me.error("Could not force download (your browser may block it).",{id:"download"})}},Qe=async Vt=>{S(Vt),re(!0),Q(""),X(!0);try{const{data:hs,error:Ts}=await H.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:Vt.bunny_video_id,title:Vt.title,isAgentVideo:!0,shareToken:Vt.share_token}});if(Ts||!(hs!=null&&hs.html))throw new Error("Failed to generate CRM embed code");Q(hs.html)}catch(hs){console.error("CRM embed error:",hs),me.error("Failed to generate CRM embed code"),X(!1)}finally{re(!1)}},He=Vt=>{S(Vt),L(!0)},Je=async()=>{if(k)try{await l.mutateAsync({id:k.id,bunnyVideoId:k.bunny_video_id,hardDelete:!0}),O(!1),S(null),me.success("Video deleted successfully")}catch{me.error("Failed to delete video")}};return e.jsx(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:()=>_("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${b==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Videos"}),p&&((it=p.team)==null?void 0:it.shared_videos_enabled)&&e.jsxs("button",{onClick:()=>_("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${b==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(pr,{className:"h-3.5 w-3.5"}),"Team"]}),e.jsxs("button",{onClick:()=>_("analytics"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${b==="analytics"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(No,{className:"h-3.5 w-3.5"}),"Analytics"]})]})]}),b==="my"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>U(!0),children:[e.jsx(li,{className:"h-4 w-4 mr-2"}),"Upload Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Record New Video"]})]})]}),b==="team"?e.jsx(Tjs,{videos:f,isLoading:g,searchTerm:j,setSearchTerm:w}):b==="analytics"?e.jsx(kjs,{}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:Ve?"border-amber-500":at?"border-destructive":"",children:e.jsxs(De,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(oL,{className:`h-5 w-5 ${at?"text-destructive":Ve?"text-amber-500":"text-muted-foreground"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:"Storage Used"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[Ae.toFixed(1)," MB / ",ft>=1024?`${(ft/1024).toFixed(0)} GB`:`${ft} MB`]})]}),e.jsx(Bi,{value:Math.min(fe,100),className:`h-2 ${at?"[&>div]:bg-destructive":Ve?"[&>div]:bg-amber-500":""}`})]}),Ve&&!at&&e.jsxs(tt,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(kl,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),at&&e.jsxs(tt,{variant:"destructive",children:[e.jsx(kl,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),at&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:"You've reached your storage limit. Delete videos to record more."})]})}),e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search videos by contact, title, or notes...",value:j,onChange:Vt=>w(Vt.target.value),className:"pl-10"})]}),r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})}):(ke==null?void 0:ke.length)===0?e.jsx(Ee,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(An,{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($s,{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:ke==null?void 0:ke.map(Vt=>{var hs,Ts;return e.jsx(Cjs,{video:Vt,previewSrc:(hs=Ne[Vt.id])==null?void 0:hs.previewUrl,thumbnailSrc:(Ts=Ne[Vt.id])==null?void 0:Ts.thumbnailUrl,onOpen:()=>He(Vt),onDelete:()=>{S(Vt),O(!0)},onRename:()=>{S(Vt),Me(Vt.title||""),pe(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${Vt.contact_id}`),onGetEmbedCode:()=>{S(Vt),V(!0)},onCopyEmailHtml:()=>qe(Vt),onEmbedToCrm:()=>Qe(Vt),onShareWithTemplate:()=>{S(Vt),ce(!0)},onSendViaGmail:()=>{S(Vt),ge(!0)},isGmailConnected:c,getContactName:Oe,getShareUrl:Ce,copyToClipboard:et,formatDuration:Te},Vt.id)})}),e.jsx(fs,{open:M,onOpenChange:L,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:(k==null?void 0:k.title)||"Video Preview"}),e.jsx(Gr,{children:(k==null?void 0:k.contact_id)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(to,{className:"h-3 w-3"}),Oe(k.contact_id)]})})]}),k&&e.jsxs("div",{className:"space-y-4",children:[k.status==="processing"?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-6 bg-muted/50 rounded-lg border border-dashed border-border text-center space-y-4",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(ws,{className:"h-8 w-8 text-primary animate-spin"})})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Video is still processing"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:"Your video is being encoded and will be ready shortly. This usually takes 1–3 minutes. Check back soon!"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(!1),n()},children:[e.jsx(Go,{className:"h-4 w-4 mr-2"}),"Refresh Library"]})]}):e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:k.playback_url?(()=>{let Vt=k.playback_url;return Vt.includes("iframe.mediadelivery.net/play/")&&(Vt=Vt.replace("/play/","/embed/"),Vt+=(Vt.includes("?")?"&":"?")+"autoplay=false&responsive=true"),Vt.includes("iframe.mediadelivery.net")?e.jsx("iframe",{src:Vt,title:k.title||"Video preview",className:"absolute top-0 left-0 w-full h-full rounded-lg",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsx("video",{src:k.playback_url,controls:!0,playsInline:!0,preload:"metadata",poster:k.thumbnail_url||void 0,className:"absolute top-0 left-0 w-full h-full rounded-lg object-cover",onError:()=>me.error("Video preview failed to load")},k.playback_url)})():e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-muted rounded-lg",children:[e.jsx(An,{className:"h-12 w-12 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground ml-2",children:"Video not available"})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>rt(k),children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!c&&e.jsxs(K,{variant:"outline",onClick:()=>Ge(k),children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>et(Ce(k),"Share link"),children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(K,{variant:"outline",onClick:()=>qe(k),children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(K,{variant:"outline",onClick:()=>Ze(k),children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>{L(!1),Qe(k)},children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(K,{variant:"outline",onClick:()=>{L(!1),ce(!0)},children:[e.jsx(ac,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),c&&(k==null?void 0:k.share_token)&&e.jsxs(K,{variant:"outline",onClick:()=>{L(!1),ge(!0)},children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]})]}),e.jsx("div",{className:"flex justify-end pt-2 border-t",children:e.jsxs(K,{variant:"destructive",onClick:()=>{L(!1),O(!0)},children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),e.jsx(fs,{open:I,onOpenChange:O,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Delete Video"}),e.jsx(Gr,{children:"Are you sure you want to delete this video? This action cannot be undone."})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Je,disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(pjs,{open:q,onOpenChange:U}),e.jsx(fs,{open:B,onOpenChange:V,children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Embed Video"}),e.jsx(Gr,{children:"Copy this code to embed the video on your website."})]}),k&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Embed Code"}),e.jsx(Er,{readOnly:!0,rows:5,value:``,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{className:"flex-1",onClick:()=>{const Vt=``;et(Vt,"Embed code")},children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy Embed Code"]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste this code into your website's HTML where you want the video to appear. The video will automatically resize to fit its container."})]})]})}),k&&e.jsx(olt,{open:oe,onOpenChange:ce,video:k,contactName:Oe(k.contact_id)}),k&&e.jsx(_js,{open:xe,onOpenChange:ge,video:k,gmailEmail:u,signedThumbnailUrl:(Lt=Ne[k.id])==null?void 0:Lt.thumbnailUrl}),e.jsx(fs,{open:ue,onOpenChange:pe,children:e.jsxs(ps,{className:"max-w-sm",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Rename Video"}),e.jsx(Gr,{children:"Enter a new title for this video."})]}),e.jsx(ze,{value:be,onChange:Vt=>Me(Vt.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:Vt=>{Vt.key==="Enter"&&be.trim()&&i.mutate({id:k.id,title:be.trim()},{onSuccess:()=>{me.success("Video renamed"),pe(!1)}})}}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>pe(!1),children:"Cancel"}),e.jsx(K,{disabled:!be.trim()||i.isPending,onClick:()=>{i.mutate({id:k.id,title:be.trim()},{onSuccess:()=>{me.success("Video renamed"),pe(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(fs,{open:Z,onOpenChange:X,children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(tn,{className:"h-5 w-5"}),"Embed to CRM"]}),e.jsx(Gr,{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."})]}),ie?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):ee?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(Er,{readOnly:!0,rows:12,value:ee,className:"font-mono text-xs"})]}),e.jsxs(K,{className:"w-full",onClick:()=>{et(ee,"CRM embed code")},children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy CRM Embed Code"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste this into your CRM's email HTML editor. The recipient will see the video thumbnail and can click to watch. Works with Follow Up Boss, KvCORE, BoomTown, Sierra, and more."})]}):null]})})]})]})})}function Tjs({videos:t,isLoading:s,searchTerm:r,setSearchTerm:n}){const a=N.useMemo(()=>{if(!r)return t;const i=r.toLowerCase();return t.filter(c=>(c.title||"").toLowerCase().includes(i)||(c.owner_name||"").toLowerCase().includes(i)||(c.recipient_name||"").toLowerCase().includes(i))},[t,r]),o=N.useMemo(()=>{const i=new Map;return a.forEach(c=>{const u=i.get(c.owner_user_id);u?u.videos.push(c):i.set(c.owner_user_id,{name:c.owner_name,avatar:c.owner_avatar_url,videos:[c]})}),Array.from(i.entries())},[a]),l=i=>{if(!i)return"0:00";const c=Math.floor(i/60),u=i%60;return`${c}:${u.toString().padStart(2,"0")}`};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search team videos by title, owner, or recipient...",value:r,onChange:i=>n(i.target.value),className:"pl-10"})]}),s?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})}):a.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(pr,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No team videos"}),e.jsx("p",{className:"text-muted-foreground",children:t.length===0?"Your teammates haven't recorded any videos yet.":"No videos match your search."})]})}):e.jsx("div",{className:"space-y-6",children:o.map(([i,c])=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Nn,{className:"h-7 w-7",children:[e.jsx($a,{src:c.avatar||""}),e.jsx(kn,{children:(c.name||"?").charAt(0).toUpperCase()})]}),e.jsx("h3",{className:"font-semibold text-sm",children:c.name}),e.jsx(tt,{variant:"secondary",className:"text-xs",children:c.videos.length})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:c.videos.map(u=>e.jsxs(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(An,{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(De,{className:"p-3",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:u.title||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[u.recipient_name&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(to,{className:"h-3 w-3"}),u.recipient_name]}),u.view_count!=null&&u.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(On,{className:"h-3 w-3"}),u.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(u.created_at),"MMM d")]})]})]})]},u.id))})]},i))})]})}const Ajs=()=>{const{user:t}=Ds();return mt({queryKey:["team-deals",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.rpc("get_team_deals",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},cze=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function Ejs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Ajs(),[a,o]=N.useState(""),[l,i]=N.useState("all"),c=N.useMemo(()=>{if(!r)return new Map;const _=new Map;let j=0;return r.forEach(w=>{_.has(w.owner_user_id)||(_.set(w.owner_user_id,{name:w.owner_name||"Unknown",avatar:w.owner_avatar_url,color:cze[j%cze.length]}),j++)}),_},[r]),u=N.useMemo(()=>Array.from(c.entries()).map(([_,j])=>({id:_,...j})),[c]),p=N.useMemo(()=>{if(!r)return[];let _=r;if(l!=="all"&&(_=_.filter(j=>j.owner_user_id===l)),a.trim()){const j=a.toLowerCase();_=_.filter(w=>{var k,S,M,L;return w.deal_name.toLowerCase().includes(j)||((k=w.contact_name)==null?void 0:k.toLowerCase().includes(j))||((S=w.property_address)==null?void 0:S.toLowerCase().includes(j))||((M=w.city)==null?void 0:M.toLowerCase().includes(j))||((L=w.owner_name)==null?void 0:L.toLowerCase().includes(j))})}return _},[r,a,l]),f=N.useMemo(()=>{const _=new Map;return p.forEach(j=>{const w=j.stage_name||"Unknown";_.has(w)||_.set(w,{name:w,color:j.stage_color,icon:j.stage_icon,deals:[],totalValue:0});const k=_.get(w);k.deals.push(j),k.totalValue+=j.sale_price||0}),Array.from(_.values())},[p]),g=_=>_>=1e6?`$${(_/1e6).toFixed(1)}M`:_>=1e3?`$${(_/1e3).toFixed(0)}K`:`$${_.toFixed(0)}`,b=_=>_?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_):null;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-[95vw] w-full max-h-[90vh] flex flex-col",children:[e.jsx(_s,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(pr,{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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search deals...",value:a,onChange:_=>o(_.target.value),className:"pl-9"})]}),e.jsxs(Zs,{value:l,onValueChange:i,children:[e.jsx(Ws,{className:"w-[180px]",children:e.jsx(Xs,{placeholder:"All Members"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Members"}),u.map(_=>e.jsx(Mt,{value:_.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full inline-block",style:{backgroundColor:_.color}}),_.name]})},_.id))]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-3 ml-auto text-xs text-muted-foreground",children:[u.slice(0,6).map(_=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:_.color}}),_.name.split(" ")[0]]},_.id)),u.length>6&&e.jsxs("span",{children:["+",u.length-6," more"]})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden mt-2",children:n?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(_=>e.jsxs("div",{className:"min-w-[260px] flex-1",children:[e.jsx(ys,{className:"h-12 w-full mb-2 rounded-lg"}),e.jsx(ys,{className:"h-24 w-full mb-2 rounded-lg"}),e.jsx(ys,{className:"h-24 w-full rounded-lg"})]},_))}):f.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(pr,{className:"h-10 w-10 mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No team deals found"}),e.jsx("p",{className:"text-sm",children:"Team members' deals will appear here."})]})}):e.jsx("div",{className:"flex gap-3 h-full overflow-x-auto pb-2",children:f.map(_=>{const j=_.icon&&x2e[_.icon]||bd;return e.jsxs("div",{className:"flex flex-col h-full min-w-[260px] max-w-[300px] flex-1 bg-muted/30 rounded-xl border border-border/50",children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:_.color||"hsl(var(--border))",borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{backgroundColor:_.color?`${_.color}20`:void 0},children:e.jsx(j,{className:"h-3.5 w-3.5",style:{color:_.color||void 0}})}),e.jsx("h3",{className:"font-semibold text-sm",children:_.name})]}),e.jsx(tt,{variant:"secondary",className:"text-xs px-2",children:_.deals.length})]}),_.totalValue>0&&e.jsx("p",{className:"text-xs text-muted-foreground ml-8",children:g(_.totalValue)})]}),e.jsx(Gi,{className:"flex-1 p-2",children:e.jsx("div",{className:"space-y-2",children:_.deals.map(w=>{const k=c.get(w.owner_user_id);return e.jsx(Pjs,{deal:w,ownerColor:(k==null?void 0:k.color)||"#888",ownerName:(k==null?void 0:k.name)||"Unknown",ownerAvatar:(k==null?void 0:k.avatar)||null,formatPrice:b},w.id)})})})]},_.name)})})}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-2 border-t shrink-0",children:[p.length," deal",p.length!==1?"s":""," across ",f.length," stage",f.length!==1?"s":""," from ",u.length," member",u.length!==1?"s":""]})]})})}function Pjs({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(Nn,{className:"h-4 w-4",children:[e.jsx($a,{src:n||""}),e.jsx(kn,{className:"text-[8px] font-semibold text-white",style:{backgroundColor:s},children:r.charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-[10px] font-medium truncate",style:{color:s},children:r})]}),e.jsxs("div",{className:"flex items-start justify-between gap-1",children:[e.jsx("h4",{className:"font-medium text-sm leading-tight line-clamp-2",children:t.deal_name}),l&&e.jsx(tt,{variant:"outline",className:It("text-[10px] px-1.5 py-0 shrink-0",l.className),children:l.label})]}),t.contact_name&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:t.contact_name}),(t.property_address||t.city)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(bn,{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(nc,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:a(t.sale_price)})]})]})}function Ijs({members:t,enabledMembers:s,onToggleMember:r,isOpen:n,onToggleOpen:a}){const o=s.size;return e.jsxs("div",{className:It("shrink-0 border-r border-border/50 bg-muted/20 transition-all duration-300 flex flex-col",n?"w-[220px]":"w-[48px]"),children:[e.jsx("div",{className:"p-2 border-b border-border/50 shrink-0",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 px-2",onClick:a,children:[e.jsx(pr,{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(cl,{className:"h-3 w-3 text-muted-foreground"})]}),!n&&o>0&&e.jsx("span",{className:"absolute -top-1 -right-1 text-[9px] bg-primary text-primary-foreground rounded-full w-4 h-4 flex items-center justify-center",children:o})]})}),n?e.jsxs(Gi,{className:"flex-1 p-2",children:[e.jsx("div",{className:"space-y-1",children:t.map(l=>{const i=s.has(l.id);return e.jsxs("button",{onClick:()=>r(l.id),className:It("w-full flex items-center gap-2 px-2 py-2 rounded-lg text-left transition-colors",i?"bg-primary/10 hover:bg-primary/15":"hover:bg-muted/50"),children:[e.jsxs("div",{className:"relative",children:[e.jsxs(Nn,{className:"h-7 w-7",children:[e.jsx($a,{src:l.avatar_url||""}),e.jsx(kn,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:l.color},children:l.name.charAt(0).toUpperCase()})]}),i&&e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-background",style:{backgroundColor:l.color}})]}),e.jsx("span",{className:It("text-xs truncate flex-1",i?"font-medium text-foreground":"text-muted-foreground"),children:l.name}),e.jsx(qr,{checked:i,onCheckedChange:()=>r(l.id),className:"scale-75",onClick:c=>c.stopPropagation()})]},l.id)})}),t.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No team members"})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center pt-2 gap-2",children:[t.slice(0,5).map(l=>{const i=s.has(l.id);return e.jsx("button",{onClick:()=>r(l.id),className:"relative",title:l.name,children:e.jsxs(Nn,{className:It("h-7 w-7 transition-all",i?"ring-2 ring-offset-1 ring-offset-background":"opacity-50"),style:i?{"--tw-ring-color":l.color}:{},children:[e.jsx($a,{src:l.avatar_url||""}),e.jsx(kn,{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 dze=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function Ljs(){const t=ci(),{data:s}=Bx(),r=(s==null?void 0:s.role)==="team_leader",n=s==null?void 0:s.teamId,a=mt({queryKey:["team-pipeline-members",n,t],queryFn:async()=>{const{data:o,error:l}=await H.from("team_members").select("user_id, role").eq("team_id",n).neq("user_id",t);if(l)throw l;if(!o||o.length===0)return[];const i=o.map(p=>p.user_id),{data:c,error:u}=await H.from("profiles").select("id, name, avatar_url").in("id",i);if(u)throw u;return(c||[]).map((p,f)=>({id:p.id,name:p.name||"Unknown",avatar_url:p.avatar_url,color:dze[f%dze.length]}))},enabled:!!n&&!!t&&r,staleTime:5*60*1e3});return{isTeamLeader:r,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function Djs(t){return mt({queryKey:["team-member-deals",t],queryFn:async()=>{if(t.length===0)return[];const{data:s,error:r}=await H.from("deal_pipeline").select(` *, contact:innercircle_contacts(id, first_name, last_name, email, phone), listing:listings(id, property_address, city, state, price, status, created_at), deal_pipeline_stages(name) `).in("owner_user_id",t).order("updated_at",{ascending:!1});if(r)throw r;return(s||[]).map(n=>{var a;return{...n,_stage_name:((a=n.deal_pipeline_stages)==null?void 0:a.name)||null}})},enabled:t.length>0})}function llt({stages:t,currentStageId:s,onStageSelect:r,disabled:n}){const[a,o]=N.useState(!1),l=t.find(c=>c.id===s),i=c=>{c.id!==s&&r(c.id,c.name),o(!1)};return e.jsxs(iu,{open:a,onOpenChange:o,children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5",disabled:n,onClick:c=>c.stopPropagation(),children:[l&&e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:l.color}}),e.jsx("span",{className:"max-w-[80px] truncate",children:(l==null?void 0:l.name)||"Move"}),e.jsx(da,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(Bd,{align:"end",className:"w-48 z-50 bg-popover",onClick:c=>c.stopPropagation(),children:t.map(c=>{const u=c.icon&&x2e[c.icon]||bd,p=c.id===s;return e.jsxs(Ma,{onClick:()=>i(c),className:It("flex items-center gap-2 cursor-pointer",p&&"bg-accent"),children:[e.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center shrink-0",style:{backgroundColor:`${c.color}20`},children:e.jsx(u,{className:"h-3 w-3",style:{color:c.color}})}),e.jsx("span",{className:"flex-1",children:c.name}),p&&e.jsx(va,{className:"h-4 w-4 text-primary"})]},c.id)})})]})}const Ojs={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"}},Rjs={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 clt({deal:t,onClick:s,isDragging:r,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var S,M;const c=NE(),u=Ojs[t.deal_type],p=Rjs[t.priority],f=N.useMemo(()=>t.target_close_date?oy(Dl(t.target_close_date),new Date):null,[t.target_close_date]),g=f!==null&&f<0,b=f!==null&&f<=7&&f>=0,_=N.useMemo(()=>{var O;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const L=((O=t.listing)==null?void 0:O.created_at)||t.listing_date;if(!L)return null;const I=t.contract_date?Dl(t.contract_date):new Date;return oy(I,Dl(L))},[t]),j=l&&!t.scorecard_transaction_id,w=!!t.scorecard_transaction_id,k=L=>L?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(L):null;return e.jsx(Ee,{className:It("cursor-pointer transition-all duration-200 hover:shadow-md hover:border-primary/30 group overflow-hidden",r&&"opacity-50 rotate-2 shadow-xl",g&&"border-red-200 bg-red-50/30",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(De,{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(Nn,{className:"h-4 w-4",children:[e.jsx($a,{src:i.avatar_url||""}),e.jsx(kn,{className:"text-[8px] font-semibold text-white",style:{backgroundColor:i.color},children:i.name.charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-[10px] font-medium",style:{color:i.color},children:i.name})]}),e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("h4",{className:"font-medium text-sm leading-tight line-clamp-2 group-hover:text-primary transition-colors",children:t.deal_name})}),e.jsx(tt,{variant:"outline",className:It("text-[10px] px-1.5 py-0 shrink-0",u.color),children:u.label})]}),t.contact&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Nn,{className:"h-5 w-5",children:e.jsxs(kn,{className:"text-[10px] bg-primary/10 text-primary",children:[(S=t.contact.first_name)==null?void 0:S[0],(M=t.contact.last_name)==null?void 0:M[0]]})}),e.jsxs("span",{className:"truncate",children:[t.contact.first_name," ",t.contact.last_name]})]}),t.listing&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(dl,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"text-primary truncate",children:"Linked to Listing Exchange"})]}),j&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 px-2 py-1 rounded",children:[e.jsx(xo,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:"Add to Scorecard"})]}),w&&l&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx(sa,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:"Synced to Scorecard"})]}),_!==null&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(QI,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsxs("span",{className:It("font-medium",_>90?"text-red-600":_>60?"text-amber-600":"text-muted-foreground"),children:[_," DOM"]}),t.contract_date&&e.jsx("span",{className:"text-muted-foreground",children:"(final)"})]}),!t.listing&&(t.property_address||t.city)&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(bn,{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(nc,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:k(t.expected_price)}),t.expected_commission&&e.jsxs("span",{className:"text-muted-foreground",children:["• ",k(t.expected_commission)," GCI"]}),(()=>{const L=yx(t);return L!==null&&L!==t.expected_commission?e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:["• ",k(L)," Net"]}):null})()]}),e.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:It("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",p.color),children:[e.jsx("div",{className:It("w-1.5 h-1.5 rounded-full",p.dot)}),e.jsx("span",{className:"capitalize",children:t.priority})]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[t.probability,"%"]})]}),o&&c&&n&&a?e.jsx(llt,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(L,I)=>a(t.id,L,I)}):t.target_close_date?e.jsxs("div",{className:It("flex items-center gap-1 text-[10px]",g&&"text-red-600",b&&!g&&"text-amber-600",!g&&!b&&"text-muted-foreground"),children:[g?e.jsx(kl,{className:"h-3 w-3"}):e.jsx(hn,{className:"h-3 w-3"}),e.jsx("span",{children:g?`${Math.abs(f)}d overdue`:b?`${f}d left`:ms(Dl(t.target_close_date),"MMM d")})]}):null]})]})})}function Fjs({stage:t,deals:s,onDealClick:r,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:c=!1,getOwnerInfo:u}){const p=N.useRef(null),f=s.reduce((w,k)=>w+(k.expected_price||0),0),g=s.reduce((w,k)=>w+(k.expected_commission||0),0),b=s.reduce((w,k)=>w+(yx(k)||0),0),_=w=>w>=1e6?`$${(w/1e6).toFixed(1)}M`:w>=1e3?`$${(w/1e3).toFixed(0)}K`:`$${w.toFixed(0)}`,j=t.icon&&x2e[t.icon]||bd;return e.jsxs("div",{ref:p,className:It("flex flex-col h-full min-w-[280px] max-w-[320px] bg-muted/30 rounded-xl border border-border/50 transition-all duration-200",i&&"border-primary/50 bg-primary/5 ring-2 ring-primary/20"),onDragOver:w=>o(w,t.id),onDrop:w=>l(w,t.id),children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:t.color,borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color}20`},children:e.jsx(j,{className:"h-4 w-4",style:{color:t.color}})}),e.jsx("div",{children:e.jsx("h3",{className:"font-semibold text-sm",children:t.name})})]}),e.jsx(tt,{variant:"secondary",className:"text-xs font-medium px-2",children:s.length})]}),f>0&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-wrap",children:[e.jsx("span",{className:"font-medium text-foreground",children:_(f)}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[_(g)," GCI"]}),b>0&&b!==g&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:[_(b)," Net"]})]})]})]}),e.jsx(Gi,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(w=>e.jsx("div",{draggable:!0,onDragStart:k=>{k.dataTransfer.effectAllowed="move",a(w.id,t.id)},children:e.jsx(clt,{deal:w,onClick:()=>r(w),isWonStage:c,ownerInfo:(u==null?void 0:u(w))||null})},w.id)),s.length===0&&e.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground text-sm",children:[e.jsx("p",{className:"mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-xs",children:"Drag deals here or add new"})]})]})}),e.jsx("div",{className:"p-2 border-t border-border/50 shrink-0",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground hover:text-foreground",onClick:()=>n(t.id),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Deal"]})})]})}function zjs({stats:t,isLoading:s}){const r=a=>a>=1e6?`$${(a/1e6).toFixed(1)}M`:a>=1e3?`$${(a/1e3).toFixed(0)}K`:`$${a.toLocaleString()}`,n=[{label:"Active Deals",value:(t==null?void 0:t.activeDeals)||0,icon:zm,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Weighted GCI",value:r((t==null?void 0:t.weightedGCI)||0),icon:jL,color:"text-indigo-500",bgColor:"bg-indigo-500/10",tooltip:"GCI adjusted by each deal's win probability"},{label:"Weighted Net",value:r((t==null?void 0:t.weightedNet)||0),icon:OL,color:"text-teal-500",bgColor:"bg-teal-500/10",tooltip:"Net to Agent adjusted by each deal's win probability"},{label:"YTD Closed Net",value:r((t==null?void 0:t.ytdWonNet)||0),icon:XI,color:"text-green-500",bgColor:"bg-green-500/10",subtitle:`${(t==null?void 0:t.ytdWonDeals)||0} deals`,tooltip:"Net commission from deals closed this year"},{label:"Projected Annual",value:r((t==null?void 0:t.projectedAnnualNet)||0),icon:ul,color:"text-amber-500",bgColor:"bg-amber-500/10",tooltip:"YTD Closed Net + Weighted Active Net"}];return s?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[1,2,3,4,5].map(a=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(De,{className:"p-4",children:e.jsx("div",{className:"h-10 bg-muted rounded"})})},a))}):e.jsx(z1,{children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:n.map(a=>{const o=e.jsx(Ee,{className:"border-border/50 hover:shadow-sm transition-shadow",children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:It("p-2 rounded-lg",a.bgColor),children:e.jsx(a.icon,{className:It("h-5 w-5",a.color)})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:a.label}),e.jsx("p",{className:"text-xl font-bold",children:a.value}),"subtitle"in a&&a.subtitle&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a.subtitle})]})]})})},a.label);return"tooltip"in a&&a.tooltip?e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:o}),e.jsx(Yl,{children:e.jsx("p",{children:a.tooltip})})]},a.label):o})})})}function Bjs({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=Ds(),[a,o]=N.useState(t.portal_enabled);if(!n)return e.jsxs("div",{className:"border rounded-lg p-4 opacity-60",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(tt,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Give your clients a premium, real-time view of their transaction — coming soon!"})]});const l=i=>{s({...t,...i})};return e.jsx(gf,{open:a,onOpenChange:o,children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs(yf,{className:"w-full p-4 flex items-center justify-between hover:bg-muted/50 transition-colors rounded-t-lg",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),t.portal_enabled&&e.jsx(tt,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),e.jsx(Eo,{className:It("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),e.jsx(vf,{children:e.jsxs("div",{className:"px-4 pb-4 space-y-5 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(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(qr,{checked:t.portal_enabled,onCheckedChange:i=>l({portal_enabled:i})})]}),t.portal_enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Portal Visibility"}),e.jsxs(gNe,{value:t.visibility,onValueChange:i=>l({visibility:i}),className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{className:It("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t.visibility==="private"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[e.jsx(Woe,{value:"private"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Th,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:"Private"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Link-only access"})]})]}),e.jsxs("label",{className:It("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t.visibility==="public"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[e.jsx(Woe,{value:"public"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(su,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:"Public"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Shareable link"})]})]})]})]}),e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-muted/30",children:[e.jsx(Oo,{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(Oo,{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(ze,{value:t.client_name,onChange:i=>l({client_name:i.target.value}),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Email"}),e.jsx(ze,{type:"email",value:t.client_email,onChange:i=>l({client_email:i.target.value}),placeholder:"jane@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Phone"}),e.jsx(ze,{type:"tel",value:t.client_phone,onChange:i=>l({client_phone:i.target.value}),placeholder:"(555) 123-4567"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Preferred Invite Method"}),e.jsxs(Zs,{value:t.invite_method,onValueChange:i=>l({invite_method:i}),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"email",children:"Email"}),e.jsxs(Mt,{value:"sms",disabled:!t.client_phone,children:["SMS ",!t.client_phone&&"(add phone first)"]})]})]})]})]})]})]})]})})]})})}const $js=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],qjs=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function Ujs({open:t,onOpenChange:s,deal:r,defaultStageId:n}){const{data:a}=Whe(),{data:o}=Gm(),{data:l}=eXe(),i=_ue(),c=tit(),u=sit(),p=lSe(),[f,g]=N.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[b,_]=N.useState(""),[j,w]=N.useState(!1),[k,S]=N.useState(!1),[M,L]=N.useState({first_name:"",last_name:"",email:"",phone:""}),I=(l==null?void 0:l.filter(ee=>((r==null?void 0:r.listing_id)===ee.id,!0)))||[],[O,q]=N.useState({deal_name:"",deal_type:"buyer",stage_id:"",contact_id:"",listing_id:"",property_address:"",city:"",state:"",zip_code:"",expected_price:"",commission_percentage:"3",brokerage_split_pct:"",team_split_pct:"",referral_fee_pct:"",franchise_fee_pct:"",transaction_fee:"",commission_calc_method:"standard",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""});N.useEffect(()=>{var ee,Q,ie,re,oe,ce,xe,ge;t&&(r?(q({deal_name:r.deal_name,deal_type:r.deal_type,stage_id:r.stage_id||"",contact_id:r.contact_id||"",listing_id:r.listing_id||"",property_address:r.property_address||"",city:r.city||"",state:r.state||"",zip_code:r.zip_code||"",expected_price:((ee=r.expected_price)==null?void 0:ee.toString())||"",commission_percentage:((Q=r.commission_percentage)==null?void 0:Q.toString())||"3",brokerage_split_pct:((ie=r.brokerage_split_pct)==null?void 0:ie.toString())||"",team_split_pct:((re=r.team_split_pct)==null?void 0:re.toString())||"",referral_fee_pct:((oe=r.referral_fee_pct)==null?void 0:oe.toString())||"",franchise_fee_pct:((ce=r.franchise_fee_pct)==null?void 0:ce.toString())||"",transaction_fee:((xe=r.transaction_fee)==null?void 0:xe.toString())||"",commission_calc_method:r.commission_calc_method||"standard",target_close_date:r.target_close_date?Dl(r.target_close_date):void 0,contract_date:r.contract_date?Dl(r.contract_date):void 0,listing_date:r.listing_date?Dl(r.listing_date):void 0,priority:r.priority,probability:r.probability.toString(),notes:r.notes||""}),r.contact&&_(`${r.contact.first_name} ${r.contact.last_name}`)):(q({deal_name:"",deal_type:"buyer",stage_id:n||((ge=a==null?void 0:a[0])==null?void 0:ge.id)||"",contact_id:"",listing_id:"",property_address:"",city:"",state:"",zip_code:"",expected_price:"",commission_percentage:"3",brokerage_split_pct:"",team_split_pct:"",referral_fee_pct:"",franchise_fee_pct:"",transaction_fee:"",commission_calc_method:"standard",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""}),_(""),g({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"})))},[t,r,n,a]);const U=o==null?void 0:o.filter(ee=>{var ie,re,oe;const Q=b.toLowerCase();return((ie=ee.first_name)==null?void 0:ie.toLowerCase().includes(Q))||((re=ee.last_name)==null?void 0:re.toLowerCase().includes(Q))||((oe=ee.email)==null?void 0:oe.toLowerCase().includes(Q))}).slice(0,5),B=()=>{const ee=parseFloat(O.expected_price)||0,Q=parseFloat(O.commission_percentage)||0;return ee*(Q/100)},V=()=>{const ee=B();if(!ee)return null;const Q=parseFloat(O.brokerage_split_pct)||0,ie=parseFloat(O.team_split_pct)||0,re=parseFloat(O.referral_fee_pct)||0,oe=parseFloat(O.franchise_fee_pct)||0,ce=parseFloat(O.transaction_fee)||0;if(O.commission_calc_method==="referral_first"){let ge=ee;re&&(ge-=ee*re/100);let ue=ge;return Q&&(ue-=ge*Q/100),ie&&(ue-=ee*ie/100),oe&&(ue-=ee*oe/100),ce&&(ue-=ce),Math.max(0,ue)}let xe=ee;return Q&&(xe=xe*((100-Q)/100)),ie&&(xe=xe*((100-ie)/100)),re&&(xe=xe-ee*re/100),oe&&(xe=xe-ee*oe/100),ce&&(xe=xe-ce),Math.max(0,xe)},Z=async ee=>{var Q,ie,re;if(ee.preventDefault(),!O.deal_name.trim()){me.error("Please enter a deal name");return}try{const oe={deal_name:O.deal_name,deal_type:O.deal_type,stage_id:O.stage_id||null,contact_id:O.contact_id||null,listing_id:O.listing_id||null,property_address:O.property_address||null,city:O.city||null,state:O.state||null,zip_code:O.zip_code||null,expected_price:O.expected_price?parseFloat(O.expected_price):null,expected_commission:B()||null,commission_percentage:O.commission_percentage?parseFloat(O.commission_percentage):3,brokerage_split_pct:O.brokerage_split_pct?parseFloat(O.brokerage_split_pct):null,team_split_pct:O.team_split_pct?parseFloat(O.team_split_pct):null,referral_fee_pct:O.referral_fee_pct?parseFloat(O.referral_fee_pct):null,franchise_fee_pct:O.franchise_fee_pct?parseFloat(O.franchise_fee_pct):null,transaction_fee:O.transaction_fee?parseFloat(O.transaction_fee):null,commission_calc_method:O.commission_calc_method,target_close_date:((Q=O.target_close_date)==null?void 0:Q.toISOString().split("T")[0])||null,contract_date:((ie=O.contract_date)==null?void 0:ie.toISOString().split("T")[0])||null,listing_date:((re=O.listing_date)==null?void 0:re.toISOString().split("T")[0])||null,priority:O.priority,probability:parseInt(O.probability)||50,notes:O.notes||null};if(r)await u.mutateAsync({id:r.id,...oe}),me.success("Deal updated successfully");else{const ce=await c.mutateAsync(oe);if(me.success("Deal created successfully"),f.portal_enabled&&(ce!=null&&ce.id))try{await p.mutateAsync({deal_id:ce.id,visibility:f.visibility,require_onboarding:f.require_onboarding,allow_spouse:f.allow_spouse,client_name:f.client_name||null,client_email:f.client_email||null,client_phone:f.client_phone||null,invite_method:f.invite_method}),me.success("Client portal created!")}catch{me.error("Deal created, but portal setup failed")}}s(!1)}catch{me.error("Failed to save deal")}},X=c.isPending||u.isPending;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:r?"Edit Deal":"Add New Deal"}),e.jsx(Gr,{children:r?"Update the deal details below.":"Enter the details for your new deal."})]}),e.jsxs("form",{onSubmit:Z,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(ze,{id:"deal_name",value:O.deal_name,onChange:ee=>q(Q=>({...Q,deal_name:ee.target.value})),placeholder:"e.g., Smith Family - 123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Deal Type"}),e.jsxs(Zs,{value:O.deal_type,onValueChange:ee=>q(Q=>({...Q,deal_type:ee})),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:$js.map(ee=>e.jsx(Mt,{value:ee.value,children:ee.label},ee.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Stage"}),e.jsxs(Zs,{value:O.stage_id||"none",onValueChange:ee=>q(Q=>({...Q,stage_id:ee==="none"?"":ee})),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select stage"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:"No Stage"}),a==null?void 0:a.map(ee=>e.jsx(Mt,{value:ee.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:ee.color}}),ee.name]})},ee.id))]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Link to Contact"}),e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:b,onChange:ee=>{_(ee.target.value),w(!0),S(!1),ee.target.value||q(Q=>({...Q,contact_id:""}))},onFocus:()=>w(!0),placeholder:"Search contacts...",className:"pl-9"}),j&&b&&e.jsxs("div",{className:"absolute z-10 w-full mt-1 bg-background border rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[U&&U.length>0?U.map(ee=>e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2",onClick:()=>{q(Q=>({...Q,contact_id:ee.id})),_(`${ee.first_name} ${ee.last_name}`),w(!1)},children:[e.jsx(to,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:[ee.first_name," ",ee.last_name]}),ee.email&&e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:ee.email})]},ee.id)):e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"No contacts found"}),e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2 border-t text-primary font-medium",onClick:()=>{const ee=b.trim().split(/\s+/);L({first_name:ee[0]||"",last_name:ee.slice(1).join(" ")||"",email:"",phone:""}),S(!0),w(!1)},children:[e.jsx(Tl,{className:"h-4 w-4"}),e.jsxs("span",{children:['Create new contact "',b.trim(),'"']})]})]})]}),k&&e.jsxs("div",{className:"border rounded-lg p-3 space-y-3 bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(Tl,{className:"h-3.5 w-3.5"}),"Quick Add Contact"]}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>S(!1),children:"Cancel"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(ze,{placeholder:"First name *",value:M.first_name,onChange:ee=>L(Q=>({...Q,first_name:ee.target.value})),className:"h-8 text-sm"}),e.jsx(ze,{placeholder:"Last name",value:M.last_name,onChange:ee=>L(Q=>({...Q,last_name:ee.target.value})),className:"h-8 text-sm"}),e.jsx(ze,{placeholder:"Email",type:"email",value:M.email,onChange:ee=>L(Q=>({...Q,email:ee.target.value})),className:"h-8 text-sm"}),e.jsx(ze,{placeholder:"Phone",type:"tel",value:M.phone,onChange:ee=>L(Q=>({...Q,phone:ee.target.value})),className:"h-8 text-sm"})]}),e.jsx(K,{type:"button",size:"sm",className:"w-full h-8",disabled:!M.first_name.trim()||i.isPending,onClick:async()=>{try{const ee=await i.mutateAsync({first_name:M.first_name.trim(),last_name:M.last_name.trim()||null,email:M.email.trim()||null,phone:M.phone.trim()||null});ee&&(q(Q=>({...Q,contact_id:ee.id})),_(`${ee.first_name} ${ee.last_name||""}`.trim()),S(!1))}catch{}},children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-3.5 w-3.5 mr-1 animate-spin"})," Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Tl,{className:"h-3.5 w-3.5 mr-1"})," Add & Link Contact"]})})]})]}),I.length>0&&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"}),"Link to Listing Exchange"]}),e.jsxs(Zs,{value:O.listing_id||"none",onValueChange:ee=>{const Q=ee==="none"?"":ee,ie=I.find(re=>re.id===Q);q(ie?re=>{var oe;return{...re,listing_id:Q,deal_type:"seller",property_address:ie.property_address||re.property_address,city:ie.city||re.city,state:ie.state||re.state,expected_price:((oe=ie.price)==null?void 0:oe.toString())||re.expected_price}}:re=>({...re,listing_id:Q}))},children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select a listing to sync status..."})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:"None"}),I.map(ee=>e.jsx(Mt,{value:ee.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:ee.property_address||`${ee.city}, ${ee.state}`}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["$",(ee.price/1e3).toFixed(0),"K"]})]})},ee.id))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Status changes will sync automatically between the deal and listing."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Property Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"col-span-2 space-y-2",children:[e.jsx(ve,{htmlFor:"property_address",children:"Address"}),e.jsx(ze,{id:"property_address",value:O.property_address,onChange:ee=>q(Q=>({...Q,property_address:ee.target.value})),placeholder:"123 Main Street"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:O.city,onChange:ee=>q(Q=>({...Q,city:ee.target.value}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:O.state,onChange:ee=>q(Q=>({...Q,state:ee.target.value})),maxLength:2,placeholder:"TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"zip_code",children:"ZIP"}),e.jsx(ze,{id:"zip_code",value:O.zip_code,onChange:ee=>q(Q=>({...Q,zip_code:ee.target.value}))})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Financial Details"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(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(ze,{id:"expected_price",type:"number",value:O.expected_price,onChange:ee=>q(Q=>({...Q,expected_price:ee.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(ze,{id:"commission_percentage",type:"number",step:"0.1",value:O.commission_percentage,onChange:ee=>q(Q=>({...Q,commission_percentage:ee.target.value})),className:"pr-7"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Expected GCI"}),e.jsx(ze,{value:B()?`$${B().toLocaleString()}`:"-",disabled:!0,className:"bg-muted"})]})]}),e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"text-xs font-medium text-muted-foreground cursor-pointer hover:text-foreground flex items-center gap-1 py-1",children:[e.jsx("span",{className:"group-open:rotate-90 transition-transform text-[10px]",children:"▶"}),"Commission Splits (optional)"]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/50",children:[e.jsx(ve,{className:"text-xs whitespace-nowrap",children:"Calculation Method:"}),e.jsxs(Zs,{value:O.commission_calc_method,onValueChange:ee=>q(Q=>({...Q,commission_calc_method:ee})),children:[e.jsx(Ws,{className:"h-7 text-xs",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"standard",children:"Standard (all splits on GCI)"}),e.jsx(Mt,{value:"referral_first",children:"Referral First (brokerage split after referral)"})]})]})]}),O.commission_calc_method==="referral_first"&&e.jsx("p",{className:"text-[10px] text-muted-foreground bg-blue-50 dark:bg-blue-950/30 p-2 rounded",children:"💡 Referral fee is deducted from GCI first, then the brokerage split is applied to the remaining amount."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Brokerage Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:O.brokerage_split_pct,onChange:ee=>q(Q=>({...Q,brokerage_split_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"30"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"% that goes to brokerage"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Team Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:O.team_split_pct,onChange:ee=>q(Q=>({...Q,team_split_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"% that goes to team lead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Referral Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:O.referral_fee_pct,onChange:ee=>q(Q=>({...Q,referral_fee_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Franchise Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:O.franchise_fee_pct,onChange:ee=>q(Q=>({...Q,franchise_fee_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(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(ze,{type:"number",step:"1",min:"0",value:O.transaction_fee,onChange:ee=>q(Q=>({...Q,transaction_fee:ee.target.value})),className:"pl-7 h-8 text-sm",placeholder:"500"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Flat fee deducted"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Net to Agent"}),e.jsx(ze,{value:V()?`$${Math.round(V()).toLocaleString()}`:"-",disabled:!0,className:"bg-muted h-8 text-sm font-semibold"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Dates & Status"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Target Close Date"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!O.target_close_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),O.target_close_date?ms(O.target_close_date,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:O.target_close_date,onSelect:ee=>q(Q=>({...Q,target_close_date:ee})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Contract Date"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!O.contract_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),O.contract_date?ms(O.contract_date,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:O.contract_date,onSelect:ee=>q(Q=>({...Q,contract_date:ee})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),(O.deal_type==="seller"||O.deal_type==="dual")&&!O.listing_id&&e.jsxs("div",{className:"space-y-2 col-span-2",children:[e.jsx(ve,{children:"Listing Date (for Days on Market)"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!O.listing_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),O.listing_date?ms(O.listing_date,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:O.listing_date,onSelect:ee=>q(Q=>({...Q,listing_date:ee})),initialFocus:!0,className:"pointer-events-auto"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used to calculate Days on Market. Auto-filled for linked listings."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Priority"}),e.jsxs(Zs,{value:O.priority,onValueChange:ee=>q(Q=>({...Q,priority:ee})),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:qjs.map(ee=>e.jsx(Mt,{value:ee.value,children:ee.label},ee.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Win Probability"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",min:"0",max:"100",value:O.probability,onChange:ee=>q(Q=>({...Q,probability:ee.target.value})),className:"pr-7"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"notes",children:"Notes"}),e.jsx(Er,{id:"notes",value:O.notes,onChange:ee=>q(Q=>({...Q,notes:ee.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!r&&e.jsx(Bjs,{formData:f,onChange:g}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:X,children:[X&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Deal":"Create Deal"]})]})]})]})})}function Vjs({dealId:t}){const s=ci(),r=Qt(),[n,a]=N.useState(""),[o,l]=N.useState(!1),{data:i=[]}=mt({queryKey:["deal-tags",t],queryFn:async()=>{const{data:_,error:j}=await H.from("deal_tags").select("*").eq("deal_id",t).order("created_at");if(j)throw j;return _},enabled:!!t}),{data:c=[]}=mt({queryKey:["all-deal-tags",s],queryFn:async()=>{if(!s)return[];const{data:_,error:j}=await H.from("deal_tags").select("tag").eq("owner_user_id",s);if(j)throw j;return[...new Set(_.map(k=>k.tag))].sort()},enabled:!!s}),u=Dt({mutationFn:async _=>{if(!s)throw new Error("Not authenticated");const{error:j}=await H.from("deal_tags").insert({deal_id:t,owner_user_id:s,tag:_.trim()});if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]}),r.invalidateQueries({queryKey:["all-deal-tags"]}),a("")}}),p=Dt({mutationFn:async _=>{const{error:j}=await H.from("deal_tags").delete().eq("id",_);if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]})}}),f=()=>{const _=n.trim();_&&(i.some(j=>j.tag.toLowerCase()===_.toLowerCase())||u.mutate(_))},g=i.map(_=>_.tag.toLowerCase()),b=c.filter(_=>_.toLowerCase().includes(n.toLowerCase())&&!g.includes(_.toLowerCase())).slice(0,5);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[i.map(_=>e.jsxs(tt,{variant:"secondary",className:"gap-1 text-xs",children:[_.tag,e.jsx("button",{type:"button",onClick:()=>p.mutate(_.id),className:"ml-0.5 hover:text-destructive",children:e.jsx(Rr,{className:"h-3 w-3"})})]},_.id)),!o&&e.jsxs("button",{type:"button",onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground px-2 py-0.5 rounded border border-dashed border-border hover:border-primary transition-colors",children:[e.jsx($s,{className:"h-3 w-3"})," Add tag"]})]}),o&&e.jsxs("div",{className:"relative",children:[e.jsx(ze,{value:n,onChange:_=>a(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),f()),_.key==="Escape"&&(l(!1),a(""))},placeholder:"Type tag and press Enter...",className:"h-7 text-xs",autoFocus:!0,onBlur:()=>{n.trim()||l(!1)}}),n&&b.length>0&&e.jsx("div",{className:"absolute z-10 w-full mt-1 bg-background border rounded shadow-lg max-h-32 overflow-y-auto",children:b.map(_=>e.jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-left text-xs hover:bg-muted",onMouseDown:j=>{j.preventDefault(),u.mutate(_)},children:_},_))})]})]})}function Hjs(t){return mt({queryKey:["deal-files",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_files").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Wjs(){const t=ci(),s=Qt();return Dt({mutationFn:async({dealId:r,file:n})=>{if(!t)throw new Error("Not authenticated");const a=n.name.split(".").pop(),o=`${t}/${r}/${crypto.randomUUID()}.${a}`,{error:l}=await H.storage.from("deal-files").upload(o,n);if(l)throw l;const{data:i,error:c}=await H.from("deal_files").insert({deal_id:r,owner_user_id:t,file_name:n.name,file_size:n.size,file_type:n.type||null,storage_path:o}).select().single();if(c)throw c;return i},onSuccess:(r,n)=>{s.invalidateQueries({queryKey:["deal-files",n.dealId]})}})}function Gjs(){const t=Qt();return Dt({mutationFn:async({fileId:s,storagePath:r,dealId:n})=>{await H.storage.from("deal-files").remove([r]);const{error:a}=await H.from("deal_files").delete().eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}function Kjs(){const t=Qt();return Dt({mutationFn:async({fileId:s,visible:r,dealId:n})=>{const{error:a}=await H.from("deal_files").update({visible_on_portal:r}).eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}async function Zjs(t){const{data:s,error:r}=await H.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;return s.signedUrl}const uze={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function Yjs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=l_s(),a=c_s(),o=d_s(),l=u_s(),[i,c]=N.useState(!1),[u,p]=N.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[f,g]=N.useState(""),b=async()=>{if(u.question_text.trim())try{await a.mutateAsync({question_text:u.question_text.trim(),field_type:u.field_type,options:u.field_type==="dropdown"?u.options:[],is_required:u.is_required,sort_order:((r==null?void 0:r.length)||0)+1}),p({question_text:"",field_type:"text",options:[],is_required:!1}),g(""),c(!1),me.success("Question added")}catch{me.error("Failed to add question")}},_=async S=>{try{await l.mutateAsync(S),me.success("Question removed")}catch{me.error("Failed to remove question")}},j=async(S,M)=>{try{await o.mutateAsync({id:S,is_required:M})}catch{me.error("Failed to update question")}},w=()=>{f.trim()&&(p(S=>({...S,options:[...S.options,f.trim()]})),g(""))},k=S=>{p(M=>({...M,options:M.options.filter((L,I)=>I!==S)}))};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md max-h-[85vh] flex flex-col",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Custom Intake Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These questions appear on all your portal onboarding forms."})]}),e.jsx(Gi,{className:"flex-1",children:e.jsxs("div",{className:"space-y-3 pr-2",children:[n&&e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),r==null?void 0:r.map(S=>{var M;return e.jsx("div",{className:"border rounded-lg p-3 space-y-2",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:S.question_text}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(tt,{variant:"secondary",className:"text-xs",children:uze[S.field_type]||S.field_type}),S.is_required&&e.jsx(tt,{variant:"outline",className:"text-xs",children:"Required"})]}),S.field_type==="dropdown"&&((M=S.options)==null?void 0:M.length)>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Options: ",S.options.join(", ")]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(qr,{checked:S.is_required,onCheckedChange:L=>j(S.id,L),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>_(S.id),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})},S.id)}),!n&&(r==null?void 0:r.length)===0&&!i&&e.jsxs("div",{className:"text-center py-8 border border-dashed rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"No custom questions yet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add questions that clients will answer during onboarding."})]}),i&&e.jsxs("div",{className:"border-2 border-primary/20 rounded-lg p-4 space-y-3 bg-primary/5",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Question"}),e.jsx(ze,{value:u.question_text,onChange:S=>p(M=>({...M,question_text:S.target.value})),className:"mt-1",placeholder:"e.g., Do you have a home to sell first?",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(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(uze).map(([S,M])=>e.jsx("button",{type:"button",onClick:()=>p(L=>({...L,field_type:S,options:[]})),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${u.field_type===S?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:M},S))})]}),u.field_type==="dropdown"&&e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Options"}),e.jsxs("div",{className:"space-y-1.5 mt-1.5",children:[u.options.map((S,M)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex-1 text-sm bg-muted/50 rounded px-2 py-1",children:S}),e.jsx("button",{onClick:()=>k(M),className:"text-muted-foreground hover:text-destructive",children:e.jsx(Rr,{className:"h-3.5 w-3.5"})})]},M)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:f,onChange:S=>g(S.target.value),onKeyDown:S=>S.key==="Enter"&&(S.preventDefault(),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($s,{className:"h-3 w-3"})})]})]})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:u.is_required,onCheckedChange:S=>p(M=>({...M,is_required:S}))}),e.jsx(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:()=>c(!1),className:"flex-1",children:"Cancel"}),e.jsxs(K,{size:"sm",onClick:b,disabled:!u.question_text.trim()||a.isPending,className:"flex-1",children:[a.isPending?e.jsx(ws,{className:"h-3 w-3 mr-1 animate-spin"}):null,"Add Question"]})]})]})]})}),e.jsxs("div",{className:"flex justify-between pt-4 border-t shrink-0",children:[i?e.jsx("div",{}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>c(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Add Question"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Done"})]})]})})}function Xjs({portalId:t,ownerId:s,clientEmail:r,linkedPortalId:n,onLink:a}){const[o,l]=N.useState(""),[i,c]=N.useState(!1),{data:u,isLoading:p}=mt({queryKey:["all-owner-portals",s],queryFn:async()=>{const{data:_,error:j}=await H.from("client_portals").select(` id, slug, client_name, client_email, deal_id, archived_at, deal_pipeline (id, deal_name, deal_type, property_address) `).eq("owner_user_id",s).neq("id",t).is("archived_at",null).eq("is_enabled",!0);if(j)throw j;return _},enabled:i||!!n}),f=N.useMemo(()=>!n||!u?null:u.find(_=>_.id===n),[n,u]),g=N.useMemo(()=>!u||!r?[]:u.filter(_=>{var j;return((j=_.client_email)==null?void 0:j.toLowerCase())===r.toLowerCase()&&_.id!==t}),[u,r,t]),b=N.useMemo(()=>{if(!u||!o.trim())return[];const _=o.toLowerCase();return u.filter(j=>{var k,S,M,L;const w=j.deal_pipeline;return((k=j.client_name)==null?void 0:k.toLowerCase().includes(_))||((S=j.client_email)==null?void 0:S.toLowerCase().includes(_))||((M=w==null?void 0:w.deal_name)==null?void 0:M.toLowerCase().includes(_))||((L=w==null?void 0:w.property_address)==null?void 0:L.toLowerCase().includes(_))})},[u,o]);if(n){const _=f==null?void 0:f.deal_pipeline;return e.jsxs("div",{className:"space-y-2",children:[e.jsx(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(dl,{className:"h-4 w-4 text-primary shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:(f==null?void 0:f.client_name)||(_==null?void 0:_.deal_name)||"Linked Portal"}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[(_==null?void 0:_.deal_type)==="listing"?"🏠 Listing":"🔑 Purchase"," · ",(_==null?void 0:_.property_address)||"No address"]})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive shrink-0",onClick:()=>a(null),children:[e.jsx(xS,{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:()=>c(!i),children:[e.jsx(dl,{className:"h-3 w-3 mr-1"}),i?"Cancel":"Link"]})]}),!i&&g.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground font-medium",children:"✨ Suggested match (same client email)"}),g.map(_=>{const j=_.deal_pipeline;return e.jsxs("button",{onClick:()=>a(_.id),className:"w-full flex items-center gap-2 bg-amber-50 border border-amber-200 rounded-lg p-2.5 hover:bg-amber-100 transition-colors text-left",children:[e.jsx(tt,{variant:"outline",className:"text-[10px] shrink-0 bg-amber-100 border-amber-300 text-amber-700",children:(j==null?void 0:j.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(j==null?void 0:j.deal_name)||_.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:j==null?void 0:j.property_address})]}),e.jsx(dl,{className:"h-3.5 w-3.5 text-amber-600 shrink-0"})]},_.id)})]}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{value:o,onChange:_=>l(_.target.value),placeholder:"Search by name, email, or address...",className:"pl-8 h-8 text-xs",autoFocus:!0})]}),p&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),b.length>0&&e.jsx("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:b.map(_=>{const j=_.deal_pipeline;return e.jsxs("button",{onClick:()=>{a(_.id),c(!1),l("")},className:"w-full flex items-center gap-2 border rounded-lg p-2 hover:bg-muted/50 transition-colors text-left",children:[e.jsx(tt,{variant:"outline",className:"text-[10px] shrink-0",children:(j==null?void 0:j.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(j==null?void 0:j.deal_name)||_.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:_.client_email})]})]},_.id)})}),o&&b.length===0&&!p&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No portals found"})]})]})}function oCe({userId:t,onSelect:s,triggerLabel:r="Library",triggerSize:n="sm",triggerVariant:a="outline",triggerClassName:o}){const[l,i]=N.useState(!1),[c,u]=N.useState([]),[p,f]=N.useState(!1),[g,b]=N.useState("");N.useEffect(()=>{!l||!t||(f(!0),H.from("agent_videos").select("id, title, recipient_name, playback_url, thumbnail_url, created_at, duration_seconds").eq("owner_user_id",t).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1}).limit(50).then(({data:j})=>{u(j||[]),f(!1)}))},[l,t]);const _=c.filter(j=>!g||(j.title||j.recipient_name||"").toLowerCase().includes(g.toLowerCase()));return e.jsxs(fs,{open:l,onOpenChange:i,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:a,size:n,className:o||"gap-1.5 shrink-0",children:[e.jsx(gu,{className:"h-3.5 w-3.5"}),r]})}),e.jsxs(ps,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[e.jsxs(_s,{children:[e.jsx(vs,{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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search videos...",value:g,onChange:j=>b(j.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-2 min-h-0",children:p?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-16 w-full"}),e.jsx(ys,{className:"h-16 w-full"})]}):_.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:c.length===0?"No videos in your library yet":"No videos match your search"}):_.map(j=>e.jsxs("button",{onClick:()=>{s(j.playback_url||""),i(!1)},className:"w-full flex items-center gap-3 p-3 rounded-lg border border-border hover:border-primary/50 hover:bg-accent/50 transition-colors text-left",children:[e.jsx("div",{className:"w-16 h-10 rounded bg-muted flex items-center justify-center shrink-0 overflow-hidden",children:j.thumbnail_url?e.jsx("img",{src:j.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:w=>{const k=w.currentTarget.parentElement;if(k){w.currentTarget.remove();const S=document.createElement("span");S.innerHTML="🎬",S.className="text-lg",k.appendChild(S)}}}):e.jsx(An,{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 lCe({contactId:t,onVideoReady:s}){const[r,n]=N.useState(!1),[a,o]=N.useState("record"),[l,i]=N.useState(0),[c,u]=N.useState(0),p=SC(),f=()=>{o("record"),i(0),u(0)},g=_=>{!_&&(a==="uploading"||a==="processing")||(n(_),_||f())},b=N.useCallback(async(_,j)=>{o("uploading");try{const w="Card Video",{videoId:k,libraryId:S}=await pR(w),{uploadUrl:M,apiKey:L}=await fR(k),I=new XMLHttpRequest;I.upload.onprogress=X=>{X.lengthComputable&&i(X.loaded/X.total*100)},await new Promise((X,ee)=>{I.onload=()=>I.status>=200&&I.status<300?X():ee(new Error("Upload failed")),I.onerror=()=>ee(new Error("Upload failed")),I.open("PUT",M),I.setRequestHeader("AccessKey",L),I.send(_)}),o("processing");let O=0;const q=Date.now(),U=9e4,B=`https://iframe.mediadelivery.net/embed/${S}/${k}`;for(;O<4;){if(await new Promise(ee=>setTimeout(ee,3e3)),Date.now()-q>U){const ee=_.size/1048576;await p.mutateAsync({bunny_video_id:k,playback_url:`https://iframe.mediadelivery.net/play/${S}/${k}`,file_size_mb:ee,title:w,contact_id:t||void 0,status:"processing",touch_type:"video"}),s(B),me.success("Video saved — still encoding. It will be ready shortly."),o("done"),setTimeout(()=>{n(!1),f()},1500);return}const X=await _A(k);if(O=X.status,u(X.encodeProgress||0),O===5||O===6)throw new Error("Video processing failed")}const V=await _A(k),Z=(V.storageSize||_.size)/(1024*1024);await p.mutateAsync({bunny_video_id:k,contact_id:t||void 0,playback_url:V.directPlayUrl||B,thumbnail_url:V.thumbnailUrl,preview_url:V.previewUrl||null,duration_seconds:V.length||j,file_size_mb:Z,title:w,status:"ready",touch_type:"video"}),s(B),me.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),f()},1500)}catch(w){console.error("Recording upload error:",w),me.error("Failed to process video. Please try again."),o("record")}},[t,s,p]);return e.jsxs(fs,{open:r,onOpenChange:g,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 w-full",children:[e.jsx(An,{className:"h-3.5 w-3.5"}),"Record Video"]})}),e.jsxs(ps,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Record a Video for Your Card"})}),a==="record"&&e.jsx(gme,{maxDurationSeconds:60,onRecordingComplete:b,onError:_=>me.error(_)}),a==="uploading"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(ws,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Uploading video..."}),e.jsx(Bi,{value:l,className:"w-64"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(l),"%"]})]}),a==="processing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(ws,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Processing video..."}),e.jsx(Bi,{value:c,className:"w-64"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(c),"%"]})]}),a==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[e.jsx(xi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}const Qjs=t=>`portal-settings-draft:${t}`;function dlt({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=xR(),[o,l]=N.useState(!1),i=N.useMemo(()=>Qjs(r.id),[r.id]),[c,u]=N.useState(!1),[p,f]=N.useState(r.next_step_text||""),[g,b]=N.useState(r.next_step_video_url||""),[_,j]=N.useState(r.inspection_date||""),[w,k]=N.useState(r.appraisal_date||""),[S,M]=N.useState(r.welcome_message||""),[L,I]=N.useState(r.review_url||""),[O,q]=N.useState(r.show_post_close_tips),[U,B]=N.useState(r.notify_client),[V,Z]=N.useState(r.require_onboarding),[X,ee]=N.useState(r.allow_spouse),[Q,ie]=N.useState(r.visibility),[re,oe]=N.useState(r.stage_mapping||[]),[ce,xe]=N.useState(null),[ge,ue]=N.useState(r.linked_portal_id||null),pe=()=>{f(r.next_step_text||""),b(r.next_step_video_url||""),j(r.inspection_date||""),k(r.appraisal_date||""),M(r.welcome_message||""),I(r.review_url||""),q(r.show_post_close_tips),B(r.notify_client),Z(r.require_onboarding),ee(r.allow_spouse),ie(r.visibility),oe(r.stage_mapping||[]),ue(r.linked_portal_id||null)};N.useEffect(()=>{u(!1);const ke=localStorage.getItem(i);if(ke)try{const Be=JSON.parse(ke);f(Be.nextStepText||""),b(Be.nextStepVideo||""),j(Be.inspectionDate||""),k(Be.appraisalDate||""),M(Be.welcomeMessage||""),I(Be.reviewUrl||""),q(!!Be.showPostClose),B(!!Be.notifyClient),Z(!!Be.requireOnboarding),ee(!!Be.allowSpouse),ie(Be.visibility||r.visibility),oe(Be.stageMapping||[]),ue(Be.linkedPortalId??null),u(!0);return}catch{localStorage.removeItem(i)}pe(),u(!0)},[i,r]),N.useEffect(()=>{if(!c)return;const ke={nextStepText:p,nextStepVideo:g,inspectionDate:_,appraisalDate:w,welcomeMessage:S,reviewUrl:L,showPostClose:O,notifyClient:U,requireOnboarding:V,allowSpouse:X,visibility:Q,stageMapping:re,linkedPortalId:ge};p!==(r.next_step_text||"")||g!==(r.next_step_video_url||"")||_!==(r.inspection_date||"")||w!==(r.appraisal_date||"")||S!==(r.welcome_message||"")||L!==(r.review_url||"")||O!==r.show_post_close_tips||U!==r.notify_client||V!==r.require_onboarding||X!==r.allow_spouse||Q!==r.visibility||JSON.stringify(re)!==JSON.stringify(r.stage_mapping||[])||ge!==(r.linked_portal_id||null)?localStorage.setItem(i,JSON.stringify(ke)):localStorage.removeItem(i)},[p,g,_,w,S,L,O,U,V,X,Q,re,ge,i,c,r]);const be=()=>{localStorage.removeItem(i),pe()},Me=async()=>{try{await a.mutateAsync({id:r.id,next_step_text:p||null,next_step_video_url:g||null,inspection_date:_||null,appraisal_date:w||null,welcome_message:S||null,review_url:L||null,show_post_close_tips:O,notify_client:U,require_onboarding:V,allow_spouse:X,visibility:Q,stage_mapping:re.length>0?re:null,linked_portal_id:ge});const ke=r.linked_portal_id;ge&&ge!==ke&&await H.from("client_portals").update({linked_portal_id:r.id}).eq("id",ge),!ge&&ke&&await H.from("client_portals").update({linked_portal_id:null}).eq("id",ke),localStorage.removeItem(i),me.success("Portal settings saved"),s(!1)}catch{me.error("Failed to save settings")}},Ne=()=>{oe([...re,{label:""}])},Pe=ke=>{oe(re.filter((Be,nt)=>nt!==ke)),ce===ke&&xe(null)},Oe=(ke,Be,nt)=>{const Ae=[...re];Ae[ke]={...Ae[ke],[Be]:nt},oe(Ae)},Te=()=>{const Be=tNe(null).map(nt=>({label:nt.label,description:nt.description,stageId:void 0}));oe(Be)};return e.jsxs(e.Fragment,{children:[e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-lg max-h-[85vh] flex flex-col",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Portal Settings"})}),e.jsxs(ba,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(pa,{className:"grid grid-cols-3 shrink-0",children:[e.jsx(ns,{value:"general",children:"General"}),e.jsx(ns,{value:"timeline",children:"Timeline"}),e.jsx(ns,{value:"content",children:"Content"})]}),e.jsxs(Gi,{className:"flex-1 mt-4",children:[e.jsxs(bs,{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(ke=>e.jsx("button",{onClick:()=>ie(ke),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${Q===ke?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:ke.charAt(0).toUpperCase()+ke.slice(1)},ke))})]}),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(qr,{checked:V,onCheckedChange:Z})]}),V&&e.jsxs("div",{className:"flex items-center justify-between pl-4 border-l-2 border-primary/20",children:[e.jsxs("div",{children:[e.jsx(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(qr,{checked:X,onCheckedChange:ee})]}),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(qr,{checked:O,onCheckedChange:q})]}),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(qr,{checked:U,onCheckedChange:B})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(Xjs,{portalId:r.id,ownerId:n,clientEmail:r.client_email,linkedPortalId:ge,onLink:ue})}),e.jsx("div",{children:e.jsx(ze,{type:"date",value:_,onChange:ke=>j(ke.target.value),className:"mt-1"})}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Appraisal Date"}),e.jsx(ze,{type:"date",value:w,onChange:ke=>k(ke.target.value),className:"mt-1"})]})]}),e.jsx(bs,{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:Te,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.'}),re.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:Te,children:"Customize journey labels"})]}),e.jsx("div",{className:"space-y-2 mt-2",children:re.map((ke,Be)=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(ze,{value:ke.label,onChange:nt=>Oe(Be,"label",nt.target.value),placeholder:`Stage ${Be+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:()=>xe(ce===Be?null:Be),children:ce===Be?"Less":"More"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>Pe(Be),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]}),ce===Be&&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:ke.description||"",onChange:nt=>Oe(Be,"description",nt.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"}),ke.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:ke.video_url.length>40?ke.video_url.slice(0,40)+"...":ke.video_url}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>Oe(Be,"video_url",""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(lCe,{onVideoReady:nt=>Oe(Be,"video_url",nt)}),e.jsx(oCe,{userId:n,onSelect:nt=>Oe(Be,"video_url",nt),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 nt=prompt("Paste a YouTube or Loom URL:");nt&&Oe(Be,"video_url",nt)},children:[e.jsx(Bo,{className:"h-3 w-3"}),"Paste URL"]})]})]})]})]},Be))}),re.length>0&&e.jsxs(K,{variant:"outline",size:"sm",onClick:Ne,className:"mt-2 text-xs w-full",children:[e.jsx($s,{className:"h-3 w-3 mr-1"})," Add Stage"]})]})}),e.jsxs(bs,{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:S,onChange:ke=>M(ke.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:p,onChange:ke=>f(ke.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(ze,{value:g,onChange:ke=>b(ke.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(ze,{value:L,onChange:ke=>I(ke.target.value),className:"mt-1",placeholder:"https://g.page/r/..."})]})]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2 pt-4 border-t shrink-0",children:[e.jsx(K,{variant:"ghost",onClick:be,children:"Reset Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(K,{onClick:Me,disabled:a.isPending,children:[a.isPending?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(qc,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})]})}),e.jsx(Yjs,{open:o,onOpenChange:l})]})}const Jjs=t=>`portal-update-draft:${t}`;function ult({open:t,onOpenChange:s,portalId:r,portalSlug:n,notifyClient:a}){const o=N.useMemo(()=>Jjs(r),[r]),[l,i]=N.useState(""),[c,u]=N.useState(""),[p,f]=N.useState(""),[g,b]=N.useState(!1),[_,j]=N.useState(a??!1),[w,k]=N.useState(!1),S=Vat();N.useEffect(()=>{k(!1);const I=localStorage.getItem(o);if(I)try{const O=JSON.parse(I);i(O.title||""),u(O.content||""),f(O.videoUrl||""),b(!!O.isStageChange),j(typeof O.sendNotification=="boolean"?O.sendNotification:a??!1),k(!0);return}catch{localStorage.removeItem(o)}i(""),u(""),f(""),b(!1),j(a??!1),k(!0)},[o,a]),N.useEffect(()=>{if(!w)return;const I={title:l,content:c,videoUrl:p,isStageChange:g,sendNotification:_};l.trim()||c.trim()||p.trim()||g||_!==(a??!1)?localStorage.setItem(o,JSON.stringify(I)):localStorage.removeItem(o)},[l,c,p,g,_,w,o,a]);const M=()=>{localStorage.removeItem(o),i(""),u(""),f(""),b(!1),j(a??!1)},L=async()=>{if(l.trim())try{if(await S.mutateAsync({portal_id:r,title:l.trim(),content:c.trim()||void 0,video_url:p.trim()||void 0,is_stage_change:g}),_&&n)try{const I=b1(n);await H.functions.invoke("send-portal-notification",{body:{portal_id:r,update_title:l.trim(),update_content:c.trim()||null,portal_url:I}}),me.success("Update posted & client notified")}catch(I){console.error("Notification failed:",I),me.success("Update posted (notification failed to send)")}else me.success("Update posted to portal");M(),s(!1)}catch{me.error("Failed to post update")}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{value:l,onChange:I=>i(I.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:c,onChange:I=>u(I.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(ze,{value:p,onChange:I=>f(I.target.value),className:"pl-9",placeholder:"YouTube or Loom link"}),e.jsx(An,{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:()=>b(!g),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${g?"bg-emerald-500/10 text-emerald-700 border-emerald-200":"bg-background text-muted-foreground border-input"}`,children:"📊 Stage Change"}),e.jsxs("button",{type:"button",onClick:()=>j(!_),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors flex items-center gap-1.5 ${_?"bg-blue-500/10 text-blue-700 border-blue-200":"bg-background text-muted-foreground border-input"}`,children:[_?e.jsx(Lm,{className:"h-3 w-3"}):e.jsx(t1,{className:"h-3 w-3"}),_?"Notify Client":"No Notification"]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",onClick:M,children:"Clear Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(K,{onClick:L,disabled:!l.trim()||S.isPending,children:[S.isPending?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})]})})}function hlt({open:t,onOpenChange:s,portal:r,dealName:n}){const a=xR(),{isGmailConnected:o,gmailEmail:l}=Wx(),[i,c]=N.useState(r.client_name||""),[u,p]=N.useState(r.client_email||""),[f,g]=N.useState(!1),[b,_]=N.useState(!1),j=b1(r.slug),w=i.split(" ")[0]||"there",k=`Your Transaction Portal – ${n}`,S=`Hi ${w}, I've set up a dedicated portal where you can track the progress of your transaction in real-time. Here's your link: ${j} You can view your timeline, key dates, documents, and any updates I post along the way. Let me know if you have any questions!`,M=()=>{navigator.clipboard.writeText(j),_(!0),setTimeout(()=>_(!1),2e3),me.success("Portal link copied!")},L=async()=>{if(!u.trim()){me.error("Please enter the client email");return}g(!0);try{await a.mutateAsync({id:r.id,client_name:i||null,client_email:u||null,invite_sent_at:new Date().toISOString(),invite_method:"email"});const{error:O}=await H.functions.invoke("gmail-send",{body:{to:u,subject:k,body:S.replace(/\n/g,"
")}});if(O)throw O;me.success(`Invite sent to ${u}`),s(!1)}catch(O){me.error(O.message||"Failed to send invite")}finally{g(!1)}},I=()=>{const O=encodeURIComponent(k),q=encodeURIComponent(S);window.open(`mailto:${u}?subject=${O}&body=${q}`,"_blank"),a.mutateAsync({id:r.id,client_name:i||null,client_email:u||null,invite_sent_at:new Date().toISOString(),invite_method:"email"}).catch(()=>{})};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{value:i,onChange:O=>c(O.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(ze,{type:"email",value:u,onChange:O=>p(O.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:M,className:"shrink-0",children:b?e.jsx(va,{className:"h-4 w-4 text-emerald-600"}):e.jsx(gi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[o?e.jsxs(K,{onClick:L,disabled:f||!u.trim(),className:"w-full",children:[f?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Send via Gmail (",l,")"]}):e.jsxs(K,{onClick:I,disabled:!u.trim(),className:"w-full",variant:"outline",children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),e.jsxs(K,{variant:"ghost",onClick:M,className:"w-full text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function eNs({deal:t}){const{isAdmin:s,user:r}=Ds(),{data:n,isLoading:a}=n_s(t.id),o=lSe(),l=xR(),[i,c]=N.useState(!1),[u,p]=N.useState(!1),[f,g]=N.useState(!1),[b,_]=N.useState(!1),j=`portal-management-ui:${t.id}`;if(N.useEffect(()=>{const O=sessionStorage.getItem(j);if(O)try{const q=JSON.parse(O);p(!!q.settingsOpen),g(!!q.composerOpen),_(!!q.inviteOpen)}catch{sessionStorage.removeItem(j)}},[j]),N.useEffect(()=>{u||f||b?sessionStorage.setItem(j,JSON.stringify({settingsOpen:u,composerOpen:f,inviteOpen:b})):sessionStorage.removeItem(j)},[u,f,b,j]),a)return e.jsx("div",{className:"border rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(ws,{className:"h-3 w-3 animate-spin ml-auto"})]})});const w=async()=>{var O,q;c(!0);try{await o.mutateAsync({deal_id:t.id,visibility:"private",require_onboarding:!0,client_name:t.contact?`${t.contact.first_name} ${t.contact.last_name}`:void 0,client_email:((O=t.contact)==null?void 0:O.email)||void 0,client_phone:((q=t.contact)==null?void 0:q.phone)||void 0}),me.success("Client portal enabled!")}catch{me.error("Failed to create portal")}finally{c(!1)}},k=async O=>{if(n)try{await l.mutateAsync({id:n.id,is_enabled:O}),me.success(O?"Portal enabled":"Portal disabled")}catch{me.error("Failed to update portal")}},S=()=>{if(!n)return;const O=b1(n.slug);navigator.clipboard.writeText(O),me.success("Portal link copied!")},M=()=>{if(!n)return;const O=b1(n.slug);window.open(O,"_blank")};if(!n)return e.jsxs("div",{className:"border rounded-lg p-4 border-dashed",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pn,{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:w,disabled:i,size:"sm",className:"w-full",children:[i?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(pn,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const L=b1(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(pn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(tt,{variant:"outline",className:n.is_enabled?"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-xs bg-muted text-muted-foreground",children:n.is_enabled?"Active":"Disabled"})]}),e.jsx(qr,{checked:n.is_enabled,onCheckedChange:k})]}),e.jsxs("div",{className:"space-y-1.5 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Visibility:"}),e.jsx(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:n.visibility==="private"?"Private":"Public"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Onboarding:"}),e.jsx("span",{className:"text-foreground",children:n.require_onboarding?"Required":"Disabled"})]}),n.client_name&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Client:"}),e.jsx("span",{className:"text-foreground",children:n.client_name})]})]}),e.jsx("div",{className:"bg-muted/50 rounded-md p-2 mb-3",children:e.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:L})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:S,className:"text-xs flex-1 min-w-0",children:[e.jsx(gi,{className:"h-3 w-3 mr-1 shrink-0"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:M,className:"text-xs flex-1 min-w-0",children:[e.jsx(tn,{className:"h-3 w-3 mr-1 shrink-0"}),"Preview"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>_(!0),className:"text-xs flex-1 min-w-0",children:[e.jsx(Bn,{className:"h-3 w-3 mr-1 shrink-0"}),"Invite"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>g(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(FM,{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(Xo,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]})]}),e.jsx(dlt,{open:u,onOpenChange:p,portal:n,dealOwnerId:I}),e.jsx(ult,{open:f,onOpenChange:g,portalId:n.id,portalSlug:n.slug,notifyClient:n.notify_client}),e.jsx(hlt,{open:b,onOpenChange:_,portal:n,dealName:t.deal_name})]})}const tNs=["Client","Co-Buyer","Co-Seller","Spouse","Lender","Title Company","Inspector","Appraiser","Attorney","Contractor","Other"];function sNs(t){return mt({queryKey:["deal-contacts",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_contacts").select(` id, deal_id, contact_id, role, created_at, contact:innercircle_contacts(id, first_name, last_name, email, phone) `).eq("deal_id",t).order("created_at");if(r)throw r;return s||[]},enabled:!!t})}function rNs(){const t=Qt();return Dt({mutationFn:async({dealId:s,contactId:r,role:n})=>{const{data:a,error:o}=await H.from("deal_contacts").insert({deal_id:s,contact_id:r,role:n}).select().single();if(o)throw o;return a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-contacts",r.dealId]}),me.success("Contact linked to deal")},onError:s=>{var r;(r=s.message)!=null&&r.includes("duplicate")?me.error("This contact is already linked to this deal"):me.error("Failed to link contact")}})}function nNs(){const t=Qt();return Dt({mutationFn:async({id:s,dealId:r})=>{const{error:n}=await H.from("deal_contacts").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-contacts",r.dealId]}),me.success("Contact removed from deal")},onError:()=>{me.error("Failed to remove contact")}})}function aNs({dealId:t,primaryContactId:s}){const r=fr(),{data:n,isLoading:a}=sNs(t),{data:o}=Gm(),l=rNs(),i=nNs(),[c,u]=N.useState(!1),[p,f]=N.useState(""),[g,b]=N.useState("Client"),_=new Set((n==null?void 0:n.map(M=>M.contact_id))||[]);s&&_.add(s);const j=o==null?void 0:o.filter(M=>{var I,O,q;if(_.has(M.id))return!1;if(!p.trim())return!0;const L=p.toLowerCase();return((I=M.first_name)==null?void 0:I.toLowerCase().includes(L))||((O=M.last_name)==null?void 0:O.toLowerCase().includes(L))||((q=M.email)==null?void 0:q.toLowerCase().includes(L))}).slice(0,8),w=M=>{l.mutate({dealId:t,contactId:M,role:g}),u(!1),f("")},k=M=>{i.mutate({id:M,dealId:t})},S={Client:"bg-primary/10 text-primary","Co-Buyer":"bg-blue-500/10 text-blue-600","Co-Seller":"bg-emerald-500/10 text-emerald-600",Spouse:"bg-pink-500/10 text-pink-600",Lender:"bg-amber-500/10 text-amber-600","Title Company":"bg-purple-500/10 text-purple-600",Inspector:"bg-orange-500/10 text-orange-600",Appraiser:"bg-cyan-500/10 text-cyan-600",Attorney:"bg-slate-500/10 text-slate-600",Contractor:"bg-lime-500/10 text-lime-600",Other:"bg-muted text-muted-foreground"};return!(n!=null&&n.length)&&!c?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),"Additional Contacts"]})}),e.jsxs($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"w-full text-muted-foreground",children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1"}),"Link a contact (lender, spouse, vendor...)"]})}),e.jsx(Ro,{className:"w-80 p-3",align:"start",children:e.jsx(hze,{search:p,setSearch:f,selectedRole:g,setSelectedRole:b,filteredContacts:j,onAdd:w})})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),"Linked Contacts",n&&n.length>0&&e.jsx(tt,{variant:"secondary",className:"text-[10px] px-1.5",children:n.length})]}),e.jsxs($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx($s,{className:"h-3.5 w-3.5"})})}),e.jsx(Ro,{className:"w-80 p-3",align:"end",children:e.jsx(hze,{search:p,setSearch:f,selectedRole:g,setSelectedRole:b,filteredContacts:j,onAdd:w})})]})]}),e.jsx("div",{className:"space-y-1.5",children:n==null?void 0:n.map(M=>{var L,I,O,q,U,B,V,Z;return e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/40 group",children:[e.jsx(Nn,{className:"h-7 w-7",children:e.jsxs(kn,{className:"text-[10px] bg-primary/10 text-primary",children:[(I=(L=M.contact)==null?void 0:L.first_name)==null?void 0:I[0],(q=(O=M.contact)==null?void 0:O.last_name)==null?void 0:q[0]]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("button",{onClick:()=>r(`/mission-control/contacts/${M.contact_id}`),className:"text-sm font-medium hover:underline text-primary truncate block",children:[(U=M.contact)==null?void 0:U.first_name," ",(B=M.contact)==null?void 0:B.last_name]})}),e.jsx(tt,{variant:"outline",className:`text-[10px] px-1.5 py-0 shrink-0 ${S[M.role]||S.Other}`,children:M.role}),e.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[((V=M.contact)==null?void 0:V.phone)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`tel:${M.contact.phone}`,children:e.jsx(Un,{className:"h-3 w-3"})})}),((Z=M.contact)==null?void 0:Z.email)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`mailto:${M.contact.email}`,children:e.jsx(cr,{className:"h-3 w-3"})})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>k(M.id),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]},M.id)})})]})}function hze({search:t,setSearch:s,selectedRole:r,setSelectedRole:n,filteredContacts:a,onAdd:o}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs(Zs,{value:r,onValueChange:n,children:[e.jsx(Ws,{className:"h-8 text-sm",children:e.jsx(Xs,{placeholder:"Role"})}),e.jsx(Gs,{children:tNs.map(l=>e.jsx(Mt,{value:l,children:l},l))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{value:t,onChange:l=>s(l.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Gi,{className:"max-h-40",children:a&&a.length>0?e.jsx("div",{className:"space-y-0.5",children:a.map(l=>e.jsxs("button",{onClick:()=>o(l.id),className:"w-full text-left px-2 py-1.5 rounded hover:bg-accent transition-colors",children:[e.jsxs("div",{className:"text-sm font-medium truncate",children:[l.first_name," ",l.last_name]}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[l.phone,l.email].filter(Boolean).join(" · ")||"No contact info"})]},l.id))}):e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:t?"No contacts found":"Type to search"})})]})}const iNs={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"}},oNs={note:so,call:Un,email:cr,meeting:hn,stage_change:tn,task_completed:sa,document:bn,system:un};function lNs({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var Oe,Te;const{data:l,isLoading:i}=Q_s((t==null?void 0:t.id)||""),{data:c,isLoading:u}=ews((t==null?void 0:t.id)||""),p=J_s(),f=sws(),g=tws(),b=X_s(),{data:_,isLoading:j}=Hjs((t==null?void 0:t.id)||""),w=Wjs(),k=Gjs(),S=Kjs(),M=N.useRef(null),[L,I]=N.useState(""),[O,q]=N.useState(""),[U,B]=N.useState(!1),[V,Z]=N.useState(!1);if(!t)return null;const X=iNs[t.deal_type],ee=(()=>{var nt;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const ke=((nt=t.listing)==null?void 0:nt.created_at)||t.listing_date;if(!ke)return null;const Be=t.contract_date?Dl(t.contract_date):new Date;return oy(Be,Dl(ke))})(),Q=ke=>ke?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ke):"-",ie=async()=>{if(L.trim())try{await p.mutateAsync({deal_id:t.id,activity_type:"note",title:"Note added",description:L}),I(""),me.success("Note added")}catch{me.error("Failed to add note")}},re=async()=>{if(O.trim())try{await f.mutateAsync({deal_id:t.id,title:O,sort_order:((c==null?void 0:c.length)||0)+1}),q(""),me.success("Task added")}catch{me.error("Failed to add task")}},oe=async(ke,Be)=>{try{await g.mutateAsync({id:ke,is_completed:Be,deal_id:t.id})}catch{me.error("Failed to update task")}},ce=async()=>{try{await b.mutateAsync(t.id),me.success("Deal deleted"),r(!1)}catch{me.error("Failed to delete deal")}},xe=(c==null?void 0:c.filter(ke=>ke.is_completed).length)||0,ge=(c==null?void 0:c.length)||0,ue=(_==null?void 0:_.length)||0,pe=ke=>ke<1024?`${ke} B`:ke<1024*1024?`${(ke/1024).toFixed(1)} KB`:`${(ke/(1024*1024)).toFixed(1)} MB`,be=ke=>ke?ke.startsWith("image/")?gl:ke.includes("pdf")?Sn:TM:TM,Me=async ke=>{const Be=ke.target.files;if(!(!Be||!t)){Z(!0);try{for(const nt of Array.from(Be)){if(nt.size>20*1024*1024){me.error(`${nt.name} exceeds 20MB limit`);continue}await w.mutateAsync({dealId:t.id,file:nt})}me.success("File(s) uploaded")}catch{me.error("Failed to upload file")}finally{Z(!1),M.current&&(M.current.value="")}}},Ne=async(ke,Be)=>{if(t)try{await k.mutateAsync({fileId:ke,storagePath:Be,dealId:t.id}),me.success("File deleted")}catch{me.error("Failed to delete file")}},Pe=async(ke,Be)=>{try{const nt=await Zjs(ke),Ae=document.createElement("a");Ae.href=nt,Ae.download=Be,Ae.target="_blank",document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae)}catch{me.error("Failed to download file")}};return e.jsxs(e.Fragment,{children:[e.jsx(JA,{open:s,onOpenChange:r,children:e.jsxs(yC,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[e.jsx(eE,{className:"p-6 pb-4 border-b shrink-0",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(tt,{variant:"outline",className:It("text-xs",X.color),children:X.label}),e.jsxs(tt,{variant:"secondary",className:"text-xs capitalize",children:[t.priority," priority"]})]}),e.jsx(tE,{className:"text-xl",children:t.deal_name}),e.jsx("div",{className:"mt-2",children:e.jsx(Vjs,{dealId:t.id})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>n(t),children:e.jsx(ud,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"text-destructive hover:bg-destructive/10",onClick:()=>B(!0),children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})}),e.jsx(Gi,{className:"flex-1",children:e.jsxs("div",{className:"p-6 space-y-6",children:[t.contact&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(Nn,{className:"h-10 w-10",children:e.jsxs(kn,{className:"bg-primary/10 text-primary",children:[(Oe=t.contact.first_name)==null?void 0:Oe[0],(Te=t.contact.last_name)==null?void 0:Te[0]]})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"font-medium",children:[t.contact.first_name," ",t.contact.last_name]}),t.contact.email&&e.jsx("p",{className:"text-sm text-muted-foreground",children:t.contact.email})]}),e.jsxs("div",{className:"flex gap-2",children:[t.contact.phone&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`tel:${t.contact.phone}`,children:e.jsx(Un,{className:"h-4 w-4"})})}),t.contact.email&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`mailto:${t.contact.email}`,children:e.jsx(cr,{className:"h-4 w-4"})})})]})]}),e.jsx(aNs,{dealId:t.id,primaryContactId:t.contact_id}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[(t.property_address||t.city)&&e.jsxs("div",{className:"col-span-2 flex items-start gap-2 text-sm",children:[e.jsx(bn,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t.property_address||"Address TBD"}),e.jsx("p",{className:"text-muted-foreground",children:[t.city,t.state,t.zip_code].filter(Boolean).join(", ")})]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected Price"}),e.jsx("p",{className:"text-lg font-bold",children:Q(t.expected_price)})]}),e.jsxs("div",{className:"bg-emerald-500/10 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected GCI"}),e.jsx("p",{className:"text-lg font-bold text-emerald-600",children:Q(t.expected_commission)})]}),(t.brokerage_split_pct||t.team_split_pct||t.referral_fee_pct||t.franchise_fee_pct||t.transaction_fee)&&e.jsxs("div",{className:"col-span-2 bg-muted/30 rounded-lg p-3 space-y-1.5",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Commission Splits"}),t.brokerage_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Brokerage Split"}),e.jsxs("span",{children:[t.brokerage_split_pct,"%",t.expected_commission?` (${Q(t.expected_commission*t.brokerage_split_pct/100)})`:""]})]}),t.team_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Team Split"}),e.jsxs("span",{children:[t.team_split_pct,"%"]})]}),t.referral_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Referral Fee"}),e.jsxs("span",{children:[t.referral_fee_pct,"%"]})]}),t.franchise_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Franchise Fee"}),e.jsxs("span",{children:[t.franchise_fee_pct,"%"]})]}),t.transaction_fee!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Transaction Fee"}),e.jsx("span",{children:Q(t.transaction_fee)})]}),t.net_commission!=null&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"border-t pt-1.5 mt-1.5",children:e.jsxs("div",{className:"flex justify-between text-sm font-semibold",children:[e.jsx("span",{children:"Net to Agent"}),e.jsx("span",{className:"text-emerald-600",children:Q(t.net_commission)})]})})})]}),o&&!t.scorecard_transaction_id&&a&&e.jsxs(K,{onClick:()=>a(t),className:"w-full bg-green-600 hover:bg-green-700",children:[e.jsx(xo,{className:"h-4 w-4 mr-2"}),"Add to Scorecard"]}),t.scorecard_transaction_id&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground bg-muted/50 rounded-lg p-3",children:[e.jsx(sa,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{children:"Synced to Scorecard"})]}),ee!==null&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 col-span-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Days on Market"}),e.jsxs("p",{className:It("text-lg font-bold",ee>90?"text-red-600":ee>60?"text-amber-600":"text-foreground"),children:[ee," ",t.contract_date?"(final)":"days"]})]}),t.target_close_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(hn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Close: ",ms(Dl(t.target_close_date),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(nc,{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(eNs,{deal:t}),e.jsxs(ba,{defaultValue:"tasks",className:"w-full",children:[e.jsxs(pa,{className:"w-full grid grid-cols-3",children:[e.jsxs(ns,{value:"tasks",className:"gap-1",children:[e.jsx(sa,{className:"h-4 w-4"}),"Tasks ",ge>0&&`(${xe}/${ge})`]}),e.jsxs(ns,{value:"files",className:"gap-1",children:[e.jsx(dS,{className:"h-4 w-4"}),"Files ",ue>0&&`(${ue})`]}),e.jsxs(ns,{value:"activity",className:"gap-1",children:[e.jsx(un,{className:"h-4 w-4"}),"Activity"]})]}),e.jsxs(bs,{value:"tasks",className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Add a new task...",value:O,onChange:ke=>q(ke.target.value),onKeyDown:ke=>ke.key==="Enter"&&re()}),e.jsx(K,{onClick:re,disabled:!O.trim(),children:e.jsx($s,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[c==null?void 0:c.map(ke=>e.jsxs("div",{className:It("flex items-center gap-3 p-3 rounded-lg border transition-colors",ke.is_completed?"bg-muted/50 border-border":"bg-background"),children:[e.jsx(Oo,{checked:ke.is_completed,onCheckedChange:Be=>oe(ke.id,!!Be)}),e.jsx("span",{className:It("flex-1 text-sm",ke.is_completed&&"line-through text-muted-foreground"),children:ke.title}),ke.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(ke.due_date),"MMM d")})]},ke.id)),(c==null?void 0:c.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No tasks yet. Add one above!"})]})]}),e.jsxs(bs,{value:"files",className:"mt-4 space-y-3",children:[e.jsx("input",{type:"file",ref:M,className:"hidden",multiple:!0,onChange:Me,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 ke;return(ke=M.current)==null?void 0:ke.click()},disabled:V,children:[V?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(li,{className:"h-4 w-4 mr-2"}),V?"Uploading...":"Upload Files"]}),e.jsxs("div",{className:"space-y-2",children:[_==null?void 0:_.map(ke=>{const Be=be(ke.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(Be,{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:ke.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[pe(ke.file_size)," · ",ms(new Date(ke.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(z1,{children:e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${ke.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>S.mutate({fileId:ke.id,visible:!ke.visible_on_portal,dealId:t.id}),children:ke.visible_on_portal?e.jsx(On,{className:"h-4 w-4"}):e.jsx(kp,{className:"h-4 w-4"})})}),e.jsx(Yl,{side:"top",children:ke.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Pe(ke.storage_path,ke.file_name),children:e.jsx(yi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>Ne(ke.id,ke.storage_path),children:e.jsx(Rr,{className:"h-4 w-4"})})]})]},ke.id)}),(_==null?void 0:_.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No files yet. Upload contracts, disclosures, or other documents."})]})]}),e.jsxs(bs,{value:"activity",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Er,{placeholder:"Add a note...",value:L,onChange:ke=>I(ke.target.value),rows:2}),e.jsxs(K,{onClick:ie,disabled:!L.trim(),size:"sm",className:"w-full",children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),e.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(ke=>{const Be=oNs[ke.activity_type]||un;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center shrink-0",children:e.jsx(Be,{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:ke.title}),ke.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:ke.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Uc(new Date(ke.created_at),{addSuffix:!0})})]})]},ke.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(kc,{open:U,onOpenChange:B,children:e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Delete Deal?"}),e.jsxs(tc,{children:['This will permanently delete "',t.deal_name,'" and all associated data. This action cannot be undone.']})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:ce,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function cNs({open:t,onOpenChange:s,deal:r,onComplete:n}){const a=wue(),o=sit(),{data:l}=sE(),{data:i}=Ux(),[c,u]=N.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:ms(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});N.useEffect(()=>{if(r&&t){const g=r.deal_type==="seller"?"seller":"buyer",b=r.expected_price||0,_=r.commission_percentage||3,j=r.expected_commission||b*_/100;u({property_address:r.property_address||r.deal_name||"",city:r.city||"",state:r.state||"",zip:r.zip_code||"",transaction_type:g,close_date:r.actual_close_date||r.target_close_date||ms(new Date,"yyyy-MM-dd"),sale_price:b,commission_amount:j,lead_source_id:"",client_type_id:"",notes:r.notes||""})}},[r,t]);const p=async g=>{if(g.preventDefault(),!!r)try{const b=await a.mutateAsync({property_address:c.property_address,city:c.city||null,state:c.state||null,zip:c.zip||null,transaction_type:c.transaction_type,close_date:c.close_date,sale_price:c.sale_price,commission_amount:c.commission_amount||null,brokerage_split_pct:r.brokerage_split_pct||null,team_split_pct:r.team_split_pct||null,franchise_fee_pct:r.franchise_fee_pct||null,referral_fee_pct:r.referral_fee_pct||null,transaction_fee:r.transaction_fee||null,lead_source_id:c.lead_source_id||null,client_type_id:c.client_type_id||null,contact_id:r.contact_id||null,notes:c.notes||null,is_win:!0});await o.mutateAsync({id:r.id,scorecard_transaction_id:b.id,actual_close_date:c.close_date}),me.success("Deal added to Scorecard! 🎉"),s(!1),n==null||n()}catch(b){console.error("Error syncing to scorecard:",b),me.error("Failed to add to scorecard")}},f=g=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(g);return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[550px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{className:"space-y-3",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100 dark:bg-green-900/20",children:e.jsx(xo,{className:"h-6 w-6 text-green-600 dark:text-green-400"})}),e.jsx(vs,{className:"text-center text-xl",children:"Congratulations on Closing! 🎉"}),e.jsx(Gr,{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(bn,{className:"h-4 w-4 text-muted-foreground"}),"Property Address *"]}),e.jsx(ze,{id:"property_address",value:c.property_address,onChange:g=>u(b=>({...b,property_address:g.target.value})),placeholder:"123 Main St",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:c.city,onChange:g=>u(b=>({...b,city:g.target.value})),placeholder:"City"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:c.state,onChange:g=>u(b=>({...b,state:g.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"zip",children:"Zip"}),e.jsx(ze,{id:"zip",value:c.zip,onChange:g=>u(b=>({...b,zip:g.target.value})),placeholder:"75001"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Transaction Type *"}),e.jsxs(Zs,{value:c.transaction_type,onValueChange:g=>u(b=>({...b,transaction_type:g})),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"close_date",className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-muted-foreground"}),"Close Date *"]}),e.jsx(ze,{id:"close_date",type:"date",value:c.close_date,onChange:g=>u(b=>({...b,close_date:g.target.value})),required:!0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"sale_price",className:"flex items-center gap-2",children:[e.jsx(nc,{className:"h-4 w-4 text-muted-foreground"}),"Sale Price *"]}),e.jsx(ze,{id:"sale_price",type:"number",value:c.sale_price||"",onChange:g=>u(b=>({...b,sale_price:Number(g.target.value)})),placeholder:"450000",required:!0,min:0}),c.sale_price>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:f(c.sale_price)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"commission_amount",className:"flex items-center gap-2",children:[e.jsx(uS,{className:"h-4 w-4 text-muted-foreground"}),"GCI (Commission)"]}),e.jsx(ze,{id:"commission_amount",type:"number",value:c.commission_amount||"",onChange:g=>u(b=>({...b,commission_amount:Number(g.target.value)})),placeholder:"13500",min:0}),c.commission_amount>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:f(c.commission_amount)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Lead Source"}),e.jsxs(Zs,{value:c.lead_source_id,onValueChange:g=>u(b=>({...b,lead_source_id:g})),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select source"})}),e.jsx(Gs,{children:l==null?void 0:l.map(g=>e.jsx(Mt,{value:g.id,children:g.name},g.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Client Type"}),e.jsxs(Zs,{value:c.client_type_id,onValueChange:g=>u(b=>({...b,client_type_id:g})),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select type"})}),e.jsx(Gs,{children:i==null?void 0:i.map(g=>e.jsx(Mt,{value:g.id,children:g.name},g.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"notes",children:"Notes"}),e.jsx(Er,{id:"notes",value:c.notes,onChange:g=>u(b=>({...b,notes:g.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(qn,{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(Qa,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}const dNs={buyer:{label:"Buyer",color:"bg-blue-500/10 text-blue-600 border-blue-200"},seller:{label:"Seller",color:"bg-emerald-500/10 text-emerald-600 border-emerald-200"},dual:{label:"Dual",color:"bg-purple-500/10 text-purple-600 border-purple-200"},referral:{label:"Referral",color:"bg-orange-500/10 text-orange-600 border-orange-200"},lease:{label:"Lease",color:"bg-cyan-500/10 text-cyan-600 border-cyan-200"}},mze={urgent:0,high:1,medium:2,low:3};function uNs({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=N.useState("target_close_date"),[l,i]=N.useState("asc"),c=b=>{a===b?i(_=>_==="asc"?"desc":"asc"):(o(b),i("asc"))},u=N.useMemo(()=>[...t].sort((b,_)=>{var w,k;let j=0;switch(a){case"deal_name":j=b.deal_name.localeCompare(_.deal_name);break;case"stage":{const S=((w=s.find(L=>L.id===b.stage_id))==null?void 0:w.sort_order)||0,M=((k=s.find(L=>L.id===_.stage_id))==null?void 0:k.sort_order)||0;j=S-M;break}case"expected_price":j=(b.expected_price||0)-(_.expected_price||0);break;case"expected_commission":j=(b.expected_commission||0)-(_.expected_commission||0);break;case"target_close_date":{const S=b.target_close_date?Dl(b.target_close_date).getTime():1/0,M=_.target_close_date?Dl(_.target_close_date).getTime():1/0;j=S-M;break}case"priority":j=mze[b.priority]-mze[_.priority];break}return l==="asc"?j:-j}),[t,s,a,l]),p=b=>b?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(b):"—",f=b=>b?s.find(_=>_.id===b):null,g=({field:b,children:_})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>c(b),children:[_,a===b?l==="asc"?e.jsx(ku,{className:"ml-2 h-4 w-4"}):e.jsx(Wh,{className:"ml-2 h-4 w-4"}):e.jsx(vd,{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(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/50",children:[e.jsx(St,{className:"w-[250px]",children:e.jsx(g,{field:"deal_name",children:"Deal Name"})}),e.jsx(St,{className:"w-[150px]",children:e.jsx(g,{field:"stage",children:"Stage"})}),e.jsx(St,{className:"w-[100px]",children:"Type"}),e.jsx(St,{className:"w-[120px]",children:e.jsx(g,{field:"expected_price",children:"Price"})}),e.jsx(St,{className:"w-[120px]",children:e.jsx(g,{field:"expected_commission",children:"GCI"})}),e.jsx(St,{className:"w-[130px]",children:e.jsx(g,{field:"target_close_date",children:"Close Date"})}),e.jsx(St,{className:"w-[100px]",children:e.jsx(g,{field:"priority",children:"Priority"})})]})}),e.jsx(zn,{children:u.map(b=>{f(b.stage_id);const _=dNs[b.deal_type],j=b.target_close_date?oy(Dl(b.target_close_date),new Date):null,w=j!==null&&j<0,k=j!==null&&j<=7&&j>=0;return e.jsxs(Ss,{className:It("cursor-pointer hover:bg-muted/50 transition-colors",w&&"bg-red-50/50"),onClick:()=>r(b),children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{children:[e.jsx("p",{className:"truncate max-w-[230px]",children:b.deal_name}),b.contact&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[b.contact.first_name," ",b.contact.last_name]})]})}),e.jsx(dt,{onClick:S=>S.stopPropagation(),children:e.jsx(llt,{stages:s,currentStageId:b.stage_id||"",onStageSelect:(S,M)=>n(b.id,S,M)})}),e.jsx(dt,{children:e.jsx(tt,{variant:"outline",className:It("text-xs",_.color),children:_.label})}),e.jsx(dt,{children:e.jsx("span",{className:"font-medium",children:p(b.expected_price)})}),e.jsx(dt,{children:e.jsx("span",{className:"text-emerald-600",children:p(b.expected_commission)})}),e.jsx(dt,{children:b.target_close_date?e.jsxs("div",{className:It("flex items-center gap-1 text-sm",w&&"text-red-600",k&&!w&&"text-amber-600"),children:[w&&e.jsx(kl,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:ms(Dl(b.target_close_date),"MMM d, yyyy")})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{children:e.jsx(tt,{variant:"outline",className:It("text-xs capitalize",b.priority==="urgent"&&"border-red-200 bg-red-50 text-red-700",b.priority==="high"&&"border-orange-200 bg-orange-50 text-orange-700",b.priority==="medium"&&"border-amber-200 bg-amber-50 text-amber-700",b.priority==="low"&&"border-slate-200 bg-slate-50 text-slate-600"),children:b.priority})})]},b.id)})})]})})}function hNs(){const t=ci();return mt({queryKey:["deal-tasks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("deal_tasks").select(` *, deal:deal_pipeline(id, deal_name, stage_id), contact:innercircle_contacts(id, first_name, last_name), stage:deal_pipeline_stages(id, name, color) `).eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function mNs(t){const s=ci();return mt({queryKey:["deal-tasks","deal",t,s],queryFn:async()=>{if(!s||!t)return[];const{data:r,error:n}=await H.from("deal_tasks").select(` *, stage:deal_pipeline_stages(id, name, color) `).eq("owner_user_id",s).eq("deal_id",t).order("sort_order",{ascending:!0});if(n)throw n;return r},enabled:!!s&&!!t})}function pNs(){const t=ci(),s=Qt();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("deal_tasks").insert({owner_user_id:t,title:r.title,description:r.description||null,deal_id:r.deal_id||null,contact_id:r.contact_id||null,stage_id:r.stage_id||null,priority:r.priority||"medium",status:r.status||"todo",due_date:r.due_date||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}function fNs(){const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("deal_tasks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function xNs(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("deal_tasks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function cCe(){const t=Qt();return Dt({mutationFn:async({id:s,status:r})=>{const{data:n,error:a}=await H.from("deal_tasks").update({status:r,completed_at:r==="done"?new Date().toISOString():null}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function gNs(){const t=Qt();return Dt({mutationFn:async s=>{if(s.length===0)return;const{error:r}=await H.from("deal_tasks").update({status:"done",completed_at:new Date().toISOString()}).in("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function yNs(t){const s=ci();return mt({queryKey:["deal-task-templates",s,t],queryFn:async()=>{if(!s)return[];let r=H.from("deal_task_templates").select("*").eq("owner_user_id",s).order("sort_order",{ascending:!0});t&&(r=r.eq("stage_id",t));const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!s})}function vNs(){const t=ci(),s=Qt();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("deal_task_templates").insert({owner_user_id:t,stage_id:r.stage_id,title:r.title,description:r.description||null,priority:r.priority||"medium",default_due_offset_days:r.default_due_offset_days||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-task-templates"]})}})}function bNs(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("deal_task_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-task-templates"]})}})}function _Ns(){const t=ci(),s=Qt();return Dt({mutationFn:async({dealId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await H.from("deal_task_templates").select("*").eq("owner_user_id",t).eq("stage_id",n).order("sort_order");if(o)throw o;if(!a||a.length===0)return[];const{data:l}=await H.from("deal_tasks").select("title, stage_id").eq("deal_id",r).eq("stage_id",n),i=new Set((l||[]).map(f=>f.title)),c=a.filter(f=>!i.has(f.title)).map((f,g)=>({owner_user_id:t,deal_id:r,stage_id:n,title:f.title,description:f.description,priority:f.priority,due_date:f.default_due_offset_days?new Date(Date.now()+f.default_due_offset_days*864e5).toISOString().split("T")[0]:null,sort_order:g,status:"todo"}));if(c.length===0)return[];const{data:u,error:p}=await H.from("deal_tasks").insert(c).select();if(p)throw p;return u},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}const wNs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function jNs({open:t,onOpenChange:s,dealId:r,dealName:n,fromStageName:a,toStageName:o,toStageId:l,onConfirm:i}){const{data:c,isLoading:u}=mNs(t?r:void 0),p=gNs(),f=_Ns(),[g,b]=N.useState(new Set),[_,j]=N.useState(!1),w=(c||[]).filter(L=>L.status!=="done");N.useEffect(()=>{w.length>0&&b(new Set(w.map(L=>L.id)))},[c]);const k=L=>{b(I=>{const O=new Set(I);return O.has(L)?O.delete(L):O.add(L),O})},S=async()=>{j(!0);try{const L=Array.from(g);L.length>0&&await p.mutateAsync(L),await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(L){console.error("Stage move failed:",L),me.error((L==null?void 0:L.message)||"Failed to move deal. Please try again.")}finally{j(!1)}},M=async()=>{j(!0);try{await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(L){console.error("Stage move (skip) failed:",L),me.error((L==null?void 0:L.message)||"Failed to move deal. Please try again.")}finally{j(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[480px]",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Move Deal"}),e.jsxs(Gr,{children:["Moving ",e.jsx("span",{className:"font-medium text-foreground",children:n})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2",children:[e.jsx(tt,{variant:"outline",className:"text-sm",children:a}),e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(tt,{className:"text-sm bg-primary",children:o})]}),u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You have ",e.jsx("span",{className:"font-medium text-foreground",children:w.length})," incomplete task",w.length!==1?"s":"",". Select which to mark as done:"]}),e.jsx(Gi,{className:"max-h-[250px]",children:e.jsx("div",{className:"space-y-1",children:w.map(L=>e.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-muted/50 cursor-pointer transition-colors",children:[e.jsx(Oo,{checked:g.has(L.id),onCheckedChange:()=>k(L.id)}),e.jsxs("span",{className:"text-sm flex-1",children:[wNs[L.priority]," ",L.title]}),L.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full",style:{backgroundColor:L.stage.color+"20",color:L.stage.color},children:L.stage.name})]},L.id))})}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>{g.size===w.length?b(new Set):b(new Set(w.map(L=>L.id)))},children:g.size===w.length?"Deselect All":"Select All"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:M,disabled:_,children:"Skip"}),e.jsxs(K,{size:"sm",onClick:S,disabled:_,children:[_&&e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}),g.size>0?`Complete ${g.size} & Move`:"Move Deal"]})]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-center py-4",children:[e.jsx(sa,{className:"h-8 w-8 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"All tasks completed! Ready to move."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:S,disabled:_,children:[_&&e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}),"Move to ",o]})]})]})]})})}function NNs(){const t=ci();return mt({queryKey:["all-client-portals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("client_portals").select("*").eq("owner_user_id",t);if(r)throw r;return s||[]},enabled:!!t})}function kNs({dealId:t,dealName:s,contactName:r,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const c=lSe(),u=xR(),p=a_s(),f=i_s(),[g,b]=N.useState(!1),_=!!(n!=null&&n.archived_at),j=async()=>{b(!0);try{await c.mutateAsync({deal_id:t,visibility:"private",require_onboarding:!0}),me.success("Portal enabled!")}catch{me.error("Failed to create portal")}finally{b(!1)}},w=async I=>{if(n)try{await u.mutateAsync({id:n.id,is_enabled:I}),me.success(I?"Portal enabled":"Portal disabled")}catch{me.error("Failed to update portal")}},k=()=>{n&&(navigator.clipboard.writeText(b1(n.slug)),me.success("Link copied!"))},S=()=>{n&&window.open(b1(n.slug),"_blank")},M=async()=>{if(n)try{await p.mutateAsync(n.id),me.success("Portal archived")}catch{me.error("Failed to archive portal")}},L=async()=>{if(n)try{await f.mutateAsync(n.id),me.success("Portal restored")}catch{me.error("Failed to restore portal")}};return n?_?e.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg opacity-60 bg-muted/30",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx(tt,{variant:"outline",className:"text-[10px] bg-muted text-muted-foreground",children:"Archived"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||r||"No client name"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:L,className:"text-xs gap-1",children:[e.jsx(VI,{className:"h-3.5 w-3.5"}),"Restore"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>i(n),className:"text-xs gap-1 text-destructive hover:text-destructive",children:[e.jsx(Nr,{className:"h-3.5 w-3.5"}),"Delete"]})]})]}):e.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx(tt,{variant:"outline",className:n.is_enabled?"text-[10px] bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-[10px] bg-muted text-muted-foreground",children:n.is_enabled?"Active":"Disabled"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||r||"No client name"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:k,title:"Copy link",children:e.jsx(gi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:S,title:"Preview",children:e.jsx(tn,{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(Bn,{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(FM,{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(Xo,{className:"h-3.5 w-3.5"})}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(px,{className:"h-3.5 w-3.5"})})}),e.jsx(Bd,{align:"end",children:e.jsxs(Ma,{onClick:M,children:[e.jsx(NM,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),e.jsx(qr,{checked:n.is_enabled,onCheckedChange:w,className:"ml-1"})]})]}):e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg border-dashed bg-muted/20",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r||"No contact"})]}),e.jsxs(K,{size:"sm",onClick:j,disabled:g,className:"shrink-0 ml-4",children:[g?e.jsx(ws,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(pn,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function SNs(){const{data:t,isLoading:s}=Ghe(),{data:r,isLoading:n}=NNs(),[a,o]=N.useState(""),[l,i]=N.useState("all"),c=o_s(),[u,p]=N.useState(null),[f,g]=N.useState(null),[b,_]=N.useState(null),[j,w]=N.useState(null),k=ci(),S=s||n,M=new Map;r==null||r.forEach(V=>M.set(V.deal_id,V));const I=[...(t||[]).filter(V=>{var ie,re,oe,ce,xe;const Z=M.get(V.id),X=a.toLowerCase(),ee=!X||V.deal_name.toLowerCase().includes(X)||((re=(ie=V.contact)==null?void 0:ie.first_name)==null?void 0:re.toLowerCase().includes(X))||((ce=(oe=V.contact)==null?void 0:oe.last_name)==null?void 0:ce.toLowerCase().includes(X))||((xe=Z==null?void 0:Z.client_name)==null?void 0:xe.toLowerCase().includes(X));let Q=!0;return l==="active"?Q=!!(Z!=null&&Z.is_enabled)&&!(Z!=null&&Z.archived_at):l==="disabled"?Q=!!Z&&!Z.is_enabled&&!Z.archived_at:l==="archived"?Q=!!(Z!=null&&Z.archived_at):l==="none"?Q=!Z:l==="all"&&(Q=!(Z!=null&&Z.archived_at)||!Z),ee&&Q})].sort((V,Z)=>{const X=M.get(V.id),ee=M.get(Z.id);if(X!=null&&X.archived_at&&!(ee!=null&&ee.archived_at))return 1;if(!(X!=null&&X.archived_at)&&(ee!=null&&ee.archived_at)||X&&!ee)return-1;if(!X&&ee)return 1;if(X&&ee){if(X.is_enabled&&!ee.is_enabled)return-1;if(!X.is_enabled&&ee.is_enabled)return 1}return 0}),O=(r==null?void 0:r.filter(V=>!V.archived_at).length)||0,q=(r==null?void 0:r.filter(V=>V.is_enabled&&!V.archived_at).length)||0,U=(r==null?void 0:r.filter(V=>V.archived_at).length)||0,B=async()=>{if(j)try{await c.mutateAsync({id:j.id,dealId:j.deal_id}),me.success("Portal permanently deleted"),w(null)}catch{me.error("Failed to delete portal")}};return S?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(pn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"font-medium",children:[O," Portals"]})]}),e.jsxs("span",{className:"text-muted-foreground",children:[q," active · ",O-q," disabled",U>0&&` · ${U} archived`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search deals or clients...",value:a,onChange:V=>o(V.target.value),className:"pl-9 pr-8"}),a&&e.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Rr,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:["all","active","disabled","archived","none"].map(V=>e.jsx(K,{variant:l===V?"secondary":"ghost",size:"sm",onClick:()=>i(V),className:"text-xs px-3 capitalize",children:V==="none"?"No Portal":V},V))})]}),e.jsx(Gi,{className:"h-[calc(100vh-22rem)]",children:e.jsxs("div",{className:"space-y-2 pb-4",children:[I.map(V=>{const Z=M.get(V.id)||null,X=V.contact?`${V.contact.first_name||""} ${V.contact.last_name||""}`.trim():"";return e.jsx(kNs,{dealId:V.id,dealName:V.deal_name,contactName:X,portal:Z,onSettingsOpen:p,onComposerOpen:ee=>g(ee),onInviteOpen:(ee,Q)=>_({portal:ee,dealName:Q}),onDeleteConfirm:w},V.id)}),I.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(pn,{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(dlt,{open:!!u,onOpenChange:V=>!V&&p(null),portal:u,dealOwnerId:k||""}),f&&e.jsx(ult,{open:!!f,onOpenChange:V=>!V&&g(null),portalId:f.id,portalSlug:f.slug,notifyClient:f.notify_client}),b&&e.jsx(hlt,{open:!!b,onOpenChange:V=>!V&&_(null),portal:b.portal,dealName:b.dealName}),e.jsx(kc,{open:!!j,onOpenChange:V=>!V&&w(null),children:e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Permanently delete this portal?"}),e.jsx(tc,{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(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:B,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class CNs extends N.Component{constructor(s){super(s),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,r){console.error("DealPipeline error:",s,r)}render(){return this.state.hasError?e.jsx(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}}const cI="deal-pipeline-detail-sheet";function MNs(){var Cs;const t=NE(),{data:s,isLoading:r}=Whe(),{data:n,isLoading:a,refetch:o}=Ghe(),{data:l,isLoading:i}=rws(),c=eit(),u=Y_s(),[p,f]=N.useState("board"),[g,b]=N.useState(!1),[_,j]=N.useState(!1),[w,k]=N.useState(null),[S,M]=N.useState(null),[L,I]=N.useState(null),[O,q]=N.useState(null),[U,B]=N.useState(!1),[V,Z]=N.useState(null),[X,ee]=N.useState(""),[Q,ie]=N.useState("all"),[re,oe]=N.useState(!1),[ce,xe]=N.useState(!1),[ge,ue]=N.useState(new Set),pe=N.useRef(!1),[be,Me]=N.useState(null),{data:Ne}=Bx(),{isTeamLeader:Pe,teamMembers:Oe}=Ljs(),Te=N.useMemo(()=>Array.from(ge),[ge]),{data:ke}=Djs(Te),Be=N.useMemo(()=>{const cs=new Map;return Oe.forEach(er=>cs.set(er.id,{name:er.name,avatar_url:er.avatar_url,color:er.color})),cs},[Oe]),nt=N.useCallback(cs=>cs.owner_user_id&&Be.get(cs.owner_user_id)||null,[Be]),Ae=N.useCallback(cs=>{ue(er=>{const xt=new Set(er);return xt.has(cs)?xt.delete(cs):xt.add(cs),xt})},[]);N.useEffect(()=>{!r&&s&&s.length===0&&c.mutate()},[r,s]);const[ft,fe]=Cc(),Ve=N.useRef(!1);N.useEffect(()=>{const cs=ft.get("deal");if(cs&&n&&n.length>0&&!Ve.current){const er=n.find(xt=>xt.id===cs);er&&(Ve.current=!0,k(er),j(!0),ft.delete("deal"),fe(ft,{replace:!0}))}},[n,ft]);const at=N.useMemo(()=>{if(!ke||!s)return[];const cs=new Map(s.map(er=>[er.name,er.id]));return ke.map(er=>{const xt=er._stage_name&&cs.get(er._stage_name)||null;return{...er,stage_id:xt||er.stage_id}})},[ke,s]),et=N.useMemo(()=>[...n||[],...at],[n,at]);N.useEffect(()=>{if(pe.current||et.length===0)return;pe.current=!0;const cs=sessionStorage.getItem(cI);if(cs)try{const er=JSON.parse(cs);if(!er.open||!er.dealId)return;const xt=et.find(Es=>Es.id===er.dealId);xt&&(k(xt),j(!0))}catch{sessionStorage.removeItem(cI)}},[et]),N.useEffect(()=>{_&&(w!=null&&w.id)?sessionStorage.setItem(cI,JSON.stringify({dealId:w.id,open:!0})):sessionStorage.removeItem(cI)},[_,w==null?void 0:w.id]);const Ce=et.filter(cs=>{var ur,Mr,Lr,fn,ki,Ea;const er=X.toLowerCase(),xt=!er||cs.deal_name.toLowerCase().includes(er)||((Mr=(ur=cs.contact)==null?void 0:ur.first_name)==null?void 0:Mr.toLowerCase().includes(er))||((fn=(Lr=cs.contact)==null?void 0:Lr.last_name)==null?void 0:fn.toLowerCase().includes(er))||((ki=cs.property_address)==null?void 0:ki.toLowerCase().includes(er))||((Ea=cs.city)==null?void 0:Ea.toLowerCase().includes(er)),Es=Q==="all"||cs.deal_type===Q;return xt&&Es}),rt=N.useMemo(()=>{if(!s)return l||null;const cs=new Set(s.filter(Lr=>Lr.is_won_stage).map(Lr=>Lr.id)),er=new Set(s.filter(Lr=>Lr.is_lost_stage).map(Lr=>Lr.id)),xt=et.filter(Lr=>Lr.stage_id&&!cs.has(Lr.stage_id)&&!er.has(Lr.stage_id)),Es=et.filter(Lr=>Lr.stage_id&&cs.has(Lr.stage_id)),ur=new Date().getFullYear(),Mr=Es.filter(Lr=>Lr.actual_close_date?new Date(Lr.actual_close_date).getFullYear()===ur:!0);return{totalDeals:et.length,activeDeals:xt.length,wonDeals:Es.length,pipelineValue:xt.reduce((Lr,fn)=>Lr+(fn.expected_price||0),0),expectedCommission:xt.reduce((Lr,fn)=>Lr+(fn.expected_commission||0),0),expectedNetToAgent:xt.reduce((Lr,fn)=>Lr+(yx(fn)||0),0),wonValue:Es.reduce((Lr,fn)=>Lr+(fn.expected_price||0),0),weightedGCI:xt.reduce((Lr,fn)=>Lr+(fn.expected_commission||0)*((fn.probability??50)/100),0),weightedNet:xt.reduce((Lr,fn)=>Lr+(yx(fn)||0)*((fn.probability??50)/100),0),ytdWonDeals:Mr.length,ytdWonGCI:Mr.reduce((Lr,fn)=>Lr+(fn.expected_commission||0),0),ytdWonNet:Mr.reduce((Lr,fn)=>Lr+(yx(fn)||0),0),projectedAnnualNet:Mr.reduce((Lr,fn)=>Lr+(yx(fn)||0),0)+xt.reduce((Lr,fn)=>Lr+(yx(fn)||0)*((fn.probability??50)/100),0)}},[et,s,l]),Ge=cs=>{k(cs),j(!0)},ct=cs=>{M(cs||null),k(null),b(!0)},qe=cs=>{k(cs),j(!1),b(!0)},Ze=cs=>{j(cs),cs||sessionStorage.removeItem(cI)},Qe=(cs,er)=>{I(cs)},He=(cs,er)=>{cs.preventDefault(),cs.dataTransfer.dropEffect="move",q(er)},Je=async(cs,er)=>{if(cs.preventDefault(),q(null),!L)return;const xt=n==null?void 0:n.find(Mr=>Mr.id===L),Es=s==null?void 0:s.find(Mr=>Mr.id===er),ur=s==null?void 0:s.find(Mr=>Mr.id===(xt==null?void 0:xt.stage_id));if(!xt||!Es||xt.stage_id===er){I(null);return}Me({dealId:L,dealName:xt.deal_name,fromStageName:(ur==null?void 0:ur.name)||"Unknown",toStageName:Es.name,toStageId:er,isWonStage:Es.is_won_stage,deal:xt}),I(null)},it=async()=>{if(!be)return;const{dealId:cs,toStageId:er,toStageName:xt,isWonStage:Es,deal:ur}=be;if(await u.mutateAsync({dealId:cs,stageId:er,stageName:xt}),me.success(`Moved to ${xt}`),Es&&!ur.scorecard_transaction_id){const Mr={...ur,stage_id:er};Z(Mr),B(!0)}},Lt=N.useCallback(async(cs,er,xt)=>{const Es=n==null?void 0:n.find(Lr=>Lr.id===cs),ur=s==null?void 0:s.find(Lr=>Lr.id===er),Mr=s==null?void 0:s.find(Lr=>Lr.id===(Es==null?void 0:Es.stage_id));!Es||!ur||Es.stage_id===er||Me({dealId:cs,dealName:Es.deal_name,fromStageName:(Mr==null?void 0:Mr.name)||"Unknown",toStageName:xt,toStageId:er,isWonStage:ur.is_won_stage,deal:Es})},[n,s]),Vt=cs=>Ce.filter(er=>er.stage_id===cs),hs=r||a,Ts=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(Go,{className:"h-4 w-4"})}),!t&&e.jsx(z1,{children:e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsxs(K,{variant:p==="board"?"secondary":"ghost",size:"sm",onClick:()=>f("board"),className:"px-3 gap-1.5",children:[e.jsx(Cp,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),e.jsx(Yl,{children:"Kanban board view"})]}),e.jsxs(bc,{children:[e.jsx(_c,{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(Mh,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(Yl,{children:"Grouped list view"})]}),e.jsxs(bc,{children:[e.jsx(_c,{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($M,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(Yl,{children:"Sortable table view"})]}),e.jsxs(bc,{children:[e.jsx(_c,{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(pn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(Yl,{children:"Client portal management"})]})]})}),Ne&&!Pe&&e.jsxs(K,{variant:"outline",onClick:()=>oe(!0),children:[e.jsx(pr,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(K,{onClick:()=>ct(),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),Ts!=="portals"&&e.jsx(zjs,{stats:rt,isLoading:i}),Ts!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search deals, contacts, addresses...",value:X,onChange:cs=>ee(cs.target.value),className:"pl-9 pr-8"}),X&&e.jsx("button",{onClick:()=>ee(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Rr,{className:"h-4 w-4"})})]}),e.jsxs(Zs,{value:Q,onValueChange:ie,children:[e.jsx(Ws,{className:"w-[140px]",children:e.jsx(Xs,{placeholder:"All Types"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"}),e.jsx(Mt,{value:"dual",children:"Dual"}),e.jsx(Mt,{value:"referral",children:"Referral"}),e.jsx(Mt,{value:"lease",children:"Lease"})]})]}),(X||Q!=="all")&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[Ce.length," of ",(n==null?void 0:n.length)||0," deals"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[Pe&&!t&&Oe.length>0&&e.jsx(Ijs,{members:Oe,enabledMembers:ge,onToggleMember:Ae,isOpen:ce,onToggleOpen:()=>xe(cs=>!cs)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:hs?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(cs=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(ys,{className:"h-full rounded-xl"})},cs))}):Ts==="board"?e.jsxs(Gi,{className:"h-full -mx-4 md:-mx-6 px-4 md:px-6",children:[e.jsx("div",{className:"flex gap-4 h-full pb-4",children:s==null?void 0:s.map(cs=>e.jsx(Fjs,{stage:cs,deals:Vt(cs.id),onDealClick:Ge,onAddDeal:ct,onDragStart:Qe,onDragOver:He,onDrop:Je,isDragOver:O===cs.id,isWonStage:cs.is_won_stage,getOwnerInfo:nt},cs.id))}),e.jsx(nue,{orientation:"horizontal"})]}):Ts==="table"?e.jsx(Gi,{className:"h-full",children:e.jsx(uNs,{deals:Ce,stages:s||[],onDealClick:Ge,onStageChange:Lt})}):Ts==="portals"?e.jsx(SNs,{}):e.jsx(Gi,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(cs=>{const er=Vt(cs.id);return er.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:cs.color}}),e.jsx("h3",{className:"font-semibold",children:cs.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",er.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:er.map(xt=>e.jsx(clt,{deal:xt,onClick:()=>Ge(xt),stages:s,onStageChange:Lt,showStagePicker:!0,isWonStage:cs.is_won_stage,ownerInfo:nt(xt)},xt.id))})]},cs.id)}),(n==null?void 0:n.length)===0&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-muted rounded-full flex items-center justify-center",children:e.jsx(Cp,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start tracking your opportunities by adding your first deal"}),e.jsxs(K,{onClick:()=>ct(),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&Ce.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(cn,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No matching deals"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Try adjusting your search or filters"}),e.jsx(K,{variant:"outline",onClick:()=>{ee(""),ie("all")},children:"Clear Filters"})]})]})})})]})]}),e.jsx(Ujs,{open:g,onOpenChange:b,deal:w,defaultStageId:S}),e.jsx(lNs,{deal:w,open:_,onOpenChange:Ze,onEdit:qe,isWonStage:w?(Cs=s==null?void 0:s.find(cs=>cs.id===w.stage_id))==null?void 0:Cs.is_won_stage:!1,onAddToScorecard:cs=>{Z(cs),B(!0),j(!1)}}),e.jsx(cNs,{open:U,onOpenChange:B,deal:V,onComplete:()=>{o(),Z(null)}}),be&&e.jsx(jNs,{open:!!be,onOpenChange:cs=>{cs||Me(null)},dealId:be.dealId,dealName:be.dealName,fromStageName:be.fromStageName,toStageName:be.toStageName,toStageId:be.toStageId,onConfirm:it}),e.jsx(Ejs,{open:re,onOpenChange:oe})]})}function TNs(){return e.jsx(CNs,{children:e.jsx(MNs,{})})}function mlt({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var ee;const o=pNs(),l=fNs(),{data:i}=Ghe(),c=ci(),{data:u}=mt({queryKey:["contacts-for-tasks",c],queryFn:async()=>{if(!c)return[];const{data:Q,error:ie}=await H.from("innercircle_contacts").select("id, first_name, last_name").eq("owner_user_id",c).order("first_name").limit(500);if(ie)throw ie;return Q},enabled:!!c&&t}),[p,f]=N.useState(""),[g,b]=N.useState(""),[_,j]=N.useState("none"),[w,k]=N.useState("none"),[S,M]=N.useState("medium"),[L,I]=N.useState("todo"),[O,q]=N.useState(),[U,B]=N.useState(!1),[V,Z]=N.useState(!1);N.useEffect(()=>{r?(f(r.title),b(r.description||""),j(r.deal_id||"none"),k(r.contact_id||"none"),M(r.priority),I(r.status),q(r.due_date?jm(r.due_date):void 0)):(f(""),b(""),j(n||"none"),k("none"),M("medium"),I("todo"),q(void 0))},[r,t,n]);const X=async()=>{if(!p.trim()){me.error("Task title is required");return}try{const Q={title:p.trim(),description:g.trim()||null,deal_id:_==="none"?null:_,contact_id:w==="none"?null:w,stage_id:a||null,priority:S,status:L,due_date:O?ms(O,"yyyy-MM-dd"):null};r?(await l.mutateAsync({id:r.id,...Q}),me.success("Task updated")):(await o.mutateAsync(Q),me.success("Task created")),s(!1)}catch{me.error("Failed to save task")}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[480px]",children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{value:p,onChange:Q=>f(Q.target.value),placeholder:"e.g., Send inspection report"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Er,{value:g,onChange:Q=>b(Q.target.value),placeholder:"Optional details...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Priority"}),e.jsxs(Zs,{value:S,onValueChange:Q=>M(Q),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"low",children:"🟢 Low"}),e.jsx(Mt,{value:"medium",children:"🟡 Medium"}),e.jsx(Mt,{value:"high",children:"🟠 High"}),e.jsx(Mt,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Status"}),e.jsxs(Zs,{value:L,onValueChange:Q=>I(Q),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"todo",children:"To Do"}),e.jsx(Mt,{value:"in_progress",children:"In Progress"}),e.jsx(Mt,{value:"done",children:"Done"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Due Date"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!O&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),O?ms(O,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:O,onSelect:q,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Link to Deal"}),e.jsxs($o,{open:U,onOpenChange:B,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(ka,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),_!=="none"?((ee=i==null?void 0:i.find(Q=>Q.id===_))==null?void 0:ee.deal_name)||"Select deal":"No Deal"]}),e.jsx(Sx,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search deals..."}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:"No deals found."}),e.jsxs(Fx,{children:[e.jsxs(bp,{value:"no-deal",onSelect:()=>{j("none"),B(!1)},children:[e.jsx(va,{className:It("mr-2 h-4 w-4",_==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(Q=>e.jsxs(bp,{value:Q.deal_name,onSelect:()=>{j(Q.id),B(!1)},children:[e.jsx(va,{className:It("mr-2 h-4 w-4",_===Q.id?"opacity-100":"opacity-0")}),Q.deal_name]},Q.id))]})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Link to Contact"}),e.jsxs($o,{open:V,onOpenChange:Z,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(to,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),w!=="none"?(()=>{const Q=u==null?void 0:u.find(ie=>ie.id===w);return Q?`${Q.first_name} ${Q.last_name}`:"Select contact"})():"No Contact"]}),e.jsx(Sx,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search contacts..."}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:"No contacts found."}),e.jsxs(Fx,{children:[e.jsxs(bp,{value:"no-contact",onSelect:()=>{k("none"),Z(!1)},children:[e.jsx(va,{className:It("mr-2 h-4 w-4",w==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),u==null?void 0:u.map(Q=>e.jsxs(bp,{value:`${Q.first_name} ${Q.last_name}`,onSelect:()=>{k(Q.id),Z(!1)},children:[e.jsx(va,{className:It("mr-2 h-4 w-4",w===Q.id?"opacity-100":"opacity-0")}),Q.first_name," ",Q.last_name]},Q.id))]})]})]})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:X,disabled:o.isPending||l.isPending,children:r?"Save Changes":"Create Task"})]})]})]})})}const ANs={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 ENs({tasks:t}){const s=cCe(),r=xNs(),n=fr(),[a,o]=N.useState(null),l=async p=>{const f=p.status==="done"?"todo":"done";try{await s.mutateAsync({id:p.id,status:f})}catch{me.error("Failed to update task")}},i=async p=>{try{await r.mutateAsync(p),me.success("Task deleted")}catch{me.error("Failed to delete task")}};if(t.length===0)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx(sa,{className:"h-12 w-12 text-muted-foreground/30 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:"No tasks found"}),e.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"Create a new task to get started"})]});const c=new Map,u=[];return t.forEach(p=>{if(p.deal){const f=c.get(p.deal.id)||{dealName:p.deal.deal_name,tasks:[]};f.tasks.push(p),c.set(p.deal.id,f)}else u.push(p)}),e.jsxs("div",{className:"space-y-4",children:[u.length>0&&e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 px-4 py-2 border-b",children:e.jsx("h3",{className:"font-medium text-sm text-muted-foreground",children:"General Tasks"})}),u.map(p=>e.jsx(pze,{task:p,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:f=>n(`/mission-control/pipeline?deal=${f}`)},p.id))]}),Array.from(c.entries()).map(([p,f])=>e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(`/mission-control/pipeline?deal=${p}`),className:"w-full bg-muted/30 px-4 py-2 border-b flex items-center gap-2 hover:bg-muted/50 transition-colors text-left",children:[e.jsx(ka,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("h3",{className:"font-medium text-sm",children:f.dealName}),e.jsxs(tt,{variant:"secondary",className:"ml-auto text-xs",children:[f.tasks.filter(g=>g.status==="done").length,"/",f.tasks.length]}),e.jsx(da,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),f.tasks.map(g=>e.jsx(pze,{task:g,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:b=>n(`/mission-control/pipeline?deal=${b}`)},g.id))]},p)),a&&e.jsx(mlt,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function pze({task:t,onToggle:s,onDelete:r,onEdit:n,onNavigateDeal:a}){const o=t.status==="done",l=!o&&t.due_date&&b0(jm(t.due_date))&&!bu(jm(t.due_date)),i=!o&&t.due_date&&bu(jm(t.due_date)),c=ANs[t.priority];return e.jsxs("div",{className:It("flex items-center gap-3 px-4 py-3 border-b last:border-b-0 group hover:bg-muted/30 transition-colors",o&&"opacity-60"),children:[e.jsx("button",{onClick:()=>s(t),className:"shrink-0",children:o?e.jsx(sa,{className:"h-5 w-5 text-emerald-500"}):e.jsx(bd,{className:"h-5 w-5 text-muted-foreground hover:text-primary transition-colors"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:It("text-sm font-medium truncate",o&&"line-through text-muted-foreground"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[t.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:t.stage.color+"20",color:t.stage.color},children:t.stage.name}),t.contact&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(to,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]})]}),e.jsxs(tt,{variant:"outline",className:It("text-[10px] shrink-0",c.color),children:[c.dot," ",c.label]}),t.due_date&&e.jsxs("span",{className:It("text-xs shrink-0 flex items-center gap-1",l&&"text-destructive font-medium",i&&"text-amber-600 font-medium",!l&&!i&&"text-muted-foreground"),children:[e.jsx(un,{className:"h-3 w-3"}),ms(jm(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(ud,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("button",{onClick:()=>r(t.id),className:"p-1 hover:bg-destructive/10 rounded",children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]})]})}const PNs=[{status:"todo",label:"To Do",icon:bd,color:"border-t-slate-400"},{status:"in_progress",label:"In Progress",icon:pp,color:"border-t-blue-500"},{status:"done",label:"Done",icon:sa,color:"border-t-emerald-500"}],INs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function LNs({tasks:t}){const s=cCe(),r=N.useMemo(()=>{const o={todo:[],in_progress:[],done:[]};return t.forEach(l=>o[l.status].push(l)),o},[t]),n=(o,l)=>{o.dataTransfer.setData("taskId",l)},a=async(o,l)=>{o.preventDefault();const i=o.dataTransfer.getData("taskId");if(!i)return;const c=t.find(u=>u.id===i);if(!(!c||c.status===l))try{await s.mutateAsync({id:i,status:l})}catch{me.error("Failed to move task")}};return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:PNs.map(o=>e.jsxs("div",{className:It("border rounded-lg border-t-4 bg-muted/20",o.color),onDragOver:l=>l.preventDefault(),onDrop:l=>a(l,o.status),children:[e.jsxs("div",{className:"px-4 py-3 flex items-center gap-2",children:[e.jsx(o.icon,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold text-sm",children:o.label}),e.jsx(tt,{variant:"secondary",className:"ml-auto text-xs",children:r[o.status].length})]}),e.jsxs("div",{className:"p-2 space-y-2 min-h-[200px]",children:[r[o.status].map(l=>e.jsx(DNs,{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 DNs({task:t,onDragStart:s}){const r=t.status==="done",n=!r&&t.due_date&&b0(jm(t.due_date))&&!bu(jm(t.due_date)),a=!r&&t.due_date&&bu(jm(t.due_date));return e.jsx("div",{draggable:!0,onDragStart:o=>s(o,t.id),className:It("bg-background border rounded-lg p-3 cursor-grab active:cursor-grabbing shadow-sm hover:shadow-md transition-shadow",n&&"border-destructive/50"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs mt-0.5",children:INs[t.priority]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:It("text-sm font-medium",r&&"line-through text-muted-foreground"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[t.deal&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(ka,{className:"h-2.5 w-2.5"}),t.deal.deal_name]}),t.contact&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(to,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]}),t.due_date&&e.jsxs("div",{className:It("text-[10px] mt-1.5 flex items-center gap-1",n&&"text-destructive font-medium",a&&"text-amber-600 font-medium",!n&&!a&&"text-muted-foreground"),children:[e.jsx(un,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",ms(jm(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 fze={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function ONs({tasks:t}){const[s,r]=N.useState(new Date),n=cCe(),a=Fc(s),o=lx(s),l=Xh(a),i=Jde(o),c=g4t({start:l,end:i}),u=N.useMemo(()=>{const g=new Map;return t.forEach(b=>{if(!b.due_date)return;const _=b.due_date,j=g.get(_)||[];j.push(b),g.set(_,j)}),g},[t]),p=N.useMemo(()=>t.filter(g=>!g.due_date),[t]),f=async g=>{const b=g.status==="done"?"todo":"done";try{await n.mutateAsync({id:g.id,status:b})}catch{me.error("Failed to update task")}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(y4(s,1)),children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold",children:ms(s,"MMMM yyyy")}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(Bm(s,1)),children:e.jsx(da,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"grid grid-cols-7 text-center",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(g=>e.jsx("div",{className:"text-xs font-medium text-muted-foreground py-2",children:g},g))}),e.jsx("div",{className:"grid grid-cols-7 border-l border-t",children:c.map(g=>{const b=ms(g,"yyyy-MM-dd"),_=u.get(b)||[],j=tue(g,s),w=bu(g);return e.jsxs("div",{className:It("border-r border-b min-h-[100px] p-1",!j&&"bg-muted/30",w&&"bg-primary/5"),children:[e.jsx("div",{className:It("text-xs font-medium mb-1 text-right px-1",!j&&"text-muted-foreground/40",w&&"text-primary font-bold"),children:ms(g,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[_.slice(0,3).map(k=>e.jsxs("button",{onClick:()=>f(k),className:It("w-full text-left text-[10px] px-1 py-0.5 rounded truncate flex items-center gap-0.5 hover:bg-muted transition-colors",k.status==="done"?"text-muted-foreground line-through":"text-foreground"),children:[k.status==="done"?e.jsx(sa,{className:"h-2.5 w-2.5 text-emerald-500 shrink-0"}):e.jsx(bd,{className:"h-2.5 w-2.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[fze[k.priority]," ",k.title]})]},k.id)),_.length>3&&e.jsxs("p",{className:"text-[9px] text-muted-foreground text-center",children:["+",_.length-3," more"]})]})]},b)})}),p.length>0&&e.jsxs("div",{className:"border rounded-lg p-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:["No Due Date (",p.length,")"]}),e.jsx("div",{className:"space-y-1",children:p.map(g=>e.jsxs("button",{onClick:()=>f(g),className:It("w-full text-left text-xs px-2 py-1.5 rounded flex items-center gap-2 hover:bg-muted transition-colors",g.status==="done"&&"opacity-50 line-through"),children:[g.status==="done"?e.jsx(sa,{className:"h-3.5 w-3.5 text-emerald-500 shrink-0"}):e.jsx(bd,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[fze[g.priority]," ",g.title]}),g.deal&&e.jsxs("span",{className:"text-muted-foreground ml-auto shrink-0",children:["• ",g.deal.deal_name]})]},g.id))})]})]})}const RNs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function FNs({open:t,onOpenChange:s,stages:r}){var k;const[n,a]=N.useState(((k=r[0])==null?void 0:k.id)||""),{data:o,isLoading:l}=yNs(n||void 0),i=vNs(),c=bNs(),[u,p]=N.useState(""),[f,g]=N.useState("medium"),[b,_]=N.useState(""),j=async()=>{if(!(!u.trim()||!n))try{await i.mutateAsync({stage_id:n,title:u.trim(),priority:f,default_due_offset_days:b?parseInt(b):null,sort_order:((o==null?void 0:o.length)||0)+1}),p(""),_(""),me.success("Template added")}catch{me.error("Failed to add template")}},w=async S=>{try{await c.mutateAsync(S),me.success("Template deleted")}catch{me.error("Failed to delete template")}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[560px]",children:[e.jsx(_s,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(rL,{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(S=>!S.is_won_stage&&!S.is_lost_stage).map(S=>e.jsx("button",{onClick:()=>a(S.id),className:It("px-3 py-1.5 rounded-full text-xs font-medium border transition-colors",n===S.id?"border-primary bg-primary/10 text-primary":"border-border hover:bg-muted"),children:S.name},S.id))})]}),e.jsx(Gi,{className:"max-h-[250px]",children:e.jsxs("div",{className:"space-y-1.5",children:[o==null?void 0:o.map((S,M)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border rounded-lg group",children:[e.jsx("span",{className:"text-xs",children:RNs[S.priority]}),e.jsx("span",{className:"text-sm flex-1 truncate",children:S.title}),S.default_due_offset_days&&e.jsxs(tt,{variant:"outline",className:"text-[10px]",children:["+",S.default_due_offset_days,"d"]}),e.jsx("button",{onClick:()=>w(S.id),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]},S.id)),(o==null?void 0:o.length)===0&&n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No templates for this stage yet"})]})}),n&&e.jsxs("div",{className:"space-y-3 border-t pt-3",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Add Template Task"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Task title...",value:u,onChange:S=>p(S.target.value),className:"flex-1",onKeyDown:S=>S.key==="Enter"&&j()}),e.jsxs(Zs,{value:f,onValueChange:S=>g(S),children:[e.jsx(Ws,{className:"w-[100px]",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"low",children:"🟢 Low"}),e.jsx(Mt,{value:"medium",children:"🟡 Med"}),e.jsx(Mt,{value:"high",children:"🟠 High"}),e.jsx(Mt,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ve,{className:"text-xs",children:"Due offset (days from entering stage)"}),e.jsx(ze,{type:"number",placeholder:"e.g., 7",value:b,onChange:S=>_(S.target.value)})]}),e.jsxs(K,{onClick:j,disabled:!u.trim()||i.isPending,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function zNs(){const{data:t,isLoading:s}=hNs(),{data:r}=Whe(),[n,a]=N.useState("list"),[o,l]=N.useState(""),[i,c]=N.useState("active"),[u,p]=N.useState("all"),[f,g]=N.useState("all"),[b,_]=N.useState(!1),[j,w]=N.useState(!1),k=N.useMemo(()=>{if(!t)return[];const L=new Map;return t.forEach(I=>{I.deal&&L.set(I.deal.id,I.deal.deal_name)}),Array.from(L,([I,O])=>({id:I,name:O}))},[t]),S=N.useMemo(()=>t?t.filter(L=>{var V,Z,X,ee;const I=o.toLowerCase(),O=!I||L.title.toLowerCase().includes(I)||((Z=(V=L.deal)==null?void 0:V.deal_name)==null?void 0:Z.toLowerCase().includes(I))||`${((X=L.contact)==null?void 0:X.first_name)||""} ${((ee=L.contact)==null?void 0:ee.last_name)||""}`.toLowerCase().includes(I),q=i==="all"||i==="active"&&L.status!=="done"||i==="todo"&&L.status==="todo"||i==="in_progress"&&L.status==="in_progress"||i==="done"&&L.status==="done"||i==="overdue"&&L.status!=="done"&&L.due_date&&b0(jm(L.due_date))&&!bu(jm(L.due_date)),U=u==="all"||L.priority===u,B=f==="all"||f==="no_deal"&&!L.deal_id||L.deal_id===f;return O&&q&&U&&B}):[],[t,o,i,u,f]),M=N.useMemo(()=>{if(!t)return{total:0,overdue:0,dueToday:0,dueThisWeek:0,completed:0};const L=t.filter(I=>I.status!=="done");return{total:L.length,overdue:L.filter(I=>I.due_date&&b0(jm(I.due_date))&&!bu(jm(I.due_date))).length,dueToday:L.filter(I=>I.due_date&&bu(jm(I.due_date))).length,dueThisWeek:L.filter(I=>I.due_date&&mCt(jm(I.due_date))).length,completed:t.filter(I=>I.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(Xg,{className:"h-4 w-4 mr-1"}),"Templates"]}),e.jsxs(K,{size:"sm",onClick:()=>_(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"New Task"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsxs("button",{onClick:()=>c("active"),className:`p-3 rounded-lg border text-left transition-colors ${i==="active"?"border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs font-medium",children:[e.jsx(Mh,{className:"h-3.5 w-3.5"}),"Active"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:M.total})]}),e.jsxs("button",{onClick:()=>c("overdue"),className:`p-3 rounded-lg border text-left transition-colors ${i==="overdue"?"border-destructive bg-destructive/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-destructive text-xs font-medium",children:[e.jsx(Ku,{className:"h-3.5 w-3.5"}),"Overdue"]}),e.jsx("p",{className:"text-xl font-bold mt-1 text-destructive",children:M.overdue})]}),e.jsxs("button",{onClick:()=>{c("active")},className:"p-3 rounded-lg border text-left hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-xs font-medium",children:[e.jsx(un,{className:"h-3.5 w-3.5"}),"Due Today"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:M.dueToday})]}),e.jsxs("button",{onClick:()=>{c("active")},className:"p-3 rounded-lg border text-left hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 text-blue-600 text-xs font-medium",children:[e.jsx(Dd,{className:"h-3.5 w-3.5"}),"This Week"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:M.dueThisWeek})]}),e.jsxs("button",{onClick:()=>c("done"),className:`p-3 rounded-lg border text-left transition-colors ${i==="done"?"border-emerald-500 bg-emerald-500/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-emerald-600 text-xs font-medium",children:[e.jsx(sa,{className:"h-3.5 w-3.5"}),"Completed"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:M.completed})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 items-start md:items-center",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search tasks...",value:o,onChange:L=>l(L.target.value),className:"pl-9"})]}),e.jsxs(Zs,{value:u,onValueChange:p,children:[e.jsx(Ws,{className:"w-[130px]",children:e.jsx(Xs,{placeholder:"Priority"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Priorities"}),e.jsx(Mt,{value:"urgent",children:"🔴 Urgent"}),e.jsx(Mt,{value:"high",children:"🟠 High"}),e.jsx(Mt,{value:"medium",children:"🟡 Medium"}),e.jsx(Mt,{value:"low",children:"🟢 Low"})]})]}),e.jsxs(Zs,{value:f,onValueChange:g,children:[e.jsx(Ws,{className:"w-[160px]",children:e.jsx(Xs,{placeholder:"Deal"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Deals"}),e.jsx(Mt,{value:"no_deal",children:"No Deal"}),k.map(L=>e.jsx(Mt,{value:L.id,children:L.name},L.id))]})]}),e.jsxs("div",{className:"flex items-center border rounded-lg p-0.5 ml-auto",children:[e.jsx("button",{onClick:()=>a("list"),className:`p-1.5 rounded-md transition-colors ${n==="list"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(Mh,{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(h0,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>a("calendar"),className:`p-1.5 rounded-md transition-colors ${n==="calendar"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(Dd,{className:"h-4 w-4"})})]})]}),s?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-primary border-t-transparent rounded-full"})}):e.jsxs(e.Fragment,{children:[n==="list"&&e.jsx(ENs,{tasks:S}),n==="kanban"&&e.jsx(LNs,{tasks:S}),n==="calendar"&&e.jsx(ONs,{tasks:S})]}),e.jsx(mlt,{open:b,onOpenChange:_}),e.jsx(FNs,{open:j,onOpenChange:w,stages:r||[]})]})})}const owe=[{value:"video_intro",label:"Video Intro",icon:An,description:"Add an intro video"},{value:"testimonials",label:"Testimonials",icon:pL,description:"Client testimonials carousel"},{value:"specialties",label:"Specialties",icon:Fm,description:"Tags for your specialties"},{value:"custom_links",label:"Custom Links",icon:dl,description:"Custom CTA buttons"},{value:"social_media",label:"Social Media",icon:_d,description:"Links to your social profiles"}],BNs=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],$Ns={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function plt({cardId:t}){const{data:s,isLoading:r}=hkt(t),n=mkt(),a=pkt(),o=fkt(),[l,i]=N.useState(!1),[c,u]=N.useState(""),[p,f]=N.useState(null);if(r)return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ys,{className:"h-16 w-full"}),e.jsx(ys,{className:"h-16 w-full"})]});const g=()=>{c&&n.mutate({card_id:t,block_type:c,sort_order:(s==null?void 0:s.length)||0,config:$Ns[c]||{}},{onSuccess:()=>{i(!1),u("")}})},b=S=>{a.mutate({id:S.id,is_visible:!S.is_visible})},_=(S,M)=>{if(!s)return;const L=s.findIndex(q=>q.id===S.id),I=M==="up"?L-1:L+1;if(I<0||I>=s.length)return;const O=s[I];a.mutate({id:S.id,sort_order:O.sort_order}),a.mutate({id:O.id,sort_order:S.sort_order})},j=S=>{confirm("Remove this block from this card?")&&o.mutate(S.id)},w=(S,M)=>{a.mutate({id:S.id,config:M},{onSuccess:()=>f(null)})},k=S=>owe.find(M=>M.value===S);return e.jsxs("div",{className:"space-y-3",children:[!s||s.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted-foreground mb-4 text-sm",children:"No blocks yet. Add a block to customize this card."}),e.jsxs(K,{size:"sm",onClick:()=>i(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Add Block"]})]}):e.jsxs(e.Fragment,{children:[s.map((S,M)=>{const L=k(S.block_type),I=(L==null?void 0:L.icon)||Fm;return e.jsx(Ee,{className:S.is_visible?"":"opacity-50",children:e.jsx(De,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx(I,{className:"h-4 w-4 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs",children:(L==null?void 0:L.label)||S.block_type}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:qNs(S)})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(S,"up"),disabled:M===0,children:e.jsx(ku,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(S,"down"),disabled:M===s.length-1,children:e.jsx(Wh,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(S),children:S.is_visible?e.jsx(On,{className:"h-3 w-3"}):e.jsx(kp,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>f(S),children:"Edit"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>j(S),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]})})},S.id)}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>i(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Add Block"]})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Add Block"})}),e.jsx("div",{className:"grid gap-3",children:owe.map(S=>{const M=S.icon;return e.jsxs("button",{onClick:()=>u(S.value),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors ${c===S.value?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[e.jsx(M,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:S.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.description})]})]},S.value)})}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{onClick:g,disabled:!c||n.isPending,children:"Add Block"})]})]})}),p&&e.jsx(UNs,{block:p,onSave:S=>w(p,S),onClose:()=>f(null)})]})}function qNs(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 UNs({block:t,onSave:s,onClose:r}){const[n,a]=N.useState(t.config),o=owe.find(l=>l.value===t.block_type);return e.jsx(fs,{open:!0,onOpenChange:r,children:e.jsxs(ps,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsxs(vs,{children:["Edit ",o==null?void 0:o.label]})}),t.block_type==="video_intro"&&e.jsx(VNs,{config:n,onChange:a,cardId:t.card_id}),t.block_type==="testimonials"&&e.jsx(HNs,{config:n,onChange:a}),t.block_type==="specialties"&&e.jsx(WNs,{config:n,onChange:a}),t.block_type==="custom_links"&&e.jsx(GNs,{config:n,onChange:a}),t.block_type==="social_media"&&e.jsx(KNs,{config:n,onChange:a}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(K,{onClick:()=>s(n),children:"Save"})]})]})})}function VNs({config:t,onChange:s,cardId:r}){var b,_;const[n,a]=N.useState(""),[o,l]=N.useState((b=t.video_url)!=null&&b.includes("youtube")||(_=t.video_url)!=null&&_.includes("youtu.be")?"youtube":"library"),{data:i}=mt({queryKey:["card-owner",r],queryFn:async()=>{const{data:j}=await H.from("agent_cards").select("user_id").eq("id",r).single();return j==null?void 0:j.user_id},enabled:!!r}),{data:c,isLoading:u}=mt({queryKey:["agent-videos-library",i],queryFn:async()=>{const{data:j,error:w}=await H.from("agent_videos").select("id, title, bunny_video_id, thumbnail_url, playback_url, created_at").eq("owner_user_id",i).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(w)throw w;return j||[]},enabled:!!i}),p=(c==null?void 0:c.filter(j=>!n||(j.title||"").toLowerCase().includes(n.toLowerCase())))||[],f=t.bunny_video_id,g=j=>{var M;const w=(M=j.playback_url)==null?void 0:M.match(/\/(?:play|embed)\/(\d+)\//),S=`https://iframe.mediadelivery.net/embed/${w?w[1]:"570924"}/${j.bunny_video_id}?autoplay=false&responsive=true`;s({...t,video_url:S,bunny_video_id:j.bunny_video_id,video_source:"library"})};return e.jsx("div",{className:"space-y-4",children:e.jsxs(ba,{value:o,onValueChange:l,children:[e.jsxs(pa,{className:"w-full",children:[e.jsx(ns,{value:"library",className:"flex-1",children:"Video Library"}),e.jsx(ns,{value:"youtube",className:"flex-1",children:"YouTube URL"})]}),e.jsxs(bs,{value:"library",className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search videos...",value:n,onChange:j=>a(j.target.value),className:"pl-9"})]}),e.jsx(Gi,{className:"h-[240px]",children:u?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ys,{className:"h-14 w-full"}),e.jsx(ys,{className:"h-14 w-full"})]}):p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:(c==null?void 0:c.length)===0?"No videos in library yet":"No matching videos"}):e.jsx("div",{className:"space-y-1.5 pr-3",children:p.map(j=>e.jsxs("button",{onClick:()=>g(j),className:`w-full flex items-center gap-3 p-2 rounded-lg border text-left transition-colors ${f===j.bunny_video_id?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[j.thumbnail_url?e.jsx("img",{src:j.thumbnail_url,alt:"",className:"h-10 w-16 rounded object-cover flex-shrink-0 bg-muted",onError:w=>{var k;w.currentTarget.style.display="none",(k=w.currentTarget.nextElementSibling)==null||k.classList.remove("hidden")}}):null,e.jsx("div",{className:`h-10 w-16 rounded bg-muted flex items-center justify-center flex-shrink-0 ${j.thumbnail_url?"hidden":""}`,children:e.jsx(An,{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(va,{className:"h-4 w-4 text-primary flex-shrink-0"})]},j.id))})})]}),e.jsx(bs,{value:"youtube",className:"space-y-3 mt-3",children:e.jsxs("div",{children:[e.jsx(ve,{children:"YouTube URL"}),e.jsx(ze,{placeholder:"https://www.youtube.com/watch?v=...",value:t.video_source==="youtube"&&t.video_url||"",onChange:j=>s({...t,video_url:j.target.value,bunny_video_id:null,video_source:"youtube"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Paste a YouTube video link"})]})})]})})}function HNs({config:t,onChange:s}){const r=t.testimonials||[],n=(l,i,c)=>{const u=[...r];u[l]={...u[l],[i]:c},s({...t,testimonials:u})},a=()=>s({...t,testimonials:[...r,{name:"",quote:"",role:""}]}),o=l=>s({...t,testimonials:r.filter((i,c)=>c!==l)});return e.jsxs("div",{className:"space-y-4",children:[r.map((l,i)=>e.jsx(Ee,{children:e.jsxs(De,{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(Nr,{className:"h-3 w-3"})})]}),e.jsx(ze,{placeholder:"Client name",value:l.name,onChange:c=>n(i,"name",c.target.value)}),e.jsx(ze,{placeholder:"Role/title (optional)",value:l.role||"",onChange:c=>n(i,"role",c.target.value)}),e.jsx("textarea",{className:"w-full min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm",placeholder:"Their testimonial quote...",value:l.quote,onChange:c=>n(i,"quote",c.target.value)})]})},i)),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Add Testimonial"]})]})}function WNs({config:t,onChange:s}){const r=t.tags||[],[n,a]=N.useState(""),o=i=>{s({...t,tags:r.includes(i)?r.filter(c=>c!==i):[...r,i]})},l=()=>{n.trim()&&!r.includes(n.trim())&&(s({...t,tags:[...r,n.trim()]}),a(""))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm mb-2 block",children:"Preset Specialties"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:BNs.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(ze,{placeholder:"Add your own...",value:n,onChange:i=>a(i.target.value),onKeyDown:i=>i.key==="Enter"&&(i.preventDefault(),l())}),e.jsx(K,{variant:"outline",size:"sm",onClick:l,children:"Add"})]})]}),r.length>0&&e.jsxs("div",{children:[e.jsxs(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 GNs({config:t,onChange:s}){const r=t.links||[],n=(l,i,c)=>{const u=[...r];u[l]={...u[l],[i]:c},s({...t,links:u})},a=()=>s({...t,links:[...r,{label:"",url:""}]}),o=l=>s({...t,links:r.filter((i,c)=>c!==l)});return e.jsxs("div",{className:"space-y-3",children:[r.map((l,i)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ze,{placeholder:"Button label",value:l.label,onChange:c=>n(i,"label",c.target.value)}),e.jsx(ze,{placeholder:"https://...",value:l.url,onChange:c=>n(i,"url",c.target.value)})]}),r.length>1&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 mt-1 text-destructive",onClick:()=>o(i),children:e.jsx(Nr,{className:"h-3 w-3"})})]},i)),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Add Link"]})]})}const xze=[{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 KNs({config:t,onChange:s}){const r=t.platforms||[],n=c=>{r.find(u=>u.platform===c)||s({...t,platforms:[...r,{platform:c,url:""}]})},a=(c,u)=>{const p=[...r];p[c]={...p[c],url:u},s({...t,platforms:p})},o=c=>{s({...t,platforms:r.filter((u,p)=>p!==c)})},l=xze.filter(c=>!r.find(u=>u.platform===c.value)),i=c=>{const u=Eve[c],p=xze.find(f=>f.value===c);return{label:(p==null?void 0:p.label)||c,color:(u==null?void 0:u.color)||"#666",iconPath:u==null?void 0:u.icon}};return e.jsxs("div",{className:"space-y-4",children:[r.length>0&&e.jsx("div",{className:"space-y-3",children:r.map((c,u)=>{const p=i(c.platform);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg flex items-center justify-center flex-shrink-0 border",style:{borderColor:p.color+"30",backgroundColor:p.color+"10"},children:p.iconPath&&e.jsx("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:p.color,children:e.jsx("path",{d:p.iconPath})})}),e.jsx("div",{className:"flex-1",children:e.jsx(ze,{placeholder:`Your ${p.label} profile URL`,value:c.url,onChange:f=>a(u,f.target.value)})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive flex-shrink-0",onClick:()=>o(u),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]},u)})}),l.length>0&&e.jsxs("div",{children:[e.jsx(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(c=>{const u=Eve[c.value];return e.jsxs("button",{onClick:()=>n(c.value),className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-full border border-border bg-muted hover:bg-muted/80 transition-colors",children:[(u==null?void 0:u.icon)&&e.jsx("svg",{viewBox:"0 0 24 24",width:12,height:12,fill:u.color,children:e.jsx("path",{d:u.icon})}),c.label]},c.value)})})]}),r.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Tap a platform above to add your social media profile."})]})}var ZNs=Object.defineProperty,ede=Object.getOwnPropertySymbols,flt=Object.prototype.hasOwnProperty,xlt=Object.prototype.propertyIsEnumerable,gze=(t,s,r)=>s in t?ZNs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,lwe=(t,s)=>{for(var r in s||(s={}))flt.call(s,r)&&gze(t,r,s[r]);if(ede)for(var r of ede(s))xlt.call(s,r)&&gze(t,r,s[r]);return t},cwe=(t,s)=>{var r={};for(var n in t)flt.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&ede)for(var n of ede(t))s.indexOf(n)<0&&xlt.call(t,n)&&(r[n]=t[n]);return r};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var dC;(t=>{const s=class po{constructor(c,u,p,f){if(this.version=c,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],cpo.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let g=[];for(let _=0;_7)throw new RangeError("Invalid value");let _,j;for(_=p;;_++){const M=po.getNumDataCodewords(_,u)*8,L=l.getTotalBits(c,_);if(L<=M){j=L;break}if(_>=f)throw new RangeError("Data too long")}for(const M of[po.Ecc.MEDIUM,po.Ecc.QUARTILE,po.Ecc.HIGH])b&&j<=po.getNumDataCodewords(_,M)*8&&(u=M);let w=[];for(const M of c){r(M.mode.modeBits,4,w),r(M.numChars,M.mode.numCharCountBits(_),w);for(const L of M.getData())w.push(L)}a(w.length==j);const k=po.getNumDataCodewords(_,u)*8;a(w.length<=k),r(0,Math.min(4,k-w.length),w),r(0,(8-w.length%8)%8,w),a(w.length%8==0);for(let M=236;w.lengthS[L>>>3]|=M<<7-(L&7)),new po(_,u,S,g)}getModule(c,u){return 0<=c&&c>>9)*1335;const f=(u<<10|p)^21522;a(f>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,n(f,g));this.setFunctionModule(8,7,n(f,6)),this.setFunctionModule(8,8,n(f,7)),this.setFunctionModule(7,8,n(f,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,n(f,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,n(f,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,n(f,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let p=0;p<12;p++)c=c<<1^(c>>>11)*7973;const u=this.version<<12|c;a(u>>>18==0);for(let p=0;p<18;p++){const f=n(u,p),g=this.size-11+p%3,b=Math.floor(p/3);this.setFunctionModule(g,b,f),this.setFunctionModule(b,g,f)}}drawFinderPattern(c,u){for(let p=-4;p<=4;p++)for(let f=-4;f<=4;f++){const g=Math.max(Math.abs(f),Math.abs(p)),b=c+f,_=u+p;0<=b&&b{(M!=j-g||I>=_)&&S.push(L[M])});return a(S.length==b),S}drawCodewords(c){if(c.length!=Math.floor(po.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let f=0;f>>3],7-(u&7)),u++)}}a(u==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let u=0;u5&&c++):(this.finderPenaltyAddHistory(_,j),b||(c+=this.finderPenaltyCountPatterns(j)*po.PENALTY_N3),b=this.modules[g][w],_=1);c+=this.finderPenaltyTerminateAndCount(b,_,j)*po.PENALTY_N3}for(let g=0;g5&&c++):(this.finderPenaltyAddHistory(_,j),b||(c+=this.finderPenaltyCountPatterns(j)*po.PENALTY_N3),b=this.modules[w][g],_=1);c+=this.finderPenaltyTerminateAndCount(b,_,j)*po.PENALTY_N3}for(let g=0;gb+(_?1:0),u);const p=this.size*this.size,f=Math.ceil(Math.abs(u*20-p*10)/p)-1;return a(0<=f&&f<=9),c+=f*po.PENALTY_N4,a(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let p=[6];for(let f=this.size-7;p.lengthpo.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*c+128)*c+64;if(c>=2){const p=Math.floor(c/7)+2;u-=(25*p-10)*p-55,c>=7&&(u-=36)}return a(208<=u&&u<=29648),u}static getNumDataCodewords(c,u){return Math.floor(po.getNumRawDataModules(c)/8)-po.ECC_CODEWORDS_PER_BLOCK[u.ordinal][c]*po.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let u=[];for(let f=0;f0);for(const f of c){const g=f^p.shift();p.push(0),u.forEach((b,_)=>p[_]^=po.reedSolomonMultiply(b,g))}return p}static reedSolomonMultiply(c,u){if(c>>>8||u>>>8)throw new RangeError("Byte out of range");let p=0;for(let f=7;f>=0;f--)p=p<<1^(p>>>7)*285,p^=(u>>>f&1)*c;return a(p>>>8==0),p}finderPenaltyCountPatterns(c){const u=c[1];a(u<=this.size*3);const p=u>0&&c[2]==u&&c[3]==u*3&&c[4]==u&&c[5]==u;return(p&&c[0]>=u*4&&c[6]>=u?1:0)+(p&&c[6]>=u*4&&c[0]>=u?1:0)}finderPenaltyTerminateAndCount(c,u,p){return c&&(this.finderPenaltyAddHistory(u,p),u=0),u+=this.size,this.finderPenaltyAddHistory(u,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(c,u){u[0]==0&&(c+=this.size),u.pop(),u.unshift(c)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=s;function r(i,c,u){if(c<0||c>31||i>>>c)throw new RangeError("Value out of range");for(let p=c-1;p>=0;p--)u.push(i>>>p&1)}function n(i,c){return(i>>>c&1)!=0}function a(i){if(!i)throw new Error("Assertion error")}const o=class cd{constructor(c,u,p){if(this.mode=c,this.numChars=u,this.bitData=p,u<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(c){let u=[];for(const p of c)r(p,8,u);return new cd(cd.Mode.BYTE,c.length,u)}static makeNumeric(c){if(!cd.isNumeric(c))throw new RangeError("String contains non-numeric characters");let u=[];for(let p=0;p=1<{(s=>{const r=class{constructor(a,o){this.ordinal=a,this.formatBits=o}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(t.QrCode||(t.QrCode={}))})(dC||(dC={}));(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={}))})(dC||(dC={}));var gM=dC;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var YNs={L:gM.QrCode.Ecc.LOW,M:gM.QrCode.Ecc.MEDIUM,Q:gM.QrCode.Ecc.QUARTILE,H:gM.QrCode.Ecc.HIGH},glt=128,ylt="L",vlt="#FFFFFF",blt="#000000",_lt=!1,wlt=1,XNs=4,QNs=0,JNs=.1;function jlt(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 Nlt(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 eks(t,s,r,n){if(n==null)return null;const a=t.length+r*2,o=Math.floor(s*JNs),l=a/s,i=(n.width||o)*l,c=(n.height||o)*l,u=n.x==null?t.length/2-i/2:n.x*l,p=n.y==null?t.length/2-c/2:n.y*l,f=n.opacity==null?1:n.opacity;let g=null;if(n.excavate){let _=Math.floor(u),j=Math.floor(p),w=Math.ceil(i+u-_),k=Math.ceil(c+p-j);g={x:_,y:j,w,h:k}}const b=n.crossOrigin;return{x:u,y:p,h:c,w:i,excavation:g,opacity:f,crossOrigin:b}}function tks(t,s){return s!=null?Math.max(Math.floor(s),0):t?XNs:QNs}function klt({value:t,level:s,minVersion:r,includeMargin:n,marginSize:a,imageSettings:o,size:l,boostLevel:i}){let c=ht.useMemo(()=>{const _=(Array.isArray(t)?t:[t]).reduce((j,w)=>(j.push(...gM.QrSegment.makeSegments(w)),j),[]);return gM.QrCode.encodeSegments(_,YNs[s],r,void 0,void 0,i)},[t,s,r,i]);const{cells:u,margin:p,numCells:f,calculatedImageSettings:g}=ht.useMemo(()=>{let b=c.getModules();const _=tks(n,a),j=b.length+_*2,w=eks(b,l,_,o);return{cells:b,margin:_,numCells:j,calculatedImageSettings:w}},[c,l,o,n,a]);return{qrcode:c,margin:p,cells:u,numCells:f,calculatedImageSettings:g}}var sks=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),rks=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=glt,level:l=ylt,bgColor:i=vlt,fgColor:c=blt,includeMargin:u=_lt,minVersion:p=wlt,boostLevel:f,marginSize:g,imageSettings:b}=n,j=cwe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:w}=j,k=cwe(j,["style"]),S=b==null?void 0:b.src,M=ht.useRef(null),L=ht.useRef(null),I=ht.useCallback(Q=>{M.current=Q,typeof r=="function"?r(Q):r&&(r.current=Q)},[r]),[O,q]=ht.useState(!1),{margin:U,cells:B,numCells:V,calculatedImageSettings:Z}=klt({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:g,imageSettings:b,size:o});ht.useEffect(()=>{if(M.current!=null){const Q=M.current,ie=Q.getContext("2d");if(!ie)return;let re=B;const oe=L.current,ce=Z!=null&&oe!==null&&oe.complete&&oe.naturalHeight!==0&&oe.naturalWidth!==0;ce&&Z.excavation!=null&&(re=Nlt(B,Z.excavation));const xe=window.devicePixelRatio||1;Q.height=Q.width=o*xe;const ge=o/V*xe;ie.scale(ge,ge),ie.fillStyle=i,ie.fillRect(0,0,V,V),ie.fillStyle=c,sks?ie.fill(new Path2D(jlt(re,U))):B.forEach(function(ue,pe){ue.forEach(function(be,Me){be&&ie.fillRect(Me+U,pe+U,1,1)})}),Z&&(ie.globalAlpha=Z.opacity),ce&&ie.drawImage(oe,Z.x+U,Z.y+U,Z.w,Z.h)}}),ht.useEffect(()=>{q(!1)},[S]);const X=lwe({height:o,width:o},w);let ee=null;return S!=null&&(ee=ht.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{q(!0)},ref:L,crossOrigin:Z==null?void 0:Z.crossOrigin})),ht.createElement(ht.Fragment,null,ht.createElement("canvas",lwe({style:X,height:o,width:o,ref:I,role:"img"},k)),ee)});rks.displayName="QRCodeCanvas";var kR=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=glt,level:l=ylt,bgColor:i=vlt,fgColor:c=blt,includeMargin:u=_lt,minVersion:p=wlt,boostLevel:f,title:g,marginSize:b,imageSettings:_}=n,j=cwe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:w,cells:k,numCells:S,calculatedImageSettings:M}=klt({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:b,imageSettings:_,size:o});let L=k,I=null;_!=null&&M!=null&&(M.excavation!=null&&(L=Nlt(k,M.excavation)),I=ht.createElement("image",{href:_.src,height:M.h,width:M.w,x:M.x+w,y:M.y+w,preserveAspectRatio:"none",opacity:M.opacity,crossOrigin:M.crossOrigin}));const O=jlt(L,w);return ht.createElement("svg",lwe({height:o,width:o,viewBox:`0 0 ${S} ${S}`,ref:r,role:"img"},j),!!g&&ht.createElement("title",null,g),ht.createElement("path",{fill:i,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),ht.createElement("path",{fill:c,d:O,shapeRendering:"crispEdges"}),I)});kR.displayName="QRCodeSVG";function nks({slug:t,agentName:s}){const r=N.useRef(null),n=`https://cards.relevelup.com/${t}`,a=N.useCallback(()=>{var f;const o=(f=r.current)==null?void 0:f.querySelector("svg");if(!o)return;const l=document.createElement("canvas"),i=1024;l.width=i,l.height=i;const c=l.getContext("2d");if(!c)return;const u=new XMLSerializer().serializeToString(o),p=new Image;p.onload=()=>{c.fillStyle="#ffffff",c.fillRect(0,0,i,i),c.drawImage(p,0,0,i,i);const g=document.createElement("a");g.download=`${t}-qr-code.png`,g.href=l.toDataURL("image/png"),g.click(),me.success("QR code downloaded!")},p.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(u)))},[t]);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(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(kR,{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(yi,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function Cye(t){return{is_published:t.is_published,theme:t.theme,title:t.title||"",positioning_statement:t.positioning_statement||"",bio:t.bio||"",review_snippet:t.review_snippet||"",review_source_url:t.review_source_url||"",booking_url:t.booking_url||"",custom_cta_label:t.custom_cta_label||"",show_photo:t.show_photo,show_bio:t.show_bio,show_credentials:t.show_credentials,show_social_links:t.show_social_links,show_save_contact:t.show_save_contact,show_leave_review:t.show_leave_review,show_refer_friend:t.show_refer_friend,brokerage_display_name:t.brokerage_display_name||"",brokerage_logo_url:t.brokerage_logo_url||"",brokerage_logo_size:t.brokerage_logo_size||56,team_name:t.team_name||"",team_logo_url:t.team_logo_url||"",team_logo_size:t.team_logo_size||56,bold_theme_colors:t.bold_theme_colors||null,display_email:t.display_email||""}}function aks(){const{user:t}=Ds(),{data:s,isLoading:r}=ckt(t==null?void 0:t.id),n=NE(),[a,o]=N.useState(null),l=N.useMemo(()=>a||(s?Cye(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(ys,{className:"h-8 w-48"}),e.jsx(ys,{className:"h-32 w-full"}),e.jsx(ys,{className:"h-32 w-full"})]})});if(!s)return e.jsx(Ms,{children:e.jsx(oks,{userId:t==null?void 0:t.id})});const i=l||Cye(s),c=u=>{o(p=>{const f=p||Cye(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(lks,{card:s}),e.jsx(hks,{card:s,form:i,setForm:c})]}),!n&&e.jsx("div",{className:"w-[400px] shrink-0","aria-hidden":"true"}),!n&&e.jsx("div",{className:"fixed right-8 top-[5.5rem] w-[400px] z-30",style:{height:"calc(100vh - 6.5rem)"},children:e.jsxs("div",{className:"rounded-xl border bg-muted/30 overflow-hidden h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b bg-card shrink-0",children:[e.jsx(cS,{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(iks,{card:s,form:i})})]})})]})})}function iks({card:t,form:s}){const{data:r}=mt({queryKey:["card-preview-profile",t.user_id],queryFn:async()=>{const{data:a}=await H.from("profiles").select("name, email, phone, avatar_url, brokerage_id").eq("id",t.user_id).single();let o=(a==null?void 0:a.avatar_url)||null;if(!o){const{data:l}=await H.storage.from("avatars").list(`${t.user_id}`);if(l&&l.length>0){const{data:i}=H.storage.from("avatars").getPublicUrl(`${t.user_id}/${l[0].name}`);o=`${i.publicUrl}?t=${Date.now()}`}}return{...a,avatar_url:o}}}),n=N.useMemo(()=>({...t,is_published:s.is_published,theme:s.theme,title:s.title||null,positioning_statement:s.positioning_statement||null,bio:s.bio||null,review_snippet:s.review_snippet||null,review_source_url:s.review_source_url||null,booking_url:s.booking_url||null,custom_cta_label:s.custom_cta_label||null,custom_cta_url:t.custom_cta_url,show_photo:s.show_photo,show_bio:s.show_bio,show_video:t.show_video,show_credentials:s.show_credentials,show_social_links:s.show_social_links,show_save_contact:s.show_save_contact,show_leave_review:s.show_leave_review,show_refer_friend:s.show_refer_friend,brokerage_display_name:s.brokerage_display_name||null,brokerage_logo_url:s.brokerage_logo_url||null,brokerage_logo_size:s.brokerage_logo_size,team_name:s.team_name||null,team_logo_url:s.team_logo_url||null,team_logo_size:s.team_logo_size,display_email:s.display_email||null,social_links:t.social_links||[],profile:{name:(r==null?void 0:r.name)||null,email:s.display_email||(r==null?void 0:r.email)||null,phone:(r==null?void 0:r.phone)||null,brokerage_id:(r==null?void 0:r.brokerage_id)||null},brokerage_name:s.brokerage_display_name||null,avatar_url:(r==null?void 0:r.avatar_url)||null}),[t,s,r]);return e.jsx("div",{className:"transform scale-[0.85] origin-top",children:e.jsx(dje,{card:n})})}function oks({userId:t}){var c;const[s,r]=N.useState(""),n=aGe(),{data:a}=mt({queryKey:["my-profile-for-card",t],queryFn:async()=>{if(!t)return null;const{data:u}=await H.from("profiles").select("name").eq("id",t).single();return u},enabled:!!t}),o=((c=a==null?void 0:a.name)==null?void 0:c.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||"",l=()=>{if(!t)return;const u=(s.trim()||o).toLowerCase().replace(/[^a-z0-9-]/g,"-");if(!u){me.error("Please enter a URL slug for your card");return}n.mutate({user_id:t,slug:u,is_published:!0},{onSuccess:()=>me.success("Your digital card has been created!")})},i=[{icon:su,title:"Shareable Link",desc:"One link that works everywhere"},{icon:Zh,title:"Lead Capture",desc:"Collect leads automatically"},{icon:th,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:ac,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(pn,{className:"h-3.5 w-3.5"}),"New Feature"]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-3 tracking-tight",children:"Your Digital Business Card"}),e.jsx("p",{className:"text-primary-foreground/80 text-lg max-w-md leading-relaxed",children:"Ditch the paper. Share a beautiful, interactive card that captures leads and makes a lasting impression."})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 mb-8",children:i.map(u=>e.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl border bg-card hover:shadow-md transition-shadow",children:[e.jsx("div",{className:"mt-0.5 p-2 rounded-lg bg-primary/10 shrink-0",children:e.jsx(u.icon,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:u.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u.desc})]})]},u.title))}),e.jsxs(Ee,{className:"shadow-lg border-2",children:[e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx(Rt,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(gr,{children:"Choose a URL slug — this is the link you'll share with clients"})]}),e.jsxs(De,{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(ze,{value:s||o,onChange:u=>r(u.target.value),placeholder:"your-name",className:"rounded-l-none"})]})]}),e.jsxs(K,{onClick:l,disabled:n.isPending,className:"w-full h-11 text-base font-semibold",size:"lg",children:[e.jsx(pn,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function lks({card:t}){const r=`https://cards.relevelup.com/${t.slug}`,n=()=>{navigator.clipboard.writeText(r),me.success("Card link copied!")};return e.jsx("div",{className:"rounded-xl border bg-card p-5",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-xl font-bold",children:"My Digital Card"}),e.jsx(tt,{variant:t.is_published?"default":"secondary",className:"text-[10px] uppercase tracking-wider",children:t.is_published?"Live":"Draft"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(su,{className:"h-3.5 w-3.5"}),"cards.relevelup.com/",t.slug]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[e.jsx(gi,{className:"h-3.5 w-3.5"})," Copy Link"]}),e.jsx(K,{size:"sm",asChild:!0,className:"gap-1.5",children:e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function cks({userId:t}){const s=Qt(),r=N.useRef(null),[n,a]=N.useState(!1),[o,l]=N.useState(""),{data:i,isLoading:c}=mt({queryKey:["card-editor-profile",t],queryFn:async()=>{const{data:Z}=await H.from("profiles").select("name, email, phone, avatar_url").eq("id",t).single();let X=(Z==null?void 0:Z.avatar_url)||null;if(!X){const{data:ee}=await H.storage.from("avatars").list(`${t}`);if(ee&&ee.length>0){const{data:Q}=H.storage.from("avatars").getPublicUrl(`${t}/${ee[0].name}`);X=`${Q.publicUrl}?t=${Date.now()}`,await H.from("profiles").update({avatar_url:X}).eq("id",t)}}return{...Z,avatar_url:X}}}),[u,p]=N.useState(null),[f,g]=N.useState(null),[b,_]=N.useState(null),[j,w]=N.useState(!1),k=u??(i==null?void 0:i.name)??"",S=f??(i==null?void 0:i.phone)??"",M=b??(i==null?void 0:i.email)??"",L=i==null?void 0:i.avatar_url,I=((i==null?void 0:i.name)||"A").split(" ").map(Z=>Z[0]).join("").toUpperCase().slice(0,2),O=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),q=Dt({mutationFn:async Z=>{const{error:X}=await H.from("profiles").update(Z).eq("id",t);if(X)throw X},onSuccess:()=>{s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),me.success("Profile updated!")},onError:()=>me.error("Failed to update profile")}),U=()=>{const Z={};if(u!==null&&u!==(i==null?void 0:i.name)&&(Z.name=u),f!==null&&f!==(i==null?void 0:i.phone)&&(Z.phone=f||null),b!==null&&b!==(i==null?void 0:i.email)&&(Z.email=b),Object.keys(Z).length===0){me.info("No changes to save");return}q.mutate(Z)},B=Z=>{var Q;const X=(Q=Z.target.files)==null?void 0:Q[0];if(!X)return;if(!X.type.startsWith("image/")){me.error("Please select an image file");return}const ee=new FileReader;ee.onloadend=()=>{l(ee.result),a(!0)},ee.readAsDataURL(X),Z.target.value=""},V=async Z=>{w(!0);try{const{data:X}=await H.storage.from("avatars").list(`${t}`);X&&X.length>0&&await H.storage.from("avatars").remove(X.map(oe=>`${t}/${oe.name}`));const ee=`${t}/avatar.jpg`,{error:Q}=await H.storage.from("avatars").upload(ee,Z,{upsert:!0,contentType:"image/jpeg"});if(Q)throw Q;const{data:ie}=H.storage.from("avatars").getPublicUrl(ee),re=ie.publicUrl+"?t="+Date.now();await H.from("profiles").update({avatar_url:re}).eq("id",t),s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),me.success("Photo updated!")}catch{me.error("Failed to upload photo")}finally{w(!1)}};return c?e.jsx(ys,{className:"h-32 w-full rounded-xl"}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:O?"border-amber-300 dark:border-amber-700":"",children:e.jsxs(De,{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"}),O&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400 font-medium",children:[e.jsx(kl,{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 Z;return(Z=r.current)==null?void 0:Z.click()},children:[e.jsxs(Nn,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx($a,{src:L||void 0,alt:k}),e.jsx(kn,{className:"text-lg font-semibold bg-primary/10 text-primary",children:I})]}),e.jsx("div",{className:"absolute inset-0 bg-black/40 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(kx,{className:"h-5 w-5 text-white"})}),e.jsx("input",{ref:r,type:"file",accept:"image/*",className:"hidden",onChange:B})]}),e.jsxs("div",{className:"flex-1 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:j?"Uploading...":L?"Tap to change photo":"Add a profile photo"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This photo appears on your card, profile, and community posts"})]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Full Name"}),e.jsx(ze,{value:k,onChange:Z=>p(Z.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(ze,{value:S,onChange:Z=>g(Z.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(ze,{value:M,onChange:Z=>_(Z.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:U,disabled:q.isPending,className:"w-full",children:q.isPending?"Saving...":"Update Profile Info"})]})}),e.jsx(_ke,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:V,aspectRatio:1})]})}function dks({form:t,setForm:s,userId:r}){const[n,a]=N.useState(null),[o,l]=N.useState(t.brokerage_logo_url?"logo":"name"),[i,c]=N.useState(t.team_logo_url?"logo":"name"),u=b=>{l(b),s(b==="name"?_=>({..._,brokerage_logo_url:""}):_=>({..._,brokerage_display_name:""}))},p=b=>{c(b),s(b==="name"?_=>({..._,team_logo_url:""}):_=>({..._,team_name:""}))},f=async(b,_)=>{var w;const j=(w=b.target.files)==null?void 0:w[0];if(j){if(!j.type.startsWith("image/")){me.error("Please select an image file");return}a(_);try{const k=j.name.split(".").pop()||"png",M=`${r}/${_==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${k}`,{error:L}=await H.storage.from("card-logos").upload(M,j,{upsert:!0});if(L)throw L;const{data:I}=H.storage.from("card-logos").getPublicUrl(M),O=I.publicUrl+"?t="+Date.now();s(_==="brokerage_logo_url"?q=>({...q,[_]:O,brokerage_display_name:""}):q=>({...q,[_]:O,team_name:""})),me.success("Logo uploaded!")}catch{me.error("Failed to upload logo")}finally{a(null),b.target.value=""}}},g=b=>{s(_=>({..._,[b]:""}))};return e.jsx(Ee,{children:e.jsxs(De,{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(ze,{value:t.brokerage_display_name,onChange:b=>s(_=>({..._,brokerage_display_name:b.target.value})),placeholder:"e.g. Keller Williams Realty",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(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:()=>g("brokerage_logo_url"),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}):null,e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(kx,{className:"h-3.5 w-3.5"}),n==="brokerage_logo_url"?"Uploading...":t.brokerage_logo_url?"Change":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:b=>f(b,"brokerage_logo_url"),disabled:n!==null})]})]}),t.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(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(Gg,{value:[t.brokerage_logo_size||56],onValueChange:([b])=>s(_=>({..._,brokerage_logo_size:b})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(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(ze,{value:t.team_name,onChange:b=>s(_=>({..._,team_name:b.target.value})),placeholder:"e.g. The Smith Group",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(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:()=>g("team_logo_url"),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}):null,e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(kx,{className:"h-3.5 w-3.5"}),n==="team_logo_url"?"Uploading...":t.team_logo_url?"Change":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:b=>f(b,"team_logo_url"),disabled:n!==null})]})]}),t.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(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(Gg,{value:[t.team_logo_size||56],onValueChange:([b])=>s(_=>({..._,team_logo_size:b})),min:24,max:120,step:4})]})]})]})]})})}function uks({form:t,setForm:s}){const r={accent:"#ff5722",dark:"#1a1a2e",button:"#ff5722"},n=t.bold_theme_colors||r,a=(i,c)=>{s(u=>({...u,bold_theme_colors:{...r,...u.bold_theme_colors,[i]:c}}))},o=()=>{s(i=>({...i,bold_theme_colors:null}))},l=[{key:"accent",label:"Accent Color",desc:"Page background, icons, highlights"},{key:"dark",label:"Dark Color",desc:"Header background, action buttons, social icons"},{key:"button",label:"CTA Button Color",desc:"Main call-to-action button"}];return e.jsxs("div",{className:"space-y-3 p-4 rounded-xl border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(ve,{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(ac,{className:"h-4 w-4"})," Brand Colors"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Customize colors to match your brand"})]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:o,children:"Reset to Default"})]}),e.jsx("div",{className:"grid gap-3",children:l.map(({key:i,label:c,desc:u})=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"relative shrink-0",children:[e.jsx("input",{type:"color",value:n[i],onChange:p=>a(i,p.target.value),className:"sr-only"}),e.jsx("div",{className:"h-10 w-10 rounded-lg border-2 border-border cursor-pointer shadow-sm hover:scale-105 transition-transform",style:{backgroundColor:n[i]}})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:c}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u})]}),e.jsx(ze,{value:n[i],onChange:p=>{const f=p.target.value;/^#[0-9a-fA-F]{0,6}$/.test(f)&&a(i,f)},className:"w-24 h-8 text-xs font-mono",placeholder:"#ff5722"})]},i))}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Preview:"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.accent}}),e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.dark}}),e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.button}})]})]})]})}function hks({card:t,form:s,setForm:r}){var j;const n=iGe(),a=Qt(),{data:o}=oGe(t.id),[l,i]=N.useState(t.slug),[c,u]=N.useState(!1),[p,f]=N.useState("idle"),g=N.useRef(JSON.stringify(s)),b=N.useRef(null);N.useEffect(()=>{const w=JSON.stringify(s);if(w!==g.current)return b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{f("saving"),n.mutate({id:t.id,...s,is_published:!0,title:s.title||null,positioning_statement:s.positioning_statement||null,bio:s.bio||null,review_snippet:s.review_snippet||null,review_source_url:s.review_source_url||null,booking_url:s.booking_url||null,custom_cta_label:s.custom_cta_label||null,brokerage_display_name:s.brokerage_display_name||null,brokerage_logo_url:s.brokerage_logo_url||null,brokerage_logo_size:s.brokerage_logo_size,team_name:s.team_name||null,team_logo_url:s.team_logo_url||null,team_logo_size:s.team_logo_size,bold_theme_colors:s.bold_theme_colors||null,display_email:s.display_email||null},{onSuccess:()=>{g.current=w,f("saved"),setTimeout(()=>f("idle"),2e3)},onError:()=>f("idle")})},1500),()=>{b.current&&clearTimeout(b.current)}},[s]);const _=async()=>{const w=l.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!w){me.error("Please enter a valid URL");return}if(w===t.slug){me.info("No changes to save");return}u(!0);try{const{data:k}=await H.from("agent_cards").select("id").eq("slug",w).neq("id",t.id).maybeSingle();if(k){me.error("This URL is already taken. Try another one.");return}const{error:S}=await H.from("agent_cards").update({slug:w}).eq("id",t.id);if(S)throw S;i(w),a.invalidateQueries({queryKey:["agent-card"]}),me.success("Card address updated!")}catch{me.error("Failed to update card address")}finally{u(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ba,{defaultValue:"content",children:[e.jsxs(pa,{className:"w-full h-11 p-1",children:[e.jsxs(ns,{value:"content",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Cx,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Content"]}),e.jsxs(ns,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(On,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),e.jsxs(ns,{value:"blocks",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Zh,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Blocks"]}),e.jsxs(ns,{value:"qrcode",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(c1,{className:"h-3.5 w-3.5 hidden sm:inline"}),"QR Code"]}),e.jsxs(ns,{value:"analytics",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Qg,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Analytics"]})]}),e.jsxs(bs,{value:"content",className:"mt-4 space-y-4",children:[e.jsx(cks,{userId:t.user_id}),e.jsx(dks,{form:s,setForm:r,userId:t.user_id}),e.jsx(Ee,{children:e.jsxs(De,{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(qr,{checked:s.is_published,onCheckedChange:w=>r(k=>({...k,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(ze,{value:l,onChange:w=>i(w.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"your-name",className:"rounded-l-none h-10"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:_,disabled:c||l===t.slug,className:"shrink-0",children:c?"Saving...":"Update"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This is your unique card URL. Only letters, numbers, and dashes allowed."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Card Email (Override)"}),e.jsx(ze,{value:s.display_email,onChange:w=>r(k=>({...k,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(Zs,{value:s.theme,onValueChange:w=>r(k=>({...k,theme:w})),children:[e.jsx(Ws,{className:"h-11",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"standard",children:"✨ Standard — Modern & Clean"}),e.jsx(Mt,{value:"luxury",children:"🌙 Luxury — Dark & Gold"}),e.jsx(Mt,{value:"bold",children:"🔥 Bold — Vibrant & Punchy"}),e.jsx(Mt,{value:"classic",children:"📋 Classic — Professional"})]})]})]}),s.theme==="bold"&&e.jsx(uks,{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(ze,{value:s.title,onChange:w=>r(k=>({...k,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(ze,{value:s.positioning_statement,onChange:w=>r(k=>({...k,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(Er,{value:s.bio,onChange:w=>r(k=>({...k,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(ze,{value:s.review_snippet,onChange:w=>r(k=>({...k,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(ze,{value:s.review_source_url,onChange:w=>r(k=>({...k,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(ze,{value:s.booking_url,onChange:w=>r(k=>({...k,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(ze,{value:s.custom_cta_label,onChange:w=>r(k=>({...k,custom_cta_label:w.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),e.jsx(bs,{value:"sections",className:"mt-4",children:e.jsx(Ee,{children:e.jsx(De,{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:k,desc:S})=>e.jsxs("div",{className:"flex items-center justify-between py-4 first:pt-0 last:pb-0",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:k}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S})]}),e.jsx(qr,{checked:s[w],onCheckedChange:M=>r(L=>({...L,[w]:M}))})]},w))})})}),e.jsx(bs,{value:"blocks",className:"mt-4",children:e.jsx(plt,{cardId:t.id})}),e.jsx(bs,{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:On,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:Qg,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:Tl,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(De,{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(Pt,{className:"pb-3",children:e.jsx(Rt,{className:"text-base",children:"Recent Leads"})}),e.jsx(De,{className:"pt-0 space-y-2",children:o.leads.slice(0,5).map(w=>e.jsxs("div",{className:"flex items-center justify-between text-sm p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:w.name}),w.phone&&e.jsx("span",{className:"text-muted-foreground ml-2",children:w.phone})]}),w.intent&&e.jsx(tt,{variant:"secondary",className:"text-xs",children:w.intent})]},w.id))})]}),(!o||o.leads.length===0)&&e.jsx(Ee,{children:e.jsxs(De,{className:"p-8 text-center",children:[e.jsx(Qg,{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(bs,{value:"qrcode",className:"mt-4 space-y-4",children:e.jsx(Ee,{children:e.jsx(De,{className:"p-6",children:e.jsx(nks,{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 mks(){const t=Qt(),[s,r]=N.useState(""),[n,a]=N.useState(!1),[o,l]=N.useState(!1),[i,c]=N.useState(null),[u,p]=N.useState(!1),[f,g]=N.useState(!1),[b,_]=N.useState(null),[j,w]=N.useState(null),[k,S]=N.useState(0),{data:M,isLoading:L}=mt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:ee,error:Q}=await H.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(Q)throw Q;return ee}}),I=Dt({mutationFn:async ee=>{const{data:Q,error:ie}=await H.functions.invoke("boldtrail-sync",{body:{action:"save_token",api_token:ee}});if(ie)throw ie;if(Q!=null&&Q.error)throw new Error(Q.error);return Q},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),r(""),me.success("BoldTrail connected successfully!")},onError:ee=>{me.error(ee.message||"Failed to connect BoldTrail")}}),O=Dt({mutationFn:async()=>{const{data:ee,error:Q}=await H.functions.invoke("boldtrail-sync",{body:{action:"disconnect"}});if(Q)throw Q;return ee},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),me.success("BoldTrail disconnected")},onError:()=>me.error("Failed to disconnect")}),q=Dt({mutationFn:async ee=>{const{data:Q,error:ie}=await H.functions.invoke("boldtrail-sync",{body:{action:"save_direction",sync_direction:ee}});if(ie)throw ie;if(Q!=null&&Q.error)throw new Error(Q.error);return Q},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),me.success("Sync direction saved")},onError:ee=>{me.error(ee.message||"Failed to save sync direction")}}),U=Dt({mutationFn:async()=>{const{data:ee,error:Q}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(Q)throw Q;if(ee!=null&&ee.error)throw new Error(ee.error);return ee},onSuccess:ee=>{_(null),c(ee),a(!0)},onError:ee=>{me.error(ee.message||"Failed to generate sync preview")}}),B=Dt({mutationFn:async()=>{w("Initializing sync..."),S(5);const{data:ee,error:Q}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:X}});if(Q)throw Q;if(ee!=null&&ee.error)throw new Error(ee.error);const ie=ee;let re=ie.sync_log_id,oe=ie.next_phase,ce=ie.next_offset;const xe=ie.push_total||0,ge=ie.pull_total||0,ue=xe+ge;let pe=0,be=0;for(;oe!=="finalize";){oe==="push"?(w(`Pushing contacts to BoldTrail... (${pe}/${xe})`),S(ue>0?pe/ue*100:0)):oe==="pull"&&(w(`Pulling contacts from BoldTrail... (${be}/${ge})`),S(ue>0?(xe+be)/ue*100:0));const{data:Pe,error:Oe}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:oe,offset:ce,sync_log_id:re,sync_direction:X}});if(Oe)throw Oe;if(Pe!=null&&Pe.error)throw new Error(Pe.error);const Te=Pe;pe+=Te.chunk_pushed||0,be+=Te.chunk_pulled||0,Te.progress&&w(Te.progress),oe==="pull"&&ge>0?S(Math.min(95,be/ge*100)):oe==="push"&&xe>0&&S(Math.min(95,pe/xe*100)),oe=Te.next_phase,ce=Te.next_offset}w("Finalizing sync..."),S(95);const{data:Me,error:Ne}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:re,sync_direction:X}});if(Ne)throw Ne;return S(100),Me},onSuccess:ee=>{w(null),S(0),a(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["contacts"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),me.success(`Sync complete! Pushed ${ee.contacts_pushed||0}, pulled ${ee.contacts_pulled||0}, skipped ${ee.contacts_skipped||0} duplicates.`)},onError:ee=>{w(null),S(0),me.error(ee.message||"Sync failed")}}),V=M==null?void 0:M.connected,Z=(M==null?void 0:M.sync_direction)||"bidirectional",X=b??Z;return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-emerald-500/10 flex items-center justify-center",children:e.jsx(vd,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["BoldTrail",V&&e.jsx(tt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}),e.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(pp,{className:"h-3.5 w-3.5"}),"Learn More"]})]}),e.jsx(gr,{children:"Sync contacts bidirectionally between Agent OS and your BoldTrail (kvCORE) CRM."})]})]})}),e.jsx(De,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Two-way contact sync with duplicate prevention"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Preview what will sync before executing"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Syncs name, email, phone, address, notes, and lead source"})]}),V?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsx("div",{className:"rounded-lg border p-3 space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"BoldTrail Connected"}),(M==null?void 0:M.last_sync_at)&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sync: ",new Date(M.last_sync_at).toLocaleString(),M.last_sync_status&&e.jsx(tt,{variant:M.last_sync_status==="success"?"default":"secondary",className:"ml-2 text-[10px]",children:M.last_sync_status})]}),(M==null?void 0:M.boldtrail_contact_count)!=null&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[M.boldtrail_contact_count," contacts in BoldTrail"]}),(M==null?void 0:M.last_sync_message)&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:M.last_sync_message})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Disconnect BoldTrail?"}),e.jsx(tc,{children:"This will remove your API token. Previously synced contacts will remain in both systems."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:()=>O.mutate(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]})}),e.jsx("div",{className:"rounded-lg border p-3",children:e.jsx(z_e,{value:Z,onChange:ee=>q.mutate(ee)})}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{onClick:()=>U.mutate(),disabled:U.isPending||B.isPending,variant:"outline",className:"gap-2",children:[U.isPending?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx(On,{className:"h-4 w-4"}),"Preview Sync"]})})]}):e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{type:"password",placeholder:"Paste your BoldTrail API token",value:s,onChange:ee=>r(ee.target.value),className:"flex-1"}),e.jsxs(K,{onClick:()=>I.mutate(s),disabled:!s||s.length<10||I.isPending,children:[I.isPending?e.jsx(Go,{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(fs,{open:n,onOpenChange:ee=>{B.isPending||a(ee)},children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(vd,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Gr,{children:"Review what will happen when you sync your contacts."})]}),i&&(()=>{const ee=X==="pull_only"?0:i.to_push,Q=X==="push_only"?0:i.to_pull;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(z_e,{value:X,onChange:_,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${X==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:ee}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(ku,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${X==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:Q}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Wh,{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(pr,{className:"h-3 w-3"})," Already synced"]})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["Agent OS: ",i.agent_os_total," contacts · BoldTrail: ",i.boldtrail_total," contacts"]}),B.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(Bi,{value:k||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:j||"Sync in progress..."})]}),ee>0&&e.jsxs(gf,{open:u,onOpenChange:p,children:[e.jsx(yf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ku,{className:"h-3 w-3 text-emerald-600"}),ee," contacts to push to BoldTrail"]}),e.jsx(Eo,{className:`h-3 w-3 transition-transform ${u?"rotate-180":""}`})]})}),e.jsx(vf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.push_preview.map((ie,re)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:ie.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:ie.email})]},re)),i.to_push>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",i.to_push-20," more"]})]})})]}),Q>0&&e.jsxs(gf,{open:f,onOpenChange:g,children:[e.jsx(yf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Wh,{className:"h-3 w-3 text-blue-600"}),Q," contacts to pull from BoldTrail"]}),e.jsx(Eo,{className:`h-3 w-3 transition-transform ${f?"rotate-180":""}`})]})}),e.jsx(vf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.pull_preview.map((ie,re)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:ie.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:ie.email})]},re)),i.to_pull>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",i.to_pull-20," more"]})]})})]}),ee===0&&Q===0&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer."}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),disabled:B.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>B.mutate(),disabled:B.isPending||ee===0&&Q===0,className:"gap-2",children:[B.isPending?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx(vd,{className:"h-4 w-4"}),B.isPending?"Syncing...":"Sync Now"]})]})]})})()]})}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{className:"sm:max-w-2xl p-0 overflow-hidden",children:[e.jsx(_s,{className:"p-6 pb-0",children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(vd,{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 Slt(){const t=fr(),[s,r]=N.useState(""),[n,a]=N.useState(""),[o,l]=N.useState("Test from ReLevelUp"),[i,c]=N.useState(!1),{data:u,isLoading:p}=mt({queryKey:["ses-config"],queryFn:async()=>{const{data:{session:b}}=await H.auth.getSession();if(!b)throw new Error("Not authenticated");return(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ses-send-campaign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b.access_token}`},body:JSON.stringify({action:"check_config"})})).json()}}),f=async()=>{if(!s||!n){me.error("Please fill in From and To email addresses");return}c(!0);try{const{data:{session:b}}=await H.auth.getSession();if(!b)throw new Error("Not authenticated");const j=await(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ses-send-campaign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b.access_token}`},body:JSON.stringify({action:"test_send",to:s,from_email:n,subject:o,body_html:"

Test Email

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

If you received this, SES is configured correctly! 🎉

"})})).json();j.success?me.success(`Test email sent! Message ID: ${j.messageId}`):me.error(j.error||"Failed to send test email")}catch(b){me.error(b.message||"Failed to send test email")}finally{c(!1)}},g=(u==null?void 0:u.configured)===!0;return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-orange-500/10 flex items-center justify-center",children:e.jsx(cr,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Amazon SES — Mass Email"}),e.jsx(gr,{children:"Send bulk email campaigns via Amazon SES"})]})]}),e.jsx(tt,{variant:g?"default":"secondary",children:p?"Checking...":g?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xi,{className:"h-3 w-3"})," Connected"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(kl,{className:"h-3 w-3"})," Not Configured"]})})]})}),g&&e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Send Test Email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'Verify your SES setup by sending a test email. The "From" address must be verified in SES or belong to a verified domain.'}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"From Email"}),e.jsx(ze,{placeholder:"notifications@mail.relevelup.com",value:n,onChange:b=>a(b.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"To Email"}),e.jsx(ze,{placeholder:"your@email.com",value:s,onChange:b=>r(b.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"Subject"}),e.jsx(ze,{value:o,onChange:b=>l(b.target.value),className:"text-sm"})]})]}),e.jsxs(K,{onClick:f,disabled:i,size:"sm",children:[i?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Send Test"]})]}),e.jsxs(K,{onClick:()=>t("/admin/email-campaigns"),className:"w-full",children:[e.jsx(Ah,{className:"h-4 w-4 mr-2"})," Launch Campaign Composer"]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Region:"})," ",u==null?void 0:u.region]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Domain:"})," send.relevelup.com (verified)"]})]})]}),!g&&!p&&e.jsx(De,{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["AWS SES credentials are not configured. Add ",e.jsx("code",{children:"AWS_SES_ACCESS_KEY_ID"}),", ",e.jsx("code",{children:"AWS_SES_SECRET_ACCESS_KEY"}),", and ",e.jsx("code",{children:"AWS_SES_REGION"})," as secrets to enable."]})})]})}function pks(){var _,j,w,k;const{user:t}=Ds(),s=Qt(),[r,n]=N.useState(!1),[a,o]=N.useState(""),[l,i]=N.useState(""),{data:c}=mt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:S,error:M}=await H.from("mass_email_settings").select("*").eq("user_id",t.id).maybeSingle();if(M)throw M;return S}}),{data:u}=mt({queryKey:["agent-profile-email",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:S,error:M}=await H.from("profiles").select("email, name").eq("id",t.id).single();if(M)throw M;return S}}),p=((_=c==null?void 0:c.reply_to_email)==null?void 0:_.trim())||((j=u==null?void 0:u.email)==null?void 0:j.trim())||"",f=((w=c==null?void 0:c.display_name)==null?void 0:w.trim())||((k=u==null?void 0:u.name)==null?void 0:k.trim())||"";N.useEffect(()=>{r||(o(p),i(f))},[r,p,f]);const g=Dt({mutationFn:async()=>{if(!t||!a.trim())throw new Error("Please enter a reply-to email");const S={reply_to_email:a.trim(),display_name:l.trim()||null,updated_at:new Date().toISOString()};if(c){const{error:M}=await H.from("mass_email_settings").update(S).eq("user_id",t.id);if(M)throw M}else{const{error:M}=await H.from("mass_email_settings").insert({user_id:t.id,...S});if(M)throw M}},onSuccess:()=>{s.invalidateQueries({queryKey:["mass-email-settings",t==null?void 0:t.id]}),s.invalidateQueries({queryKey:["mass-email-ready",t==null?void 0:t.id]}),s.invalidateQueries({queryKey:["mass-email-settings-check",t==null?void 0:t.id]}),me.success("Reply-to email saved!"),n(!1)},onError:S=>me.error(S.message)}),b=!!p;return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-orange-500/10 flex items-center justify-center",children:e.jsx(Bn,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Mass Email",b?e.jsxs(tt,{variant:"default",className:"text-xs bg-green-600",children:[e.jsx(xi,{className:"h-3 w-3 mr-1"})," Set Up"]}):e.jsx(tt,{variant:"secondary",className:"text-xs",children:"Setup Required"})]}),e.jsx(gr,{children:"Set the email address where replies from your campaigns will be sent. If you haven't customized it yet, we'll use your profile email."})]})]})}),e.jsx(De,{className:"space-y-3",children:b&&!r?e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:f||"No display name"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>n(!0),children:[e.jsx(Ra,{className:"h-3 w-3 mr-1"})," Edit"]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"Display Name"}),e.jsx(ze,{placeholder:"e.g. 🏡 Karen Hall",value:l,onChange:S=>i(S.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How your name appears in the recipient's inbox"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"Reply-To Email *"}),e.jsx(ze,{type:"email",placeholder:"your@email.com",value:a,onChange:S=>o(S.target.value)})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{size:"sm",onClick:()=>g.mutate(),disabled:g.isPending||!a.trim(),children:[e.jsx(qc,{className:"h-4 w-4 mr-1"})," Save"]}),r&&e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{n(!1),o(p),i(f)},children:[e.jsx(Rr,{className:"h-4 w-4 mr-1"})," Cancel"]})]})]})})]})}function fks(){const{isAdmin:t}=Ds(),s=Qt(),[r,n]=N.useState(!1),[a,o]=N.useState(!1),[l,i]=N.useState(!1),{data:c,isLoading:u}=mt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:L,error:I}=await H.from("gmail_integrations").select("*").maybeSingle();if(I)throw I;return L}}),{data:p}=mt({queryKey:["social-accounts"],queryFn:async()=>{const{data:{user:L}}=await H.auth.getUser();if(!L)return[];const{data:I,error:O}=await H.from("social_accounts").select("*").eq("user_id",L.id).order("created_at",{ascending:!1});if(O)throw O;return I}}),f=async()=>{n(!0);try{const{data:L,error:I}=await H.functions.invoke("gmail-oauth",{body:{action:"get_auth_url"}});if(I)throw I;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get authorization URL")}catch(L){console.error("Gmail OAuth error:",L),me.error("Failed to start Gmail connection"),n(!1)}},g=async()=>{o(!0);try{const{data:L,error:I}=await H.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(I)throw I;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get authorization URL")}catch(L){console.error("Meta OAuth error:",L),me.error("Failed to start connection. Make sure Meta App credentials are configured."),o(!1)}},b=async()=>{i(!0);try{const{data:L,error:I}=await H.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(I)throw I;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(L){console.error("LinkedIn OAuth error:",L),me.error("Failed to start LinkedIn connection. Please try again."),i(!1)}},_=Dt({mutationFn:async L=>{const{error:I}=await H.from("gmail_integrations").delete().eq("id",L);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["gmail-integration"]}),me.success("Gmail disconnected")},onError:()=>{me.error("Failed to disconnect Gmail")}}),j=Dt({mutationFn:async L=>{const{error:I}=await H.from("social_accounts").delete().eq("id",L);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["social-accounts"]}),me.success("Account disconnected")},onError:()=>{me.error("Failed to disconnect account")}}),w=!!(c!=null&&c.is_active),k=(p==null?void 0:p.filter(L=>L.platform==="facebook"))||[],S=(p==null?void 0:p.filter(L=>L.platform==="instagram"))||[],M=(p==null?void 0:p.filter(L=>L.platform==="linkedin"))||[];return e.jsx(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(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-destructive/10 flex items-center justify-center",children:e.jsx(cr,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Gmail",w&&e.jsx(tt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),e.jsx(gr,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),e.jsx(De,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Send personalized emails from your Gmail account"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Automatically log emails as activity touchpoints"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Quick compose from any contact detail page"})]}),w?e.jsxs("div",{className:"flex items-center justify-between mt-4 p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:c.gmail_email}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Gmail account"})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Disconnect Gmail?"}),e.jsx(tc,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:()=>_.mutate(c.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:f,disabled:r||u,children:[r?e.jsx(Go,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Connect Gmail",e.jsx(Qa,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(Su,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Facebook",t?k.length>0?e.jsx(tt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(tt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Th,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(gr,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),t&&e.jsxs(De,{className:"space-y-3",children:[k.length>0&&e.jsx("div",{className:"space-y-2",children:k.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:L.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Su,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.page_name||L.platform_username||"Facebook Page"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Facebook Page"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Disconnect Facebook?"}),e.jsx(tc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:()=>j.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}),e.jsxs(K,{onClick:g,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4"}),"Connect Facebook Page"]})]})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-pink-500/10 flex items-center justify-center",children:e.jsx(Mu,{className:"h-5 w-5 text-pink-600"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Instagram",t?S.length>0?e.jsx(tt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(tt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Th,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(gr,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs(De,{className:"space-y-3",children:[S.length>0&&e.jsx("div",{className:"space-y-2",children:S.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:L.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Mu,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:["@",L.platform_username||"Instagram Account"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Instagram account"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Disconnect Instagram?"}),e.jsx(tc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:()=>j.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}),e.jsxs(K,{onClick:g,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4"}),"Connect Instagram Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Instagram Business accounts must be connected to a Facebook Page."})]})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-700/10 flex items-center justify-center",children:e.jsx(Mp,{className:"h-5 w-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["LinkedIn",t?M.length>0?e.jsx(tt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(tt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Th,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(gr,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),t&&e.jsxs(De,{className:"space-y-3",children:[M.length>0&&e.jsx("div",{className:"space-y-2",children:M.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:L.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Mp,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.platform_username||"LinkedIn Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected LinkedIn profile"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Disconnect LinkedIn?"}),e.jsx(tc,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:()=>j.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}),e.jsxs(K,{onClick:b,disabled:l,variant:"outline",className:"gap-2",children:[l?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]}),e.jsx(mks,{}),e.jsx(pks,{}),t&&e.jsx(Slt,{})]})})}function xks(){const[t]=Cc(),s=fr(),[r,n]=N.useState("loading"),[a,o]=N.useState("Connecting your Gmail account...");return N.useEffect(()=>{(async()=>{const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:f,error:g}=await H.functions.invoke("gmail-oauth",{body:{action:"exchange_code",code:i,state:p}});if(g)throw g;if(f!=null&&f.success)n("success"),o(f.message||"Gmail connected successfully!"),me.success("Gmail connected!");else throw new Error((f==null?void 0:f.error)||"Unknown error")}catch(f){console.error("Gmail OAuth callback error:",f),n("error"),o(f instanceof Error?f.message:"Failed to connect Gmail"),me.error("Failed to connect: "+(f instanceof Error?f.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(vc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Rt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(De,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"Back to Integrations":"Try Again"})})]})})}function gks(){const t=fr();return N.useEffect(()=>{const s=setTimeout(()=>{t("/mission-control/integrations",{replace:!0})},1500);return()=>clearTimeout(s)},[t]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Finishing Canva connection…"})]})})}function yks(){const[t]=Cc(),s=fr(),[r,n]=N.useState("loading"),[a,o]=N.useState("Processing your connection...");return N.useEffect(()=>{(async()=>{var f;const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:g,error:b}=await H.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/mission-control/integrations/meta/callback"}});if(b)throw b;if(g!=null&&g.success)n("success"),o(`Successfully connected ${((f=g.accounts)==null?void 0:f.length)||0} account(s)!`),me.success("Social accounts connected successfully!");else throw new Error((g==null?void 0:g.error)||"Unknown error")}catch(g){console.error("OAuth callback error:",g),n("error"),o(g instanceof Error?g.message:"Failed to connect accounts"),me.error("Failed to connect: "+(g instanceof Error?g.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(vc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Rt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(De,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Integrations":"Try Again"})})]})})}const Clt=new Date().getFullYear(),vks=Array.from({length:5},(t,s)=>Clt-s);function bks(){const[t,s]=N.useState(Clt),r=fr(),{data:n,isLoading:a}=t8t();return a?e.jsx(Ms,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(o=>e.jsx(ys,{className:"h-24"},o))}),e.jsx(ys,{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(Zs,{value:String(t),onValueChange:o=>s(Number(o)),children:[e.jsx(Ws,{className:"w-[120px]",children:e.jsx(Xs,{})}),e.jsx(Gs,{children:vks.map(o=>e.jsx(Mt,{value:String(o),children:o},o))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(pr,{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(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(No,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(n==null?void 0:n.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with transactions"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Agents with Scorecards"}),e.jsx(gr,{children:"Click to view individual agent scorecards"})]}),e.jsx(De,{children:!n||n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(No,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents have added transactions yet"})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Email"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:n.map(o=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:o.name}),e.jsx(dt,{className:"text-muted-foreground",children:o.email}),e.jsx(dt,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r(`/admin/scorecard/${o.id}`),children:[e.jsx(On,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const Mlt=new Date().getFullYear(),_ks=Array.from({length:10},(t,s)=>Mlt-s);function yze(){var _;const{userId:t}=yo(),s=fr(),n=zd().pathname.startsWith("/mission-control"),[a,o]=N.useState(Mlt),{data:l,isLoading:i}=mt({queryKey:["agent-profile",t],queryFn:async()=>{const{data:j,error:w}=await H.from("profiles").select("id, name, email").eq("id",t).single();if(w)throw w;return j},enabled:!!t}),{data:c,isLoading:u}=SNe(a,t),{yearStats:p,lifetimeStats:f,showCommission:g}=uXe(a,t),{data:b}=dXe(a,t);return i?e.jsx(Ms,{title:"Agent Scorecard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(j=>e.jsx(ys,{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(Ja,{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(Zs,{value:String(a),onValueChange:j=>o(Number(j)),children:[e.jsx(Ws,{className:"w-[120px]",children:e.jsx(Xs,{})}),e.jsx(Gs,{children:_ks.map(j=>e.jsx(Mt,{value:String(j),children:j},j))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(bn,{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(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(pr,{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(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(nc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Kl(p.totalVolume,!0)})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ul,{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:Kl(p.averagePrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Nc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((_=p.topLeadSource)==null?void 0:_.name)||"-"})]})})]}),b&&e.jsx(Wat,{goals:b,stats:p,year:a,showCommission:g}),e.jsxs(ba,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"transactions",children:"Transactions"}),e.jsx(ns,{value:"charts",children:"Charts"}),e.jsxs(ns,{value:"map",children:[e.jsx(ma,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(bs,{value:"transactions",children:e.jsx(cSe,{transactions:c||[],showCommission:g,isLoading:u})}),e.jsx(bs,{value:"charts",children:e.jsx(dSe,{stats:p,year:a})}),e.jsx(bs,{value:"map",children:e.jsx(uSe,{transactions:c||[],isLoading:u})})]})]})})}function wks(){const t=Qt(),[s,r]=N.useState(""),[n,a]=N.useState("all");zZe();const{data:o,refetch:l}=mt({queryKey:["listing-exchange-flag"],queryFn:async()=>{const{data:L}=await H.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").single();return(L==null?void 0:L.enabled)??!1}}),{data:i,isLoading:c}=mt({queryKey:["admin-listings"],queryFn:async()=>{const{data:L,error:I}=await H.from("listings").select(` *, agent:profiles!listings_agent_id_fkey(id, name, email), photos:listing_photos(id, photo_url, is_primary) `).order("created_at",{ascending:!1});if(I)throw I;return L}}),{data:u}=mt({queryKey:["admin-listing-stats"],queryFn:async()=>{const{data:L}=await H.from("listings").select("id, is_approved, status"),{data:I}=await H.from("listing_shares").select("id"),{data:O}=await H.from("listing_views").select("id");return{total:(L==null?void 0:L.length)||0,pending:(L==null?void 0:L.filter(q=>!q.is_approved).length)||0,active:(L==null?void 0:L.filter(q=>q.status==="active").length)||0,totalShares:(I==null?void 0:I.length)||0,totalViews:(O==null?void 0:O.length)||0}}}),p=async(L,I,O="submit_url")=>{try{const{data:{session:q}}=await H.auth.getSession();if(!q)return;const{data:U,error:B}=await H.functions.invoke("google-indexing",{body:{action:O,listing_id:L,listing_slug:I}});if(B)throw B;if((U==null?void 0:U.configured)===!1)return;U!=null&&U.success&&me.success("Submitted to Google for indexing")}catch(q){console.error("Google indexing submission failed:",q)}},f=Dt({mutationFn:async()=>{const{data:{session:L}}=await H.auth.getSession();if(!L)throw new Error("Not authenticated");const{data:I,error:O}=await H.functions.invoke("google-indexing",{body:{action:"submit_all"}});if(O)throw O;return I},onSuccess:L=>{if((L==null?void 0:L.configured)===!1){me.error("Google Indexing API not configured. Add the GOOGLE_INDEXING_SERVICE_ACCOUNT secret.");return}me.success(`Submitted ${(L==null?void 0:L.succeeded)||0} URLs to Google (${(L==null?void 0:L.failed)||0} failed)`)},onError:L=>{me.error("Failed to submit to Google"),console.error(L)}}),g=Dt({mutationFn:async({id:L,approved:I,slug:O})=>{const{error:q}=await H.from("listings").update({is_approved:I}).eq("id",L);if(q)throw q;return{id:L,approved:I,slug:O}},onSuccess:L=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),me.success(L.approved?"Listing approved":"Listing unapproved"),L.approved?p(L.id,L.slug||null,"submit_url"):p(L.id,L.slug||null,"remove_url")}}),b=Dt({mutationFn:async({id:L,featured:I})=>{const{error:O}=await H.from("listings").update({is_featured:I}).eq("id",L);if(O)throw O},onSuccess:(L,{featured:I})=>{t.invalidateQueries({queryKey:["admin-listings"]}),me.success(I?"Listing featured":"Listing unfeatured")}}),_=Dt({mutationFn:async L=>{const{error:I}=await H.from("listings").delete().eq("id",L);if(I)throw I},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),me.success("Listing deleted")}}),j=Dt({mutationFn:async L=>{const{error:I}=await H.from("feature_flags").update({enabled:L}).eq("key","listing_exchange_enabled");if(I)throw I},onSuccess:()=>{l(),me.success("Feature flag updated")}}),w=o??!1,k=i==null?void 0:i.filter(L=>{var q,U,B,V;const I=((q=L.city)==null?void 0:q.toLowerCase().includes(s.toLowerCase()))||((B=(U=L.agent)==null?void 0:U.name)==null?void 0:B.toLowerCase().includes(s.toLowerCase()))||((V=L.property_address)==null?void 0:V.toLowerCase().includes(s.toLowerCase())),O=n==="all"||n==="pending"&&!L.is_approved||n==="approved"&&L.is_approved;return I&&O}),S=L=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(L),M=L=>{const I={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 I[L]||I.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(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(su,{className:"h-4 w-4"}),"Submit All to Google"]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Feature visible to agents"}),e.jsx(qr,{checked:w,onCheckedChange:L=>j.mutate(L)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{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(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ul,{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(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pr,{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(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(On,{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(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_d,{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(De,{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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by city, address, or agent...",value:s,onChange:L=>r(L.target.value),className:"pl-9"})]}),e.jsx(ba,{value:n,onValueChange:L=>a(L),children:e.jsxs(pa,{children:[e.jsx(ns,{value:"all",children:"All"}),e.jsx(ns,{value:"pending",children:"Pending"}),e.jsx(ns,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{children:["Listings (",(k==null?void 0:k.length)||0,")"]})}),e.jsx(De,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Property"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Price"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-center",children:"Approved"}),e.jsx(St,{className:"text-center",children:"Featured"}),e.jsx(St,{children:"Views"}),e.jsx(St,{children:"Shares"}),e.jsx(St,{children:"Date"}),e.jsx(St,{})]})}),e.jsx(zn,{children:c?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(k==null?void 0:k.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):k==null?void 0:k.map(L=>{var I,O,q,U,B;return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[(O=(I=L.photos)==null?void 0:I[0])!=null&&O.photo_url?e.jsx("img",{src:L.photos[0].photo_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(ka,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.property_address||`${L.city}, ${L.state}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(q=L.property_type)==null?void 0:q.replace("_"," ")})]})]})}),e.jsx(dt,{children:e.jsx("p",{className:"text-sm",children:((U=L.agent)==null?void 0:U.name)||"Unknown"})}),e.jsx(dt,{className:"font-medium",children:S(L.price)}),e.jsx(dt,{children:e.jsx(tt,{variant:"outline",className:M(L.status),children:(B=L.status)==null?void 0:B.replace("_"," ")})}),e.jsx(dt,{className:"text-center",children:e.jsx(qr,{checked:L.is_approved??!1,onCheckedChange:V=>g.mutate({id:L.id,approved:V,slug:L.slug})})}),e.jsx(dt,{className:"text-center",children:e.jsx(qr,{checked:L.is_featured??!1,onCheckedChange:V=>b.mutate({id:L.id,featured:V})})}),e.jsx(dt,{children:L.view_count||0}),e.jsx(dt,{children:L.share_count||0}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:ms(new Date(L.created_at),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(px,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[e.jsxs(Ma,{onClick:()=>window.open(`/mission-control/listings/${L.id}`,"_blank"),children:[e.jsx(On,{className:"h-4 w-4 mr-2"}),"View Listing"]}),e.jsxs(Ma,{onClick:()=>b.mutate({id:L.id,featured:!L.is_featured}),children:[e.jsx(Jn,{className:"h-4 w-4 mr-2"}),L.is_featured?"Unfeature":"Feature"]}),e.jsxs(Ma,{className:"text-destructive",onClick:()=>{confirm("Are you sure you want to delete this listing?")&&_.mutate(L.id)},children:[e.jsx(Rr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},L.id)})})]})})})]})]})})}const jks=()=>{var f,g;const[t,s]=N.useState(""),[r,n]=N.useState(null),{data:a,isLoading:o}=mt({queryKey:["membership-reviews"],queryFn:async()=>{const{data:b,error:_}=await H.from("membership_reviews").select("*").order("created_at",{ascending:!1});if(_)throw _;const j=(b==null?void 0:b.map(S=>S.user_id))||[],{data:w}=await H.from("profiles").select("id, name, email").in("id",j);return b==null?void 0:b.map(S=>({...S,profiles:(w==null?void 0:w.find(M=>M.id===S.user_id))||null}))}}),l=a==null?void 0:a.filter(b=>{var j,w,k,S,M;const _=t.toLowerCase();return((w=(j=b.profiles)==null?void 0:j.name)==null?void 0:w.toLowerCase().includes(_))||((S=(k=b.profiles)==null?void 0:k.email)==null?void 0:S.toLowerCase().includes(_))||((M=b.review_text)==null?void 0:M.toLowerCase().includes(_))}),i=a!=null&&a.length?(a.reduce((b,_)=>b+_.rating,0)/a.length).toFixed(1):"0.0",c=a==null?void 0:a.reduce((b,_)=>(b[_.rating]=(b[_.rating]||0)+1,b),{}),u=(a==null?void 0:a.filter(b=>b.posted_to_google).length)||0,p=b=>e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(_=>e.jsx(Jn,{className:It("h-4 w-4",b>=_?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},_))});return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Membership Reviews",description:"View and manage feedback from LevelUp members"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Total Reviews"}),e.jsx(Rt,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Average Rating"}),e.jsxs(Rt,{className:"flex items-center gap-2 text-3xl",children:[i,e.jsx(Jn,{className:"h-6 w-6 fill-yellow-400 text-yellow-400"})]})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"5-Star Reviews"}),e.jsx(Rt,{className:"text-3xl",children:(c==null?void 0:c[5])||0})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Posted to Google"}),e.jsxs(Rt,{className:"flex items-center gap-2 text-3xl",children:[u,e.jsx(tn,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or review...",value:t,onChange:b=>s(b.target.value),className:"pl-9"})]}),e.jsx(Ee,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Member"}),e.jsx(St,{children:"Rating"}),e.jsx(St,{className:"hidden md:table-cell",children:"Review"}),e.jsx(St,{children:"Google"}),e.jsx(St,{children:"Date"})]})}),e.jsx(zn,{children:o?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No reviews found"})}):l==null?void 0:l.map(b=>{var _,j;return e.jsxs(Ss,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>n(b),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:((_=b.profiles)==null?void 0:_.name)||"Unknown"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:(j=b.profiles)==null?void 0:j.email})]})}),e.jsx(dt,{children:p(b.rating)}),e.jsx(dt,{className:"hidden md:table-cell max-w-xs",children:e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:b.review_text||"-"})}),e.jsx(dt,{children:b.posted_to_google?e.jsx(tt,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):e.jsx(tt,{variant:"outline",children:"No"})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:ms(new Date(b.created_at),"MMM d, yyyy")})]},b.id)})})]})})}),e.jsx(fs,{open:!!r,onOpenChange:()=>n(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Review Details"})}),r&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-4 p-4 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:((f=r.profiles)==null?void 0:f.name)||"Unknown Member"}),((g=r.profiles)==null?void 0:g.email)&&e.jsxs("a",{href:`mailto:${r.profiles.email}`,className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-primary",children:[e.jsx(cr,{className:"h-3 w-3"}),r.profiles.email]})]}),e.jsxs("div",{className:"text-right",children:[p(r.rating),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r.rating," out of 5 stars"]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Review"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:r.review_text||"No written review provided."})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(hn,{className:"h-4 w-4"}),ms(new Date(r.created_at),"MMMM d, yyyy 'at' h:mm a")]}),r.posted_to_google?e.jsxs(tt,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(tn,{className:"h-3 w-3 mr-1"}),"Posted to Google"]}):e.jsx(tt,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},Nks=[{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"}],kks=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 Sks(){const t=Qt(),{user:s}=Ds(),[r,n]=N.useState(!1),[a,o]=N.useState(!1),[l,i]=N.useState(!1),{data:c,isLoading:u}=mt({queryKey:["weekly-digest-settings"],queryFn:async()=>{const{data:U,error:B}=await H.from("weekly_digest_settings").select("*").single();if(B)throw B;return U}}),{data:p,isLoading:f}=mt({queryKey:["weekly-digest-logs"],queryFn:async()=>{const{data:U,error:B}=await H.from("weekly_digest_logs").select("*").order("sent_at",{ascending:!1}).limit(100);if(B)throw B;return U}}),{data:g}=mt({queryKey:["digest-subscriber-count"],queryFn:async()=>{const{count:U,error:B}=await H.from("profiles").select("id",{count:"exact",head:!0}).eq("digest_opt_out",!1).not("email","is",null);if(B)throw B;return U||0}}),{data:b,refetch:_}=mt({queryKey:["digest-queue-status"],queryFn:async()=>{const U=new Date;U.setUTCHours(0,0,0,0);const[B,V,Z,X]=await Promise.all([H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","pending").gte("created_at",U.toISOString()),H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","processing").gte("created_at",U.toISOString()),H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","sent").gte("created_at",U.toISOString()),H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","failed").gte("created_at",U.toISOString())]);return{pending:B.count||0,processing:V.count||0,sent:Z.count||0,failed:X.count||0,total:(B.count||0)+(V.count||0)+(Z.count||0)+(X.count||0)}},refetchInterval:5e3});N.useEffect(()=>{if(b&&(b.pending>0||b.processing>0)){const U=setInterval(()=>{_(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})},5e3);return()=>clearInterval(U)}},[b,_,t]);const{data:j=0}=mt({queryKey:["digest-today-failed-count"],queryFn:async()=>{const U=new Date;U.setUTCHours(0,0,0,0);const{count:B,error:V}=await H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",U.toISOString());if(V)throw V;return B||0}}),w=Dt({mutationFn:async U=>{const{error:B}=await H.from("weekly_digest_settings").update(U).eq("id",c==null?void 0:c.id);if(B)throw B},onSuccess:()=>{t.invalidateQueries({queryKey:["weekly-digest-settings"]}),me.success("Settings updated")},onError:U=>{me.error("Failed to update settings: "+U.message)}}),k=async()=>{n(!0);try{const{data:U,error:B}=await H.functions.invoke("send-weekly-digest",{body:{manual:!0}});if(B)throw B;U.queued?me.success(`${U.queued.toLocaleString()} emails queued! They'll be sent automatically (~80/minute).`):U.sent!==void 0&&me.success(`Digest sent! ${U.sent} emails delivered, ${U.failed} failed`),_(),t.invalidateQueries({queryKey:["weekly-digest-logs"]})}catch(U){me.error("Failed to send digest: "+U.message)}finally{n(!1)}},S=async()=>{var U,B,V,Z,X,ee;if(!(s!=null&&s.email)){me.error("No email found for your account");return}o(!0);try{const{data:Q,error:ie}=await H.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:s.email}});if(ie)throw ie;const re=Q==null?void 0:Q.resendId,oe=Q==null?void 0:Q.resendDetails,ce=oe==null?void 0:oe.status,xe=((U=oe==null?void 0:oe.body)==null?void 0:U.status)||((V=(B=oe==null?void 0:oe.body)==null?void 0:B.data)==null?void 0:V.status),ge=((X=(Z=oe==null?void 0:oe.body)==null?void 0:Z.error)==null?void 0:X.message)||((ee=oe==null?void 0:oe.body)==null?void 0:ee.message);me.success(re?`Preview accepted by email provider (id: ${re})${ce?`, status check: ${ce}`:""}${xe?`, provider: ${xe}`:""}${ge?` (${ge})`:""}. Check spam/promotions—delivery can take a few minutes.`:"Preview accepted by email provider. Check spam/promotions—delivery can take a few minutes.")}catch(Q){me.error("Failed to send preview: "+Q.message)}finally{o(!1)}},M=async()=>{i(!0);try{const{data:U,error:B}=await H.functions.invoke("send-weekly-digest",{body:{retryFailed:!0}});if(B)throw B;U.queued===0||U.sent===0&&U.failed===0&&!U.queued?me.info("No failed emails to retry"):U.queued?me.success(`${U.queued} emails queued for retry!`):me.success(`Retry complete! ${U.sent} emails delivered, ${U.failed} failed`),_(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})}catch(U){me.error("Failed to retry: "+U.message)}finally{i(!1)}},L=b!=null&&b.total?Math.round((b.sent+b.failed)/b.total*100):0,I=((b==null?void 0:b.pending)||0)>0||((b==null?void 0:b.processing)||0)>0,{data:O}=mt({queryKey:["digest-delivery-stats"],queryFn:async()=>{var ee,Q;const U=new Date;U.setUTCHours(0,0,0,0);const[B,V,Z,X]=await Promise.all([H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","sent").gte("sent_at",U.toISOString()),H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",U.toISOString()),H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("has_agent_os_activity",!0).gte("sent_at",U.toISOString()),H.from("weekly_digest_logs").select("sent_at").order("sent_at",{ascending:!1}).limit(1)]);return{totalSent:B.count||0,totalFailed:V.count||0,agentOsEngaged:Z.count||0,lastSent:((Q=(ee=X.data)==null?void 0:ee[0])==null?void 0:Q.sent_at)||null}},refetchInterval:I?5e3:!1}),q={totalSent:(O==null?void 0:O.totalSent)||0,totalFailed:(O==null?void 0:O.totalFailed)||0,lastSent:O==null?void 0:O.lastSent,agentOsEngaged:(O==null?void 0:O.agentOsEngaged)||0};return u?e.jsx(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(ba,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"settings",className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(ns,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(No,{className:"h-4 w-4"}),"Delivery Stats"]})]}),e.jsxs(bs,{value:"settings",className:"space-y-6",children:[I&&b&&e.jsx(Ee,{className:"border-primary/50 bg-primary/5",children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx(ws,{className:"h-5 w-5 animate-spin text-primary"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:"Sending emails..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[b.sent.toLocaleString()," sent, ",b.pending.toLocaleString()," pending",b.failed>0&&`, ${b.failed} failed`]})]}),e.jsxs("span",{className:"text-sm font-medium",children:[L,"%"]})]}),e.jsx(Bi,{value:L,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Processing ~80 emails per minute. Estimated time remaining: ~",Math.ceil(b.pending/80)," min"]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsx(De,{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(pr,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:g}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscribers"})]})]})})}),e.jsx(Ee,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-emerald-500/10",children:e.jsx(sa,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:q.totalSent}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Delivered"})]})]})})}),e.jsx(Ee,{children:e.jsx(De,{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(vc,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:q.totalFailed}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed"})]})]})})}),e.jsx(Ee,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(un,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:q.lastSent?ms(new Date(q.lastSent),"MMM d"):"Never"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last Sent"})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(gr,{children:"Configure when the digest is sent"})]}),e.jsxs(De,{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(qr,{checked:c==null?void 0:c.is_enabled,onCheckedChange:U=>w.mutate({is_enabled:U})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Cron Frequency"}),e.jsxs(Zs,{value:(c==null?void 0:c.cron_frequency)||"daily",onValueChange:U=>w.mutate({cron_frequency:U}),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"daily",children:"Daily (runs once at selected time)"}),e.jsx(Mt,{value:"hourly",children:"Hourly (checks every hour)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(c==null?void 0:c.cron_frequency)==="hourly"?"Cron runs every hour; digest sends when day & hour match.":"Cron runs once daily at the selected hour (UTC)."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Day of Week"}),e.jsxs(Zs,{value:String(c==null?void 0:c.send_day),onValueChange:U=>w.mutate({send_day:parseInt(U)}),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:Nks.map(U=>e.jsx(Mt,{value:U.value,children:U.label},U.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Time (UTC)"}),e.jsxs(Zs,{value:String(c==null?void 0:c.send_hour),onValueChange:U=>w.mutate({send_hour:parseInt(U)}),disabled:(c==null?void 0:c.cron_frequency)==="daily",children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:kks.map(U=>e.jsx(Mt,{value:U.value,children:U.label},U.value))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{onClick:S,disabled:a,variant:"outline",className:"flex-1",children:[e.jsx(On,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(K,{onClick:k,disabled:r,className:"flex-1",children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),j>0&&e.jsxs(K,{onClick:M,disabled:l,variant:"outline",className:"w-full",children:[e.jsx(Go,{className:`h-4 w-4 mr-2 ${l?"animate-spin":""}`}),l?"Retrying...":`Retry ${j} Failed`]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(gr,{children:"Choose what to include in the digest"})]}),e.jsxs(De,{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(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"New Resources"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_new_resources,onCheckedChange:U=>w.mutate({include_new_resources:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"Community Highlights"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_community_posts,onCheckedChange:U=>w.mutate({include_community_posts:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(No,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"Agent OS Stats"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_agent_os_stats,onCheckedChange:U=>w.mutate({include_agent_os_stats:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"Upcoming Events"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_upcoming_events,onCheckedChange:U=>w.mutate({include_upcoming_events:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zm,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"Goals Progress"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_goals_progress,onCheckedChange:U=>w.mutate({include_goals_progress:U})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Custom Introduction"}),e.jsx(gr,{children:"Personalize the intro message (optional)"})]}),e.jsx(De,{children:e.jsx(Er,{placeholder:"Here's what's new this week to help you grow your business...",value:(c==null?void 0:c.custom_intro_text)||"",onChange:U=>w.mutate({custom_intro_text:U.target.value||null}),rows:3})})]})]}),e.jsx(bs,{value:"stats",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(gr,{children:"Recent digest emails sent to members"})]}),e.jsx(De,{children:f?e.jsx("div",{className:"animate-pulse space-y-2",children:[1,2,3,4,5].map(U=>e.jsx("div",{className:"h-12 bg-muted rounded"},U))}):p&&p.length>0?e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Sent At"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Resources"}),e.jsx(St,{children:"Agent OS"})]})}),e.jsx(zn,{children:p.map(U=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:U.email_sent_to}),e.jsx(dt,{children:ms(new Date(U.sent_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{children:e.jsx(tt,{variant:U.delivery_status==="sent"?"default":"destructive",children:U.delivery_status})}),e.jsx(dt,{children:U.resources_count}),e.jsx(dt,{children:U.has_agent_os_activity?e.jsx(tt,{variant:"secondary",children:"Active"}):e.jsx(tt,{variant:"outline",children:"Not Started"})})]},U.id))})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(cr,{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 Cks={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 Mks(){var pe,be,Me;const t=Qt(),[s,r]=N.useState(""),[n,a]=N.useState(null),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState(""),[f,g]=N.useState(""),[b,_]=N.useState(!0),[j,w]=N.useState(!1),[k,S]=N.useState(""),[M,L]=N.useState(null),{data:I,isLoading:O}=mt({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:Ne,error:Pe}=await H.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Pe)throw Pe;const Oe=(Ne==null?void 0:Ne.map(Be=>Be.user_id))||[],{data:Te}=await H.from("profiles").select("id, name, email").in("id",Oe),ke=new Map((Te==null?void 0:Te.map(Be=>[Be.id,{name:Be.name,email:Be.email}]))||[]);return Ne==null?void 0:Ne.map(Be=>({...Be,profile:ke.get(Be.user_id)||null}))}}),{data:q}=mt({queryKey:["all-profiles-for-points",I],queryFn:async()=>{const Pe=[];let Oe=0;for(;;){const{data:Te,error:ke}=await H.from("profiles").select("id, name, email").order("name").range(Oe,Oe+1e3-1);if(ke)throw ke;if(Pe.push(...Te),!Te||Te.length<1e3)break;Oe+=1e3}return Pe}}),B=((q==null?void 0:q.filter(Ne=>!(I!=null&&I.some(Pe=>Pe.user_id===Ne.id))))||[]).filter(Ne=>{var Oe,Te;if(!k)return!0;const Pe=k.toLowerCase();return((Oe=Ne.name)==null?void 0:Oe.toLowerCase().includes(Pe))||((Te=Ne.email)==null?void 0:Te.toLowerCase().includes(Pe))}),{data:V,isLoading:Z}=mt({queryKey:["agent-point-history",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Ne,error:Pe}=await H.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(Pe)throw Pe;return Ne},enabled:!!(n!=null&&n.user_id)&&i}),{data:X}=mt({queryKey:["agent-badges",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Ne,error:Pe}=await H.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(Pe)throw Pe;return Ne},enabled:!!(n!=null&&n.user_id)}),ee=Dt({mutationFn:async({userId:Ne,points:Pe,reason:Oe})=>{const{error:Te}=await H.from("agent_points").insert({user_id:Ne,points:Pe,reason:Oe});if(Te)throw Te;const{data:ke}=await H.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",Ne).maybeSingle(),Be=((ke==null?void 0:ke.total_points)||0)+Pe,nt=((ke==null?void 0:ke.spendable_points)||0)+Pe,{error:Ae}=await H.from("agent_attendance_stats").upsert({user_id:Ne,total_points:Math.max(0,Be),spendable_points:Math.max(0,nt),updated_at:new Date().toISOString()},{onConflict:"user_id"});if(Ae)throw Ae},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-agent-points"]}),t.invalidateQueries({queryKey:["agent-point-history"]}),l(!1),p(""),g(""),me.success(b?"Points awarded successfully!":"Points deducted successfully!")},onError:Ne=>{console.error("Error modifying points:",Ne),me.error("Failed to modify points")}}),Q=()=>{if(!n||!u||!f){me.error("Please fill in all fields");return}const Ne=parseInt(u);if(isNaN(Ne)||Ne<=0){me.error("Please enter a valid positive number");return}ee.mutate({userId:n.user_id,points:b?Ne:-Ne,reason:f})},ie=()=>{if(!M||!u||!f){me.error("Please fill in all fields");return}const Ne=parseInt(u);if(isNaN(Ne)||Ne<=0){me.error("Please enter a valid positive number");return}ee.mutate({userId:M.id,points:Ne,reason:f},{onSuccess:()=>{w(!1),L(null),S("")}})},re=(Ne,Pe)=>{a(Ne),_(Pe),l(!0)},oe=Ne=>{a(Ne),c(!0)},ce=I==null?void 0:I.filter(Ne=>{var ke,Be,nt,Ae;const Pe=((Be=(ke=Ne.profile)==null?void 0:ke.name)==null?void 0:Be.toLowerCase())||"",Oe=((Ae=(nt=Ne.profile)==null?void 0:nt.email)==null?void 0:Ae.toLowerCase())||"",Te=s.toLowerCase();return Pe.includes(Te)||Oe.includes(Te)}),xe=(I==null?void 0:I.reduce((Ne,Pe)=>Ne+Pe.total_points,0))||0,ge=(I==null?void 0:I.length)||0,ue=ge>0?Math.round(xe/ge):0;return O?e.jsx(Ms,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(Ne=>e.jsx(ys,{className:"h-24"},Ne))}),e.jsx(ys,{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(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(pr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),e.jsx("p",{className:"text-2xl font-bold",children:ge}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xo,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Points"})]}),e.jsx("p",{className:"text-2xl font-bold",children:xe.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"awarded across all agents"})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ul,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Average Points"})]}),e.jsx("p",{className:"text-2xl font-bold",children:ue}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"per agent"})]})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[e.jsxs("div",{className:"relative max-w-sm w-full",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:s,onChange:Ne=>r(Ne.target.value),className:"pl-10"})]}),e.jsxs(K,{onClick:()=>w(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Agent Leaderboard"}),e.jsx(gr,{children:"All agents with their points, events, and streaks"})]}),e.jsx(De,{children:!ce||ce.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(xo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents with points yet"})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-12",children:"#"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"Total Points"}),e.jsx(St,{className:"text-center",children:"Spendable"}),e.jsx(St,{className:"text-center",children:"Events"}),e.jsx(St,{className:"text-center",children:"Streak"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:ce.map((Ne,Pe)=>{var Oe,Te,ke,Be;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:Pe<3?e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center ${Pe===0?"bg-yellow-100 text-yellow-700":Pe===1?"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700"}`,children:Pe+1}):e.jsx("span",{className:"text-muted-foreground",children:Pe+1})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{children:((Te=(Oe=Ne.profile)==null?void 0:Oe.name)==null?void 0:Te.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((ke=Ne.profile)==null?void 0:ke.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(Be=Ne.profile)==null?void 0:Be.email})]})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(tt,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),Ne.total_points]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(tt,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(ko,{className:"h-3 w-3 mr-1"}),Ne.spendable_points||0]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3 text-muted-foreground"}),Ne.total_events_attended]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(eh,{className:"h-3 w-3 text-orange-500"}),Ne.current_streak]})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>re(Ne,!0),title:"Award points",children:e.jsx($s,{className:"h-4 w-4 text-green-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>re(Ne,!1),title:"Deduct points",children:e.jsx(p0,{className:"h-4 w-4 text-red-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>oe(Ne),title:"View history",children:e.jsx(PM,{className:"h-4 w-4"})})]})})]},Ne.user_id)})})]})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:b?"Award Points":"Deduct Points"}),e.jsxs(Gr,{children:[b?"Award":"Deduct"," points ",b?"to":"from"," ",((pe=n==null?void 0:n.profile)==null?void 0:pe.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(ze,{id:"points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Ne=>p(Ne.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"reason",children:"Reason"}),e.jsx(Er,{id:"reason",placeholder:"Enter reason for this adjustment...",value:f,onChange:Ne=>g(Ne.target.value)})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:Q,disabled:ee.isPending,className:b?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700",children:ee.isPending?"Saving...":b?"Award Points":"Deduct Points"})]})]})}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(_s,{children:[e.jsxs(vs,{children:["Point History: ",(be=n==null?void 0:n.profile)==null?void 0:be.name]}),e.jsx(Gr,{children:"View all point transactions and badges for this agent"})]}),e.jsxs(ba,{defaultValue:"history",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2",children:[e.jsx(ns,{value:"history",children:"Point History"}),e.jsx(ns,{value:"badges",children:"Badges"})]}),e.jsx(bs,{value:"history",className:"mt-4",children:Z?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(Ne=>e.jsx(ys,{className:"h-12"},Ne))}):!V||V.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(PM,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No point history yet"})]}):e.jsx("div",{className:"max-h-80 overflow-y-auto space-y-2",children:V.map(Ne=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:Ne.reason}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ms(new Date(Ne.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(tt,{variant:Ne.points>=0?"default":"destructive",className:Ne.points>=0?"bg-green-100 text-green-800":"",children:[Ne.points>=0?"+":"",Ne.points]})]},Ne.id))})}),e.jsx(bs,{value:"badges",className:"mt-4",children:!X||X.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Nc,{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:X.map(Ne=>e.jsxs("div",{className:`p-3 rounded-lg ${Cks[Ne.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Nc,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:Ne.badge_name})]}),Ne.badge_description&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:Ne.badge_description}),e.jsxs("p",{className:"text-xs mt-1 opacity-60",children:["Earned ",ms(new Date(Ne.earned_at),"MMM d, yyyy")]})]},Ne.id))})})]})]})}),e.jsx(fs,{open:j,onOpenChange:Ne=>{w(Ne),Ne||(L(null),S(""),p(""),g(""))},children:e.jsxs(ps,{className:"max-w-md",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Award Points to New Agent"}),e.jsx(Gr,{children:"Select an agent who doesn't have points yet and award them points"})]}),e.jsx("div",{className:"space-y-4 py-4",children:M?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(Nn,{className:"h-10 w-10",children:e.jsx(kn,{children:((Me=M.name)==null?void 0:Me.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:M.name||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:M.email})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>L(null),children:"Change"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"new-points",children:"Points Amount"}),e.jsx(ze,{id:"new-points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Ne=>p(Ne.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"new-reason",children:"Reason"}),e.jsx(Er,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:f,onChange:Ne=>g(Ne.target.value)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Search Agent"}),e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:k,onChange:Ne=>S(Ne.target.value),className:"pl-10"})]})]}),e.jsx("div",{className:"max-h-60 overflow-y-auto border rounded-lg",children:B.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(pr,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:k?"No matching agents found":"All agents already have points"})]}):B.slice(0,20).map(Ne=>{var Pe;return e.jsxs("button",{onClick:()=>L(Ne),className:"w-full flex items-center gap-3 p-3 hover:bg-muted/50 transition-colors border-b last:border-b-0 text-left",children:[e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{children:((Pe=Ne.name)==null?void 0:Pe.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:Ne.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ne.email})]})]},Ne.id)})})]})}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),M&&e.jsxs(K,{onClick:ie,disabled:ee.isPending,className:"bg-green-600 hover:bg-green-700",children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Award Points"]})]})]})})]})})}function Tks(){const{data:t,isLoading:s}=lkt(),[r,n]=N.useState(null),[a,o]=N.useState(!1),[l,i]=N.useState(""),[c,u]=N.useState("all"),[p,f]=N.useState("newest"),[g,b]=N.useState("table"),_=N.useMemo(()=>(t==null?void 0:t.map(M=>M.user_id))||[],[t]),j=N.useMemo(()=>(t==null?void 0:t.map(M=>M.id))||[],[t]),{data:w}=mt({queryKey:["card-profiles-lookup",_],queryFn:async()=>{if(_.length===0)return{};const{data:M}=await H.from("profiles").select("id, name, email").in("id",_),L={};return M==null||M.forEach(I=>{L[I.id]={name:I.name||"",email:I.email||""}}),L},enabled:_.length>0}),{data:k}=mt({queryKey:["card-stats-all",j],queryFn:async()=>{if(j.length===0)return{};const M={};j.forEach(O=>{M[O]={views:0,leads:0}});const{data:L}=await H.from("agent_card_interactions").select("card_id").in("card_id",j).eq("interaction_type","card_view");L==null||L.forEach(O=>{M[O.card_id]&&M[O.card_id].views++});const{data:I}=await H.from("agent_card_leads").select("card_id").in("card_id",j);return I==null||I.forEach(O=>{M[O.card_id]&&M[O.card_id].leads++}),M},enabled:j.length>0}),S=N.useMemo(()=>{if(!t)return[];let M=[...t];if(c==="live"?M=M.filter(L=>L.is_published):c==="draft"&&(M=M.filter(L=>!L.is_published)),l.trim()){const L=l.toLowerCase();M=M.filter(I=>{var q,U;const O=w==null?void 0:w[I.user_id];return I.slug.toLowerCase().includes(L)||((q=O==null?void 0:O.name)==null?void 0:q.toLowerCase().includes(L))||((U=O==null?void 0:O.email)==null?void 0:U.toLowerCase().includes(L))})}return p==="newest"?M.sort((L,I)=>new Date(I.created_at).getTime()-new Date(L.created_at).getTime()):p==="oldest"?M.sort((L,I)=>new Date(L.created_at).getTime()-new Date(I.created_at).getTime()):p==="name"?M.sort((L,I)=>{var O,q;return(((O=w==null?void 0:w[L.user_id])==null?void 0:O.name)||"").localeCompare(((q=w==null?void 0:w[I.user_id])==null?void 0:q.name)||"")}):p==="slug"?M.sort((L,I)=>L.slug.localeCompare(I.slug)):p==="views_desc"?M.sort((L,I)=>{var O,q;return(((O=k==null?void 0:k[I.id])==null?void 0:O.views)||0)-(((q=k==null?void 0:k[L.id])==null?void 0:q.views)||0)}):p==="views_asc"?M.sort((L,I)=>{var O,q;return(((O=k==null?void 0:k[L.id])==null?void 0:O.views)||0)-(((q=k==null?void 0:k[I.id])==null?void 0:q.views)||0)}):p==="leads_desc"?M.sort((L,I)=>{var O,q;return(((O=k==null?void 0:k[I.id])==null?void 0:O.leads)||0)-(((q=k==null?void 0:k[L.id])==null?void 0:q.leads)||0)}):p==="leads_asc"&&M.sort((L,I)=>{var O,q;return(((O=k==null?void 0:k[L.id])==null?void 0:O.leads)||0)-(((q=k==null?void 0:k[I.id])==null?void 0:q.leads)||0)}),M},[t,c,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($s,{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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or slug...",value:l,onChange:M=>i(M.target.value),className:"pl-9"})]}),e.jsxs(Zs,{value:c,onValueChange:u,children:[e.jsx(Ws,{className:"w-full sm:w-36",children:e.jsx(Xs,{placeholder:"Status"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Status"}),e.jsx(Mt,{value:"live",children:"Live"}),e.jsx(Mt,{value:"draft",children:"Draft"})]})]}),e.jsxs(Zs,{value:p,onValueChange:f,children:[e.jsx(Ws,{className:"w-full sm:w-44",children:e.jsx(Xs,{placeholder:"Sort by"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"newest",children:"Newest First"}),e.jsx(Mt,{value:"oldest",children:"Oldest First"}),e.jsx(Mt,{value:"name",children:"Name A–Z"}),e.jsx(Mt,{value:"slug",children:"Slug A–Z"}),e.jsx(Mt,{value:"views_desc",children:"Most Views"}),e.jsx(Mt,{value:"views_asc",children:"Fewest Views"}),e.jsx(Mt,{value:"leads_desc",children:"Most Leads"}),e.jsx(Mt,{value:"leads_asc",children:"Fewest Leads"})]})]}),e.jsxs("div",{className:"flex border rounded-md",children:[e.jsx(K,{variant:g==="table"?"default":"ghost",size:"sm",onClick:()=>b("table"),className:"rounded-r-none",children:e.jsx($M,{className:"h-4 w-4"})}),e.jsx(K,{variant:g==="grid"?"default":"ghost",size:"sm",onClick:()=>b("grid"),className:"rounded-l-none",children:e.jsx(Cp,{className:"h-4 w-4"})})]})]}),!s&&t&&t.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",S.length," of ",t.length," cards"]}),s?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(M=>e.jsx(ys,{className:"h-48"},M))}):S.length>0?g==="table"?e.jsx(Aks,{cards:S,cardProfiles:w,cardStats:k,onEdit:n,sortBy:p,setSortBy:f}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:S.map(M=>e.jsx(Eks,{card:M,onEdit:()=>n(M),stats:k==null?void 0:k[M.id]},M.id))}):t&&t.length>0?e.jsx(Ee,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(cn,{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(De,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(pr,{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($s,{className:"h-4 w-4 mr-2"}),"Create Card"]})]})})]}),e.jsx(Pks,{open:a,onOpenChange:o}),r&&e.jsx(Iks,{card:r,open:!!r,onOpenChange:M=>!M&&n(null)})]})}function Aks({cards:t,cardProfiles:s,cardStats:r,onEdit:n,sortBy:a,setSortBy:o}){const l=c=>{a===`${c}_desc`?o(`${c}_asc`):o(`${c}_desc`)},i=({field:c})=>a===`${c}_desc`?e.jsx(Wh,{className:"h-3 w-3"}):a===`${c}_asc`?e.jsx(ku,{className:"h-3 w-3"}):e.jsx(vd,{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(ku,{className:"h-3 w-3"})]})}),e.jsx("th",{className:"text-left p-3 font-medium text-muted-foreground hidden md:table-cell",children:"Slug"}),e.jsx("th",{className:"text-center p-3 font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-right p-3 font-medium",children:e.jsxs("button",{onClick:()=>l("views"),className:"flex items-center gap-1 ml-auto hover:text-foreground text-muted-foreground",children:["Views ",e.jsx(i,{field:"views"})]})}),e.jsx("th",{className:"text-right p-3 font-medium",children:e.jsxs("button",{onClick:()=>l("leads"),className:"flex items-center gap-1 ml-auto hover:text-foreground text-muted-foreground",children:["Leads ",e.jsx(i,{field:"leads"})]})}),e.jsx("th",{className:"text-right p-3 font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:t.map(c=>{const u=s==null?void 0:s[c.user_id],p=r==null?void 0:r[c.id],f=`https://cards.relevelup.com/${c.slug}`;return e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30 transition-colors",children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:(u==null?void 0:u.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(u==null?void 0:u.email)||""})]})}),e.jsx("td",{className:"p-3 hidden md:table-cell",children:e.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["/",c.slug]})}),e.jsx("td",{className:"p-3 text-center",children:e.jsx(tt,{variant:c.is_published?"default":"secondary",className:"text-xs",children:c.is_published?"Live":"Draft"})}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.views)??0}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.leads)??0}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>n(c),className:"h-8 w-8 p-0",children:e.jsx(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),me.success("Link copied!")},children:e.jsx(gi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",asChild:!0,children:e.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",children:e.jsx(tn,{className:"h-3.5 w-3.5"})})})]})})]},c.id)})})]})})})}function Eks({card:t,onEdit:s,stats:r}){const[n,a]=N.useState(null);N.useEffect(()=>{(async()=>{const{data:c}=await H.from("profiles").select("name").eq("id",t.user_id).single();let u=null;try{const{data:p}=await H.storage.from("avatars").list(`${t.user_id}`);if(p&&p.length>0){const{data:f}=H.storage.from("avatars").getPublicUrl(`${t.user_id}/${p[0].name}`);u=f.publicUrl}}catch{}a({name:(c==null?void 0:c.name)||"Unknown",avatar_url:u})})()},[t.user_id]);const o=`https://cards.relevelup.com/${t.slug}`,l=()=>{navigator.clipboard.writeText(o),me.success("Link copied!")};return e.jsx(Ee,{children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:(n==null?void 0:n.avatar_url)||void 0}),e.jsx(kn,{children:((n==null?void 0:n.name)||"U")[0]})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold truncate",children:(n==null?void 0:n.name)||"Loading..."}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["/card/",t.slug]})]}),e.jsx(tt,{variant:t.is_published?"default":"secondary",children:t.is_published?"Live":"Draft"})]}),e.jsxs("div",{className:"flex items-center gap-3 mb-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(On,{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(pr,{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(gi,{className:"h-3 w-3"})}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:e.jsx(tn,{className:"h-3 w-3"})})})]})]})})}function Pks({open:t,onOpenChange:s}){const[r,n]=N.useState(""),[a,o]=N.useState(""),[l,i]=N.useState(""),[c,u]=N.useState(!1),p=aGe(),f=l.trim(),{data:g}=mt({queryKey:["profiles-search-for-cards",f],queryFn:async()=>{let S=H.from("profiles").select("id, name, email").order("name").limit(50);f.length>=2&&(S=S.or(`name.ilike.%${f}%,email.ilike.%${f}%`));const{data:M}=await S;return M||[]},enabled:t}),[b,_]=N.useState(null),j=(g==null?void 0:g.find(S=>S.id===r))||b,w=()=>{if(!r||!a.trim()){me.error("Select an agent and enter a slug");return}p.mutate({user_id:r,slug:a.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-"),is_published:!0},{onSuccess:()=>{s(!1),n(""),o(""),i("")}})},k=S=>{var L;n(S),u(!1);const M=g==null?void 0:g.find(I=>I.id===S);M&&(_(M),o(((L=M.name)==null?void 0:L.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||""))};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create Agent Card"}),e.jsx(Gr,{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($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":c,className:"w-full justify-between font-normal",children:[j?`${j.name} (${j.email})`:"Search for an agent...",e.jsx(Sx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Lx,{shouldFilter:!1,children:[e.jsx(Dx,{placeholder:"Search by name or email...",value:l,onValueChange:i}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:"No agents found."}),e.jsx(Fx,{children:(g||[]).map(S=>e.jsxs(bp,{value:S.id,onSelect:k,children:[e.jsx(va,{className:It("mr-2 h-4 w-4",r===S.id?"opacity-100":"opacity-0")}),S.name," (",S.email,")"]},S.id))})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(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(ze,{value:a,onChange:S=>o(S.target.value),placeholder:"john-doe"})]})]}),e.jsx(K,{onClick:w,disabled:p.isPending,className:"w-full",children:p.isPending?"Creating...":"Create Card"})]})]})})}function Iks({card:t,open:s,onOpenChange:r}){const n=iGe(),{data:a}=oGe(t.id),o=Qt(),[l,i]=N.useState(null),[c,u]=N.useState(!1),[p,f]=N.useState(!1),[g,b]=N.useState(""),[_,j]=N.useState(t.slug),[w,k]=N.useState(!1),[S,M]=N.useState({is_published:t.is_published,theme:t.theme,title:t.title||"",positioning_statement:t.positioning_statement||"",bio:t.bio||"",review_snippet:t.review_snippet||"",review_source_url:t.review_source_url||"",booking_url:t.booking_url||"",custom_cta_label:t.custom_cta_label||"",custom_cta_url:t.custom_cta_url||"",show_photo:t.show_photo,show_bio:t.show_bio,show_credentials:t.show_credentials,show_social_links:t.show_social_links,show_save_contact:t.show_save_contact,show_leave_review:t.show_leave_review,show_refer_friend:t.show_refer_friend,brokerage_display_name:t.brokerage_display_name||"",brokerage_logo_url:t.brokerage_logo_url||"",brokerage_logo_size:t.brokerage_logo_size||56,team_name:t.team_name||"",team_logo_url:t.team_logo_url||"",team_logo_size:t.team_logo_size||56});N.useEffect(()=>{s&&(async()=>{try{const{data:V}=await H.storage.from("avatars").list(`${t.user_id}`);if(V&&V.length>0){const{data:Z}=H.storage.from("avatars").getPublicUrl(`${t.user_id}/${V[0].name}`);i(`${Z.publicUrl}?t=${Date.now()}`)}}catch{}})()},[t.user_id,s]);const L=B=>{var X;const V=(X=B.target.files)==null?void 0:X[0];if(!V)return;if(!V.type.startsWith("image/")){me.error("Please select an image file");return}if(V.size>5*1024*1024){me.error("Image must be under 5MB");return}const Z=new FileReader;Z.onloadend=()=>{b(Z.result),f(!0)},Z.readAsDataURL(V),B.target.value=""},I=async B=>{u(!0);try{const{data:V}=await H.storage.from("avatars").list(`${t.user_id}`);V&&V.length>0&&await H.storage.from("avatars").remove(V.map(ie=>`${t.user_id}/${ie.name}`));const Z=`${t.user_id}/avatar.jpg`,{error:X}=await H.storage.from("avatars").upload(Z,B,{upsert:!0,contentType:"image/jpeg"});if(X)throw X;const{data:ee}=H.storage.from("avatars").getPublicUrl(Z),Q=`${ee.publicUrl}?t=${Date.now()}`;i(Q),await H.from("profiles").update({avatar_url:Q}).eq("id",t.user_id),o.invalidateQueries({queryKey:["agent-card-public"]}),me.success("Photo updated!")}catch(V){me.error(V.message||"Upload failed")}finally{u(!1)}},O=async()=>{const B=_.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!B){me.error("Please enter a valid URL");return}if(B===t.slug){me.info("No changes to save");return}k(!0);try{const{data:V}=await H.from("agent_cards").select("id").eq("slug",B).neq("id",t.id).maybeSingle();if(V){me.error("This URL is already taken. Try another one.");return}const{error:Z}=await H.from("agent_cards").update({slug:B}).eq("id",t.id);if(Z)throw Z;j(B),o.invalidateQueries({queryKey:["agent-cards-admin"]}),me.success("Card address updated!")}catch{me.error("Failed to update card address")}finally{k(!1)}},q=async(B,V)=>{var X;const Z=(X=B.target.files)==null?void 0:X[0];if(Z){if(!Z.type.startsWith("image/")){me.error("Please select an image file");return}try{const ee=Z.name.split(".").pop()||"png",Q=V==="brokerage_logo_url"?"brokerage-logo":"team-logo",ie=`${t.user_id}/${Q}.${ee}`,{error:re}=await H.storage.from("card-logos").upload(ie,Z,{upsert:!0});if(re)throw re;const{data:oe}=H.storage.from("card-logos").getPublicUrl(ie),ce=oe.publicUrl+"?t="+Date.now();M(V==="brokerage_logo_url"?xe=>({...xe,[V]:ce,brokerage_display_name:""}):xe=>({...xe,[V]:ce,team_name:""})),me.success("Logo uploaded!")}catch{me.error("Failed to upload logo")}finally{B.target.value=""}}},U=()=>{n.mutate({id:t.id,...S,title:S.title||null,positioning_statement:S.positioning_statement||null,bio:S.bio||null,review_snippet:S.review_snippet||null,review_source_url:S.review_source_url||null,booking_url:S.booking_url||null,custom_cta_label:S.custom_cta_label||null,custom_cta_url:S.custom_cta_url||null,brokerage_display_name:S.brokerage_display_name||null,brokerage_logo_url:S.brokerage_logo_url||null,brokerage_logo_size:S.brokerage_logo_size,team_name:S.team_name||null,team_logo_url:S.team_logo_url||null,team_logo_size:S.team_logo_size},{onSuccess:()=>r(!1)})};return e.jsxs(e.Fragment,{children:[e.jsx(fs,{open:s,onOpenChange:r,children:e.jsxs(ps,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Edit Agent Card"}),e.jsxs(Gr,{children:["/card/",t.slug]})]}),e.jsxs(ba,{defaultValue:"content",children:[e.jsxs(pa,{className:"w-full",children:[e.jsx(ns,{value:"content",className:"flex-1",children:"Content"}),e.jsx(ns,{value:"sections",className:"flex-1",children:"Sections"}),e.jsx(ns,{value:"blocks",className:"flex-1",children:"Blocks"}),e.jsx(ns,{value:"analytics",className:"flex-1",children:"Analytics"})]}),e.jsxs(bs,{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(qr,{checked:S.is_published,onCheckedChange:B=>M(V=>({...V,is_published:B}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[e.jsxs(Nn,{className:"h-16 w-16",children:[e.jsx($a,{src:l||void 0}),e.jsx(kn,{children:"?"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:L,disabled:c}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:c,children:e.jsx("span",{children:c?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(li,{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(ze,{value:_,onChange:B=>j(B.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"agent-name",className:"rounded-l-none"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:O,disabled:w||_===t.slug,className:"shrink-0",children:w?"Saving...":"Update"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Theme"}),e.jsxs(Zs,{value:S.theme,onValueChange:B=>M(V=>({...V,theme:B})),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"standard",children:"✨ Standard (Modern Clean)"}),e.jsx(Mt,{value:"luxury",children:"🌙 Luxury (Dark & Gold)"}),e.jsx(Mt,{value:"bold",children:"🔥 Bold (Vibrant & Punchy)"}),e.jsx(Mt,{value:"classic",children:"📋 Classic (Professional)"})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Title / Tagline"}),e.jsx(ze,{value:S.title,onChange:B=>M(V=>({...V,title:B.target.value})),placeholder:"e.g. Luxury Real Estate Specialist"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Shown below the agent's name on the card"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Positioning Statement"}),e.jsx(ze,{value:S.positioning_statement,onChange:B=>M(V=>({...V,positioning_statement:B.target.value})),placeholder:"Your home journey, handled with care."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Bio"}),e.jsx(Er,{value:S.bio,onChange:B=>M(V=>({...V,bio:B.target.value})),placeholder:"Short about me...",rows:3})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Review Snippet"}),e.jsx(ze,{value:S.review_snippet,onChange:B=>M(V=>({...V,review_snippet:B.target.value})),placeholder:"Best agent we've ever worked with..."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Review Source URL"}),e.jsx(ze,{value:S.review_source_url,onChange:B=>M(V=>({...V,review_source_url:B.target.value})),placeholder:"https://g.page/your-business/review"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Booking URL (optional — if empty, shows lead form)"}),e.jsx(ze,{value:S.booking_url,onChange:B=>M(V=>({...V,booking_url:B.target.value})),placeholder:"https://calendly.com/your-link"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Custom CTA Label (optional)"}),e.jsx(ze,{value:S.custom_cta_label,onChange:B=>M(V=>({...V,custom_cta_label:B.target.value})),placeholder:"Book a Call"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Custom CTA URL (optional)"}),e.jsx(ze,{value:S.custom_cta_url,onChange:B=>M(V=>({...V,custom_cta_url:B.target.value})),placeholder:"https://example.com/landing"})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(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(ze,{value:S.brokerage_display_name,onChange:B=>M(V=>({...V,brokerage_display_name:B.target.value,brokerage_logo_url:""})),placeholder:"Brokerage name (or upload logo below)",disabled:!!S.brokerage_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[S.brokerage_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:S.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${S.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>M(B=>({...B,brokerage_logo_url:""})),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(li,{className:"h-3.5 w-3.5"}),S.brokerage_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:B=>q(B,"brokerage_logo_url")})]})]}),S.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.brokerage_logo_size||56,"px"]})]}),e.jsx(Gg,{value:[S.brokerage_logo_size||56],onValueChange:([B])=>M(V=>({...V,brokerage_logo_size:B})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(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(ze,{value:S.team_name,onChange:B=>M(V=>({...V,team_name:B.target.value,team_logo_url:""})),placeholder:"Team name (or upload logo below)",disabled:!!S.team_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[S.team_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:S.team_logo_url,alt:"Team logo",style:{height:`${S.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>M(B=>({...B,team_logo_url:""})),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(li,{className:"h-3.5 w-3.5"}),S.team_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:B=>q(B,"team_logo_url")})]})]}),S.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.team_logo_size||56,"px"]})]}),e.jsx(Gg,{value:[S.team_logo_size||56],onValueChange:([B])=>M(V=>({...V,team_logo_size:B})),min:24,max:120,step:4})]})]})]})]}),e.jsx(bs,{value:"sections",className:"space-y-4 mt-4",children:[{key:"show_photo",label:"Show Photo",hint:"Photo is pulled from the agent's profile."},{key:"show_bio",label:"Show Bio"},{key:"show_credentials",label:"Show Credentials"},{key:"show_social_links",label:"Show Social Links"},{key:"show_save_contact",label:"Save Contact Button"},{key:"show_leave_review",label:"Leave Review Button"},{key:"show_refer_friend",label:"Refer a Friend Button"}].map(({key:B,label:V,hint:Z})=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx(ve,{children:V}),Z&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[Z," ",B==="show_photo"&&e.jsx("a",{href:"/profile",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:"Update Profile"})]})]}),e.jsx(qr,{checked:S[B],onCheckedChange:X=>M(ee=>({...ee,[B]:X}))})]},B))}),e.jsx(bs,{value:"blocks",className:"mt-4",children:e.jsx(plt,{cardId:t.id})}),e.jsx(bs,{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(De,{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(De,{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(De,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.leads.length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Leads"})]})})]}),a.leads.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Recent Leads"}),e.jsx("div",{className:"space-y-2",children:a.leads.slice(0,5).map(B=>e.jsxs("div",{className:"text-sm p-2 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"font-medium",children:B.name}),B.phone&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",B.phone]}),B.intent&&e.jsx(tt,{variant:"secondary",className:"ml-2 text-xs",children:B.intent})]},B.id))})]})]}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No analytics data yet"})})]}),e.jsx(K,{onClick:U,disabled:n.isPending,className:"w-full mt-4",children:n.isPending?"Saving...":"Save Changes"})]})}),e.jsx(_ke,{open:p,onClose:()=>f(!1),imageSrc:g,onCropComplete:I,aspectRatio:1})]})}const dT={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"},dCe={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 uCe(t=!0){return mt({queryKey:["marketplace-categories",t],queryFn:async()=>{let s=H.from("marketplace_categories").select("*").order("sort_order",{ascending:!0});t&&(s=s.eq("is_active",!0));const{data:r,error:n}=await s;if(n)throw n;return r}})}function Lks(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("marketplace_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),me.success("Category created successfully")},onError:s=>{me.error("Failed to create category: "+s.message)}})}function Dks(){const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("marketplace_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),me.success("Category updated successfully")},onError:s=>{me.error("Failed to update category: "+s.message)}})}function Oks(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("marketplace_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),me.success("Category deleted successfully")},onError:s=>{me.error("Failed to delete category: "+s.message)}})}function Tlt(t,s=!0){return mt({queryKey:["marketplace-products",t,s],queryFn:async()=>{let r=H.from("marketplace_products").select(` *, category:marketplace_categories(*), images:marketplace_product_images(*), video:marketplace_product_videos(*), variants:marketplace_product_variants(*) `).order("sort_order",{ascending:!0});t&&(r=r.eq("category_id",t)),s&&(r=r.eq("is_active",!0));const{data:n,error:a}=await r;if(a)throw a;return n}})}function Rks(t){return mt({queryKey:["marketplace-product",t],queryFn:async()=>{const{data:s,error:r}=await H.from("marketplace_products").select(` *, category:marketplace_categories(*), images:marketplace_product_images(*), video:marketplace_product_videos(*), variants:marketplace_product_variants(*) `).eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function Fks(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("marketplace_products").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),me.success("Product created successfully")},onError:s=>{me.error("Failed to create product: "+s.message)}})}function zks(){const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("marketplace_products").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.id]}),me.success("Product updated successfully")},onError:s=>{me.error("Failed to update product: "+s.message)}})}function Bks(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("marketplace_products").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),me.success("Product deleted successfully")},onError:s=>{me.error("Failed to delete product: "+s.message)}})}function $ks(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("marketplace_product_images").insert([s]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.product_id]})}})}function qks(){const t=Qt();return Dt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await H.from("marketplace_product_images").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),me.success("Image deleted successfully")},onError:s=>{me.error("Failed to delete image: "+s.message)}})}function Uks(){const t=Qt();return Dt({mutationFn:async({imageId:s,productId:r})=>{const{error:n}=await H.from("marketplace_product_images").update({is_primary:!1}).eq("product_id",r);if(n)throw n;const{error:a}=await H.from("marketplace_product_images").update({is_primary:!0}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),me.success("Primary image updated")},onError:s=>{me.error("Failed to set primary image: "+s.message)}})}function Vks(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("marketplace_product_variants").insert([s]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.product_id]}),me.success("Variant added successfully")}})}function Hks(){const t=Qt();return Dt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await H.from("marketplace_product_variants").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),me.success("Variant deleted successfully")}})}function Wks(){const t=Qt();return Dt({mutationFn:async({productId:s,videoUrl:r})=>{await H.from("marketplace_product_videos").delete().eq("product_id",s);const{data:n,error:a}=await H.from("marketplace_product_videos").insert({product_id:s,video_url:r}).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.productId]}),me.success("Video updated successfully")}})}function Gks(t){const{isAdmin:s}=Ds();return mt({queryKey:["marketplace-orders",t,s],queryFn:async()=>{let r=H.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).order("created_at",{ascending:!1});const{data:n,error:a}=await r;if(a)throw a;if(s&&n){const o=[...new Set(n.map(c=>c.user_id))],{data:l}=await H.from("profiles").select("id, name, email").in("id",o),i=new Map((l==null?void 0:l.map(c=>[c.id,c]))||[]);return n.map(c=>({...c,user:i.get(c.user_id)}))}return n}})}function Kks(){const{user:t}=Ds();return mt({queryKey:["my-marketplace-orders",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).eq("user_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function Zks(t){return mt({queryKey:["marketplace-order",t],queryFn:async()=>{const{data:s,error:r}=await H.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function Yks(){const t=Qt(),{user:s}=Ds();return Dt({mutationFn:async({orderId:r,status:n,notes:a,trackingNumber:o,trackingUrl:l,previousStatus:i})=>{const c={status:n};o!==void 0&&(c.tracking_number=o),l!==void 0&&(c.tracking_url=l);const{error:u}=await H.from("marketplace_orders").update(c).eq("id",r);if(u)throw u;const{error:p}=await H.from("marketplace_order_status_history").insert({order_id:r,status:n,notes:a,created_by:s==null?void 0:s.id});if(p)throw p;if(["shipped","in_production","processing","completed"].includes(n)&&n!==i)try{await H.functions.invoke("marketplace-order-notify",{body:{orderId:r,notificationType:n==="shipped"?"shipped":"status_update",newStatus:n,trackingNumber:o,trackingUrl:l}})}catch(g){console.error("Failed to send notification email:",g)}},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",n.orderId]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Order status updated")},onError:r=>{me.error("Failed to update order: "+r.message)}})}function Xks(){const t=Qt();return Dt({mutationFn:async({itemId:s,proofUrl:r,proofNotes:n,orderId:a})=>{const{error:o}=await H.from("marketplace_order_items").update({proof_url:r,proof_notes:n,proof_status:"pending"}).eq("id",s);if(o)throw o;await H.from("marketplace_orders").update({status:"awaiting_proof_approval"}).eq("id",a);try{await H.functions.invoke("marketplace-order-notify",{body:{orderId:a,notificationType:"proof_ready"}})}catch(l){console.error("Failed to send proof notification:",l)}return a},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Proof uploaded & customer notified")}})}function Qks(){const t=Qt();return Dt({mutationFn:async({itemId:s,orderId:r})=>{const{error:n}=await H.from("marketplace_order_items").update({proof_status:"approved"}).eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Proof approved")}})}function Jks(){const t=Qt();return Dt({mutationFn:async({itemId:s,orderId:r,reason:n})=>{const{error:a}=await H.from("marketplace_order_items").update({proof_status:"rejected",proof_notes:n}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Proof rejected - please upload a new proof")}})}function e4s(){const{data:t,isLoading:s}=uCe(!1),r=Lks(),n=Dks(),a=Oks(),[o,l]=N.useState(!1),[i,c]=N.useState(null),[u,p]=N.useState({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),f=()=>{p({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),c(null)},g=j=>{c(j),p({name:j.name,description:j.description||"",image_url:j.image_url||"",sort_order:j.sort_order,is_active:j.is_active}),l(!0)},b=async j=>{j.preventDefault(),i?await n.mutateAsync({id:i.id,...u}):await r.mutateAsync(u),l(!1),f()},_=async j=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(j)};return s?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(ys,{className:"h-8 w-48"})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(j=>e.jsx(ys,{className:"h-12 w-full"},j))})})]}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{children:"Categories"}),e.jsxs(fs,{open:o,onOpenChange:j=>{l(j),j||f()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Category"]})}),e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:i?"Edit Category":"Add Category"})}),e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",value:u.name,onChange:j=>p({...u,name:j.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",value:u.description,onChange:j=>p({...u,description:j.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"image_url",children:"Image URL"}),e.jsx(ze,{id:"image_url",value:u.image_url,onChange:j=>p({...u,image_url:j.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(ze,{id:"sort_order",type:"number",value:u.sort_order,onChange:j=>p({...u,sort_order:parseInt(j.target.value)||0})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{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(De,{children:t&&t.length>0?e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Sort Order"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:t.map(j=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:j.name}),e.jsx(dt,{className:"max-w-xs truncate",children:j.description}),e.jsx(dt,{children:j.sort_order}),e.jsx(dt,{children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${j.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:j.is_active?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>g(j),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(j.id),disabled:a.isPending,children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},j.id))})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first category to get started."})})]})}function t4s(){var ue,pe;const{data:t,isLoading:s}=Tlt(void 0,!1),{data:r}=uCe(!1),n=Fks(),a=zks(),o=Bks(),l=$ks(),i=qks(),c=Uks(),u=Vks(),p=Hks(),f=Wks(),[g,b]=N.useState(!1),[_,j]=N.useState(!1),[w,k]=N.useState(!1),[S,M]=N.useState(null),[L,I]=N.useState(null),[O,q]=N.useState(!1),[U,B]=N.useState({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),[V,Z]=N.useState({name:"",price_adjustment:0}),[X,ee]=N.useState(""),Q=()=>{B({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),M(null)},ie=be=>{M(be),B({name:be.name,description:be.description||"",base_price:Number(be.base_price),shipping_fee:Number(be.shipping_fee),category_id:be.category_id||"",allow_artwork_upload:be.allow_artwork_upload,requires_proof_approval:be.requires_proof_approval,is_active:be.is_active,sort_order:be.sort_order}),b(!0)},re=async be=>{be.preventDefault();const Me={...U,category_id:U.category_id||null};S?await a.mutateAsync({id:S.id,...Me}):await n.mutateAsync(Me),b(!1),Q()},oe=async be=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(be)},ce=async be=>{if(!L||!be.target.files||be.target.files.length===0)return;q(!0);const Me=be.target.files[0],Ne=Me.name.split(".").pop(),Pe=`products/${L.id}/${Date.now()}.${Ne}`;try{const{error:Oe}=await H.storage.from("marketplace").upload(Pe,Me);if(Oe)throw Oe;const{data:{publicUrl:Te}}=H.storage.from("marketplace").getPublicUrl(Pe);await l.mutateAsync({product_id:L.id,image_url:Te,is_primary:!L.images||L.images.length===0}),me.success("Image uploaded successfully")}catch(Oe){me.error("Failed to upload image: "+Oe.message)}finally{q(!1)}},xe=async be=>{be.preventDefault(),L&&(await u.mutateAsync({product_id:L.id,name:V.name,price_adjustment:V.price_adjustment}),Z({name:"",price_adjustment:0}))},ge=async()=>{!L||!X||(await f.mutateAsync({productId:L.id,videoUrl:X}),ee(""))};return s?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(ys,{className:"h-8 w-48"})}),e.jsx(De,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(be=>e.jsx(ys,{className:"h-64 w-full"},be))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{children:"Products"}),e.jsxs(fs,{open:g,onOpenChange:be=>{b(be),be||Q()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Product"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:S?"Edit Product":"Add Product"})}),e.jsxs("form",{onSubmit:re,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(ze,{id:"name",value:U.name,onChange:be=>B({...U,name:be.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"category",children:"Category"}),e.jsxs(Zs,{value:U.category_id,onValueChange:be=>B({...U,category_id:be}),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select category"})}),e.jsx(Gs,{children:r==null?void 0:r.map(be=>e.jsx(Mt,{value:be.id,children:be.name},be.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",value:U.description,onChange:be=>B({...U,description:be.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(ze,{id:"base_price",type:"number",step:"0.01",min:"0",value:U.base_price,onChange:be=>B({...U,base_price:parseFloat(be.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"shipping_fee",children:"Shipping Fee ($)"}),e.jsx(ze,{id:"shipping_fee",type:"number",step:"0.01",min:"0",value:U.shipping_fee,onChange:be=>B({...U,shipping_fee:parseFloat(be.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(ze,{id:"sort_order",type:"number",value:U.sort_order,onChange:be=>B({...U,sort_order:parseInt(be.target.value)||0})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"allow_artwork_upload",checked:U.allow_artwork_upload,onCheckedChange:be=>B({...U,allow_artwork_upload:be})}),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(qr,{id:"requires_proof_approval",checked:U.requires_proof_approval,onCheckedChange:be=>B({...U,requires_proof_approval:be})}),e.jsx(ve,{htmlFor:"requires_proof_approval",children:"Requires proof approval"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_active",checked:U.is_active,onCheckedChange:be=>B({...U,is_active:be})}),e.jsx(ve,{htmlFor:"is_active",children:"Active"})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:n.isPending||a.isPending,children:S?"Update Product":"Create Product"})]})]})]})]}),e.jsx(De,{children:t&&t.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(be=>{var Me,Ne;return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[be.images&&be.images.length>0?e.jsx("img",{src:((Me=be.images.find(Pe=>Pe.is_primary))==null?void 0:Me.image_url)||be.images[0].image_url,alt:be.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"}),!be.is_active&&e.jsx(tt,{variant:"secondary",className:"absolute top-2 right-2",children:"Inactive"})]}),e.jsxs(De,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1",children:be.name}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:((Ne=be.category)==null?void 0:Ne.name)||"No category"}),e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("span",{className:"font-bold",children:["$",Number(be.base_price).toFixed(2)]}),Number(be.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["+$",Number(be.shipping_fee).toFixed(2)," shipping"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[be.allow_artwork_upload&&e.jsx(tt,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),be.requires_proof_approval&&e.jsx(tt,{variant:"outline",className:"text-xs",children:"Proof Required"}),be.variants&&be.variants.length>0&&e.jsxs(tt,{variant:"outline",className:"text-xs",children:[be.variants.length," Variants"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ie(be),children:[e.jsx(Ra,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{I(be),j(!0)},children:[e.jsx(a1,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{I(be),k(!0)},children:[e.jsx(Fm,{className:"h-3 w-3 mr-1"}),"Variants"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>oe(be.id),children:e.jsx(Nr,{className:"h-3 w-3 text-destructive"})})]})]})]},be.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(fs,{open:_,onOpenChange:j,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(vs,{children:["Manage Images - ",L==null?void 0:L.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-4",children:(ue=L==null?void 0:L.images)==null?void 0:ue.map(be=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:be.image_url,alt:"",className:"w-full aspect-square object-cover rounded-lg"}),be.is_primary&&e.jsx(tt,{className:"absolute top-2 left-2",variant:"default",children:"Primary"}),e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[!be.is_primary&&e.jsx(K,{variant:"secondary",size:"icon",onClick:async()=>{var Me;await c.mutateAsync({imageId:be.id,productId:L.id}),I({...L,images:(Me=L.images)==null?void 0:Me.map(Ne=>({...Ne,is_primary:Ne.id===be.id}))})},disabled:c.isPending,title:"Set as primary",children:e.jsx(Jn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"destructive",size:"icon",onClick:async()=>{var Ne;await i.mutateAsync({id:be.id,productId:L.id});const Me=t==null?void 0:t.find(Pe=>Pe.id===L.id);Me&&I({...Me,images:(Ne=Me.images)==null?void 0:Ne.filter(Pe=>Pe.id!==be.id)})},disabled:i.isPending,children:e.jsx(Nr,{className:"h-4 w-4"})})]})]},be.id))}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:ce,className:"hidden",id:"image-upload",disabled:O}),e.jsxs("label",{htmlFor:"image-upload",className:"cursor-pointer",children:[e.jsx(a1,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:O?"Uploading...":"Click to upload an image"})]})]}),e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx(ve,{children:"Product Video (optional)"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(ze,{placeholder:"Enter video URL (YouTube, Vimeo, etc.)",value:X,onChange:be=>ee(be.target.value)}),e.jsxs(K,{onClick:ge,disabled:!X,children:[e.jsx(An,{className:"h-4 w-4 mr-2"}),"Set Video"]})]}),(L==null?void 0:L.video)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Current video: ",L.video.video_url]})]})]})]})}),e.jsx(fs,{open:w,onOpenChange:k,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsxs(vs,{children:["Manage Variants - ",L==null?void 0:L.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:xe,className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Variant name (e.g., 500 count)",value:V.name,onChange:be=>Z({...V,name:be.target.value}),required:!0}),e.jsx(ze,{type:"number",step:"0.01",placeholder:"Price adj.",value:V.price_adjustment,onChange:be=>Z({...V,price_adjustment:parseFloat(be.target.value)||0}),className:"w-32"}),e.jsx(K,{type:"submit",children:"Add"})]}),e.jsxs("div",{className:"space-y-2",children:[(pe=L==null?void 0:L.variants)==null?void 0:pe.map(be=>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:be.name}),e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:[Number(be.price_adjustment)>=0?"+":"","$",Number(be.price_adjustment).toFixed(2)]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutateAsync({id:be.id,productId:L.id}),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]},be.id)),(!(L!=null&&L.variants)||L.variants.length===0)&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:'No variants yet. Add variants like "250 count", "500 count", etc.'})]})]})]})})]})}const s4s=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function r4s(){var j,w,k;const{data:t,isLoading:s}=Gks(),r=Yks(),n=Xks(),[a,o]=N.useState(null),[l,i]=N.useState(!1),[c,u]=N.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[p,f]=N.useState(!1),g=S=>{o(S),u({status:S.status,notes:"",trackingNumber:S.tracking_number||"",trackingUrl:S.tracking_url||""}),i(!0)},b=async()=>{a&&(await r.mutateAsync({orderId:a.id,status:c.status,notes:c.notes,trackingNumber:c.trackingNumber,trackingUrl:c.trackingUrl,previousStatus:a.status}),i(!1))},_=async(S,M)=>{if(!a||!S.target.files||S.target.files.length===0)return;f(!0);const L=S.target.files[0],I=L.name.split(".").pop(),O=`proofs/${a.id}/${M}/${Date.now()}.${I}`;try{const{error:q}=await H.storage.from("marketplace").upload(O,L);if(q)throw q;const{data:{publicUrl:U}}=H.storage.from("marketplace").getPublicUrl(O);await n.mutateAsync({itemId:M,proofUrl:U,orderId:a.id}),me.success("Proof uploaded successfully")}catch(q){me.error("Failed to upload proof: "+q.message)}finally{f(!1)}};return s?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(ys,{className:"h-8 w-48"})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(S=>e.jsx(ys,{className:"h-16 w-full"},S))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Orders"})}),e.jsx(De,{children:t&&t.length>0?e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Order #"}),e.jsx(St,{children:"Customer"}),e.jsx(St,{children:"Date"}),e.jsx(St,{children:"Total"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:t.map(S=>{var M,L;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-mono",children:S.order_number}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((M=S.user)==null?void 0:M.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(L=S.user)==null?void 0:L.email})]})}),e.jsx(dt,{children:ms(new Date(S.created_at),"MMM d, yyyy")}),e.jsxs(dt,{className:"font-bold",children:["$",Number(S.total).toFixed(2)]}),e.jsx(dt,{children:e.jsx(tt,{className:dCe[S.status],children:dT[S.status]})}),e.jsx(dt,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>g(S),children:[e.jsx(On,{className:"h-4 w-4 mr-1"}),"View"]})})]},S.id)})})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No orders yet."})})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsxs(vs,{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:(k=a.items)==null?void 0:k.map(S=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.product_name}),S.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.variant_name})]}),e.jsxs("p",{className:"font-bold",children:["$",Number(S.unit_price).toFixed(2)," x ",S.quantity]})]}),S.artwork_url&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Customer Artwork:"}),e.jsx("a",{href:S.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Artwork"})]}),e.jsx("div",{className:"mt-3 pt-3 border-t",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Proof Status: "}),e.jsx(tt,{variant:S.proof_status==="approved"?"default":"secondary",children:S.proof_status||"No proof yet"})]}),S.proof_url?e.jsx("a",{href:S.proof_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Proof"}):e.jsxs("div",{children:[e.jsx("input",{type:"file",accept:"image/*,.pdf",onChange:M=>_(M,S.id),className:"hidden",id:`proof-${S.id}`,disabled:p}),e.jsx("label",{htmlFor:`proof-${S.id}`,children:e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("span",{children:[e.jsx(li,{className:"h-4 w-4 mr-1"}),p?"Uploading...":"Upload Proof"]})})})]})]})})]},S.id))})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Subtotal"}),e.jsxs("span",{children:["$",Number(a.subtotal).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",Number(a.shipping_total).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between font-bold text-lg mt-2",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",Number(a.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Update Order Status"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Status"}),e.jsxs(Zs,{value:c.status,onValueChange:S=>u({...c,status:S}),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:s4s.map(S=>e.jsx(Mt,{value:S,children:dT[S]},S))})]})]}),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(ze,{value:c.trackingNumber,onChange:S=>u({...c,trackingNumber:S.target.value}),placeholder:"Enter tracking number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Tracking URL"}),e.jsx(ze,{value:c.trackingUrl,onChange:S=>u({...c,trackingUrl:S.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Notes (optional)"}),e.jsx(Er,{value:c.notes,onChange:S=>u({...c,notes:S.target.value}),placeholder:"Add a note about this status change..."})]}),e.jsxs(K,{onClick:b,disabled:r.isPending,className:"w-full",children:[e.jsx(Ml,{className:"h-4 w-4 mr-2"}),"Update Status"]})]})]}),a.status_history&&a.status_history.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Status History"}),e.jsx("div",{className:"space-y-2",children:a.status_history.map(S=>e.jsxs("div",{className:"flex justify-between text-sm p-2 bg-muted rounded",children:[e.jsxs("div",{children:[e.jsx(tt,{variant:"outline",children:dT[S.status]}),S.notes&&e.jsx("p",{className:"text-muted-foreground mt-1",children:S.notes})]}),e.jsx("span",{className:"text-muted-foreground",children:ms(new Date(S.created_at),"MMM d, h:mm a")})]},S.id))})]})]})]})})]})}function n4s(){const[t,s]=N.useState("products"),r=fr();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(tn,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),e.jsxs(ba,{value:t,onValueChange:s,children:[e.jsxs(pa,{className:"grid w-full grid-cols-3",children:[e.jsxs(ns,{value:"products",className:"flex items-center gap-2",children:[e.jsx(Ml,{className:"h-4 w-4"}),"Products"]}),e.jsxs(ns,{value:"categories",className:"flex items-center gap-2",children:[e.jsx(Om,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(ns,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(vp,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx(bs,{value:"products",children:e.jsx(t4s,{})}),e.jsx(bs,{value:"categories",children:e.jsx(e4s,{})}),e.jsx(bs,{value:"orders",children:e.jsx(r4s,{})})]})]})})}function Alt(){return mt({queryKey:["reward-categories"],queryFn:async()=>{const{data:t,error:s}=await H.from("reward_store_categories").select("*").order("sort_order",{ascending:!0});if(s)throw s;return t}})}function a4s(t){return mt({queryKey:["reward-items",t],queryFn:async()=>{let s=H.from("reward_store_items").select(` *, category:reward_store_categories(*) `).order("created_at",{ascending:!1});const{data:r,error:n}=await s;if(n)throw n;return r}})}function i4s(t){return mt({queryKey:["active-reward-items",t],queryFn:async()=>{let s=H.from("reward_store_items").select(` *, category:reward_store_categories(*) `).eq("is_active",!0).order("created_at",{ascending:!1});t&&(s=s.eq("category_id",t));const{data:r,error:n}=await s;if(n)throw n;return r}})}function o4s(t){return mt({queryKey:["user-purchases",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("reward_store_purchases").select(` *, item:reward_store_items(*) `).eq("user_id",t).order("purchased_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function l4s(){return mt({queryKey:["all-reward-purchases"],queryFn:async()=>{const{data:t,error:s}=await H.from("reward_store_purchases").select(` *, item:reward_store_items(*) `).order("purchased_at",{ascending:!1});if(s)throw s;if(!t||t.length===0)return[];const r=[...new Set(t.map(l=>l.user_id))],{data:n,error:a}=await H.from("profiles").select("id, name, email").in("id",r);if(a)throw a;const o=new Map((n==null?void 0:n.map(l=>[l.id,l]))||[]);return t.map(l=>({...l,user:o.get(l.user_id)||null}))}})}function c4s(t){return mt({queryKey:["spendable-points",t],queryFn:async()=>{if(!t)return 0;const{data:s,error:r}=await H.from("agent_attendance_stats").select("spendable_points").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return(s==null?void 0:s.spendable_points)||0},enabled:!!t})}function d4s(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.rpc("purchase_reward_item",{p_item_id:s});if(n)throw n;const a=r;if(!a.success)throw new Error(a.error||"Purchase failed");return a},onSuccess:()=>{t.invalidateQueries({queryKey:["user-purchases"]}),t.invalidateQueries({queryKey:["spendable-points"]}),t.invalidateQueries({queryKey:["active-reward-items"]}),t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["homereel-credits"]})}})}function u4s(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("reward_store_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function h4s(){const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("reward_store_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function m4s(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("reward_store_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function p4s(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("reward_store_items").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function f4s(){const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("reward_store_items").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function x4s(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("reward_store_items").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function g4s(t){const s=t.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return s?{bucket:s[1],path:s[2]}:null}async function Mye(t,s){const r=g4s(t);if(r)try{const{data:n,error:a}=await H.storage.from(r.bucket).download(r.path);if(a){console.error("Error downloading file:",a),me.error("Failed to download file");return}const o=URL.createObjectURL(n),l=document.createElement("a");l.href=o,l.download=s||r.path.split("/").pop()||"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(o),100)}catch(n){console.error("Download error:",n),me.error("Failed to download file")}else try{const a=await(await fetch(t)).blob(),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=s||t.split("/").pop()||"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(o),100)}catch(n){console.error("External download error:",n),me.error("Failed to download file")}}function Elt(){return mt({queryKey:["point-reward-settings"],queryFn:async()=>{const{data:t,error:s}=await H.from("point_reward_settings").select("*").order("action_name");if(s)throw s;return t}})}function y4s(){const t=Qt();return Dt({mutationFn:async({id:s,points:r,is_active:n})=>{const a={points:r};n!==void 0&&(a.is_active=n);const{data:o,error:l}=await H.from("point_reward_settings").update(a).eq("id",s).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["point-reward-settings"]})}})}function v4s(){const{user:t}=Ds(),[s,r]=N.useState("items"),[n,a]=N.useState(!1),[o,l]=N.useState(null),[i,c]=N.useState(""),[u,p]=N.useState(""),[f,g]=N.useState(""),[b,_]=N.useState(null),[j,w]=N.useState(!1),[k,S]=N.useState(null),[M,L]=N.useState(""),[I,O]=N.useState(""),[q,U]=N.useState(null),[B,V]=N.useState(""),[Z,X]=N.useState("file"),[ee,Q]=N.useState(""),[ie,re]=N.useState(""),[oe,ce]=N.useState(""),[xe,ge]=N.useState(!0),[ue,pe]=N.useState(null),[be,Me]=N.useState(!1),[Ne,Pe]=N.useState(!1),Oe=N.useRef(null),Te=N.useRef(null),{data:ke,isLoading:Be}=Alt(),{data:nt,isLoading:Ae}=a4s(),{data:ft,isLoading:fe}=l4s(),{data:Ve,isLoading:at}=Elt(),et=u4s(),Ce=h4s(),rt=m4s(),Ge=p4s(),ct=f4s(),qe=x4s(),Ze=y4s(),[Qe,He]=N.useState({}),Je=xt=>{xt?(l(xt),c(xt.name),p(xt.description||""),g(xt.icon||"")):(l(null),c(""),p(""),g("")),a(!0)},it=async()=>{if(!i.trim()){me.error("Please enter a category name");return}try{o?(await Ce.mutateAsync({id:o.id,name:i,description:u||null,icon:f||null}),me.success("Category updated successfully")):(await et.mutateAsync({name:i,description:u||null,icon:f||null,sort_order:((ke==null?void 0:ke.length)||0)+1}),me.success("Category created successfully")),a(!1)}catch(xt){console.error("Error saving category:",xt),me.error("Failed to save category")}},Lt=async()=>{if(b)try{await rt.mutateAsync(b),me.success("Category deleted successfully"),_(null)}catch(xt){console.error("Error deleting category:",xt),me.error("Failed to delete category")}},Vt=xt=>{var Es;xt?(S(xt),L(xt.name),O(xt.description||""),U(xt.category_id),V(xt.points_cost.toString()),X(xt.item_type),Q(xt.file_url||""),re(xt.preview_image_url||""),ce(((Es=xt.max_quantity)==null?void 0:Es.toString())||""),ge(xt.is_active)):(S(null),L(""),O(""),U(null),V(""),X("file"),Q(""),re(""),ce(""),ge(!0)),w(!0)},hs=async(xt,Es)=>{Es==="file"?Me(!0):Pe(!0);try{const ur=xt.name.split(".").pop(),Mr=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ur}`,Lr=`${Es==="file"?"items":"previews"}/${Mr}`,{error:fn}=await H.storage.from("reward-store").upload(Lr,xt);if(fn)throw fn;const{data:{publicUrl:ki}}=H.storage.from("reward-store").getPublicUrl(Lr);Es==="file"?Q(ki):re(ki),me.success("File uploaded successfully")}catch(ur){console.error("Error uploading file:",ur),me.error("Failed to upload file")}finally{Es==="file"?Me(!1):Pe(!1)}},Ts=async()=>{if(!M.trim()){me.error("Please enter an item name");return}if(!B||parseInt(B)<0){me.error("Please enter a valid points cost");return}try{const xt={name:M,description:I||null,category_id:q,points_cost:parseInt(B),item_type:Z,file_url:ee||null,preview_image_url:ie||null,max_quantity:oe?parseInt(oe):null,current_quantity:oe?parseInt(oe):null,is_active:xe,created_by:t==null?void 0:t.id};k?(await ct.mutateAsync({id:k.id,...xt,current_quantity:k.max_quantity!==(oe?parseInt(oe):null)?oe?parseInt(oe):null:k.current_quantity}),me.success("Item updated successfully")):(await Ge.mutateAsync(xt),me.success("Item created successfully")),w(!1)}catch(xt){console.error("Error saving item:",xt),me.error("Failed to save item")}},Cs=async()=>{if(ue)try{await qe.mutateAsync(ue),me.success("Item deleted successfully"),pe(null)}catch(xt){console.error("Error deleting item:",xt),me.error("Failed to delete item")}},cs=async(xt,Es)=>{const ur=Qe[xt];if(ur===void 0||ur===Es.toString())return;const Mr=parseInt(ur);if(isNaN(Mr)||Mr<0){me.error("Please enter a valid positive number");return}try{await Ze.mutateAsync({id:xt,points:Mr}),me.success("Points updated successfully"),He(Lr=>{const fn={...Lr};return delete fn[xt],fn})}catch(Lr){console.error("Error updating points:",Lr),me.error("Failed to update points")}};return Be||Ae||fe||at?e.jsx(Ms,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-8 w-64"}),e.jsx(ys,{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(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Ml,{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:(nt==null?void 0:nt.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(nt==null?void 0:nt.filter(xt=>xt.is_active).length)||0," active"]})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Om,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Categories"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(ke==null?void 0:ke.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Jn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg. Cost"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[nt&&nt.length>0?Math.round(nt.reduce((xt,Es)=>xt+Es.points_cost,0)/nt.length):0," pts"]})]})})]}),e.jsxs(ba,{value:s,onValueChange:r,children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"items",children:"Items"}),e.jsx(ns,{value:"categories",children:"Categories"}),e.jsx(ns,{value:"purchases",children:"Purchases"}),e.jsx(ns,{value:"point-settings",children:"Point Settings"})]}),e.jsx(bs,{value:"items",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Store Items"}),e.jsx(gr,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(K,{onClick:()=>Vt(),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),e.jsx(De,{children:!nt||nt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ko,{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(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Item"}),e.jsx(St,{children:"Category"}),e.jsx(St,{className:"text-center",children:"Cost"}),e.jsx(St,{className:"text-center",children:"Type"}),e.jsx(St,{className:"text-center",children:"Quantity"}),e.jsx(St,{className:"text-center",children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:nt.map(xt=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[xt.preview_image_url?e.jsx("img",{src:xt.preview_image_url,alt:xt.name,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded bg-muted flex items-center justify-center",children:e.jsx(ko,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:xt.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:xt.description||"No description"})]})]})}),e.jsx(dt,{children:xt.category?e.jsx(tt,{variant:"outline",children:xt.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"text-center",children:e.jsxs(tt,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),xt.points_cost]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[xt.item_type==="file"?e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Bo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:xt.item_type})]})}),e.jsx(dt,{className:"text-center",children:xt.max_quantity!==null?e.jsxs("span",{className:xt.current_quantity===0?"text-red-500":"",children:[xt.current_quantity,"/",xt.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(dt,{className:"text-center",children:e.jsx(tt,{variant:xt.is_active?"default":"secondary",children:xt.is_active?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Vt(xt),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>pe(xt.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},xt.id))})]})})]})}),e.jsx(bs,{value:"categories",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Categories"}),e.jsx(gr,{children:"Organize your store items into categories"})]}),e.jsxs(K,{onClick:()=>Je(),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(De,{children:!ke||ke.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Om,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No categories yet. Add your first category!"})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"text-center",children:"Items"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:ke.map(xt=>e.jsxs(Ss,{children:[e.jsxs(dt,{className:"font-medium",children:[xt.icon&&e.jsx("span",{className:"mr-2",children:xt.icon}),xt.name]}),e.jsx(dt,{className:"text-muted-foreground",children:xt.description||"—"}),e.jsx(dt,{className:"text-center",children:(nt==null?void 0:nt.filter(Es=>Es.category_id===xt.id).length)||0}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Je(xt),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(xt.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},xt.id))})]})})]})}),e.jsx(bs,{value:"purchases",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(vp,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(gr,{children:"View all reward redemptions by agents"})]}),e.jsx(De,{children:!ft||ft.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(vp,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No purchases yet."})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Date"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Item"}),e.jsx(St,{className:"text-center",children:"Points Spent"})]})}),e.jsx(zn,{children:ft.map(xt=>{var Es,ur,Mr,Lr;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"text-muted-foreground",children:ms(new Date(xt.purchased_at),"MMM d, yyyy 'at' h:mm a")}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(to,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Es=xt.user)==null?void 0:Es.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((ur=xt.user)==null?void 0:ur.email)||"—"})]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(Mr=xt.item)!=null&&Mr.preview_image_url?e.jsx("img",{src:xt.item.preview_image_url,alt:xt.item.name,className:"h-8 w-8 rounded object-cover"}):e.jsx("div",{className:"h-8 w-8 rounded bg-muted flex items-center justify-center",children:e.jsx(ko,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((Lr=xt.item)==null?void 0:Lr.name)||"Deleted item"})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(tt,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),xt.points_spent]})})]},xt.id)})})]})})]})})]})]}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:o?"Edit Category":"Add Category"}),e.jsx(Gr,{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(ze,{id:"categoryName",value:i,onChange:xt=>c(xt.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(Er,{id:"categoryDescription",value:u,onChange:xt=>p(xt.target.value),placeholder:"Optional description..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),e.jsx(ze,{id:"categoryIcon",value:f,onChange:xt=>g(xt.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{onClick:it,disabled:et.isPending||Ce.isPending,children:et.isPending||Ce.isPending?"Saving...":"Save"})]})]})}),e.jsx(fs,{open:j,onOpenChange:w,children:e.jsxs(ps,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:k?"Edit Item":"Add Item"}),e.jsx(Gr,{children:k?"Update the item details":"Create a new reward item for agents to purchase"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"itemName",children:"Name *"}),e.jsx(ze,{id:"itemName",value:M,onChange:xt=>L(xt.target.value),placeholder:"e.g., Premium Template Pack"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"itemDescription",children:"Description"}),e.jsx(Er,{id:"itemDescription",value:I,onChange:xt=>O(xt.target.value),placeholder:"Describe the item..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"itemCategory",children:"Category"}),e.jsxs(Zs,{value:q||"none",onValueChange:xt=>U(xt==="none"?null:xt),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select category"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:"No category"}),ke==null?void 0:ke.map(xt=>e.jsxs(Mt,{value:xt.id,children:[xt.icon&&`${xt.icon} `,xt.name]},xt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"itemPointsCost",children:"Points Cost *"}),e.jsx(ze,{id:"itemPointsCost",type:"number",min:"0",value:B,onChange:xt=>V(xt.target.value),placeholder:"e.g., 100"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"itemType",children:"Type"}),e.jsxs(Zs,{value:Z,onValueChange:X,children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"file",children:"File Download"}),e.jsx(Mt,{value:"link",children:"External Link"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"itemMaxQuantity",children:"Max Quantity"}),e.jsx(ze,{id:"itemMaxQuantity",type:"number",min:"1",value:oe,onChange:xt=>ce(xt.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(ze,{value:ee,onChange:xt=>Q(xt.target.value),placeholder:Z==="file"?"Upload a file or paste URL":"Paste external link"}),Z==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var xt;return(xt=Oe.current)==null?void 0:xt.click()},disabled:be,children:e.jsx(li,{className:"h-4 w-4"})}),e.jsx("input",{ref:Oe,type:"file",className:"hidden",onChange:xt=>{var ur;const Es=(ur=xt.target.files)==null?void 0:ur[0];Es&&hs(Es,"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(ze,{value:ie,onChange:xt=>re(xt.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var xt;return(xt=Te.current)==null?void 0:xt.click()},disabled:Ne,children:e.jsx(gl,{className:"h-4 w-4"})}),e.jsx("input",{ref:Te,type:"file",accept:"image/*",className:"hidden",onChange:xt=>{var ur;const Es=(ur=xt.target.files)==null?void 0:ur[0];Es&&hs(Es,"preview")}})]}),ie&&e.jsx("img",{src:ie,alt:"Preview",className:"mt-2 h-24 rounded object-cover"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"itemIsActive",checked:xe,onCheckedChange:ge}),e.jsx(ve,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(K,{onClick:Ts,disabled:Ge.isPending||ct.isPending,children:Ge.isPending||ct.isPending?"Saving...":"Save"})]})]})}),e.jsx(kc,{open:!!b,onOpenChange:()=>_(null),children:e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Delete Category"}),e.jsx(tc,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:Lt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(kc,{open:!!ue,onOpenChange:()=>pe(null),children:e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Delete Item"}),e.jsx(tc,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:Cs,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(Ee,{className:"mt-4",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Point Reward Settings"}),e.jsx(gr,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),e.jsx(De,{children:!Ve||Ve.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 point settings configured."})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Action"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"text-center w-32",children:"Points"}),e.jsx(St,{className:"text-right w-24",children:"Save"})]})}),e.jsx(zn,{children:Ve.map(xt=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx("p",{className:"font-medium",children:xt.action_name})}),e.jsx(dt,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:xt.description})}),e.jsx(dt,{className:"text-center",children:e.jsx(ze,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:Qe[xt.id]??xt.points.toString(),onChange:Es=>He(ur=>({...ur,[xt.id]:Es.target.value}))})}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{size:"sm",variant:"outline",disabled:Qe[xt.id]===void 0||Qe[xt.id]===xt.points.toString()||Ze.isPending,onClick:()=>cs(xt.id,xt.points),children:e.jsx(qc,{className:"h-4 w-4"})})})]},xt.id))})]})})]})]})}const vze=()=>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"})]}),bze=[{value:"template",label:"Templates"},{value:"brand",label:"Brand Assets"},{value:"listing",label:"Listing Assets"},{value:"social",label:"Social Media"},{value:"general",label:"General"}];function b4s(){const t=Qt(),[s,r]=N.useState(!1),[n,a]=N.useState(!1),[o,l]=N.useState(!1),[i,c]=N.useState({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""}),{data:u,isLoading:p}=mt({queryKey:["canva-integration"],queryFn:async()=>{const{data:S,error:M}=await H.from("canva_integration").select("*").eq("is_active",!0).maybeSingle();if(M)throw M;return S}}),{data:f}=mt({queryKey:["brokerages-list"],queryFn:async()=>{const{data:S,error:M}=await H.from("brokerages").select("id, name").order("name");if(M)throw M;return S}}),{data:g}=mt({queryKey:["canva-brokerage-folders"],queryFn:async()=>{const{data:S,error:M}=await H.from("canva_brokerage_folders").select("*, brokerages(name)").order("sort_order");if(M)throw M;return S}}),b=async()=>{var S;r(!0);try{const{data:M}=await H.auth.getSession(),L=(S=M==null?void 0:M.session)==null?void 0:S.access_token;if(!L)throw new Error("Not authenticated");const q=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${L}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"get_auth_url"})}),U=await q.json();if(!q.ok||U!=null&&U.error)throw new Error((U==null?void 0:U.error)||"Failed to get authorization URL");if(U!=null&&U.authUrl){localStorage.setItem("canva_code_verifier",U.codeVerifier),localStorage.setItem("canva_oauth_state",U.state);const B=window.open(U.authUrl,"canva-oauth","width=600,height=700,scrollbars=yes,resizable=yes");if(!B){me.error("Popup was blocked. Please allow popups for this site and try again."),r(!1);return}const V=X=>{var ee,Q;X.origin===window.location.origin&&(((ee=X.data)==null?void 0:ee.type)==="canva-oauth-success"?(window.removeEventListener("message",V),me.success("Canva connected successfully!"),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1)):((Q=X.data)==null?void 0:Q.type)==="canva-oauth-error"&&(window.removeEventListener("message",V),me.error("Canva connection failed: "+(X.data.error||"Unknown error")),r(!1)))};window.addEventListener("message",V);const Z=setInterval(()=>{B.closed&&(clearInterval(Z),window.removeEventListener("message",V),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1))},500)}else throw new Error("Failed to get authorization URL")}catch(M){console.error("Canva connect error:",M);const L=(M==null?void 0:M.message)||"";L.includes("CANVA_CLIENT_ID")?me.error("Canva app credentials not configured yet."):me.error(L||"Failed to start Canva connection"),r(!1)}},_=Dt({mutationFn:async S=>{var B;const{data:M}=await H.auth.getSession(),L=(B=M==null?void 0:M.session)==null?void 0:B.access_token;if(!L)throw new Error("Not authenticated");const q=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${L}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"disconnect",integrationId:S})}),U=await q.json();if(!q.ok||U!=null&&U.error)throw new Error((U==null?void 0:U.error)||"Failed to disconnect")},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-integration"]}),me.success("Canva disconnected")},onError:S=>{me.error(S.message||"Failed to disconnect Canva")}}),j=Dt({mutationFn:async S=>{const{error:M}=await H.from("canva_brokerage_folders").insert({brokerage_id:S.brokerage_id,folder_id:S.folder_id.trim(),folder_name:S.folder_name.trim(),folder_type:S.folder_type,description:S.description.trim()||null,sort_order:(g==null?void 0:g.length)||0});if(M)throw M},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),me.success("Folder added"),l(!1),c({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""})},onError:()=>me.error("Failed to add folder")}),w=Dt({mutationFn:async S=>{const{error:M}=await H.from("canva_brokerage_folders").delete().eq("id",S);if(M)throw M},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),me.success("Folder removed")},onError:()=>me.error("Failed to remove folder")}),k=!!u;return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-accent flex items-center justify-center",children:e.jsx(vze,{})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Canva Connect",k&&e.jsx(tt,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(tt,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(gr,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),e.jsx(De,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"OAuth 2.0 + PKCE for secure authorization"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"Map brokerage folders to auto-share with agents on connection"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"Multiple folders per brokerage (templates, brand assets, listings)"})]}),e.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-muted border border-dashed",children:[e.jsx("p",{className:"text-xs font-medium text-foreground mb-1",children:"Canva App Redirect URL"}),e.jsx("code",{className:"text-xs text-muted-foreground break-all select-all",children:"https://dashboard.relevelup.com/canva-callback.html"})]}),k?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:u.canva_team_id?`Team: ${u.canva_team_id}`:"Canva Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u.expires_at?`Token expires ${new Date(u.expires_at).toLocaleDateString()}`:"Platform integration active"})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Disconnect Canva?"}),e.jsx(tc,{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(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:()=>_.mutate(u.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}),e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-center justify-between p-3 text-sm font-medium hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Om,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",g&&g.length>0&&e.jsx(tt,{variant:"secondary",className:"text-xs",children:g.length})]}),n?e.jsx(pf,{className:"h-4 w-4"}):e.jsx(Eo,{className:"h-4 w-4"})]}),n&&e.jsxs("div",{className:"border-t p-3 space-y-2",children:[g&&g.length>0?g.map(S=>{var M,L;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md bg-muted/50 text-sm",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",children:S.folder_name}),e.jsx(tt,{variant:"outline",className:"text-xs shrink-0",children:((M=bze.find(I=>I.value===S.folder_type))==null?void 0:M.label)||S.folder_type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(L=S.brokerages)==null?void 0:L.name," · ID: ",e.jsx("span",{className:"font-mono",children:S.folder_id})]})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive shrink-0 ml-2",onClick:()=>w.mutate(S.id),children:e.jsx(Rr,{className:"h-3.5 w-3.5"})})]},S.id)}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"No folders mapped yet"}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full gap-1.5 mt-1",onClick:()=>l(!0),children:[e.jsx($s,{className:"h-3.5 w-3.5"}),"Add Folder Mapping"]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:b,disabled:s||p,children:[s?e.jsx(Go,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx("div",{className:"mr-2",children:e.jsx(vze,{})}),"Connect Canva",e.jsx(Qa,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{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(Zs,{value:i.brokerage_id,onValueChange:S=>c(M=>({...M,brokerage_id:S})),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select a brokerage…"})}),e.jsx(Gs,{children:f==null?void 0:f.map(S=>e.jsx(Mt,{value:S.id,children:S.name},S.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Canva Folder ID"}),e.jsx(ze,{placeholder:"e.g. FABCdef123456",value:i.folder_id,onChange:S=>c(M=>({...M,folder_id:S.target.value}))}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Found in the Canva folder URL: canva.com/folder/",e.jsx("strong",{children:"FOLDER_ID"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Folder Display Name"}),e.jsx(ze,{placeholder:"e.g. Brand Templates 2024",value:i.folder_name,onChange:S=>c(M=>({...M,folder_name:S.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Folder Type"}),e.jsxs(Zs,{value:i.folder_type,onValueChange:S=>c(M=>({...M,folder_type:S})),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:bze.map(S=>e.jsx(Mt,{value:S.value,children:S.label},S.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(ze,{placeholder:"What's in this folder?",value:i.description,onChange:S=>c(M=>({...M,description:S.target.value}))})]})]}),e.jsxs(qn,{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(Go,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function _4s(){return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(oh,{title:"Integrations",description:"Manage platform-level service connections"}),e.jsx(b4s,{}),e.jsx(Slt,{})]})})}const w4s={new_events:{label:"New Events",icon:"📅"},new_templates:{label:"New Templates",icon:"📄"},new_toolbox:{label:"New Toolbox Resources",icon:"🧰"},new_social_swag:{label:"New Social Swag",icon:"🎨"},new_newsletters:{label:"New Newsletters",icon:"📰"},new_community_posts:{label:"New Community Posts",icon:"💬"}};function dI(t,s=18,r=10){return t.length<=s+r+3?t:`${t.slice(0,s)}…${t.slice(-r)}`}function j4s(){var Z,X,ee,Q,ie;const t=Qt(),[s,r]=N.useState("Test Push"),[n,a]=N.useState("Testing web push notification"),[o,l]=N.useState("/community"),[i,c]=N.useState(!1),[u,p]=N.useState(!1),[f,g]=N.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[b,_]=N.useState(null),[j,w]=N.useState(null),{data:k,isLoading:S}=mt({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:re,error:oe}=await H.from("push_notification_settings").select("*").order("setting_key");if(oe)throw oe;return re}}),{data:M,isLoading:L}=mt({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:re,error:oe}=await H.from("push_subscriptions").select("*",{count:"exact",head:!0});if(oe)throw oe;return{totalSubscriptions:re||0}}}),I=Dt({mutationFn:async({settingKey:re,isEnabled:oe})=>{const{error:ce}=await H.from("push_notification_settings").update({is_enabled:oe}).eq("setting_key",re);if(ce)throw ce},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),me.success("Notification setting updated")},onError:re=>{me.error("Failed to update setting: "+re.message)}}),O=N.useMemo(()=>{var re,oe;return f.isSupported?`perm=${f.permission??"unknown"} · controller=${f.controllerPresent?"yes":"no"} · sw=${((re=f.serviceWorker)==null?void 0:re.activeState)??"unknown"} · sub=${(oe=f.subscription)!=null&&oe.endpoint?"yes":"no"}`:"Push not supported in this browser."},[f]);N.useEffect(()=>{let re=!0;const oe=async()=>{var ue,pe,be,Me,Ne,Pe,Oe;const xe="serviceWorker"in navigator&&"PushManager"in window,ge={isSupported:xe,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((ue=navigator.serviceWorker)!=null&&ue.controller)};if(!xe){re&&g(ge);return}try{const{data:Te,error:ke}=await H.functions.invoke("get-vapid-public-key",{body:{}});if(ke)throw ke;ge.vapidPublicKey=Te==null?void 0:Te.vapidPublicKey;const nt=(await navigator.serviceWorker.getRegistrations()).find(Ae=>{var fe,Ve,at;return(((fe=Ae.active)==null?void 0:fe.scriptURL)||((Ve=Ae.waiting)==null?void 0:Ve.scriptURL)||((at=Ae.installing)==null?void 0:at.scriptURL)||"").includes("/sw.js")});if(nt){ge.pushWorkerScriptUrl=((pe=nt.active)==null?void 0:pe.scriptURL)||((be=nt.waiting)==null?void 0:be.scriptURL)||((Me=nt.installing)==null?void 0:Me.scriptURL),ge.serviceWorker={scope:nt.scope,activeState:(Ne=nt.active)==null?void 0:Ne.state};const Ae=await nt.pushManager.getSubscription();if(Ae){const ft=Ae.toJSON();ge.subscription={endpoint:ft.endpoint,p256dh:(Pe=ft.keys)==null?void 0:Pe.p256dh,auth:(Oe=ft.keys)==null?void 0:Oe.auth}}}}catch(Te){ge.error=(Te==null?void 0:Te.message)||String(Te)}re&&g(ge)};oe();const ce=window.setInterval(oe,4e3);return()=>{re=!1,window.clearInterval(ce)}},[]);const q=async()=>{if(typeof Notification>"u"){me.error("Notifications API not available in this browser.");return}try{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted"){me.error("Notification permission not granted.");return}new Notification("Local notification test",{body:"If you see this, OS/browser notifications can display."}),me.success("Triggered a local notification (not push).")}catch(re){me.error(`Local notification failed: ${(re==null?void 0:re.message)||String(re)}`)}},U=async()=>{c(!0),_(null);try{const{data:re,error:oe}=await H.functions.invoke("send-push-notification",{body:{title:s,body:n,url:o}});if(oe)throw oe;_({sent:re==null?void 0:re.sent,failed:re==null?void 0:re.failed,expiredCleaned:re==null?void 0:re.expiredCleaned,vapidPublicKey:re==null?void 0:re.vapidPublicKey}),(re==null?void 0:re.sent)>0?me.success(`Test notification sent to ${re.sent} subscriber(s)`):(re==null?void 0:re.failed)>0?me.warning(`Notification failed for ${re.failed} subscriber(s). ${re.expired||0} expired subscriptions cleaned up.`):me.info("No active subscriptions to send to")}catch(re){console.error("Error sending test notification:",re),_({error:(re==null?void 0:re.message)||String(re)}),me.error("Failed to send test notification: "+(re.message||"Unknown error"))}finally{c(!1)}},B=async()=>{p(!0),w(null);try{const{data:re,error:oe}=await H.functions.invoke("generate-vapid-keys",{body:{}});if(oe)throw oe;const ce=re==null?void 0:re.publicKey,xe=re==null?void 0:re.privateKey;if(!ce||!xe)throw new Error("generate-vapid-keys did not return keys");w({publicKey:ce,privateKey:xe}),me.success("Generated new VAPID keys. Update backend secrets, then clear + re-subscribe.")}catch(re){console.error("Error generating VAPID keys:",re),me.error("Failed to generate VAPID keys: "+((re==null?void 0:re.message)||"Unknown error"))}finally{p(!1)}},V=Dt({mutationFn:async()=>{const{error:re}=await H.from("push_subscriptions").delete().neq("id","00000000-0000-0000-0000-000000000000");if(re)throw re},onSuccess:()=>{me.success("All subscriptions cleared. Users will need to re-enable notifications."),t.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:re=>{me.error("Failed to clear subscriptions: "+re.message)}});return e.jsx(Ms,{title:"Notification Settings",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(gr,{children:"Current active push notification subscriptions"})]}),e.jsx(De,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"text-4xl font-bold",children:L?"...":(M==null?void 0:M.totalSubscriptions)||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"active subscriptions"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(gr,{children:"Control which types of push notifications are sent to users"})]}),e.jsx(De,{children:S?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):e.jsx("div",{className:"space-y-4",children:k==null?void 0:k.map(re=>{const oe=w4s[re.setting_key]||{label:re.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:oe.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:oe.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:re.description})]})]}),e.jsx(qr,{checked:re.is_enabled,onCheckedChange:ce=>I.mutate({settingKey:re.setting_key,isEnabled:ce}),disabled:I.isPending})]},re.id)})})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Lm,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(gr,{children:"Send a test push notification to all subscribed users"})]}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"Client push debug"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:O}),f.error&&e.jsx("div",{className:"mt-2 text-destructive",children:f.error}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Backend VAPID public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:f.vapidPublicKey?dI(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: ",(Z=f.serviceWorker)!=null&&Z.scope?dI(f.serviceWorker.scope,24,8):"none"]}),e.jsxs("div",{children:["active: ",((X=f.serviceWorker)==null?void 0:X.activeState)??"none"]})]})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Current browser subscription"}),e.jsxs("div",{className:"rounded-md border bg-background p-2 font-mono text-xs",children:[e.jsxs("div",{children:["endpoint: ",(ee=f.subscription)!=null&&ee.endpoint?dI(f.subscription.endpoint,40,12):"none"]}),e.jsxs("div",{children:["p256dh: ",(Q=f.subscription)!=null&&Q.p256dh?dI(f.subscription.p256dh,22,10):"none"]}),e.jsxs("div",{children:["auth: ",(ie=f.subscription)!=null&&ie.auth?dI(f.subscription.auth,22,10):"none"]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(K,{variant:"outline",onClick:q,children:"Local notification test"}),e.jsx(K,{variant:"outline",onClick:()=>window.location.reload(),children:"Reload page"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"test-title",children:"Notification Title"}),e.jsx(ze,{id:"test-title",value:s,onChange:re=>r(re.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(Er,{id:"test-body",value:n,onChange:re=>a(re.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(ze,{id:"test-url",value:o,onChange:re=>l(re.target.value),placeholder:"/community or full URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Where users will be taken when they click the notification"})]}),e.jsxs(K,{onClick:U,disabled:i||!s||!n,className:"w-full sm:w-auto",children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),i?"Sending...":"Send Test Notification"]}),b&&e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"Last send debug"}),b.error?e.jsxs("div",{className:"mt-1 text-destructive",children:["Error: ",b.error]}):e.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[e.jsxs("div",{children:["Result: ",b.sent??0," sent, ",b.failed??0," failed, ",b.expiredCleaned??0," expired cleaned"]}),b.vapidPublicKey?e.jsxs("div",{className:"break-all",children:["Backend VAPID public key: ",e.jsx("span",{className:"font-mono",children:b.vapidPublicKey})]}):e.jsx("div",{children:"Backend VAPID public key: (not returned)"})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Nr,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(gr,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),e.jsxs(De,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"If you've recently updated the VAPID keys, existing subscriptions will no longer work. Use this to clear all subscriptions so users can re-subscribe with the new keys."}),e.jsxs(K,{variant:"destructive",onClick:()=>V.mutate(),disabled:V.isPending,children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),V.isPending?"Clearing...":"Clear All Subscriptions"]}),e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"VAPID key rotation helper"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:"If you suspect the backend public/private keys don’t match, generate a fresh pair, update backend secrets, then clear subscriptions and have users re-enable push."}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:e.jsx(K,{variant:"outline",onClick:B,disabled:u,children:u?"Generating…":"Generate VAPID keys"})}),j&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"text-muted-foreground",children:["Copy these into backend secrets ",e.jsx("span",{className:"font-mono",children:"VAPID_PUBLIC_KEY"})," and ",e.jsx("span",{className:"font-mono",children:"VAPID_PRIVATE_KEY"}),"."]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:j.publicKey})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Private key (keep secret)"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:j.privateKey})]})]})]})]})]})]})})}function N4s(){const{toast:t}=Ua(),[s,r]=N.useState([]),[n,a]=N.useState({totalPresentations:0,totalViews:0,totalLeads:0,totalCtaClicks:0,agentsUsing:0}),[o,l]=N.useState(!0),{sortKey:i,sortDirection:c,handleSort:u,sortData:p}=YO("presentation_count","desc"),f=p(s,{name:_=>{var j;return((j=_.name)==null?void 0:j.toLowerCase())||""},presentations:_=>_.presentation_count,views:_=>_.total_views,leads:_=>_.total_leads,cta_clicks:_=>_.total_cta_clicks,conversion:_=>_.total_views>0?_.total_leads/_.total_views*100:0});N.useEffect(()=>{g()},[]);const g=async()=>{try{l(!0);const{data:_,error:j}=await H.rpc("get_admin_presentation_stats");if(j)throw j;if(!_||_.length===0){l(!1);return}const w=_.map(I=>I.owner_user_id),{data:k,error:S}=await H.from("profiles").select("id, name, email, avatar_url").in("id",w);if(S)throw S;const M=new Map((k==null?void 0:k.map(I=>[I.id,I]))||[]),L=_.map(I=>{const O=M.get(I.owner_user_id);return{owner_user_id:I.owner_user_id,name:(O==null?void 0:O.name)||"Unknown",email:(O==null?void 0:O.email)||"",avatar_url:(O==null?void 0:O.avatar_url)||null,presentation_count:Number(I.presentation_count),total_views:Number(I.total_views),total_leads:Number(I.total_leads),total_cta_clicks:Number(I.total_cta_clicks)}});r(L),r(L),a({totalPresentations:L.reduce((I,O)=>I+O.presentation_count,0),totalViews:L.reduce((I,O)=>I+O.total_views,0),totalLeads:L.reduce((I,O)=>I+O.total_leads,0),totalCtaClicks:L.reduce((I,O)=>I+O.total_cta_clicks,0),agentsUsing:L.length})}catch(_){console.error("Error loading presentation stats:",_),t({title:"Error",description:"Failed to load presentation analytics",variant:"destructive"})}finally{l(!1)}},b=[{label:"Agents Using",value:n.agentsUsing,icon:pr,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:Jg,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:On,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:Tl,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:Qg,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:b.map(_=>e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:_.label}),e.jsx(_.icon,{className:`h-4 w-4 ${_.color}`})]}),e.jsx(De,{children:o?e.jsx(ys,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:_.value.toLocaleString()})})]},_.label))}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(ul,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(De,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((_,j)=>e.jsx(ys,{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(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(yl,{sortKey:"name",currentSortKey:i,currentDirection:c,onSort:u,children:"Agent"}),e.jsx(yl,{sortKey:"presentations",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Presentations"}),e.jsx(yl,{sortKey:"views",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Views"}),e.jsx(yl,{sortKey:"leads",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Leads"}),e.jsx(yl,{sortKey:"cta_clicks",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"CTA Clicks"}),e.jsx(yl,{sortKey:"conversion",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Conversion"})]})}),e.jsx(zn,{children:f.map(_=>{var w,k;const j=_.total_views>0?(_.total_leads/_.total_views*100).toFixed(1):"0.0";return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:_.avatar_url?e.jsx("img",{src:_.avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((k=(w=_.name)==null?void 0:w.charAt(0))==null?void 0:k.toUpperCase())||"?"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:_.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:_.email})]})]})}),e.jsx(dt,{className:"text-center font-medium",children:_.presentation_count}),e.jsx(dt,{className:"text-center",children:_.total_views.toLocaleString()}),e.jsx(dt,{className:"text-center",children:_.total_leads>0?e.jsx(tt,{variant:"secondary",children:_.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(dt,{className:"text-center",children:_.total_cta_clicks}),e.jsx(dt,{className:"text-center",children:e.jsxs("span",{className:Number(j)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[j,"%"]})})]},_.owner_user_id)})})]})})]})]})})}function k4s(){const{toast:t}=Ua(),[s,r]=N.useState([]),[n,a]=N.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=N.useState(!0);N.useEffect(()=>{i()},[]);const i=async()=>{try{l(!0);const{data:u,error:p}=await H.rpc("get_admin_guest_book_stats");if(p)throw p;if(!u||u.length===0){l(!1);return}const f=u.map(w=>w.agent_id),{data:g,error:b}=await H.from("profiles").select("id, name, email, avatar_url").in("id",f);if(b)throw b;const _=new Map((g==null?void 0:g.map(w=>[w.id,w]))||[]),j=u.map(w=>{const k=_.get(w.agent_id);return{agent_id:w.agent_id,name:(k==null?void 0:k.name)||"Unknown",email:(k==null?void 0:k.email)||"",avatar_url:(k==null?void 0:k.avatar_url)||null,open_house_count:Number(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,k)=>k.total_visitors-w.total_visitors),r(j),a({totalOpenHouses:j.reduce((w,k)=>w+k.open_house_count,0),totalVisitors:j.reduce((w,k)=>w+k.total_visitors,0),totalLeads:j.reduce((w,k)=>w+k.total_leads,0),activeOpenHouses:j.reduce((w,k)=>w+k.active_count,0),agentsUsing:j.length})}catch(u){console.error("Error loading guest book stats:",u),t({title:"Error",description:"Failed to load guest book analytics",variant:"destructive"})}finally{l(!1)}},c=[{label:"Agents Using",value:n.agentsUsing,icon:pr,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:bn,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:xi,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:On,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:Tl,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:c.map(u=>e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:u.label}),e.jsx(u.icon,{className:`h-4 w-4 ${u.color}`})]}),e.jsx(De,{children:o?e.jsx(ys,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:u.value.toLocaleString()})})]},u.label))}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(ul,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(De,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((u,p)=>e.jsx(ys,{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(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"Open Houses"}),e.jsx(St,{className:"text-center",children:"Active"}),e.jsx(St,{className:"text-center",children:"Visitors"}),e.jsx(St,{className:"text-center",children:"Leads"}),e.jsx(St,{className:"text-center",children:"Conversion"})]})}),e.jsx(zn,{children:s.map(u=>{var f,g;const p=u.total_visitors>0?(u.total_leads/u.total_visitors*100).toFixed(1):"0.0";return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:u.avatar_url?e.jsx("img",{src:u.avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((g=(f=u.name)==null?void 0:f.charAt(0))==null?void 0:g.toUpperCase())||"?"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:u.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:u.email})]})]})}),e.jsx(dt,{className:"text-center font-medium",children:u.open_house_count}),e.jsx(dt,{className:"text-center",children:u.active_count>0?e.jsx(tt,{variant:"secondary",className:"bg-emerald-100 text-emerald-700",children:u.active_count}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(dt,{className:"text-center",children:u.total_visitors.toLocaleString()}),e.jsx(dt,{className:"text-center",children:u.total_leads>0?e.jsx(tt,{variant:"secondary",children:u.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(dt,{className:"text-center",children:e.jsxs("span",{className:Number(p)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[p,"%"]})})]},u.agent_id)})})]})})]})]})})}function S4s(){const[t]=Cc(),s=fr(),[r,n]=N.useState("loading"),[a,o]=N.useState("Processing connection...");return N.useEffect(()=>{(async()=>{const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Failed to connect: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("Failed to connect: No authorization code");return}try{const{data:f,error:g}=await H.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p}});if(g)throw g;if(f!=null&&f.success)n("success"),o(f.message||"Accounts connected successfully!"),me.success(f.message||"Social accounts connected!");else throw new Error((f==null?void 0:f.error)||"Failed to connect accounts")}catch(f){console.error("Callback error:",f),n("error"),o(f.message||"Failed to complete connection"),me.error(f.message||"Failed to connect accounts")}})()},[t]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx(vc,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(Rt,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(De,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/admin/integrations"),children:r==="success"?"View Integrations":"Back to Integrations"})})]})})}function C4s(){const t=Qt(),[s,r]=N.useState(""),[n,a]=N.useState(""),[o,l]=N.useState([]),i=N.useRef(null),{data:c,isLoading:u}=mt({queryKey:["prospect-emails"],queryFn:async()=>{const{data:w,error:k}=await H.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(k)throw k;return w}}),p={total:(c==null?void 0:c.length)||0,sent:(c==null?void 0:c.filter(w=>w.status==="sent").length)||0,converted:(c==null?void 0:c.filter(w=>w.status==="converted").length)||0,conversionRate:c!=null&&c.length?Math.round(c.filter(w=>w.status==="converted").length/c.length*100):0},f=Dt({mutationFn:async w=>{const{data:k,error:S}=await H.functions.invoke("send-prospect-email",{body:{emails:w}});if(S)throw S;return k},onSuccess:w=>{t.invalidateQueries({queryKey:["prospect-emails"]}),me.success(`${w.sent} email${w.sent>1?"s":""} sent successfully!`),r(""),a(""),l([])},onError:w=>{me.error("Failed to send: "+w.message)}}),g=Dt({mutationFn:async()=>{var M,L;const{data:{user:w}}=await H.auth.getUser();if(!(w!=null&&w.email))throw new Error("Could not get your email");const{data:k,error:S}=await H.functions.invoke("send-prospect-email",{body:{emails:[{email:w.email,first_name:(L=(M=w.user_metadata)==null?void 0:M.name)==null?void 0:L.split(" ")[0]}],test_mode:!0}});if(S)throw S;return k},onSuccess:()=>{me.success("Test email sent to your inbox!")},onError:w=>{me.error("Failed to send test: "+w.message)}}),b=()=>{if(!s.trim()){me.error("Please enter an email address");return}if(c==null?void 0:c.find(k=>k.email.toLowerCase()===s.trim().toLowerCase())){me.error("This email has already been prospected");return}f.mutate([{email:s.trim(),first_name:n.trim()||void 0}])},_=w=>{var M;const k=(M=w.target.files)==null?void 0:M[0];if(!k)return;const S=new FileReader;S.onload=L=>{var B,V;const O=((B=L.target)==null?void 0:B.result).split(` `).filter(Z=>Z.trim()),q=[],U=(V=O[0])!=null&&V.toLowerCase().includes("email")?1:0;for(let Z=U;Zie.trim().replace(/"/g,"")),ee=X[0],Q=X[1];ee&&ee.includes("@")&&q.push({email:ee,first_name:Q||void 0})}l(q),me.success(`${q.length} entries loaded from CSV`)},S.readAsText(k),i.current&&(i.current.value="")},j=()=>{if(o.length===0){me.error("No entries to send");return}const w=new Set((c==null?void 0:c.map(S=>S.email.toLowerCase()))||[]),k=o.filter(S=>!w.has(S.email.toLowerCase()));if(k.length===0){me.error("All emails have already been prospected");return}k.lengthg.mutate(),disabled:g.isPending,className:"gap-2 ml-4 shrink-0",children:[g.isPending?e.jsx(ws,{className:"h-3 w-3 animate-spin"}):e.jsx(cr,{className:"h-3 w-3"}),"Send Test to Me"]})]})]}),e.jsx(De,{children:e.jsxs(ba,{defaultValue:"single",children:[e.jsxs(pa,{className:"mb-4",children:[e.jsxs(ns,{value:"single",children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(ns,{value:"bulk",children:[e.jsx(li,{className:"h-4 w-4 mr-2"}),"Bulk CSV"]})]}),e.jsx(bs,{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(ze,{id:"prospect-email",type:"email",placeholder:"agent@example.com",value:s,onChange:w=>r(w.target.value),onKeyDown:w=>w.key==="Enter"&&b()})]}),e.jsxs("div",{className:"w-full sm:w-48",children:[e.jsx(ve,{htmlFor:"prospect-name",className:"sr-only",children:"First Name"}),e.jsx(ze,{id:"prospect-name",placeholder:"First name (optional)",value:n,onChange:w=>a(w.target.value),onKeyDown:w=>w.key==="Enter"&&b()})]}),e.jsxs(K,{onClick:b,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4"}),"Send Invite"]})]})}),e.jsx(bs,{value:"bulk",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{ref:i,type:"file",accept:".csv",onChange:_,className:"hidden"}),e.jsxs(K,{variant:"outline",onClick:()=>{var w;return(w=i.current)==null?void 0:w.click()},className:"gap-2",children:[e.jsx(Sn,{className:"h-4 w-4"}),"Upload CSV"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Format: email, first_name (one per line)"})]}),o.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[e.jsx(pr,{className:"h-3 w-3"}),o.length," entries ready"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>l([]),children:[e.jsx(Rr,{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,k)=>e.jsxs("div",{className:"text-muted-foreground",children:[w.email,w.first_name?` — ${w.first_name}`:""]},k)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(K,{onClick:j,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(gr,{children:"Track all sent invitations and their conversion status"})]}),e.jsx(De,{children:u?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((w,k)=>e.jsx(ys,{className:"h-12 w-full"},k))}):c&&c.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Email"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Name"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Sent"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Converted"})]})}),e.jsx("tbody",{children:c.map(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:ms(new Date(w.sent_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-3 px-4",children:w.status==="converted"?e.jsxs(tt,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-0",children:[e.jsx(sa,{className:"h-3 w-3 mr-1"}),"Converted"]}):e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),"Sent"]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:w.converted_at?ms(new Date(w.converted_at),"MMM d, yyyy"):"—"})]},w.id))})]})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(zm,{className:"h-12 w-12 text-muted-foreground/30 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No prospects yet. Send your first invite above!"})]})})]})]})})}function yme(t){const s=Qt(),{toast:r}=Ua(),n=mt({queryKey:["recruit-stages",t],queryFn:async()=>{if(!t)return[];const{data:c,error:u}=await H.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(u)throw u;return c},enabled:!!t}),a=mt({queryKey:["recruit-prospects",t],queryFn:async()=>{if(!t)return[];const c=1e3;let u=[],p=0,f=!0;for(;f;){const{data:g,error:b}=await H.from("recruit_prospects").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1}).range(p,p+c-1);if(b)throw b;u=u.concat(g),f=g.length===c,p+=c}return u},enabled:!!t}),o=Dt({mutationFn:async c=>{const{data:{user:u}}=await H.auth.getUser();if(!u)throw new Error("Not authenticated");const p={first_name:c.first_name||"",last_name:c.last_name||null,email:c.email||null,phone:c.phone||null,current_brokerage:c.current_brokerage||null,license_number:c.license_number||null,experience_years:c.experience_years??null,annual_production:c.annual_production||null,source:c.source||"manual",notes:c.notes||null,stage_id:c.stage_id||null,brokerage_id:t,created_by:u.id,address:c.address||null,city:c.city||null,state:c.state||null,zip_code:c.zip_code||null,last_year_volume:c.last_year_volume||null,last_year_transactions:c.last_year_transactions??null,avg_sale_price:c.avg_sale_price||null,specialties:c.specialties||null,linkedin_url:c.linkedin_url||null,website_url:c.website_url||null,instagram_handle:c.instagram_handle||null,facebook_url:c.facebook_url||null,birthday:c.birthday||null,spouse_name:c.spouse_name||null,interests:c.interests||null,referred_by:c.referred_by||null},{data:f,error:g}=await H.from("recruit_prospects").insert(p).select().single();if(g)throw g;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect added"})},onError:c=>r({title:"Error",description:c.message,variant:"destructive"})}),l=Dt({mutationFn:async({id:c,...u})=>{const{data:p,error:f}=await H.from("recruit_prospects").update({...u,updated_at:new Date().toISOString()}).eq("id",c).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]})},onError:c=>r({title:"Error",description:c.message,variant:"destructive"})}),i=Dt({mutationFn:async c=>{const{error:u}=await H.from("recruit_prospects").delete().eq("id",c);if(u)throw u},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect removed"})}});return{stages:n.data||[],prospects:a.data||[],isLoading:n.isLoading||a.isLoading,addProspect:o,updateProspect:l,deleteProspect:i}}function M4s(t){const s=Qt(),{toast:r}=Ua(),n=mt({queryKey:["recruit-activities",t],queryFn:async()=>{if(!t)return[];const{data:o,error:l}=await H.from("recruit_activities").select("*").eq("prospect_id",t).order("created_at",{ascending:!1});if(l)throw l;return o},enabled:!!t}),a=Dt({mutationFn:async o=>{const{data:{user:l}}=await H.auth.getUser();if(!l)throw new Error("Not authenticated");const{data:i,error:c}=await H.from("recruit_activities").insert({...o,created_by:l.id}).select().single();if(c)throw c;return i},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-activities",t]}),r({title:"Activity logged"})},onError:o=>r({title:"Error",description:o.message,variant:"destructive"})});return{activities:n.data||[],isLoading:n.isLoading,addActivity:a}}const _ze=(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 Plt({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=N.useState(_ze(n,r)),c=p=>f=>i(g=>({...g,[p]:f.target.value})),u=p=>{p.preventDefault(),a({...l,experience_years:l.experience_years?parseInt(l.experience_years):null,last_year_transactions:l.last_year_transactions?parseInt(l.last_year_transactions):null,stage_id:l.stage_id||null}),i(_ze(n,r)),s(!1)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Add Recruit Prospect"})}),e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs(ba,{defaultValue:"basic",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-4",children:[e.jsx(ns,{value:"basic",children:"Basic Info"}),e.jsx(ns,{value:"production",children:"Production"}),e.jsx(ns,{value:"social",children:"Social & Web"}),e.jsx(ns,{value:"personal",children:"Personal"})]}),e.jsxs(bs,{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(ze,{required:!0,value:l.first_name,onChange:c("first_name")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Last Name"}),e.jsx(ze,{value:l.last_name,onChange:c("last_name")})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Email"}),e.jsx(ze,{type:"email",value:l.email,onChange:c("email")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Phone"}),e.jsx(ze,{value:l.phone,onChange:c("phone")})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Current Brokerage"}),e.jsx(ze,{value:l.current_brokerage,onChange:c("current_brokerage")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"License #"}),e.jsx(ze,{value:l.license_number,onChange:c("license_number")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Experience (years)"}),e.jsx(ze,{type:"number",min:"0",value:l.experience_years,onChange:c("experience_years")})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Address"}),e.jsx(ze,{placeholder:"Street address",value:l.address,onChange:c("address")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"City"}),e.jsx(ze,{value:l.city,onChange:c("city")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"State"}),e.jsx(ze,{value:l.state,onChange:c("state")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Zip"}),e.jsx(ze,{value:l.zip_code,onChange:c("zip_code")})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Pipeline Stage"}),e.jsxs(Zs,{value:l.stage_id,onValueChange:p=>i(f=>({...f,stage_id:p})),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:r.map(p=>e.jsx(Mt,{value:p.id,children:p.name},p.id))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Referred By"}),e.jsx(ze,{placeholder:"Who referred this prospect?",value:l.referred_by,onChange:c("referred_by")})]})]}),e.jsxs(bs,{value:"production",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Annual Production Volume"}),e.jsx(ze,{placeholder:"e.g. $5M, 20 transactions",value:l.annual_production,onChange:c("annual_production")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Last Year Volume"}),e.jsx(ze,{placeholder:"e.g. $8.2M",value:l.last_year_volume,onChange:c("last_year_volume")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Last Year Transactions"}),e.jsx(ze,{type:"number",min:"0",placeholder:"e.g. 24",value:l.last_year_transactions,onChange:c("last_year_transactions")})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Avg Sale Price"}),e.jsx(ze,{placeholder:"e.g. $350K",value:l.avg_sale_price,onChange:c("avg_sale_price")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Specialties / Niche"}),e.jsx(ze,{placeholder:"e.g. Luxury, First-time buyers, Investment",value:l.specialties,onChange:c("specialties")})]})]}),e.jsxs(bs,{value:"social",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"LinkedIn URL"}),e.jsx(ze,{type:"url",placeholder:"https://linkedin.com/in/...",value:l.linkedin_url,onChange:c("linkedin_url")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Website URL"}),e.jsx(ze,{type:"url",placeholder:"https://...",value:l.website_url,onChange:c("website_url")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Instagram Handle"}),e.jsx(ze,{placeholder:"@handle",value:l.instagram_handle,onChange:c("instagram_handle")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Facebook URL"}),e.jsx(ze,{type:"url",placeholder:"https://facebook.com/...",value:l.facebook_url,onChange:c("facebook_url")})]})]}),e.jsxs(bs,{value:"personal",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Birthday"}),e.jsx(ze,{type:"date",value:l.birthday,onChange:c("birthday")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Spouse / Partner Name"}),e.jsx(ze,{value:l.spouse_name,onChange:c("spouse_name")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Interests / Hobbies"}),e.jsx(ze,{placeholder:"Golf, travel, community events...",value:l.interests,onChange:c("interests")})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Notes"}),e.jsx(Er,{value:l.notes,onChange:c("notes"),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:o,children:"Add Prospect"})]})]})]})})}const dwe=[{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 T4s(t){return mt({queryKey:["recruit-videos",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("recruit_videos").select(` *, prospect:recruit_prospects(id, first_name, last_name, email, phone, current_brokerage), video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status) `).eq("brokerage_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function A4s(t){return mt({queryKey:["recruit-videos-prospect",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("recruit_videos").select(` *, video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status) `).eq("prospect_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function E4s(){const t=Qt(),{toast:s}=Ua();return Dt({mutationFn:async r=>{const{data:{user:n}}=await H.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await H.from("recruit_videos").insert({prospect_id:r.prospect_id,video_id:r.video_id,brokerage_id:r.brokerage_id,message:r.message||null,created_by:n.id}).select("*, prospect:recruit_prospects(id, first_name, last_name, email, phone, current_brokerage), video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status)").single();if(o)throw o;return a},onSuccess:r=>{t.invalidateQueries({queryKey:["recruit-videos"]}),t.invalidateQueries({queryKey:["recruit-videos-prospect",r.prospect_id]}),s({title:"Video linked to prospect"})},onError:r=>s({title:"Error",description:r.message,variant:"destructive"})})}function Ilt(){const t=Qt();return Dt({mutationFn:async({id:s,sent_via:r})=>{const{error:n}=await H.from("recruit_videos").update({sent_at:new Date().toISOString(),sent_via:r,updated_at:new Date().toISOString()}).eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-videos"]})}})}function Llt(t){return mt({queryKey:["recruit-video-scripts",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("recruit_video_scripts").select("*").or(`brokerage_id.eq.${t},is_global.eq.true`).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function P4s(){const t=Qt(),{toast:s}=Ua();return Dt({mutationFn:async r=>{const{data:{user:n}}=await H.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await H.from("recruit_video_scripts").insert({...r,created_by:n.id}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]}),s({title:"Script saved"})},onError:r=>s({title:"Error",description:r.message,variant:"destructive"})})}function I4s(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("recruit_video_scripts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]})}})}function L4s({prospectId:t,prospectName:s,brokerageId:r}){var B;const{data:n=[],isLoading:a}=A4s(t),{data:o=[]}=Llt(r),l=E4s(),i=SC(),c=Ilt(),[u,p]=N.useState("idle"),[f,g]=N.useState(0),[b,_]=N.useState(0),[j,w]=N.useState(""),[k,S]=N.useState(""),[M,L]=N.useState(!1),I=((B=o.find(V=>V.id===j))==null?void 0:B.script_text)||"",O=()=>{p("idle"),g(0),_(0),w(""),S("")},q=N.useCallback(async(V,Z)=>{p("uploading");try{const X=`Recruiting: ${s}`,{videoId:ee,libraryId:Q}=await pR(X),{uploadUrl:ie,apiKey:re}=await fR(ee),oe=new XMLHttpRequest;oe.upload.onprogress=Ne=>{Ne.lengthComputable&&g(Ne.loaded/Ne.total*100)},await new Promise((Ne,Pe)=>{oe.onload=()=>oe.status>=200&&oe.status<300?Ne():Pe(new Error("Upload failed")),oe.onerror=()=>Pe(new Error("Upload failed")),oe.open("PUT",ie),oe.setRequestHeader("AccessKey",re),oe.send(V)}),p("processing");let ce=0;const xe=Date.now(),ge=9e4,ue=`https://iframe.mediadelivery.net/embed/${Q}/${ee}`;for(;ce<4&&(await new Promise(Pe=>setTimeout(Pe,3e3)),!(Date.now()-xe>ge));){const Ne=await _A(ee);if(ce=Ne.status,_(Ne.encodeProgress||0),ce===5||ce===6)throw new Error("Video processing failed")}const pe=await _A(ee),be=(pe.storageSize||V.size)/(1024*1024),Me=await i.mutateAsync({bunny_video_id:ee,playback_url:pe.directPlayUrl||ue,thumbnail_url:pe.thumbnailUrl,preview_url:pe.previewUrl||null,duration_seconds:pe.length||Z,file_size_mb:be,title:X,status:ce>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:Me.id,brokerage_id:r,message:k||void 0}),p("done"),me.success("Video recorded and linked to prospect!"),setTimeout(()=>{L(!1),O()},1500)}catch(X){me.error(X.message||"Failed to upload video"),p("record")}},[t,s,r,k,i,l]),U=V=>{V&&(navigator.clipboard.writeText(`${window.location.origin}/recruit-video/${V}`),me.success("Share link copied"))};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-1.5",children:[e.jsx(An,{className:"h-4 w-4"})," Video Outreach"]}),e.jsxs(fs,{open:M,onOpenChange:V=>{!V&&(u==="uploading"||u==="processing")||(L(V),V||O())},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>p("script"),children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1"})," Record Video"]})}),e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(vs,{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(Zs,{value:j,onValueChange:w,children:[e.jsx(Ws,{className:"mt-1",children:e.jsx(Xs,{placeholder:"No script — speak freely"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"none",children:"No script"}),o.map(V=>{var Z;return e.jsx(Mt,{value:V.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[V.title,e.jsx(tt,{variant:"outline",className:"text-[9px] ml-1",children:(Z=dwe.find(X=>X.value===V.category))==null?void 0:Z.label})]})},V.id)})]})]}),I&&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:I})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Personal Message (shown on landing page)"}),e.jsx(Er,{value:k,onChange:V=>S(V.target.value),placeholder:`Hi ${s.split(" ")[0]}, I'd love to chat about what we're building here...`,rows:3,className:"mt-1"})]}),e.jsxs(K,{onClick:()=>p("record"),className:"w-full",children:[e.jsx(An,{className:"h-4 w-4 mr-2"})," Start Recording"]})]}),u==="record"&&e.jsx(gme,{maxDurationSeconds:60,onRecordingComplete:q,teleprompterContent:I||void 0}),u==="uploading"&&e.jsxs("div",{className:"py-8 space-y-4 text-center",children:[e.jsx("p",{className:"font-medium",children:"Uploading video…"}),e.jsx(Bi,{value:f,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(f),"%"]})]}),u==="processing"&&e.jsxs("div",{className:"py-8 space-y-4 text-center",children:[e.jsx("p",{className:"font-medium",children:"Processing video…"}),e.jsx(Bi,{value:b,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(b),"%"]})]}),u==="done"&&e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-3",children:e.jsx(nl,{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 Z,X;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:(Z=V.video)!=null&&Z.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(An,{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:((X=V.video)==null?void 0:X.title)||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[V.view_count>0?e.jsxs(tt,{variant:"secondary",className:"text-[9px] h-4",children:[e.jsx(On,{className:"h-2.5 w-2.5 mr-0.5"}),V.view_count]}):V.sent_at?e.jsxs(tt,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(Bn,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(tt,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(un,{className:"h-2.5 w-2.5 mr-0.5"}),"Draft"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ms(new Date(V.created_at),"MMM d")})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>U(V.share_token),children:e.jsx(gi,{className:"h-3 w-3"})}),!V.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c.mutate({id:V.id,sent_via:"email"}),children:e.jsx(Bn,{className:"h-3 w-3"})})]})]},V.id)})})]})}function D4s(t){return mt({queryKey:["recruit-campaign-sends",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("recruit_campaign_sends").select("id, prospect_id, subject, email_number, status, sent_at, opened_at, clicked_at, error_message, created_at").eq("prospect_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}const wze=[{value:"call",label:"Phone Call",icon:Un},{value:"email",label:"Email",icon:cr},{value:"text",label:"Text Message",icon:so},{value:"meeting",label:"Meeting",icon:hn},{value:"note",label:"Note",icon:Sn},{value:"campaign_email",label:"Campaign Email",icon:Bn}];function Yp({label:t,value:s,icon:r}){return s?e.jsxs("div",{children:[e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[r&&e.jsx(r,{className:"h-3 w-3"})," ",t]}),e.jsx("p",{className:"font-medium text-sm",children:s})]}):null}function e9({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(tn,{className:"h-3 w-3 opacity-50"})]}):null}function mc({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(ze,{type:n,value:s,onChange:o=>r(o.target.value),placeholder:a,className:"mt-1 h-8 text-sm"})]})}function Dlt({prospect:t,stages:s,brokerageId:r,open:n,onOpenChange:a,onUpdate:o,onDelete:l}){const{activities:i,addActivity:c}=M4s((t==null?void 0:t.id)||null),{data:u=[]}=D4s((t==null?void 0:t.id)||null),[p,f]=N.useState({type:"note",title:"",description:""}),[g,b]=N.useState(!1),[_,j]=N.useState(!1),[w,k]=N.useState({});if(!t)return null;const S=()=>{var X,ee;k({first_name:t.first_name||"",last_name:t.last_name||"",email:t.email||"",phone:t.phone||"",current_brokerage:t.current_brokerage||"",license_number:t.license_number||"",experience_years:((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:((ee=t.last_year_transactions)==null?void 0:ee.toString())||"",avg_sale_price:t.avg_sale_price||"",specialties:t.specialties||"",annual_production:t.annual_production||"",linkedin_url:t.linkedin_url||"",website_url:t.website_url||"",instagram_handle:t.instagram_handle||"",facebook_url:t.facebook_url||"",birthday:t.birthday||"",spouse_name:t.spouse_name||"",interests:t.interests||"",referred_by:t.referred_by||""}),j(!0)},M=()=>{const X={id:t.id};for(const[ee,Q]of Object.entries(w))ee==="experience_years"||ee==="last_year_transactions"?X[ee]=Q?parseInt(Q):null:X[ee]=Q||null;o(X),j(!1)},L=()=>j(!1),I=X=>ee=>k(Q=>({...Q,[X]:ee})),O=()=>{p.title.trim()&&(c.mutate({prospect_id:t.id,activity_type:p.type,title:p.title,description:p.description||null}),f({type:"note",title:"",description:""}),b(!1))},q=s.find(X=>X.id===t.stage_id),U=t.address||t.city||t.state,B=t.last_year_volume||t.last_year_transactions||t.avg_sale_price||t.specialties||t.annual_production,V=t.linkedin_url||t.website_url||t.instagram_handle||t.facebook_url,Z=t.birthday||t.spouse_name||t.interests||t.referred_by;return e.jsx(JA,{open:n,onOpenChange:X=>{X||j(!1),a(X)},children:e.jsx(yC,{className:"w-full sm:max-w-lg p-0",children:e.jsx(Gi,{className:"h-full",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsx(eE,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(tE,{className:"text-xl",children:[t.first_name," ",t.last_name]}),q&&e.jsx(tt,{variant:"outline",style:{borderColor:q.color,color:q.color},className:"mt-1",children:q.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[_?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:L,children:e.jsx(Rr,{className:"h-4 w-4"})}),e.jsx(K,{variant:"default",size:"icon",onClick:M,children:e.jsx(qc,{className:"h-4 w-4"})})]}):e.jsx(K,{variant:"ghost",size:"icon",onClick:S,title:"Edit prospect",children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Delete prospect?"}),e.jsx(tc,{children:"This will permanently remove this prospect and all their activity history."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{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(cr,{className:"h-3.5 w-3.5"})," ",t.email]}),t.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," ",t.phone]}),U&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ma,{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(Zs,{value:t.stage_id||"",onValueChange:X=>o({id:t.id,stage_id:X}),children:[e.jsx(Ws,{className:"mt-1",children:e.jsx(Xs,{})}),e.jsx(Gs,{children:s.map(X=>e.jsx(Mt,{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(ba,{defaultValue:"details",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-4 h-8 text-xs",children:[e.jsx(ns,{value:"details",className:"text-xs",children:"Details"}),e.jsx(ns,{value:"production",className:"text-xs",children:"Production"}),e.jsx(ns,{value:"social",className:"text-xs",children:"Social"}),e.jsx(ns,{value:"personal",className:"text-xs",children:"Personal"})]}),_?e.jsxs(e.Fragment,{children:[e.jsxs(bs,{value:"details",className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(mc,{label:"First Name",value:w.first_name,onChange:I("first_name")}),e.jsx(mc,{label:"Last Name",value:w.last_name,onChange:I("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(mc,{label:"Email",value:w.email,onChange:I("email"),type:"email"}),e.jsx(mc,{label:"Phone",value:w.phone,onChange:I("phone")})]}),e.jsx(mc,{label:"Current Brokerage",value:w.current_brokerage,onChange:I("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(mc,{label:"License #",value:w.license_number,onChange:I("license_number")}),e.jsx(mc,{label:"Experience (years)",value:w.experience_years,onChange:I("experience_years"),type:"number"})]}),e.jsx(mc,{label:"Address",value:w.address,onChange:I("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(mc,{label:"City",value:w.city,onChange:I("city")}),e.jsx(mc,{label:"State",value:w.state,onChange:I("state")}),e.jsx(mc,{label:"Zip",value:w.zip_code,onChange:I("zip_code")})]}),e.jsx(mc,{label:"Source",value:w.source,onChange:I("source")}),e.jsx(mc,{label:"Referred By",value:w.referred_by,onChange:I("referred_by")}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Notes"}),e.jsx(Er,{value:w.notes,onChange:X=>k(ee=>({...ee,notes:X.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs(bs,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(mc,{label:"Annual Production",value:w.annual_production,onChange:I("annual_production"),placeholder:"e.g. $5M"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(mc,{label:"Last Year Volume",value:w.last_year_volume,onChange:I("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(mc,{label:"Last Year Transactions",value:w.last_year_transactions,onChange:I("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(mc,{label:"Avg Sale Price",value:w.avg_sale_price,onChange:I("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(mc,{label:"Specialties / Niche",value:w.specialties,onChange:I("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs(bs,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(mc,{label:"LinkedIn URL",value:w.linkedin_url,onChange:I("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(mc,{label:"Website URL",value:w.website_url,onChange:I("website_url"),type:"url",placeholder:"https://..."}),e.jsx(mc,{label:"Instagram Handle",value:w.instagram_handle,onChange:I("instagram_handle"),placeholder:"@handle"}),e.jsx(mc,{label:"Facebook URL",value:w.facebook_url,onChange:I("facebook_url"),type:"url",placeholder:"https://facebook.com/..."})]}),e.jsxs(bs,{value:"personal",className:"mt-3 space-y-3",children:[e.jsx(mc,{label:"Birthday",value:w.birthday,onChange:I("birthday"),type:"date"}),e.jsx(mc,{label:"Spouse / Partner",value:w.spouse_name,onChange:I("spouse_name")}),e.jsx(mc,{label:"Interests / Hobbies",value:w.interests,onChange:I("interests"),placeholder:"Golf, travel, community events..."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(bs,{value:"details",className:"mt-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Yp,{label:"Current Brokerage",value:t.current_brokerage}),e.jsx(Yp,{label:"License #",value:t.license_number}),e.jsx(Yp,{label:"Experience",value:t.experience_years!=null?`${t.experience_years} years`:null}),e.jsx(Yp,{label:"Referred By",value:t.referred_by}),e.jsx(Yp,{label:"Source",value:t.source})]}),t.notes&&e.jsxs("div",{className:"mt-3",children:[e.jsx(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(bs,{value:"production",className:"mt-3",children:B?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Yp,{label:"Annual Production",value:t.annual_production}),e.jsx(Yp,{label:"Last Year Volume",value:t.last_year_volume}),e.jsx(Yp,{label:"Last Year Transactions",value:t.last_year_transactions}),e.jsx(Yp,{label:"Avg Sale Price",value:t.avg_sale_price}),e.jsx(Yp,{label:"Specialties / Niche",value:t.specialties})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No production data added yet"})}),e.jsx(bs,{value:"social",className:"mt-3",children:V?e.jsxs("div",{className:"space-y-2",children:[e.jsx(e9,{label:"LinkedIn",url:t.linkedin_url,icon:Mp}),e.jsx(e9,{label:"Website",url:t.website_url,icon:su}),t.instagram_handle&&e.jsx(e9,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:Mu}),e.jsx(e9,{label:"Facebook",url:t.facebook_url,icon:Su})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No social profiles added yet"})}),e.jsx(bs,{value:"personal",className:"mt-3",children:Z?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Yp,{label:"Birthday",value:t.birthday?ms(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:ko}),e.jsx(Yp,{label:"Spouse / Partner",value:t.spouse_name,icon:ni}),e.jsx("div",{className:"col-span-2",children:e.jsx(Yp,{label:"Interests / Hobbies",value:t.interests})})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No personal details added yet"})})]})]}),e.jsx(L4s,{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:()=>b(!g),children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1"})," Log Activity"]})]}),g&&e.jsxs("div",{className:"border rounded-lg p-3 mb-4 space-y-3 bg-muted/30",children:[e.jsxs(Zs,{value:p.type,onValueChange:X=>f(ee=>({...ee,type:X})),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:wze.map(X=>e.jsx(Mt,{value:X.value,children:X.label},X.value))})]}),e.jsx(ze,{placeholder:"Subject / Title",value:p.title,onChange:X=>f(ee=>({...ee,title:X.target.value}))}),e.jsx(Er,{placeholder:"Details (optional)",value:p.description,onChange:X=>f(ee=>({...ee,description:X.target.value})),rows:2}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{size:"sm",onClick:O,disabled:!p.title.trim(),children:"Save"})]})]}),e.jsx("div",{className:"space-y-3",children:(()=>{const X=[...i.map(ee=>({type:"manual",data:ee,date:ee.created_at})),...u.map(ee=>({type:"campaign_email",data:ee,date:ee.sent_at||ee.created_at}))].sort((ee,Q)=>new Date(Q.date).getTime()-new Date(ee.date).getTime());return X.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"}):X.map(ee=>{if(ee.type==="manual"){const ie=ee.data,re=wze.find(ce=>ce.value===ie.activity_type),oe=(re==null?void 0:re.icon)||Sn;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(oe,{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:ie.title}),ie.description&&e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:ie.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ms(new Date(ie.created_at),"MMM d, yyyy h:mm a")})]})]},`activity-${ie.id}`)}const Q=ee.data;return e.jsxs("div",{className:"flex gap-3 text-sm",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("div",{className:"h-7 w-7 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Bn,{className:"h-3.5 w-3.5 text-primary"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"font-medium",children:["Campaign Email #",Q.email_number]}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:Q.subject}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1.5",children:[Q.status==="failed"?e.jsx(tt,{variant:"destructive",className:"text-[10px] px-1.5 py-0 h-4",children:"Failed"}):e.jsxs(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-green-500 text-green-600",children:[e.jsx(Bn,{className:"h-2.5 w-2.5 mr-0.5"})," Sent"]}),Q.opened_at?e.jsxs(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-blue-500 text-blue-600",children:[e.jsx(On,{className:"h-2.5 w-2.5 mr-0.5"})," Opened ",ms(new Date(Q.opened_at),"MMM d, h:mm a")]}):Q.status!=="failed"?e.jsx(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 text-muted-foreground",children:"Not opened"}):null,Q.clicked_at&&e.jsxs(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-purple-500 text-purple-600",children:[e.jsx(wh,{className:"h-2.5 w-2.5 mr-0.5"})," Clicked ",ms(new Date(Q.clicked_at),"MMM d, h:mm a")]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ms(new Date(Q.sent_at||Q.created_at),"MMM d, yyyy h:mm a")})]})]},`send-${Q.id}`)})})()})]})]})})})})}const O4s=["first_name","last_name","email","phone","current_brokerage","license_number","experience_years","annual_production","notes","address","city","state","zip_code","last_year_volume","last_year_transactions","avg_sale_price","linkedin_url","website_url","specialties","referred_by"];function Olt({open:t,onOpenChange:s,brokerageId:r,stages:n}){var V;const{toast:a}=Ua(),o=Qt(),l=N.useRef(null),[i,c]=N.useState([]),[u,p]=N.useState([]),[f,g]=N.useState({}),[b,_]=N.useState(((V=n[0])==null?void 0:V.id)||""),[j,w]=N.useState(!1),[k,S]=N.useState("upload"),[M,L]=N.useState(0),I=()=>{c([]),p([]),g({}),S("upload"),L(0)},O=Z=>{var Q;const X=(Q=Z.target.files)==null?void 0:Q[0];if(!X)return;const ee=new FileReader;ee.onload=ie=>{var pe;const oe=((pe=ie.target)==null?void 0:pe.result).split(/\r?\n/).filter(be=>be.trim());if(oe.length<2){a({title:"Invalid CSV",description:"File must have a header row and at least one data row",variant:"destructive"});return}const ce=q(oe[0]);p(ce);const xe={},ge=new Set;ce.forEach((be,Me)=>{const Ne=be.toLowerCase().replace(/[^a-z0-9]/g,"");let Pe=null;/^firstname$/.test(Ne)||Ne==="first"?Pe="first_name":/^lastname$/.test(Ne)||Ne==="last"?Pe="last_name":/^email$/.test(Ne)||Ne==="emailaddress"?Pe="email":/^mobile$|^phone$|^cellphone$|^mobilephone$/.test(Ne)?Pe="phone":/officename|currentbrokerage|brokerage|company/.test(Ne)?Pe="current_brokerage":/membernumber|licensenumber|license/.test(Ne)?Pe="license_number":/experienceyears|yearsexperience/.test(Ne)?Pe="experience_years":/^totalvolume$|annualproduction/.test(Ne)?Pe="annual_production":/^address$/.test(Ne)?Pe="address":/^city$/.test(Ne)?Pe="city":/^state$/.test(Ne)?Pe="state":/^postalcode$|^zip$|^zipcode$/.test(Ne)?Pe="zip_code":/listsidevolume|lastyearvolume/.test(Ne)?Pe="last_year_volume":/^totalcount$|lastyeartransactions/.test(Ne)?Pe="last_year_transactions":/avgsaleprice|averageprice/.test(Ne)?Pe="avg_sale_price":/linkedin/.test(Ne)?Pe="linkedin_url":/website/.test(Ne)?Pe="website_url":/specialt/.test(Ne)?Pe="specialties":/referr/.test(Ne)?Pe="referred_by":/^notes$|^note$/.test(Ne)&&(Pe="notes"),Pe&&!ge.has(Pe)&&(xe[String(Me)]=Pe,ge.add(Pe))}),g(xe);const ue=oe.slice(1).map(be=>{const Me=q(be),Ne={};return ce.forEach((Pe,Oe)=>{Ne[String(Oe)]=Me[Oe]||""}),Ne});c(ue),S("map")},ee.readAsText(X)},q=Z=>{const X=[];let ee="",Q=!1;for(const ie of Z)ie==='"'?Q=!Q:ie===","&&!Q?(X.push(ee.trim()),ee=""):ee+=ie;return X.push(ee.trim()),X},U=async()=>{w(!0);try{const{data:{user:Z}}=await H.auth.getUser();if(!Z)throw new Error("Not authenticated");const X=i.map(Q=>{const ie={brokerage_id:r,created_by:Z.id,stage_id:b,source:"csv_import",first_name:"Unknown"};return Object.entries(f).forEach(([re,oe])=>{var xe;const ce=(xe=Q[re])==null?void 0:xe.trim();ce&&(oe==="experience_years"||oe==="last_year_transactions"?ie[oe]=parseInt(ce.replace(/[^0-9.-]/g,""))||null:oe==="annual_production"||oe==="last_year_volume"||oe==="avg_sale_price"?ie[oe]=ce.replace(/[^0-9.$,.-]/g,""):ie[oe]=ce)}),ie});let ee=0;for(let Q=0;Q{const Z=`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`,X=new Blob([Z],{type:"text/csv"}),ee=URL.createObjectURL(X),Q=document.createElement("a");Q.href=ee,Q.download="recruit-prospects-template.csv",Q.click(),URL.revokeObjectURL(ee)};return e.jsx(fs,{open:t,onOpenChange:Z=>{Z||I(),s(Z)},children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Import Prospects from CSV"})}),k==="upload"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx(r1,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Upload a CSV file with prospect data"}),e.jsx("input",{ref:l,type:"file",accept:".csv",className:"hidden",onChange:O}),e.jsxs(K,{onClick:()=>{var Z;return(Z=l.current)==null?void 0:Z.click()},children:[e.jsx(li,{className:"h-4 w-4 mr-2"})," Choose File"]})]}),e.jsx(K,{variant:"link",className:"text-xs",onClick:B,children:"Download CSV template"})]}),k==="map"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," rows found"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:"Import to stage:"}),e.jsxs(Zs,{value:b,onValueChange:_,children:[e.jsx(Ws,{className:"w-[180px]",children:e.jsx(Xs,{})}),e.jsx(Gs,{children:n.map(Z=>e.jsx(Mt,{value:Z.id,children:Z.name},Z.id))})]})]})]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[140px]",children:"CSV Column"}),e.jsx(St,{className:"w-[160px]",children:"Map To"}),e.jsx(St,{children:"Preview"})]})}),e.jsx(zn,{children:u.map((Z,X)=>{var ee;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium text-xs",children:Z}),e.jsx(dt,{children:e.jsxs(Zs,{value:f[String(X)]||"skip",onValueChange:Q=>g(ie=>({...ie,[String(X)]:Q==="skip"?"":Q})),children:[e.jsx(Ws,{className:"h-8 text-xs",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"skip",children:"— Skip —"}),O4s.map(Q=>e.jsx(Mt,{value:Q,children:Q.replace(/_/g," ")},Q))]})]})}),e.jsx(dt,{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:((ee=i[0])==null?void 0:ee[String(X)])||"—"})]},X)})})]})}),!Object.values(f).includes("first_name")&&e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-sm",children:[e.jsx(kl,{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:()=>{I()},children:"Back"}),e.jsx(K,{onClick:U,disabled:j||!Object.values(f).includes("first_name"),children:j?"Importing...":`Import ${i.length} Prospects`})]})]}),k==="done"&&e.jsxs("div",{className:"text-center py-6 space-y-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-green-500/10 flex items-center justify-center mx-auto",children:e.jsx(va,{className:"h-6 w-6 text-green-600"})}),e.jsxs("p",{className:"font-semibold",children:[M," prospects imported successfully!"]}),e.jsx(K,{onClick:()=>{I(),s(!1)},children:"Close"})]})]})})}function Rlt({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=yme(t),[i,c]=N.useState(!1),[u,p]=N.useState(),[f,g]=N.useState(null),[b,_]=N.useState(!1),[j,w]=N.useState(!1),[k,S]=N.useState(null);if(n)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});const M=B=>r.filter(V=>V.stage_id===B),L=(B,V)=>{S(V),B.dataTransfer.effectAllowed="move"},I=B=>{B.preventDefault(),B.dataTransfer.dropEffect="move"},O=(B,V)=>{B.preventDefault(),k&&(o.mutate({id:k,stage_id:V}),S(null))},q=B=>{p(B),c(!0)},U=B=>{g(B),_(!0)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.length," prospect",r.length!==1?"s":""]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>w(!0),children:[e.jsx(li,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>{p(void 0),c(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs(Gi,{className:"w-full",children:[e.jsx("div",{className:"flex gap-4 pb-4",style:{minWidth:s.length*300},children:s.map(B=>{const V=M(B.id);return e.jsxs("div",{className:"w-[280px] flex-shrink-0 flex flex-col",onDragOver:I,onDrop:Z=>O(Z,B.id),children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:B.color}}),e.jsx("h3",{className:"font-semibold text-sm",children:B.name}),e.jsx(tt,{variant:"secondary",className:"text-xs h-5 px-1.5",children:V.length})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>q(B.id),children:e.jsx($s,{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(Z=>e.jsx(Ee,{className:"p-3 cursor-pointer hover:shadow-md transition-shadow border-l-4 group",style:{borderLeftColor:B.color},draggable:!0,onDragStart:X=>L(X,Z.id),onClick:()=>U(Z),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(to,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"font-medium text-sm truncate",children:[Z.first_name," ",Z.last_name]})]}),Z.current_brokerage&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(ka,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:Z.current_brokerage})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Z.email&&e.jsx(cr,{className:"h-3 w-3 text-muted-foreground"}),Z.phone&&e.jsx(Un,{className:"h-3 w-3 text-muted-foreground"}),Z.experience_years!=null&&e.jsxs(tt,{variant:"secondary",className:"text-[10px] h-4 px-1",children:[Z.experience_years,"yr"]})]})]})]})},Z.id))})]},B.id)})}),e.jsx(nue,{orientation:"horizontal"})]}),e.jsx(Plt,{open:i,onOpenChange:c,stages:s,defaultStageId:u,onSubmit:B=>a.mutate(B),isSubmitting:a.isPending}),e.jsx(Dlt,{prospect:f,stages:s,brokerageId:t,open:b,onOpenChange:_,onUpdate:B=>{o.mutate(B),g(V=>V?{...V,...B}:null)},onDelete:B=>l.mutate(B)}),e.jsx(Olt,{open:j,onOpenChange:w,brokerageId:t,stages:s})]})}function tde({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=yme(t),{user:i}=Ds(),c=Qt(),[u,p]=N.useState(!1),[f,g]=N.useState(null),[b,_]=N.useState(!1),[j,w]=N.useState(!1),[k,S]=N.useState(""),[M,L]=N.useState("all"),[I,O]=N.useState("all"),[q,U]=N.useState("all"),[B,V]=N.useState(null),[Z,X]=N.useState("asc"),[ee,Q]=N.useState(new Set),[ie,re]=N.useState(!1),[oe,ce]=N.useState(""),xe=N.useMemo(()=>{const Ae=new Set;return r.forEach(ft=>{ft.current_brokerage&&Ae.add(ft.current_brokerage)}),Array.from(Ae).sort()},[r]),{data:ge=[]}=mt({queryKey:["recruit-campaigns-list",t],queryFn:async()=>{const{data:Ae,error:ft}=await H.from("recruit_campaigns").select("id, name, warmth_level").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("name");if(ft)throw ft;return Ae}}),{data:ue=[]}=mt({queryKey:["recruit-campaign-assignments-lookup",t],queryFn:async()=>{const{data:Ae,error:ft}=await H.from("recruit_campaign_assignments").select("prospect_id, campaign_id, status").eq("brokerage_id",t);if(ft)throw ft;return Ae}}),pe=N.useMemo(()=>{const Ae=new Map;return ue.forEach(ft=>{Ae.has(ft.prospect_id)||Ae.set(ft.prospect_id,new Set),Ae.get(ft.prospect_id).add(ft.campaign_id)}),Ae},[ue]),be=Ae=>{B===Ae?X(ft=>ft==="asc"?"desc":"asc"):(V(Ae),X("asc"))},Me=({column:Ae})=>B!==Ae?e.jsx(vd,{className:"h-3.5 w-3.5 ml-1 text-muted-foreground/50"}):Z==="asc"?e.jsx(ku,{className:"h-3.5 w-3.5 ml-1 text-primary"}):e.jsx(Wh,{className:"h-3.5 w-3.5 ml-1 text-primary"}),Ne=Ae=>s.find(ft=>ft.id===Ae),Pe=N.useMemo(()=>{let Ae=r.filter(ft=>{var Ce,rt,Ge;const fe=!k||`${ft.first_name} ${ft.last_name}`.toLowerCase().includes(k.toLowerCase())||((Ce=ft.email)==null?void 0:Ce.toLowerCase().includes(k.toLowerCase()))||((rt=ft.current_brokerage)==null?void 0:rt.toLowerCase().includes(k.toLowerCase())),Ve=M==="all"||ft.stage_id===M,at=I==="all"||ft.current_brokerage===I;let et=!0;return q==="in_campaign"?et=pe.has(ft.id):q==="not_in_campaign"?et=!pe.has(ft.id):q!=="all"&&(et=((Ge=pe.get(ft.id))==null?void 0:Ge.has(q))??!1),fe&&Ve&&at&&et});return B&&(Ae=[...Ae].sort((ft,fe)=>{var Ce,rt;let Ve=null,at=null;switch(B){case"name":Ve=`${ft.first_name} ${ft.last_name||""}`.toLowerCase(),at=`${fe.first_name} ${fe.last_name||""}`.toLowerCase();break;case"stage":Ve=((Ce=Ne(ft.stage_id))==null?void 0:Ce.sort_order)??999,at=((rt=Ne(fe.stage_id))==null?void 0:rt.sort_order)??999;break;case"brokerage":Ve=(ft.current_brokerage||"").toLowerCase(),at=(fe.current_brokerage||"").toLowerCase();break;case"experience":Ve=ft.experience_years??-1,at=fe.experience_years??-1;break;case"production":Ve=(ft.annual_production||"").toLowerCase(),at=(fe.annual_production||"").toLowerCase();break;case"source":Ve=(ft.source||"").toLowerCase(),at=(fe.source||"").toLowerCase();break;default:return 0}if(Ve===at)return 0;if(Ve==null)return 1;if(at==null)return-1;const et=Ve0&&Pe.every(Ae=>ee.has(Ae.id)),Te=Pe.some(Ae=>ee.has(Ae.id)),ke=()=>{Q(Oe?new Set:new Set(Pe.map(Ae=>Ae.id)))},Be=Ae=>{Q(ft=>{const fe=new Set(ft);return fe.has(Ae)?fe.delete(Ae):fe.add(Ae),fe})},nt=Dt({mutationFn:async()=>{if(!oe||!(i!=null&&i.id))throw new Error("Select a campaign");const Ae=new Set(ue.filter(Ve=>Ve.campaign_id===oe).map(Ve=>Ve.prospect_id)),ft=Array.from(ee).filter(Ve=>!Ae.has(Ve)).map(Ve=>({prospect_id:Ve,campaign_id:oe,brokerage_id:t,assigned_by:i.id,status:"active",current_email_number:0}));if(ft.length===0)throw new Error("All selected prospects are already in this campaign");const{error:fe}=await H.from("recruit_campaign_assignments").insert(ft);if(fe)throw fe;return ft.length},onSuccess:Ae=>{me.success(`${Ae} prospect(s) added to campaign`),re(!1),Q(new Set),ce(""),c.invalidateQueries({queryKey:["recruit-campaign-assignments-lookup"]})},onError:Ae=>me.error(Ae.message)});return n?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm min-w-[200px]",children:[e.jsx(cn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search prospects...",value:k,onChange:Ae=>S(Ae.target.value),className:"pl-8"})]}),e.jsxs("div",{className:"flex gap-2",children:[ee.size>0&&e.jsxs(K,{variant:"secondary",onClick:()=>re(!0),className:"gap-1.5",children:[e.jsx(Bn,{className:"h-4 w-4"})," Add ",ee.size," to Campaign"]}),e.jsxs(K,{variant:"outline",onClick:()=>w(!0),children:[e.jsx(li,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>p(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Xg,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(Zs,{value:M,onValueChange:L,children:[e.jsx(Ws,{className:"w-[160px] h-8 text-xs",children:e.jsx(Xs,{placeholder:"All stages"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All stages"}),s.map(Ae=>e.jsx(Mt,{value:Ae.id,children:Ae.name},Ae.id))]})]}),e.jsxs(Zs,{value:I,onValueChange:O,children:[e.jsxs(Ws,{className:"w-[200px] h-8 text-xs",children:[e.jsx(ka,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(Xs,{placeholder:"All brokerages"})]}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All brokerages"}),xe.map(Ae=>e.jsx(Mt,{value:Ae,children:Ae},Ae))]})]}),e.jsxs(Zs,{value:q,onValueChange:U,children:[e.jsxs(Ws,{className:"w-[200px] h-8 text-xs",children:[e.jsx(cr,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(Xs,{placeholder:"Campaign status"})]}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All contacts"}),e.jsx(Mt,{value:"in_campaign",children:"In any campaign"}),e.jsx(Mt,{value:"not_in_campaign",children:"Not in any campaign"}),ge.map(Ae=>e.jsxs(Mt,{value:Ae.id,children:["In: ",Ae.name]},Ae.id))]})]}),(M!=="all"||I!=="all"||q!=="all")&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 text-xs text-muted-foreground",onClick:()=>{L("all"),O("all"),U("all")},children:"Clear filters"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Oo,{checked:Oe,onCheckedChange:ke,"aria-label":"Select all",...Te&&!Oe?{"data-state":"indeterminate"}:{}})}),e.jsx(St,{className:"cursor-pointer select-none",onClick:()=>be("name"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Name ",e.jsx(Me,{column:"name"})]})}),e.jsx(St,{className:"cursor-pointer select-none",onClick:()=>be("stage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Stage ",e.jsx(Me,{column:"stage"})]})}),e.jsx(St,{className:"hidden md:table-cell cursor-pointer select-none",onClick:()=>be("brokerage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Brokerage ",e.jsx(Me,{column:"brokerage"})]})}),e.jsx(St,{className:"hidden md:table-cell",children:"Contact"}),e.jsx(St,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>be("experience"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Experience ",e.jsx(Me,{column:"experience"})]})}),e.jsx(St,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>be("production"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Production ",e.jsx(Me,{column:"production"})]})}),e.jsx(St,{className:"hidden lg:table-cell",children:"Campaigns"}),e.jsx(St,{className:"w-[50px]"})]})}),e.jsx(zn,{children:Pe.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:9,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):Pe.map(Ae=>{const ft=Ne(Ae.stage_id),fe=pe.get(Ae.id),Ve=(fe==null?void 0:fe.size)??0;return e.jsxs(Ss,{className:"cursor-pointer",onClick:()=>{g(Ae),_(!0)},children:[e.jsx(dt,{onClick:at=>at.stopPropagation(),children:e.jsx(Oo,{checked:ee.has(Ae.id),onCheckedChange:()=>Be(Ae.id),"aria-label":`Select ${Ae.first_name}`})}),e.jsxs(dt,{className:"font-medium",children:[Ae.first_name," ",Ae.last_name]}),e.jsx(dt,{children:ft?e.jsxs(tt,{variant:"outline",className:"text-xs gap-1 whitespace-nowrap",style:{borderColor:ft.color,color:ft.color,backgroundColor:`${ft.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:ft.color}}),ft.name]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"—"})}),e.jsx(dt,{className:"hidden md:table-cell",children:Ae.current_brokerage?e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(ka,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:Ae.current_brokerage})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Ae.email&&e.jsx(cr,{className:"h-3.5 w-3.5 text-muted-foreground"}),Ae.phone&&e.jsx(Un,{className:"h-3.5 w-3.5 text-muted-foreground"}),!Ae.email&&!Ae.phone&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]})}),e.jsx(dt,{className:"hidden lg:table-cell",children:Ae.experience_years!=null?`${Ae.experience_years} yr`:"—"}),e.jsx(dt,{className:"hidden lg:table-cell",children:Ae.annual_production||"—"}),e.jsx(dt,{className:"hidden lg:table-cell",children:Ve>0?e.jsxs(tt,{variant:"secondary",className:"text-xs",children:[Ve," campaign",Ve>1?"s":""]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"None"})}),e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:at=>{at.stopPropagation(),l.mutate(Ae.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})})]},Ae.id)})})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ee.size>0&&e.jsxs("span",{className:"font-medium text-foreground",children:[ee.size," selected · "]}),Pe.length," of ",r.length," prospects"]}),e.jsx(fs,{open:ie,onOpenChange:re,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Add to Campaign"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Add ",e.jsx("span",{className:"font-medium text-foreground",children:ee.size})," selected prospect(s) to a recruiting campaign drip."]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Campaign"}),e.jsxs(Zs,{value:oe,onValueChange:ce,children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select a campaign..."})}),e.jsx(Gs,{children:ge.map(Ae=>e.jsxs(Mt,{value:Ae.id,children:[Ae.name," ",e.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",Ae.warmth_level,")"]})]},Ae.id))})]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>re(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>nt.mutate(),disabled:!oe||nt.isPending,children:nt.isPending?"Adding...":"Add to Campaign"})]})]})}),e.jsx(Plt,{open:u,onOpenChange:p,stages:s,onSubmit:Ae=>a.mutate(Ae),isSubmitting:a.isPending}),e.jsx(Dlt,{prospect:f,stages:s,brokerageId:t,open:b,onOpenChange:_,onUpdate:Ae=>{o.mutate(Ae),g(ft=>ft?{...ft,...Ae}:null)},onDelete:Ae=>l.mutate(Ae)}),e.jsx(Olt,{open:j,onOpenChange:w,brokerageId:t,stages:s})]})}function Flt({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=yme(t),a=N.useMemo(()=>{if(!s.length||!r.length)return null;const o=r.length,l=s.find(k=>k.name==="Signed"),i=s.find(k=>k.name==="Onboarded"),c=r.filter(k=>k.stage_id===(l==null?void 0:l.id)||k.stage_id===(i==null?void 0:i.id)).length,u=o>0?(c/o*100).toFixed(1):"0",p=new Date,f=o>0?Math.round(r.reduce((k,S)=>k+oy(p,new Date(S.created_at)),0)/o):0,g=s.map(k=>({...k,count:r.filter(S=>S.stage_id===k.id).length})),b={};r.forEach(k=>{const S=k.source||"unknown";b[S]=(b[S]||0)+1});const _=Object.entries(b).sort((k,S)=>S[1]-k[1]),j=new Date;j.setDate(j.getDate()-30);const w=r.filter(k=>new Date(k.created_at)>=j).length;return{total:o,signed:c,conversionRate:u,avgDays:f,byStage:g,bySrc:_,recentCount:w}},[s,r]);return n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsx(De,{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(pr,{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(De,{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(ul,{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(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-amber-500/10 flex items-center justify-center",children:e.jsx(un,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:[a.avgDays,"d"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Avg Days in Pipeline"})]})]})})}),e.jsx(Ee,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-violet-500/10 flex items-center justify-center",children:e.jsx(zm,{className:"h-5 w-5 text-violet-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.recentCount}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Added (30 days)"})]})]})})})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Pipeline Breakdown"})}),e.jsx(De,{className:"space-y-3",children:a.byStage.map(o=>{const l=a.total>0?o.count/a.total*100:0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:o.color}}),e.jsx("span",{children:o.name})]}),e.jsx("span",{className:"font-medium",children:o.count})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${l}%`,backgroundColor:o.color}})})]},o.id)})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(De,{className:"space-y-3",children:[a.bySrc.map(([o,l])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(tt,{variant:"secondary",className:"capitalize",children:o.replace(/_/g," ")}),e.jsx("span",{className:"text-sm font-medium",children:l})]},o)),a.bySrc.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No source data"})]})]})]})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No prospect data yet. Add prospects to see metrics."})}const jze=[{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 zlt({brokerageId:t}){const{toast:s}=Ua(),[r,n]=N.useState(null),[a,o]=N.useState(null),l=(c,u)=>{navigator.clipboard.writeText(c),n(u),s({title:"Copied to clipboard!"}),setTimeout(()=>n(null),2e3)},i=[...new Set(jze.map(c=>c.category))];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pre-built email templates for recruiting outreach. Click to expand and copy."}),i.map(c=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(cr,{className:"h-4 w-4"})," ",c]}),jze.filter(u=>u.category===c).map(u=>e.jsxs(Ee,{className:`cursor-pointer transition-all ${a===u.id?"ring-2 ring-primary/20":"hover:shadow-sm"}`,onClick:()=>o(a===u.id?null:u.id),children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{className:"text-sm",children:u.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Subject: ",u.subject]})]}),e.jsx(tt,{variant:"secondary",className:"text-[10px]",children:u.category})]})}),a===u.id&&e.jsxs(De,{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(va,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(gi,{className:"h-3.5 w-3.5 mr-1"}),"Copy Subject"]}),e.jsxs(K,{size:"sm",onClick:p=>{p.stopPropagation(),l(u.body,u.id+"-body")},children:[r===u.id+"-body"?e.jsx(va,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(gi,{className:"h-3.5 w-3.5 mr-1"}),"Copy Body"]})]})]})]},u.id))]},c))]})}const Nze={call:Un,email:cr,text:so,meeting:hn,note:Sn};function Blt({brokerageId:t}){const{data:s,isLoading:r}=mt({queryKey:["recruit-activity-report",t],queryFn:async()=>{const{data:n,error:a}=await H.from("recruit_prospects").select("id, created_by").eq("brokerage_id",t);if(a)throw a;const o=(n==null?void 0:n.map(b=>b.id))||[];if(o.length===0)return{recruiters:[],recentActivities:[]};const{data:l,error:i}=await H.from("recruit_activities").select("*").in("prospect_id",o).order("created_at",{ascending:!1});if(i)throw i;const c=[...new Set([...n.map(b=>b.created_by),...(l||[]).map(b=>b.created_by)])],{data:u}=await H.from("profiles").select("id, name, email").in("id",c),p=Object.fromEntries((u||[]).map(b=>[b.id,b])),f=hie(new Date,30);return{recruiters:c.map(b=>{var S,M;const _=(l||[]).filter(L=>L.created_by===b),j=_.filter(L=>new Date(L.created_at)>=f),w={};j.forEach(L=>{w[L.activity_type]=(w[L.activity_type]||0)+1});const k=n.filter(L=>L.created_by===b).length;return{id:b,name:((S=p[b])==null?void 0:S.name)||"Unknown",email:((M=p[b])==null?void 0:M.email)||"",totalActivities:_.length,recentActivities:j.length,byType:w,prospectsCreated:k}}).sort((b,_)=>_.recentActivities-b.recentActivities),recentActivities:(l||[]).slice(0,20)}},enabled:!!t});return r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):s!=null&&s.recruiters.length?e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Recruiter Leaderboard (Last 30 Days)"})}),e.jsx(De,{className:"space-y-4",children:s.recruiters.map((n,a)=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-primary/10 text-primary font-bold text-sm",children:a+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"font-medium text-sm",children:n.name})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(n.byType).map(([o,l])=>{const i=Nze[o]||Sn;return e.jsxs(tt,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(i,{className:"h-2.5 w-2.5"})," ",l," ",o,l!==1?"s":""]},o)})})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-lg font-bold",children:n.recentActivities}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"activities"})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-lg font-bold",children:n.prospectsCreated}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"prospects"})]})]},n.id))})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Recent Activity"})}),e.jsx(De,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=Nze[n.activity_type]||Sn;return e.jsxs("div",{className:"flex items-start gap-3 text-sm",children:[e.jsx("div",{className:"h-7 w-7 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(a,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium",children:n.title}),n.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:ms(new Date(n.created_at),"MMM d, h:mm a")})]})]},n.id)})})]})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No recruiter activity yet."})}function $lt({brokerageId:t}){const{toast:s}=Ua(),r=Qt(),[n,a]=N.useState(!1),[o,l]=N.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),{data:i=[],isLoading:c}=mt({queryKey:["recruit-referrals",t],queryFn:async()=>{const{data:w,error:k}=await H.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(k)throw k;return w}}),u=[...new Set(i.map(w=>w.referred_by))],{data:p=[]}=mt({queryKey:["referral-profiles",u],queryFn:async()=>{if(!u.length)return[];const{data:w}=await H.from("profiles").select("id, name, email").in("id",u);return w||[]},enabled:u.length>0}),f=Object.fromEntries(p.map(w=>[w.id,w])),g=Dt({mutationFn:async w=>{const{data:{user:k}}=await H.auth.getUser();if(!k)throw new Error("Not authenticated");const{error:S}=await H.from("recruit_referrals").insert({brokerage_id:t,referred_by:k.id,referee_first_name: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(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-referrals",t]}),s({title:"Referral submitted!"}),l({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),a(!1)},onError:w=>s({title:"Error",description:w.message,variant:"destructive"})}),b=Dt({mutationFn:async({id:w,status:k,incentive_status:S})=>{const M={updated_at:new Date().toISOString()};k&&(M.status=k),S&&(M.incentive_status=S);const{error:L}=await H.from("recruit_referrals").update(M).eq("id",w);if(L)throw L},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-referrals",t]})}),_=w=>w==="approved"||w==="signed"?e.jsx(va,{className:"h-3 w-3"}):w==="rejected"?e.jsx(vc,{className:"h-3 w-3"}):e.jsx(un,{className:"h-3 w-3"}),j=w=>w==="approved"||w==="signed"||w==="paid"?"bg-green-500/10 text-green-600 border-green-200":w==="rejected"?"bg-red-500/10 text-red-600 border-red-200":"bg-amber-500/10 text-amber-600 border-amber-200";return c?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," referral",i.length!==1?"s":""]}),e.jsxs(K,{onClick:()=>a(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"})," Submit Referral"]})]}),i.length===0?e.jsxs(Ee,{className:"py-12 text-center",children:[e.jsx(Tl,{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 k;return e.jsx(Ee,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-medium",children:[w.referee_first_name," ",w.referee_last_name]}),e.jsxs(tt,{variant:"outline",className:j(w.status),children:[_(w.status)," ",w.status]}),w.incentive_status&&e.jsxs(tt,{variant:"outline",className:j(w.incentive_status),children:[e.jsx(ko,{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: ",((k=f[w.referred_by])==null?void 0:k.name)||"Unknown"," • ",ms(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(Zs,{value:w.status,onValueChange:S=>b.mutate({id:w.id,status:S}),children:[e.jsx(Ws,{className:"h-7 text-xs w-[110px]",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"pending",children:"Pending"}),e.jsx(Mt,{value:"contacted",children:"Contacted"}),e.jsx(Mt,{value:"approved",children:"Approved"}),e.jsx(Mt,{value:"signed",children:"Signed"}),e.jsx(Mt,{value:"rejected",children:"Rejected"})]})]}),e.jsxs(Zs,{value:w.incentive_status||"pending",onValueChange:S=>b.mutate({id:w.id,incentive_status:S}),children:[e.jsx(Ws,{className:"h-7 text-xs w-[100px]",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"pending",children:"Unpaid"}),e.jsx(Mt,{value:"paid",children:"Paid"}),e.jsx(Mt,{value:"n/a",children:"N/A"})]})]})]})]})},w.id)})}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Submit a Recruit Referral"})}),e.jsxs("form",{onSubmit:w=>{w.preventDefault(),g.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"First Name *"}),e.jsx(ze,{required:!0,value:o.first_name,onChange:w=>l(k=>({...k,first_name:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Last Name"}),e.jsx(ze,{value:o.last_name,onChange:w=>l(k=>({...k,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(ze,{type:"email",value:o.email,onChange:w=>l(k=>({...k,email:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Phone"}),e.jsx(ze,{value:o.phone,onChange:w=>l(k=>({...k,phone:w.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Current Brokerage"}),e.jsx(ze,{value:o.current_brokerage,onChange:w=>l(k=>({...k,current_brokerage:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Notes"}),e.jsx(Er,{value:o.notes,onChange:w=>l(k=>({...k,notes:w.target.value})),rows:2})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:g.isPending,children:"Submit"})]})]})]})})]})}function qlt({brokerageId:t}){const{toast:s}=Ua(),r=Qt(),[n,a]=N.useState(!1),{data:o}=mt({queryKey:["brokerage-recruit-form",t],queryFn:async()=>{const{data:g,error:b}=await H.from("brokerages").select("id, name, recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(b)throw b;return g}}),{data:l=[]}=mt({queryKey:["recruit-interest-submissions",t],queryFn:async()=>{const{data:g,error:b}=await H.from("recruit_interest_submissions").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(b)throw b;return g}}),i=Dt({mutationFn:async g=>{const{error:b}=await H.from("brokerages").update({recruit_form_enabled:g}).eq("id",t);if(b)throw b},onSuccess:()=>{r.invalidateQueries({queryKey:["brokerage-recruit-form",t]}),s({title:o!=null&&o.recruit_form_enabled?"Form disabled":"Form enabled"})}}),c=Dt({mutationFn:async({id:g,status:b})=>{const{error:_}=await H.from("recruit_interest_submissions").update({status:b}).eq("id",g);if(_)throw _},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-interest-submissions",t]})}),u=`https://bestbrokerage.relevelup.com/join-brokerage/${(o==null?void 0:o.recruit_form_slug)||""}`,p=()=>{navigator.clipboard.writeText(u),a(!0),s({title:"Link copied!"}),setTimeout(()=>a(!1),2e3)},f=g=>g==="contacted"||g==="converted"?"bg-green-500/10 text-green-600":g==="dismissed"?"bg-red-500/10 text-red-600":"bg-blue-500/10 text-blue-600";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Public Interest Form"})}),e.jsxs(De,{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(qr,{checked:(o==null?void 0:o.recruit_form_enabled)||!1,onCheckedChange:g=>i.mutate(g)})]}),(o==null?void 0:o.recruit_form_enabled)&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg",children:[e.jsx("code",{className:"text-xs flex-1 truncate",children:u}),e.jsx(K,{size:"sm",variant:"outline",onClick:p,children:n?e.jsx(va,{className:"h-3.5 w-3.5"}):e.jsx(gi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:e.jsx(tn,{className:"h-3.5 w-3.5"})})})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-base",children:["Interest Submissions (",l.length,")"]})}),e.jsx(De,{children:l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Tl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No submissions yet"})]}):e.jsx("div",{className:"space-y-3",children:l.map(g=>e.jsxs("div",{className:"flex items-start justify-between gap-4 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-medium text-sm",children:[g.first_name," ",g.last_name]}),e.jsx(tt,{variant:"outline",className:f(g.status),children:g.status})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-muted-foreground",children:[g.email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(cr,{className:"h-3 w-3"}),g.email]}),g.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Un,{className:"h-3 w-3"}),g.phone]}),g.current_brokerage&&e.jsxs("span",{children:["From: ",g.current_brokerage]}),g.experience_years&&e.jsxs("span",{children:[g.experience_years,"yr exp"]})]}),g.why_interested&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 italic",children:['"',g.why_interested,'"']}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:ms(new Date(g.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(Zs,{value:g.status,onValueChange:b=>c.mutate({id:g.id,status:b}),children:[e.jsx(Ws,{className:"h-7 text-xs w-[110px]",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"new",children:"New"}),e.jsx(Mt,{value:"contacted",children:"Contacted"}),e.jsx(Mt,{value:"converted",children:"Converted"}),e.jsx(Mt,{value:"dismissed",children:"Dismissed"})]})]})]},g.id))})})]})]})}function Ult({brokerageId:t}){const{toast:s}=Ua(),r=Qt(),[n,a]=N.useState(!1),[o,l]=N.useState({prospect_id:"",title:"",description:"",due_date:ms(El(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,c]=N.useState("pending"),{data:u=[]}=mt({queryKey:["recruit-prospects-list",t],queryFn:async()=>{const{data:I,error:O}=await H.from("recruit_prospects").select("id, first_name, last_name").eq("brokerage_id",t).order("first_name");if(O)throw O;return I}}),{data:p=[],isLoading:f}=mt({queryKey:["recruit-follow-ups",t],queryFn:async()=>{const I=u.map(U=>U.id);if(!I.length)return[];const{data:O,error:q}=await H.from("recruit_follow_ups").select("*").in("prospect_id",I).order("due_date");if(q)throw q;return O},enabled:u.length>0}),g=Object.fromEntries(u.map(I=>[I.id,I])),b=Dt({mutationFn:async I=>{const{data:{user:O}}=await H.auth.getUser();if(!O)throw new Error("Not authenticated");const{error:q}=await H.from("recruit_follow_ups").insert({prospect_id:I.prospect_id,assigned_to:O.id,title:I.title,description:I.description||null,due_date:new Date(I.due_date).toISOString()});if(q)throw q},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-follow-ups",t]}),s({title:"Follow-up scheduled"}),l({prospect_id:"",title:"",description:"",due_date:ms(El(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:I=>s({title:"Error",description:I.message,variant:"destructive"})}),_=Dt({mutationFn:async({id:I,completed:O})=>{const{error:q}=await H.from("recruit_follow_ups").update({completed_at:O?new Date().toISOString():null}).eq("id",I);if(q)throw q},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-follow-ups",t]})}),j=p.filter(I=>i==="pending"?!I.completed_at:i==="completed"?!!I.completed_at:!0),w=j.filter(I=>!I.completed_at&&b0(new Date(I.due_date))&&!bu(new Date(I.due_date))),k=j.filter(I=>!I.completed_at&&bu(new Date(I.due_date))),S=j.filter(I=>!I.completed_at&&!b0(new Date(I.due_date))&&!bu(new Date(I.due_date))),M=j.filter(I=>!!I.completed_at),L=I=>{const O=g[I.prospect_id],q=!I.completed_at&&b0(new Date(I.due_date))&&!bu(new Date(I.due_date));return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Oo,{checked:!!I.completed_at,onCheckedChange:U=>_.mutate({id:I.id,completed:U}),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-sm font-medium ${I.completed_at?"line-through text-muted-foreground":""}`,children:I.title}),I.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:I.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground",children:[O&&e.jsxs(tt,{variant:"secondary",className:"text-[10px]",children:[O.first_name," ",O.last_name]}),e.jsxs("span",{className:`flex items-center gap-1 ${q?"text-destructive font-medium":""}`,children:[q?e.jsx(kl,{className:"h-3 w-3"}):e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(I.due_date),"MMM d, h:mm a")]}),I.is_automated&&e.jsx(tt,{variant:"outline",className:"text-[10px]",children:"Auto"})]})]})]},I.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(I=>e.jsxs(K,{size:"sm",variant:i===I?"default":"outline",onClick:()=>c(I),className:"capitalize text-xs",children:[I," ",I==="pending"&&w.length+k.length+S.length>0&&`(${w.length+k.length+S.length})`]},I))}),e.jsxs(K,{size:"sm",onClick:()=>a(!0),children:[e.jsx($s,{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(kl,{className:"h-3.5 w-3.5"})," Overdue (",w.length,")"]}),w.map(L)]}),i!=="completed"&&k.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-600 flex items-center gap-1",children:[e.jsx(un,{className:"h-3.5 w-3.5"})," Today (",k.length,")"]}),k.map(L)]}),i!=="completed"&&S.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(hn,{className:"h-3.5 w-3.5"})," Upcoming (",S.length,")"]}),S.map(L)]}),i!=="pending"&&M.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(va,{className:"h-3.5 w-3.5"})," Completed (",M.length,")"]}),M.map(L)]}),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(fs,{open:n,onOpenChange:a,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Schedule Follow-up"})}),e.jsxs("form",{onSubmit:I=>{I.preventDefault(),b.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:I=>l(O=>({...O,prospect_id:I.target.value})),children:[e.jsx("option",{value:"",children:"Select prospect..."}),u.map(I=>e.jsxs("option",{value:I.id,children:[I.first_name," ",I.last_name]},I.id))]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Task *"}),e.jsx(ze,{required:!0,value:o.title,onChange:I=>l(O=>({...O,title:I.target.value})),placeholder:"e.g. Follow-up call"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Details"}),e.jsx(Er,{value:o.description,onChange:I=>l(O=>({...O,description:I.target.value})),rows:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Due Date *"}),e.jsx(ze,{type:"datetime-local",required:!0,value:o.due_date,onChange:I=>l(O=>({...O,due_date:I.target.value}))})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:b.isPending,children:"Schedule"})]})]})]})})]})}const R4s=[{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 Vlt({brokerageId:t}){const{toast:s}=Ua(),r=Qt(),[n,a]=N.useState(null),{data:o,isLoading:l}=mt({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:w,error:k}=await H.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(k)throw k;return w}}),[i,c]=N.useState({brokerage_id:t,hero_headline:"Join Our Team",hero_subtext:"Take your real estate career to the next level.",hero_image_url:null,logo_url:null,primary_color:"#406E71",accent_color:"#2a4c64",benefits:R4s,testimonials:[],gallery_images:[]});N.useEffect(()=>{o&&c({id:o.id,brokerage_id:o.brokerage_id,hero_headline:o.hero_headline,hero_subtext:o.hero_subtext||"",hero_image_url:o.hero_image_url,logo_url:o.logo_url,primary_color:o.primary_color,accent_color:o.accent_color,benefits:o.benefits||[],testimonials:o.testimonials||[],gallery_images:o.gallery_images||[]})},[o]);const u=Dt({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:k}=await H.from("recruit_landing_page_settings").update(w).eq("id",i.id);if(k)throw k}else{const{error:k}=await H.from("recruit_landing_page_settings").insert(w);if(k)throw k}},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,k)=>{const S=w.name.split(".").pop(),M=`${t}/${k}-${Date.now()}.${S}`,{error:L}=await H.storage.from("recruit-landing").upload(M,w);if(L)throw L;const{data:{publicUrl:I}}=H.storage.from("recruit-landing").getPublicUrl(M);return I},f=async(w,k)=>{var M;const S=(M=w.target.files)==null?void 0:M[0];if(S){a(k);try{const L=await p(S,k);c(I=>({...I,[k]:L})),s({title:"Image uploaded!"})}catch(L){s({title:"Upload failed",description:L.message,variant:"destructive"})}finally{a(null)}}},g=async w=>{var S;const k=(S=w.target.files)==null?void 0:S[0];if(k){a("gallery");try{const M=await p(k,"gallery");c(L=>({...L,gallery_images:[...L.gallery_images,M]})),s({title:"Gallery image added!"})}catch(M){s({title:"Upload failed",description:M.message,variant:"destructive"})}finally{a(null)}}},b=async(w,k)=>{var M;const S=(M=w.target.files)==null?void 0:M[0];if(S){a(`testimonial-${k}`);try{const L=await p(S,`testimonial-${k}`);c(I=>{const O=[...I.testimonials];return O[k]={...O[k],photo_url:L},{...I,testimonials:O}})}catch(L){s({title:"Upload failed",description:L.message,variant:"destructive"})}finally{a(null)}}},{data:_}=mt({queryKey:["brokerage-slug-for-landing",t],queryFn:async()=>{const{data:w,error:k}=await H.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(k)throw k;return w}}),j=`https://bestbrokerage.relevelup.com/join-brokerage/${(_==null?void 0:_.recruit_form_slug)||""}`;return l?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[(_==null?void 0:_.recruit_form_enabled)&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Live page:"}),e.jsx("code",{className:"text-xs flex-1 truncate",children:j}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:j,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Branding"})}),e.jsx(De,{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(li,{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=>c(k=>({...k,primary_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:i.primary_color,onChange:w=>c(k=>({...k,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=>c(k=>({...k,accent_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:i.accent_color,onChange:w=>c(k=>({...k,accent_color:w.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Hero Section"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Headline"}),e.jsx(ze,{value:i.hero_headline,onChange:w=>c(k=>({...k,hero_headline:w.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Subtext"}),e.jsx(Er,{value:i.hero_subtext,onChange:w=>c(k=>({...k,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(li,{className:"h-3.5 w-3.5 mr-1"}),n==="hero_image_url"?"Uploading...":"Upload Image"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:w=>f(w,"hero_image_url")})]}),i.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(w=>({...w,hero_image_url:null})),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>c(w=>({...w,benefits:[...w.benefits,{title:"",description:"",icon:"✨"}]})),children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(De,{className:"space-y-3",children:[i.benefits.map((w,k)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Cu,{className:"h-4 w-4 mt-2 text-muted-foreground"}),e.jsx(ze,{value:w.icon,onChange:S=>{const M=[...i.benefits];M[k]={...w,icon:S.target.value},c(L=>({...L,benefits:M}))},className:"w-14 text-center"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ze,{value:w.title,onChange:S=>{const M=[...i.benefits];M[k]={...w,title:S.target.value},c(L=>({...L,benefits:M}))},placeholder:"Benefit title"}),e.jsx(ze,{value:w.description,onChange:S=>{const M=[...i.benefits];M[k]={...w,description:S.target.value},c(L=>({...L,benefits:M}))},placeholder:"Short description"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(S=>({...S,benefits:S.benefits.filter((M,L)=>L!==k)})),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]},k)),i.benefits.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No benefits added yet"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{className:"text-base",children:"Testimonials"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>c(w=>({...w,testimonials:[...w.testimonials,{name:"",role:"",quote:""}]})),children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(De,{className:"space-y-3",children:[i.testimonials.map((w,k)=>{var S;return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[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:((S=w.name)==null?void 0:S[0])||"?"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("span",{className:"text-[10px] text-primary hover:underline",children:n===`testimonial-${k}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:M=>b(M,k)})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(ze,{value:w.name,onChange:M=>{const L=[...i.testimonials];L[k]={...w,name:M.target.value},c(I=>({...I,testimonials:L}))},placeholder:"Name"}),e.jsx(ze,{value:w.role,onChange:M=>{const L=[...i.testimonials];L[k]={...w,role:M.target.value},c(I=>({...I,testimonials:L}))},placeholder:"Role / Title"})]}),e.jsx(Er,{value:w.quote,onChange:M=>{const L=[...i.testimonials];L[k]={...w,quote:M.target.value},c(I=>({...I,testimonials:L}))},placeholder:"What they say about working here...",rows:2})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(M=>({...M,testimonials:M.testimonials.filter((L,I)=>I!==k)})),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]},k)}),i.testimonials.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No testimonials added yet"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{className:"text-base",children:"Team & Culture Gallery"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{size:"sm",variant:"outline",asChild:!0,disabled:n==="gallery",children:e.jsxs("span",{children:[e.jsx(gl,{className:"h-3.5 w-3.5 mr-1"}),n==="gallery"?"Uploading...":"Add Photo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:g})]})]}),e.jsx(De,{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,k)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:w,alt:`Gallery ${k+1}`,className:"h-24 w-full object-cover rounded-lg"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>c(S=>({...S,gallery_images:S.gallery_images.filter((M,L)=>L!==k)})),children:e.jsx(Nr,{className:"h-3 w-3"})})]},k))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No gallery images added yet"})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:()=>u.mutate(),disabled:u.isPending,size:"lg",children:[e.jsx(qc,{className:"h-4 w-4 mr-2"}),u.isPending?"Saving...":"Save Landing Page"]})})]})}function F4s(t){if(!t)return"—";const s=Math.floor(t/60),r=t%60;return s>0?`${s}m ${r}s`:`${r}s`}function z4s({video:t}){return t.cta_clicked_at?e.jsx(tt,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-200",children:"CTA Clicked"}):t.view_count>0?e.jsxs(tt,{className:"bg-blue-500/10 text-blue-600 border-blue-200",children:[e.jsx(On,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(tt,{variant:"secondary",children:[e.jsx(Bn,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(tt,{variant:"outline",children:[e.jsx(un,{className:"h-3 w-3 mr-1"}),"Draft"]})}function Hlt({brokerageId:t}){const{data:s=[],isLoading:r}=T4s(t),{data:n=[]}=Llt(t),a=P4s(),o=I4s(),l=Ilt(),[i,c]=N.useState(""),[u,p]=N.useState(!1),[f,g]=N.useState({title:"",script_text:"",category:"general"}),b=s.filter(S=>{var L,I,O,q;return i?`${((L=S.prospect)==null?void 0:L.first_name)||""} ${((I=S.prospect)==null?void 0:I.last_name)||""}`.toLowerCase().includes(i.toLowerCase())||((q=(O=S.video)==null?void 0:O.title)==null?void 0:q.toLowerCase().includes(i.toLowerCase())):!0}),_={total:s.length,sent:s.filter(S=>S.sent_at).length,viewed:s.filter(S=>S.view_count>0).length,ctaClicked:s.filter(S=>S.cta_clicked_at).length},j=N.useCallback(S=>{if(!S)return;const M=`${window.location.origin}/recruit-video/${S}`;navigator.clipboard.writeText(M),me.success("Share link copied")},[]),w=N.useCallback((S,M)=>{l.mutate({id:S,sent_via:M})},[l]),k=()=>{!f.title.trim()||!f.script_text.trim()||a.mutate({brokerage_id:t,...f},{onSuccess:()=>{g({title:"",script_text:"",category:"general"}),p(!1)}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{label:"Total Videos",value:_.total,icon:An,color:"text-primary"},{label:"Sent",value:_.sent,icon:Bn,color:"text-blue-500"},{label:"Viewed",value:_.viewed,icon:On,color:"text-amber-500"},{label:"CTA Clicked",value:_.ctaClicked,icon:sa,color:"text-emerald-500"}].map(S=>e.jsx(Ee,{children:e.jsxs(De,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:`h-10 w-10 rounded-lg bg-muted flex items-center justify-center ${S.color}`,children:e.jsx(S.icon,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:S.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.label})]})]})},S.label))}),e.jsxs(ba,{defaultValue:"videos",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"videos",children:[e.jsx(An,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(ns,{value:"scripts",children:[e.jsx(Sn,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(ns,{value:"analytics",children:[e.jsx(No,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx(bs,{value:"videos",children:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Rt,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or title...",value:i,onChange:S=>c(S.target.value),className:"pl-9"})]})]})}),e.jsx(De,{children:r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):b.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(An,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No video outreach yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Record a personalized video from any prospect's profile card"})]}):e.jsx("div",{className:"space-y-3",children:b.map(S=>{var M,L,I,O,q,U;return e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg border bg-card hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"relative h-16 w-28 rounded-md overflow-hidden bg-muted flex-shrink-0",children:[(M=S.video)!=null&&M.thumbnail_url?e.jsx("img",{src:S.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(An,{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:F4s(((L=S.video)==null?void 0:L.duration_seconds)??null)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"font-medium truncate",children:[(I=S.prospect)==null?void 0:I.first_name," ",(O=S.prospect)==null?void 0:O.last_name]}),e.jsx(z4s,{video:S})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:((q=S.video)==null?void 0:q.title)||"Untitled video"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ms(new Date(S.created_at),"MMM d, yyyy"),((U=S.prospect)==null?void 0:U.current_brokerage)&&` · ${S.prospect.current_brokerage}`]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>j(S.share_token),title:"Copy share link",children:e.jsx(gi,{className:"h-4 w-4"})}),!S.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(S.id,"email"),title:"Mark as sent",children:e.jsx(Bn,{className:"h-4 w-4"})}),S.share_token&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>window.open(`/recruit-video/${S.share_token}`,"_blank"),title:"Preview landing page",children:e.jsx(tn,{className:"h-4 w-4"})})]})]},S.id)})})})]})}),e.jsx(bs,{value:"scripts",children:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Rt,{className:"text-lg",children:"Recruiting Scripts"}),e.jsxs(fs,{open:u,onOpenChange:p,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx($s,{className:"h-4 w-4 mr-1.5"}),"New Script"]})}),e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{value:f.title,onChange:S=>g(M=>({...M,title:S.target.value})),placeholder:"e.g., Why Switch to Our Brokerage"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Category"}),e.jsxs(Zs,{value:f.category,onValueChange:S=>g(M=>({...M,category:S})),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:dwe.map(S=>e.jsx(Mt,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Script"}),e.jsx(Er,{value:f.script_text,onChange:S=>g(M=>({...M,script_text:S.target.value})),placeholder:"Hi [Name], I noticed you've been doing great work at [Brokerage]...",rows:8})]}),e.jsx(K,{onClick:k,disabled:!f.title.trim()||!f.script_text.trim(),className:"w-full",children:"Save Script"})]})]})]})]})}),e.jsx(De,{children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Sn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No scripts yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Create teleprompter scripts for common recruiting conversations"})]}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.map(S=>{var L;const M=((L=dwe.find(I=>I.value===S.category))==null?void 0:L.label)||S.category;return e.jsx(Ee,{className:"relative group",children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(tt,{variant:"outline",className:"text-[10px] mb-2",children:M}),e.jsx("h4",{className:"font-medium text-sm",children:S.title})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity text-destructive",onClick:()=>o.mutate(S.id),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-3",children:S.script_text}),S.is_global&&e.jsx(tt,{variant:"secondary",className:"mt-2 text-[10px]",children:"Template"})]})},S.id)})})})]})}),e.jsx(bs,{value:"analytics",children:e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Engagement Funnel"})}),e.jsxs(De,{children:[e.jsx("div",{className:"space-y-4",children:[{label:"Videos Created",count:_.total,pct:100,color:"bg-primary"},{label:"Sent to Prospects",count:_.sent,pct:_.total?Math.round(_.sent/_.total*100):0,color:"bg-blue-500"},{label:"Viewed by Prospect",count:_.viewed,pct:_.sent?Math.round(_.viewed/_.sent*100):0,color:"bg-amber-500"},{label:"CTA Clicked",count:_.ctaClicked,pct:_.viewed?Math.round(_.ctaClicked/_.viewed*100):0,color:"bg-emerald-500"}].map(S=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:S.label}),e.jsxs("span",{className:"font-medium",children:[S.count," (",S.pct,"%)"]})]}),e.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${S.color} rounded-full transition-all`,style:{width:`${S.pct}%`}})})]},S.label))}),s.filter(S=>S.view_count>0).length>0&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"Most Engaged Prospects"}),e.jsx("div",{className:"space-y-2",children:s.filter(S=>S.view_count>0).sort((S,M)=>M.view_count-S.view_count).slice(0,5).map(S=>{var M,L;return e.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded-md bg-muted/30",children:[e.jsxs("span",{className:"font-medium",children:[(M=S.prospect)==null?void 0:M.first_name," ",(L=S.prospect)==null?void 0:L.last_name]}),e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(On,{className:"h-3.5 w-3.5"})," ",S.view_count]}),S.cta_clicked_at&&e.jsx(sa,{className:"h-4 w-4 text-emerald-500"})]})]},S.id)})})]})]})]})})]})]})}function Wlt({brokerageId:t}){const{toast:s}=Ua(),r=Qt(),{stages:n,prospects:a}=yme(t),[o,l]=N.useState(!1),[i,c]=N.useState({title:"",target_count:"10",target_stage_id:"",period_start:ms(new Date,"yyyy-MM-dd"),period_end:ms(new Date(new Date().getFullYear(),new Date().getMonth()+3,0),"yyyy-MM-dd")}),{data:u=[],isLoading:p}=mt({queryKey:["recruit-goals",t],queryFn:async()=>{const{data:_,error:j}=await H.from("recruit_goals").select("*").eq("brokerage_id",t).order("period_end",{ascending:!1});if(j)throw j;return _}}),f=Dt({mutationFn:async _=>{const{data:{user:j}}=await H.auth.getUser();if(!j)throw new Error("Not authenticated");const{error:w}=await H.from("recruit_goals").insert({brokerage_id:t,title:_.title,target_count:parseInt(_.target_count),target_stage_id:_.target_stage_id||null,period_start:_.period_start,period_end:_.period_end,created_by:j.id});if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal created"}),l(!1)},onError:_=>s({title:"Error",description:_.message,variant:"destructive"})}),g=Dt({mutationFn:async _=>{const{error:j}=await H.from("recruit_goals").delete().eq("id",_);if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal removed"})}}),b=_=>{const j=n.find(k=>k.id===_.target_stage_id);return{count:a.filter(k=>Rg(new Date(k.created_at),{start:new Date(_.period_start),end:new Date(_.period_end)})?_.target_stage_id?k.stage_id===_.target_stage_id:!0:!1).length,stage: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($s,{className:"h-4 w-4 mr-1"})," New Goal"]})]}),u.length===0?e.jsxs(Ee,{className:"py-12 text-center",children:[e.jsx(zm,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No goals set. Create a recruiting target to track progress."})]}):e.jsx("div",{className:"grid md:grid-cols-2 gap-4",children:u.map(_=>{const{count:j,stage:w}=b(_),k=Math.min(100,j/_.target_count*100),S=Rg(new Date,{start:new Date(_.period_start),end:new Date(_.period_end)});return e.jsxs(Ee,{className:S?"":"opacity-60",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{className:"text-sm",children:_.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ms(new Date(_.period_start),"MMM d")," – ",ms(new Date(_.period_end),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[S?e.jsx(tt,{className:"text-[10px]",children:"Active"}):e.jsx(tt,{variant:"secondary",className:"text-[10px]",children:"Ended"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground",onClick:()=>g.mutate(_.id),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(De,{className:"space-y-2",children:[w&&e.jsxs(tt,{variant:"outline",className:"text-[10px]",style:{borderColor:w.color,color:w.color},children:["Stage: ",w.name]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-bold text-lg",children:j}),e.jsxs("span",{className:"text-muted-foreground",children:["/ ",_.target_count]})]}),e.jsx(Bi,{value:k,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[k.toFixed(0),"% complete"]})]})]},_.id)})}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Create Recruiting Goal"})}),e.jsxs("form",{onSubmit:_=>{_.preventDefault(),f.mutate(i)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Goal Title *"}),e.jsx(ze,{required:!0,value:i.title,onChange:_=>c(j=>({...j,title:_.target.value})),placeholder:"e.g. Q2 Recruiting Target"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Target Count *"}),e.jsx(ze,{type:"number",min:"1",required:!0,value:i.target_count,onChange:_=>c(j=>({...j,target_count:_.target.value}))})]}),e.jsxs("div",{children:[e.jsx(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:_=>c(j=>({...j,target_stage_id:_.target.value})),children:[e.jsx("option",{value:"",children:"All stages (total prospects)"}),n.map(_=>e.jsx("option",{value:_.id,children:_.name},_.id))]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Count prospects that reach this stage"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Start Date"}),e.jsx(ze,{type:"date",required:!0,value:i.period_start,onChange:_=>c(j=>({...j,period_start:_.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"End Date"}),e.jsx(ze,{type:"date",required:!0,value:i.period_end,onChange:_=>c(j=>({...j,period_end:_.target.value}))})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:f.isPending,children:"Create Goal"})]})]})]})})]})}const B4s={first_name:"Sarah",brokerage_name:"ABC Realty",city:"Austin",sender_name:"Jeremy"};function $4s({email:t,mergeValues:s=B4s,onClose:r}){var a,o;const n=l=>l.replace(/\{\{first_name\}\}/g,s.first_name).replace(/\{\{brokerage_name\}\}/g,s.brokerage_name).replace(/\{\{city\}\}/g,s.city).replace(/\{\{sender_name\}\}/g,s.sender_name).replace(/\{\{landing_page_link\}\}/g,"https://bestbrokerage.relevelup.com/join-brokerage/your-slug");return e.jsx(fs,{open:!0,onOpenChange:()=>r(),children:e.jsxs(ps,{className:"max-w-2xl max-h-[85vh] overflow-y-auto p-0",children:[e.jsxs(_s,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(vs,{className:"text-base",children:["Email #",t.email_number," — ",t.title]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsxs(tt,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),t.email_number===1?"Sent immediately":`Day ${t.delay_days}`]}),((a=t.subject_line_options)==null?void 0:a.length)>1&&e.jsxs(tt,{variant:"secondary",className:"text-xs",children:[t.subject_line_options.length," subject variants"]})]})]}),e.jsxs("div",{className:"space-y-0",children:[((o=t.subject_line_options)==null?void 0:o.length)>0&&e.jsxs("div",{className:"px-6 py-3 border-b bg-muted/20",children:[e.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-2",children:"Subject Line Options"}),e.jsx("div",{className:"flex flex-col gap-1.5",children:t.subject_line_options.map((l,i)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-[10px] font-bold uppercase px-1.5 py-0.5 rounded ${i===0?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"}`,children:i===0?"Primary":`Alt ${i}`}),e.jsx("span",{className:"text-sm",children:n(l)})]},i))})]}),e.jsxs("div",{className:"border-b",children:[e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium w-14",children:"From:"}),e.jsx("span",{children:"Jeremy "})]}),e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs text-muted-foreground border-t",children:[e.jsx("span",{className:"font-medium w-14",children:"To:"}),e.jsx("span",{children:"Sarah "})]}),e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs border-t",children:[e.jsx("span",{className:"font-medium w-14 text-muted-foreground",children:"Subject:"}),e.jsx("span",{className:"font-medium",children:n(t.subject_line)})]})]}),e.jsx("div",{className:"bg-white px-8 py-6",children:e.jsx("div",{className:"prose prose-sm max-w-none [&_p]:my-3 [&_p+p]:mt-4 [&_br]:block [&_br]:mt-2",style:{fontSize:"15px",lineHeight:"1.75",color:"#1a1a1a"},dangerouslySetInnerHTML:{__html:n(t.body_html)}})})]})]})})}function hCe({brokerageId:t}){const s=Qt(),[r,n]=N.useState({brokerage_id:t,sender_name:"LevelUp",sender_email:"recruiting@relevelup.com",reply_to_email:"",merge_fields:{city:"",broker_name:""}}),{data:a}=mt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:c,error:u}=await H.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(u)throw u;return c}}),{data:o}=mt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:c,error:u}=await H.from("brokerages").select("name, city, state").eq("id",t).single();if(u)throw u;return c}});N.useEffect(()=>{a?n({...a,merge_fields:a.merge_fields||{city:"",broker_name:""}}):o&&n(c=>({...c,merge_fields:{...c.merge_fields,brokerage_name:o.name,city:o.city||""}}))},[a,o]);const l=Dt({mutationFn:async()=>{const c={brokerage_id:t,sender_name:r.sender_name,sender_email:r.sender_email,reply_to_email:r.reply_to_email||null,merge_fields:r.merge_fields,updated_at:new Date().toISOString()};if(a!=null&&a.id){const{error:u}=await H.from("brokerage_recruit_settings").update(c).eq("id",a.id);if(u)throw u}else{const{error:u}=await H.from("brokerage_recruit_settings").insert(c);if(u)throw u}},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-recruit-settings",t]}),me.success("Recruiting email settings saved!")},onError:c=>me.error(c.message)}),i=(c,u)=>{n(p=>({...p,merge_fields:{...p.merge_fields,[c]:u}}))};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure the sender identity and merge fields for recruiting emails sent to this brokerage's prospects."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"Sender Display Name"}),e.jsx(ze,{value:r.sender_name,onChange:c=>n({...r,sender_name:c.target.value}),placeholder:"e.g. Jeremy at LevelUp"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"Sender Email Address"}),e.jsx(ze,{value:r.sender_email,onChange:c=>n({...r,sender_email:c.target.value}),placeholder:"recruiting@relevelup.com"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Must be a verified SES identity"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"Reply-To Email (optional)"}),e.jsx(ze,{value:r.reply_to_email,onChange:c=>n({...r,reply_to_email:c.target.value}),placeholder:"jeremy@relevelup.com"})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium mb-3",children:"Default Merge Fields"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"These values will auto-fill in campaign emails for this brokerage."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"{{brokerage_name}}"}),e.jsx(ze,{value:r.merge_fields.brokerage_name||"",onChange:c=>i("brokerage_name",c.target.value),placeholder:(o==null?void 0:o.name)||"Brokerage Name"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"{{city}}"}),e.jsx(ze,{value:r.merge_fields.city||"",onChange:c=>i("city",c.target.value),placeholder:"e.g. Austin"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"{{sender_name}}"}),e.jsx(ze,{value:r.merge_fields.sender_name||"",onChange:c=>i("sender_name",c.target.value),placeholder:"e.g. Jeremy"})]})]})]}),e.jsxs(K,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",children:[e.jsx(qc,{className:"h-4 w-4 mr-1"})," Save Settings"]})]})}const q4s=ly.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Hc(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),kze=[{key:"first_name",label:"First Name",preview:"Sarah"},{key:"brokerage_name",label:"Brokerage Name",preview:"ABC Realty"},{key:"city",label:"City",preview:"Austin"},{key:"sender_name",label:"Sender Name",preview:"Jeremy"},{key:"landing_page_link",label:"Landing Page URL",preview:"https://bestbrokerage.relevelup.com/join-brokerage/your-slug"}];function fh({onClick:t,active:s,disabled:r,icon:n,tooltip:a}){return e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:r,className:`h-8 w-8 p-0 ${s?"bg-accent text-accent-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(n,{className:"h-4 w-4"})})}),e.jsx(Yl,{side:"bottom",className:"text-xs",children:a})]})}function U4s({content:t,onChange:s}){const r=nke({extensions:[ike.configure({heading:{levels:[1,2,3]}}),q4s,xke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}}),gke.configure({types:["heading","paragraph"]}),yke,jat],content:t,editorProps:{attributes:{class:"prose prose-sm max-w-none focus:outline-none min-h-[350px] px-5 py-4",style:"font-size: 15px; line-height: 1.75; color: #1a1a1a;"}},onUpdate:({editor:o})=>{s(o.getHTML())}});N.useEffect(()=>{r&&t!==r.getHTML()&&r.commands.setContent(t)},[t,r]);const n=N.useCallback(()=>{if(!r)return;const o=r.getAttributes("link").href,l=window.prompt("Enter URL",o);if(l!==null){if(l===""){r.chain().focus().extendMarkRange("link").unsetLink().run();return}r.chain().focus().extendMarkRange("link").setLink({href:l}).run()}},[r]),a=N.useCallback(o=>{r&&r.chain().focus().insertContent(`{{${o}}}`).run()},[r]);return r?e.jsx(z1,{delayDuration:300,children:e.jsxs("div",{className:"border rounded-xl overflow-hidden bg-background shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30",children:[e.jsx(fh,{onClick:()=>r.chain().focus().toggleBold().run(),active:r.isActive("bold"),icon:Z4,tooltip:"Bold"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleItalic().run(),active:r.isActive("italic"),icon:tS,tooltip:"Italic"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleUnderline().run(),active:r.isActive("underline"),icon:IL,tooltip:"Underline"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleStrike().run(),active:r.isActive("strike"),icon:ML,tooltip:"Strikethrough"}),e.jsx(rl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleHeading({level:1}).run(),active:r.isActive("heading",{level:1}),icon:AM,tooltip:"Heading 1"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleHeading({level:2}).run(),active:r.isActive("heading",{level:2}),icon:EM,tooltip:"Heading 2"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleHeading({level:3}).run(),active:r.isActive("heading",{level:3}),icon:lL,tooltip:"Heading 3"}),e.jsx(rl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleBulletList().run(),active:r.isActive("bulletList"),icon:Mh,tooltip:"Bullet List"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleOrderedList().run(),active:r.isActive("orderedList"),icon:m0,tooltip:"Numbered List"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleBlockquote().run(),active:r.isActive("blockquote"),icon:V_,tooltip:"Blockquote"}),e.jsx(fh,{onClick:()=>r.chain().focus().setHorizontalRule().run(),icon:p0,tooltip:"Divider"}),e.jsx(rl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(fh,{onClick:()=>r.chain().focus().setTextAlign("left").run(),active:r.isActive({textAlign:"left"}),icon:W4,tooltip:"Align Left"}),e.jsx(fh,{onClick:()=>r.chain().focus().setTextAlign("center").run(),active:r.isActive({textAlign:"center"}),icon:H4,tooltip:"Align Center"}),e.jsx(fh,{onClick:()=>r.chain().focus().setTextAlign("right").run(),active:r.isActive({textAlign:"right"}),icon:G4,tooltip:"Align Right"}),e.jsx(rl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(fh,{onClick:n,active:r.isActive("link"),icon:Bo,tooltip:"Insert Link"}),e.jsx(rl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(fh,{onClick:()=>r.chain().focus().undo().run(),disabled:!r.can().undo(),icon:fS,tooltip:"Undo"}),e.jsx(fh,{onClick:()=>r.chain().focus().redo().run(),disabled:!r.can().redo(),icon:hS,tooltip:"Redo"}),e.jsx("div",{className:"flex-1"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs font-medium",onClick:()=>{r&&r.chain().focus().insertContent('

Learn More About Us

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

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

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

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

",body_text:"",delay_days:Oe+7,is_active:!0});if(ke)throw ke},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email added to campaign!")},onError:Me=>me.error(Me.message)}),Q=Dt({mutationFn:async Me=>{const{error:Ne}=await H.from("recruit_campaigns").delete().eq("id",Me);if(Ne)throw Ne},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Campaign deleted")},onError:Me=>me.error(Me.message)}),ie=Dt({mutationFn:async Me=>{const{error:Ne}=await H.from("recruit_campaign_emails").delete().eq("id",Me);if(Ne)throw Ne},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email removed from campaign")},onError:Me=>me.error(Me.message)}),re=Dt({mutationFn:async({emailId:Me,delay_days:Ne})=>{const{error:Pe}=await H.from("recruit_campaign_emails").update({delay_days:Ne,updated_at:new Date().toISOString()}).eq("id",Me);if(Pe)throw Pe},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Send delay updated")},onError:Me=>me.error(Me.message)});if(U)return e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});const oe=q.filter(Me=>!Me.brokerage_id),ce=q.filter(Me=>Me.brokerage_id===t);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:"Recruiting Campaigns"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"System campaigns + custom campaigns · Each can have its own email settings"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-1.5",children:[e.jsx(Xo,{className:"h-4 w-4"})," Default Settings"]}),e.jsxs(K,{size:"sm",onClick:()=>g(!0),className:"gap-1.5",children:[e.jsx($s,{className:"h-4 w-4"})," New Campaign"]})]})]}),e.jsx(Ee,{className:"border-primary/20 bg-primary/5",children:e.jsx(De,{className:"py-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(pn,{className:"h-5 w-5 text-primary mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-semibold",children:"Per-Campaign Email Settings"}),e.jsxs("p",{className:"text-muted-foreground",children:["Each campaign can override the default sender name, email, and reply-to. Click the ",e.jsx(Xo,{className:"inline h-3.5 w-3.5"})," icon on any campaign to customize."]})]})]})})}),ce.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2",children:[e.jsx(dL,{className:"h-4 w-4"})," Your Custom Campaigns"]}),e.jsx("div",{className:"space-y-3",children:ce.map(Me=>xe(Me,!0))})]}),oe.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2",children:[e.jsx(pn,{className:"h-4 w-4"})," System Campaigns"]}),e.jsx("div",{className:"space-y-3",children:oe.map(Me=>xe(Me,!1))})]}),q.length===0&&e.jsx(Ee,{children:e.jsxs(De,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(cr,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No campaigns yet. Create your first campaign to start automated outreach."}),e.jsxs(K,{className:"mt-4",onClick:()=>g(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})}),i&&e.jsx($4s,{email:i,mergeValues:I,onClose:()=>c(null)}),e.jsx(fs,{open:!!o,onOpenChange:Me=>!Me&&l(null),children:e.jsxs(ps,{className:"max-w-4xl max-h-[90vh] overflow-y-auto p-0",children:[e.jsxs(_s,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(B_,{className:"h-5 w-5 text-primary"}),"Edit Email #",o==null?void 0:o.email_number]}),e.jsx(Gr,{children:o==null?void 0:o.title})]}),o&&e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Title"}),e.jsx(ze,{value:o.title,onChange:Me=>l({...o,title:Me.target.value}),className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Delay (days after previous)"}),e.jsx(ze,{type:"number",min:0,max:90,value:o.delay_days,onChange:Me=>l({...o,delay_days:parseInt(Me.target.value)||7}),className:"h-9"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Subject Line"}),e.jsx(ze,{value:o.subject_line,onChange:Me=>l({...o,subject_line:Me.target.value}),placeholder:"e.g. Hey {{first_name}}, quick question...",className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ve,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Alternative Subject Lines ",e.jsx("span",{className:"text-muted-foreground font-normal normal-case",children:"(one per line, for A/B testing)"})]}),e.jsx(Er,{value:((be=o.subject_line_options)==null?void 0:be.join(` `))||"",onChange:Me=>l({...o,subject_line_options:Me.target.value.split(` `).filter(Boolean)}),rows:2,className:"text-sm resize-none"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Body"}),e.jsx(ba,{value:b,onValueChange:Me=>_(Me),children:e.jsxs(pa,{className:"h-7",children:[e.jsx(ns,{value:"editor",className:"text-xs px-3 h-6",children:"Editor"}),e.jsx(ns,{value:"preview",className:"text-xs px-3 h-6",children:"Preview"})]})})]}),b==="editor"?e.jsx(U4s,{content:o.body_html,onChange:Me=>l({...o,body_html:Me})}):e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"bg-muted/50 px-4 py-2 border-b space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium w-12",children:"From:"}),e.jsxs("span",{children:[I.sender_name," "]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium w-12",children:"To:"}),e.jsxs("span",{children:[I.first_name," "]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"font-medium w-12 text-muted-foreground",children:"Subject:"}),e.jsx("span",{className:"font-medium",children:O(o.subject_line)})]})]}),e.jsx("div",{className:"bg-white p-6",children:e.jsx("div",{className:"prose prose-sm max-w-none",style:{fontSize:"15px",lineHeight:"1.75",color:"#1a1a1a"},dangerouslySetInnerHTML:{__html:O(o.body_html)}})})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Changes are saved to this campaign's templates"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{size:"sm",onClick:()=>V.mutate(o),disabled:V.isPending,className:"gap-1.5",children:[e.jsx(qc,{className:"h-3.5 w-3.5"})," Save Changes"]})]})]})]})]})}),e.jsx(fs,{open:f,onOpenChange:g,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx($s,{className:"h-5 w-5 text-primary"})," Create Custom Campaign"]}),e.jsx(Gr,{children:"Build your own recruiting email sequence with custom sender settings."})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium",children:"Campaign Name *"}),e.jsx(ze,{value:k.name,onChange:Me=>S({...k,name:Me.target.value}),placeholder:"e.g. Q2 Agent Outreach"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(Zs,{value:k.warmth_level,onValueChange:Me=>S({...k,warmth_level:Me}),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"cold",children:"❄️ Cold — Curiosity"}),e.jsx(Mt,{value:"warm",children:"☀️ Warm — Growth"}),e.jsx(Mt,{value:"hot",children:"🔥 Hot — Private Invite"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium",children:"Primary CTA"}),e.jsx(ze,{value:k.primary_cta,onChange:Me=>S({...k,primary_cta:Me.target.value}),placeholder:"Learn more"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium",children:"Description"}),e.jsx(Er,{value:k.description,onChange:Me=>S({...k,description:Me.target.value}),placeholder:"What is this campaign about?",rows:2})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium",children:"Goal"}),e.jsx(ze,{value:k.goal,onChange:Me=>S({...k,goal:Me.target.value}),placeholder:"e.g. Convert warm leads to meetings"})]}),e.jsxs(gf,{children:[e.jsx(yf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs font-medium text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," Email Settings Override"]}),e.jsx(Eo,{className:"h-3.5 w-3.5"})]})}),e.jsxs(vf,{className:"space-y-3 pt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave blank to use brokerage defaults."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Sender Name"}),e.jsx(ze,{value:k.sender_name,onChange:Me=>S({...k,sender_name:Me.target.value}),placeholder:"e.g. Jeremy at LevelUp"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Sender Email"}),e.jsx(ze,{value:k.sender_email,onChange:Me=>S({...k,sender_email:Me.target.value}),placeholder:"e.g. recruiting@send.relevelup.com"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Must be a verified sending domain"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Reply-To Email"}),e.jsx(ze,{value:k.reply_to_email,onChange:Me=>S({...k,reply_to_email:Me.target.value}),placeholder:"e.g. jeremy@mybrokerage.com"})]})]})]}),e.jsxs(K,{className:"w-full",disabled:!k.name.trim()||Z.isPending,onClick:()=>Z.mutate(),children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})]})}),e.jsx(fs,{open:!!j,onOpenChange:Me=>!Me&&w(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-5 w-5 text-primary"})," Campaign Email Settings"]}),e.jsx(Gr,{children:"Override the default sender for this campaign. Leave blank to use brokerage defaults."})]}),j&&e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium",children:"Campaign Name"}),e.jsx(ze,{value:j.name,onChange:Me=>w({...j,name:Me.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(Zs,{value:j.warmth_level,onValueChange:Me=>w({...j,warmth_level:Me}),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"cold",children:"❄️ Cold"}),e.jsx(Mt,{value:"warm",children:"☀️ Warm"}),e.jsx(Mt,{value:"hot",children:"🔥 Hot"})]})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium",children:"Goal"}),e.jsx(ze,{value:j.goal||"",onChange:Me=>w({...j,goal:Me.target.value})})]}),e.jsxs("div",{className:"border-t pt-4 space-y-3",children:[e.jsxs("p",{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(cr,{className:"h-4 w-4 text-primary"})," Email Sender Override"]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Sender Name"}),e.jsx(ze,{value:j.sender_name||"",onChange:Me=>w({...j,sender_name:Me.target.value}),placeholder:"Uses brokerage default"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Sender Email"}),e.jsx(ze,{value:j.sender_email||"",onChange:Me=>w({...j,sender_email:Me.target.value}),placeholder:"Uses brokerage default"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Must be a verified sending domain"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Reply-To Email"}),e.jsx(ze,{value:j.reply_to_email||"",onChange:Me=>w({...j,reply_to_email:Me.target.value}),placeholder:"Uses brokerage default"})]})]}),e.jsxs(K,{className:"w-full",onClick:()=>X.mutate(j),disabled:X.isPending,children:[e.jsx(qc,{className:"h-4 w-4 mr-1"})," Save Campaign Settings"]})]})]})}),e.jsx(fs,{open:u,onOpenChange:p,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Default Recruiting Email Settings"}),e.jsx(Gr,{children:"These defaults apply to campaigns without their own overrides."})]}),e.jsx(hCe,{brokerageId:t})]})})]});function xe(Me,Ne){const Pe=Sze[Me.warmth_level]||Sze.cold,Oe=Pe.icon,Te=B[Me.id]||[],ke=n===Me.id,Be=!!(Me.sender_name||Me.sender_email||Me.reply_to_email);return e.jsxs(Ee,{className:"overflow-hidden transition-shadow hover:shadow-md",children:[e.jsx(Pt,{className:"cursor-pointer hover:bg-muted/40 transition-colors py-4",onClick:()=>a(ke?null:Me.id),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`h-11 w-11 rounded-xl ${Pe.bg} flex items-center justify-center`,children:e.jsx(Oe,{className:`h-5 w-5 ${Pe.color}`})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[Me.name,e.jsx(tt,{variant:Me.is_active?"default":"secondary",className:"text-[10px] px-1.5",children:Me.is_active?"Active":"Draft"}),Ne&&e.jsx(tt,{variant:"outline",className:"text-[10px] px-1.5",children:"Custom"}),Be&&e.jsxs(tt,{variant:"outline",className:"text-[10px] px-1.5 border-primary/30 text-primary",children:[e.jsx(cr,{className:"h-2.5 w-2.5 mr-0.5"})," Custom Sender"]})]}),e.jsx(gr,{className:"text-xs mt-0.5",children:Me.theme||Me.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:nt=>{nt.stopPropagation(),w({...Me})},children:e.jsx(Xo,{className:"h-4 w-4 text-muted-foreground"})}),Ne&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:nt=>{nt.stopPropagation(),confirm("Delete this campaign and all its emails? This cannot be undone.")&&Q.mutate(Me.id)},children:e.jsx(Nr,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(cr,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:[Te.length," emails"]})]}),e.jsx("div",{className:"h-7 w-7 rounded-md flex items-center justify-center",children:ke?e.jsx(pf,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Eo,{className:"h-4 w-4 text-muted-foreground"})})]})]})}),ke&&e.jsxs(De,{className:"pt-0 pb-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-3 rounded-lg bg-muted/40 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Goal"}),e.jsx("p",{className:"mt-0.5",children:Me.goal||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Primary CTA"}),e.jsx("p",{className:"mt-0.5",children:Me.primary_cta||"—"})]})]}),Be&&e.jsxs("div",{className:"p-3 rounded-lg bg-primary/5 border border-primary/10 text-sm",children:[e.jsxs("p",{className:"text-xs font-semibold text-primary mb-1 flex items-center gap-1",children:[e.jsx(cr,{className:"h-3 w-3"})," Campaign Sender Override"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs text-muted-foreground",children:[Me.sender_name&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Name:"})," ",Me.sender_name]}),Me.sender_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Email:"})," ",Me.sender_email]}),Me.reply_to_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Reply-To:"})," ",Me.reply_to_email]})]})]}),e.jsx("div",{className:"relative",children:Te.map((nt,Ae)=>e.jsxs("div",{className:"relative flex gap-4 pb-4 last:pb-0",children:[Aeft.stopPropagation(),onBlur:ft=>{const fe=parseInt(ft.target.value)||0;fe!==nt.delay_days&&re.mutate({emailId:nt.id,delay_days:fe})},onKeyDown:ft=>{ft.key==="Enter"&&ft.target.blur()}}),"days"]})]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),nt.email_number===1?"Sent immediately":`Day ${nt.delay_days}`]}),e.jsx("span",{className:"text-border",children:"•"}),e.jsxs("span",{className:"truncate",children:["Subject: ",nt.subject_line]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>c(nt),children:e.jsx(On,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{l({...nt}),_("editor")},children:e.jsx(Ra,{className:"h-4 w-4"})}),Ne&&Te.length>1&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>{confirm("Delete this email from the sequence?")&&ie.mutate(nt.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})})]},nt.id))}),Ne&&e.jsxs(K,{variant:"outline",size:"sm",className:"w-full gap-1.5",onClick:()=>ee.mutate(Me.id),disabled:ee.isPending,children:[e.jsx($s,{className:"h-3.5 w-3.5"})," Add Email to Sequence"]})]})]},Me.id)}}const Cze={active:{icon:nl,color:"bg-green-500/10 text-green-600",label:"Active"},paused:{icon:Rm,color:"bg-amber-500/10 text-amber-600",label:"Paused"},completed:{icon:xi,color:"bg-blue-500/10 text-blue-600",label:"Completed"},cancelled:{icon:vc,color:"bg-red-500/10 text-red-600",label:"Cancelled"}},Mze={sent:{icon:cr,color:"text-blue-500"},opened:{icon:On,color:"text-amber-500"},clicked:{icon:Qg,color:"text-green-500"},failed:{icon:Ku,color:"text-destructive"}};function Klt({brokerageId:t}){const{user:s}=Ds(),r=Qt(),[n,a]=N.useState(!1),[o,l]=N.useState(""),[i,c]=N.useState(new Set),[u,p]=N.useState("assignments"),{data:f=[],isLoading:g}=mt({queryKey:["recruit-campaign-assignments",t],queryFn:async()=>{const{data:Z,error:X}=await H.from("recruit_campaign_assignments").select(` *, prospect:recruit_prospects(first_name, last_name, email), campaign:recruit_campaigns(name, warmth_level) `).eq("brokerage_id",t).order("created_at",{ascending:!1});if(X)throw X;return Z}}),{data:b=[]}=mt({queryKey:["recruit-campaign-sends",t],queryFn:async()=>{const{data:Z,error:X}=await H.from("recruit_campaign_sends").select(` *, prospect:recruit_prospects(first_name, last_name, email), campaign_email:recruit_campaign_emails(title) `).eq("brokerage_id",t).order("sent_at",{ascending:!1}).limit(100);if(X)throw X;return Z}}),{data:_=[]}=mt({queryKey:["recruit-campaigns"],queryFn:async()=>{const{data:Z,error:X}=await H.from("recruit_campaigns").select("id, name, warmth_level").eq("is_active",!0).order("sort_order");if(X)throw X;return Z}}),{data:j=[]}=mt({queryKey:["recruit-prospects-for-assign",t],queryFn:async()=>{const{data:Z,error:X}=await H.from("recruit_prospects").select("id, first_name, last_name, email").eq("brokerage_id",t).order("first_name");if(X)throw X;return Z}}),w=new Set(f.map(Z=>`${Z.prospect_id}-${Z.campaign_id}`)),k=Dt({mutationFn:async()=>{if(!o||i.size===0)throw new Error("Select a campaign and at least one prospect");const Z=new Date,X=Array.from(i).filter(Q=>!w.has(`${Q}-${o}`)).map(Q=>({prospect_id:Q,campaign_id:o,brokerage_id:t,assigned_by:s.id,status:"active",current_email_number:0,next_send_at:Z.toISOString(),started_at:Z.toISOString()}));if(X.length===0)throw new Error("All selected prospects are already assigned to this campaign");const{error:ee}=await H.from("recruit_campaign_assignments").insert(X);if(ee)throw ee},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),me.success(`Campaign assigned to ${i.size} prospect(s)!`),a(!1),l(""),c(new Set)},onError:Z=>me.error(Z.message)}),S=Dt({mutationFn:async({id:Z,newStatus:X})=>{const{error:ee}=await H.from("recruit_campaign_assignments").update({status:X,updated_at:new Date().toISOString()}).eq("id",Z);if(ee)throw ee},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),me.success("Assignment updated")}}),M=Dt({mutationFn:async()=>{const{data:Z,error:X}=await H.functions.invoke("ses-recruit-drip",{body:{action:"process_drips"}});if(X)throw X;return Z},onSuccess:Z=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),r.invalidateQueries({queryKey:["recruit-campaign-sends",t]}),me.success(`Wave sent! ${Z.sent} emails delivered, ${Z.skipped} skipped, ${Z.failed} failed`)},onError:Z=>me.error(`Send failed: ${Z.message}`)}),L=f.filter(Z=>Z.status==="active").length;f.filter(Z=>Z.status==="completed").length;const I=f.filter(Z=>Z.status==="active"&&Z.next_send_at&&new Date(Z.next_send_at)<=new Date).length,O=b.length,q=b.filter(Z=>Z.opened_at).length,U=b.filter(Z=>Z.clicked_at).length,B=O>0?Math.round(q/O*100):0,V=O>0?Math.round(U/O*100):0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:"Campaign Assignments"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Assign recruiting campaigns to prospects — emails auto-send weekly via SES"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[I>0&&e.jsxs(K,{variant:"outline",onClick:()=>M.mutate(),disabled:M.isPending,className:"border-amber-500/50 text-amber-600 hover:bg-amber-500/10",children:[e.jsx(Zh,{className:"h-4 w-4 mr-1"}),M.isPending?"Sending...":`Send Next Wave (${I})`]}),e.jsxs(K,{onClick:()=>a(!0),children:[e.jsx(Bn,{className:"h-4 w-4 mr-1"})," Assign Campaign"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsx(Ee,{children:e.jsxs(De,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(pr,{className:"h-7 w-7 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:f.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Assigned"})]})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(nl,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:L}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active"})]})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(cr,{className:"h-7 w-7 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:O}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Emails Sent"})]})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(On,{className:"h-7 w-7 text-amber-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[B,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Open Rate"})]})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(Qg,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[V,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click Rate"})]})]})})]}),e.jsxs(ba,{value:u,onValueChange:p,children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"assignments",children:["Active Drips (",L,")"]}),e.jsxs(ns,{value:"history",children:["Send History (",O,")"]})]}),e.jsx(bs,{value:"assignments",className:"mt-4",children:g?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):f.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(Bn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No campaigns assigned yet"}),e.jsx("p",{className:"text-sm",children:"Assign a recruiting campaign to your prospects to start automated outreach"})]})}):e.jsx("div",{className:"space-y-2",children:f.map(Z=>{var ie,re,oe,ce;const X=Cze[Z.status]||Cze.active,ee=X.icon;return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(tt,{className:`text-xs ${X.color} border-0`,children:[e.jsx(ee,{className:"h-3 w-3 mr-1"}),X.label]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(ie=Z.prospect)==null?void 0:ie.first_name," ",(re=Z.prospect)==null?void 0:re.last_name,e.jsx("span",{className:"text-muted-foreground font-normal ml-2",children:(oe=Z.prospect)==null?void 0:oe.email})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(ce=Z.campaign)==null?void 0:ce.name," · Email ",Z.current_email_number,"/",4,Z.next_send_at&&Z.status==="active"&&e.jsxs(e.Fragment,{children:[" ","· ",e.jsx(un,{className:"h-3 w-3 inline"})," Next: ",ms(new Date(Z.next_send_at),"MMM d, h:mm a"),new Date(Z.next_send_at)<=new Date&&e.jsx(tt,{variant:"outline",className:"ml-1 text-[10px] px-1 py-0 border-amber-500 text-amber-600",children:"DUE"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[Z.status==="active"&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>S.mutate({id:Z.id,newStatus:"paused"}),children:e.jsx(Rm,{className:"h-3.5 w-3.5"})}),Z.status==="paused"&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>S.mutate({id:Z.id,newStatus:"active"}),children:e.jsx(nl,{className:"h-3.5 w-3.5"})}),(Z.status==="active"||Z.status==="paused")&&e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>S.mutate({id:Z.id,newStatus:"cancelled"}),children:e.jsx(vc,{className:"h-3.5 w-3.5"})})]})]},Z.id)})})}),e.jsx(bs,{value:"history",className:"mt-4",children:b.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(cr,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No emails sent yet"}),e.jsx("p",{className:"text-sm",children:"Emails will appear here once campaigns start sending"})]})}):e.jsx("div",{className:"space-y-1",children:b.map(Z=>{var Q,ie;const X=Mze[Z.status]||Mze.sent,ee=X.icon;return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(ee,{className:`h-4 w-4 flex-shrink-0 ${X.color}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm truncate",children:[(Q=Z.prospect)==null?void 0:Q.first_name," ",(ie=Z.prospect)==null?void 0:ie.last_name,e.jsxs("span",{className:"text-muted-foreground font-normal ml-2",children:["Email #",Z.email_number]})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Z.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-shrink-0",children:[Z.opened_at&&e.jsxs("span",{className:"flex items-center gap-1 text-amber-500",children:[e.jsx(On,{className:"h-3 w-3"})," ",ms(new Date(Z.opened_at),"MMM d")]}),Z.clicked_at&&e.jsxs("span",{className:"flex items-center gap-1 text-green-500",children:[e.jsx(Qg,{className:"h-3 w-3"})," ",ms(new Date(Z.clicked_at),"MMM d")]}),Z.status==="failed"&&e.jsx("span",{className:"text-destructive text-xs",children:"Failed"}),e.jsx("span",{children:ms(new Date(Z.sent_at),"MMM d, h:mm a")})]})]},Z.id)})})})]}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ps,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Assign Campaign to Prospects"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Select Campaign"}),e.jsxs(Zs,{value:o,onValueChange:l,children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Choose a campaign"})}),e.jsx(Gs,{children:_.map(Z=>e.jsx(Mt,{value:Z.id,children:Z.name},Z.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"text-sm font-medium",children:["Select Prospects (",i.size," selected)"]}),e.jsxs("div",{className:"border rounded-lg max-h-60 overflow-y-auto divide-y",children:[j.map(Z=>{const X=o&&w.has(`${Z.id}-${o}`);return e.jsxs("label",{className:`flex items-center gap-3 p-3 hover:bg-muted/50 cursor-pointer ${X?"opacity-50":""}`,children:[e.jsx(Oo,{checked:i.has(Z.id),disabled:!!X,onCheckedChange:ee=>{const Q=new Set(i);ee?Q.add(Z.id):Q.delete(Z.id),c(Q)}}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium",children:[Z.first_name," ",Z.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Z.email}),X&&e.jsx("p",{className:"text-xs text-amber-600",children:"Already assigned"})]})]},Z.id)}),j.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No prospects found for this brokerage"})]})]}),o&&i.size>0&&e.jsx(Ee,{className:"bg-muted/50",children:e.jsxs(De,{className:"pt-3 pb-2 text-xs text-muted-foreground",children:[e.jsxs("p",{children:["📬 ",e.jsxs("strong",{children:[i.size," prospect(s)"]})," will start receiving the campaign."]}),e.jsx("p",{children:'Emails are sent automatically every 7 days via SES using brokerage sender settings. You can also trigger sends manually with "Send Next Wave".'})]})})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>k.mutate(),disabled:k.isPending||!o||i.size===0,children:[e.jsx(Bn,{className:"h-4 w-4 mr-1"}),"Assign & Start (",i.size,")"]})]})]})})]})}function Zlt({brokerageId:t}){const s=Qt(),[r,n]=N.useState([]),[a,o]=N.useState([]),[l,i]=N.useState(!1),c=N.useRef(!1),{data:u,isLoading:p}=mt({queryKey:["recruit-stages-editor",t],queryFn:async()=>{const{data:w,error:k}=await H.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(k)throw k;return w},enabled:!!t});N.useEffect(()=>{if(u){if(c.current){c.current=!1;return}n(u.map(w=>({id:w.id,name:w.name,color:w.color,sort_order:w.sort_order}))),o([]),i(!1)}},[u]);const f=Dt({mutationFn:async()=>{for(const S of a){const{error:M}=await H.from("recruit_pipeline_stages").delete().eq("id",S);if(M)throw M}const w=r.filter(S=>S.id&&!S.isNew),k=r.filter(S=>!S.id||S.isNew);for(const S of w){const{error:M}=await H.from("recruit_pipeline_stages").update({name:S.name,color:S.color,sort_order:S.sort_order}).eq("id",S.id);if(M)throw M}if(k.length>0){const{error:S}=await H.from("recruit_pipeline_stages").insert(k.map(M=>({brokerage_id:t,name:M.name,color:M.color,sort_order:M.sort_order})));if(S)throw S}},onSuccess:()=>{o([]),s.invalidateQueries({queryKey:["recruit-stages-editor",t]}),s.invalidateQueries({queryKey:["recruit-stages",t]}),me.success("Pipeline stages saved!"),i(!1)},onError:w=>me.error(w.message)}),g=(w,k,S)=>{n(M=>M.map((L,I)=>I===w?{...L,[k]:S}:L)),i(!0)},b=()=>{const w=r.length>0?Math.max(...r.map(k=>k.sort_order)):0;n(k=>[...k,{name:"",color:"#6366f1",sort_order:w+1,isNew:!0}]),i(!0)},_=w=>{const k=r[w];k.id&&!k.isNew&&o(S=>[...S,k.id]),n(S=>S.filter((M,L)=>L!==w)),i(!0)},j=(w,k)=>{const S=w+k;if(S<0||S>=r.length)return;const M=[...r];[M[w],M[S]]=[M[S],M[w]],M.forEach((L,I)=>L.sort_order=I+1),n(M),i(!0)};return p?e.jsx("div",{className:"text-sm text-muted-foreground py-8 text-center",children:"Loading stages…"}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"Pipeline Stages"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Customize the recruiting pipeline stages for this brokerage. Changes will apply to the Kanban board and all prospect tracking."})]}),e.jsx("div",{className:"space-y-2",children:r.map((w,k)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>j(k,-1),disabled:k===0,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▲"}),e.jsx("button",{type:"button",onClick:()=>j(k,1),disabled:k===r.length-1,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▼"})]}),e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground/50 shrink-0"}),e.jsx("input",{type:"color",value:w.color,onChange:S=>g(k,"color",S.target.value),className:"h-8 w-8 rounded cursor-pointer border-0 p-0 shrink-0"}),e.jsx(ze,{value:w.name,onChange:S=>g(k,"name",S.target.value),placeholder:"Stage name…",className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground w-6 text-center shrink-0",children:k+1}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(k),className:"text-destructive hover:text-destructive shrink-0 h-8 w-8",children:e.jsx(Nr,{className:"h-4 w-4"})})]},w.id||`new-${k}`))}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:b,className:"gap-1",children:[e.jsx($s,{className:"h-4 w-4"})," Add Stage"]}),l&&e.jsxs(K,{size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,className:"gap-1",children:[e.jsx(qc,{className:"h-4 w-4"})," Save Changes"]})]}),r.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No stages configured. Add stages to build your recruiting pipeline."})]})}function V4s(){var i;const[t,s]=N.useState(""),[r,n]=N.useState("board"),{data:a=[],isLoading:o}=mt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:c,error:u}=await H.from("brokerages").select("id, name").order("name");if(u)throw u;return c}}),l=t||((i=a[0])==null?void 0:i.id)||"";return o?e.jsx(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(Zs,{value:l,onValueChange:s,children:[e.jsxs(Ws,{className:"w-[280px]",children:[e.jsx(ka,{className:"mr-2 h-4 w-4"}),e.jsx(Xs,{placeholder:"Select brokerage"})]}),e.jsx(Gs,{children:a.map(c=>e.jsx(Mt,{value:c.id,children:c.name},c.id))})]})]}),l?e.jsxs(ba,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(pa,{className:"flex-wrap h-auto gap-1",children:[e.jsx(ns,{value:"pipeline",children:"Pipeline"}),e.jsxs(ns,{value:"contacts",children:[e.jsx(pr,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(ns,{value:"video-outreach",children:[e.jsx(An,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(ns,{value:"follow-ups",children:"Follow-ups"}),e.jsx(ns,{value:"referrals",children:"Referrals"}),e.jsx(ns,{value:"interest",children:"Interest Form"}),e.jsx(ns,{value:"landing-page",children:"Landing Page"}),e.jsx(ns,{value:"goals",children:"Goals"}),e.jsx(ns,{value:"metrics",children:"Metrics"}),e.jsx(ns,{value:"templates",children:"Email Templates"}),e.jsxs(ns,{value:"campaigns",children:[e.jsx(cr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(ns,{value:"drip-assignments",children:[e.jsx(Bn,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(ns,{value:"activity",children:"Recruiter Activity"}),e.jsxs(ns,{value:"email-settings",children:[e.jsx(Xo,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(ns,{value:"pipeline-stages",children:[e.jsx(H_,{className:"h-3.5 w-3.5 mr-1"}),"Pipeline Stages"]})]}),e.jsxs(bs,{value:"pipeline",children:[e.jsx("div",{className:"flex justify-end mb-3",children:e.jsxs("div",{className:"flex items-center rounded-md border bg-muted p-0.5",children:[e.jsxs(K,{variant:r==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("board"),children:[e.jsx(Cp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(K,{variant:r==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("table"),children:[e.jsx(qM,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(Rlt,{brokerageId:l}):e.jsx(tde,{brokerageId:l})]}),e.jsx(bs,{value:"contacts",children:e.jsx(tde,{brokerageId:l})}),e.jsx(bs,{value:"video-outreach",children:e.jsx(Hlt,{brokerageId:l})}),e.jsx(bs,{value:"follow-ups",children:e.jsx(Ult,{brokerageId:l})}),e.jsx(bs,{value:"referrals",children:e.jsx($lt,{brokerageId:l})}),e.jsx(bs,{value:"interest",children:e.jsx(qlt,{brokerageId:l})}),e.jsx(bs,{value:"landing-page",children:e.jsx(Vlt,{brokerageId:l})}),e.jsx(bs,{value:"goals",children:e.jsx(Wlt,{brokerageId:l})}),e.jsx(bs,{value:"metrics",children:e.jsx(Flt,{brokerageId:l})}),e.jsx(bs,{value:"templates",children:e.jsx(zlt,{brokerageId:l})}),e.jsx(bs,{value:"campaigns",children:e.jsx(Glt,{brokerageId:l})}),e.jsx(bs,{value:"drip-assignments",children:e.jsx(Klt,{brokerageId:l})}),e.jsx(bs,{value:"activity",children:e.jsx(Blt,{brokerageId:l})}),e.jsx(bs,{value:"email-settings",children:e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"Email Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Configure sender identity, merge fields, and brokerage location for recruiting emails."}),e.jsx(hCe,{brokerageId:l})]})}),e.jsx(bs,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(Zlt,{brokerageId:l})})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(ka,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found. Create a brokerage first."})]})]})})}function H4s(){var l;const{managedBrokerages:t,selectedBrokerageId:s,setSelectedBrokerageId:r}=Ds(),[n,a]=N.useState("board"),o=s||((l=t[0])==null?void 0:l.id)||"";return t.length===0?e.jsx(Ms,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(ka,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages assigned to you. Contact an admin for access."})]})}):e.jsx(Ms,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"space-y-6",children:[t.length>1&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage:"}),e.jsxs(Zs,{value:o,onValueChange:r,children:[e.jsxs(Ws,{className:"w-[280px]",children:[e.jsx(ka,{className:"mr-2 h-4 w-4"}),e.jsx(Xs,{placeholder:"Select brokerage"})]}),e.jsx(Gs,{children:t.map(i=>e.jsx(Mt,{value:i.id,children:i.name},i.id))})]})]}),o?e.jsxs(ba,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(pa,{className:"flex-wrap h-auto gap-1",children:[e.jsx(ns,{value:"pipeline",children:"Pipeline"}),e.jsxs(ns,{value:"contacts",children:[e.jsx(pr,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(ns,{value:"video-outreach",children:[e.jsx(An,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(ns,{value:"follow-ups",children:"Follow-ups"}),e.jsx(ns,{value:"referrals",children:"Referrals"}),e.jsx(ns,{value:"interest",children:"Interest Form"}),e.jsx(ns,{value:"landing-page",children:"Landing Page"}),e.jsx(ns,{value:"goals",children:"Goals"}),e.jsx(ns,{value:"metrics",children:"Metrics"}),e.jsx(ns,{value:"templates",children:"Email Templates"}),e.jsxs(ns,{value:"campaigns",children:[e.jsx(cr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(ns,{value:"drip-assignments",children:[e.jsx(Bn,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(ns,{value:"activity",children:"Recruiter Activity"}),e.jsxs(ns,{value:"email-settings",children:[e.jsx(Xo,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(ns,{value:"pipeline-stages",children:[e.jsx(H_,{className:"h-3.5 w-3.5 mr-1"}),"Pipeline Stages"]})]}),e.jsxs(bs,{value:"pipeline",children:[e.jsx("div",{className:"flex justify-end mb-3",children:e.jsxs("div",{className:"flex items-center rounded-md border bg-muted p-0.5",children:[e.jsxs(K,{variant:n==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>a("board"),children:[e.jsx(Cp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(K,{variant:n==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>a("table"),children:[e.jsx(qM,{className:"h-3.5 w-3.5"})," Table"]})]})}),n==="board"?e.jsx(Rlt,{brokerageId:o}):e.jsx(tde,{brokerageId:o})]}),e.jsx(bs,{value:"contacts",children:e.jsx(tde,{brokerageId:o})}),e.jsx(bs,{value:"video-outreach",children:e.jsx(Hlt,{brokerageId:o})}),e.jsx(bs,{value:"follow-ups",children:e.jsx(Ult,{brokerageId:o})}),e.jsx(bs,{value:"referrals",children:e.jsx($lt,{brokerageId:o})}),e.jsx(bs,{value:"interest",children:e.jsx(qlt,{brokerageId:o})}),e.jsx(bs,{value:"landing-page",children:e.jsx(Vlt,{brokerageId:o})}),e.jsx(bs,{value:"goals",children:e.jsx(Wlt,{brokerageId:o})}),e.jsx(bs,{value:"metrics",children:e.jsx(Flt,{brokerageId:o})}),e.jsx(bs,{value:"templates",children:e.jsx(zlt,{brokerageId:o})}),e.jsx(bs,{value:"campaigns",children:e.jsx(Glt,{brokerageId:o})}),e.jsx(bs,{value:"drip-assignments",children:e.jsx(Klt,{brokerageId:o})}),e.jsx(bs,{value:"activity",children:e.jsx(Blt,{brokerageId:o})}),e.jsx(bs,{value:"email-settings",children:e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"Email Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Configure sender identity, merge fields, and brokerage location for recruiting emails."}),e.jsx(hCe,{brokerageId:o})]})}),e.jsx(bs,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(Zlt,{brokerageId:o})})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(ka,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found."})]})]})})}function W4s(){const[t,s]=N.useState(""),{data:r,isLoading:n}=mt({queryKey:["admin-brokerage-content-activity"],queryFn:async()=>{const{data:i}=await H.from("brokerages").select("id, name");if(!i)return[];const{data:c}=await H.from("brokerage_content").select("id, brokerage_id, content_type, created_at"),{data:u}=await H.from("brokerage_content_categories").select("id, brokerage_id"),p=c||[],f=u||[],g=i.map(b=>{const _=p.filter(k=>k.brokerage_id===b.id),j=f.filter(k=>k.brokerage_id===b.id),w=_.length>0?_.reduce((k,S)=>S.created_at>k?S.created_at:k,_[0].created_at):null;return{brokerage_id:b.id,brokerage_name:b.name,total_items:_.length,videos:_.filter(k=>k.content_type==="video").length,pdfs:_.filter(k=>k.content_type==="pdf").length,links:_.filter(k=>k.content_type==="link"||k.content_type==="canva_link").length,events:_.filter(k=>k.content_type==="event").length,graphics:_.filter(k=>k.content_type==="graphic").length,latest_item_date:w,categories:j.length}});return g.sort((b,_)=>_.total_items-b.total_items),g}}),a=(r||[]).filter(i=>i.brokerage_name.toLowerCase().includes(t.toLowerCase())),o=a.reduce((i,c)=>i+c.total_items,0),l=a.filter(i=>i.total_items>0).length;return e.jsx(Ms,{title:"Brokerage Content Activity",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Brokerage Content Activity",description:"See which brokerages are creating custom content for their agents"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Active Brokerages"})}),e.jsxs(De,{children:[e.jsx("p",{className:"text-2xl font-bold",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with content uploaded"})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Content Items"})}),e.jsxs(De,{children:[e.jsx("p",{className:"text-2xl font-bold",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"across all brokerages"})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Brokerages"})}),e.jsxs(De,{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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search brokerages...",value:t,onChange:i=>s(i.target.value),className:"pl-9"})]}),e.jsx(Ee,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Brokerage"}),e.jsx(St,{className:"text-center",children:"Total"}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(An,{className:"h-3 w-3"})," Videos"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"})," PDFs"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(dl,{className:"h-3 w-3"})," Links"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Dd,{className:"h-3 w-3"})," Events"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(gl,{className:"h-3 w-3"})," Graphics"]})}),e.jsx(St,{className:"text-center",children:"Categories"}),e.jsx(St,{children:"Last Upload"})]})}),e.jsx(zn,{children:n?e.jsx(Ss,{children:e.jsx(dt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):a.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"No brokerages found"})}):a.map(i=>e.jsxs(Ss,{className:i.total_items===0?"opacity-50":"",children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:i.brokerage_name})]})}),e.jsx(dt,{className:"text-center",children:i.total_items>0?e.jsx(tt,{variant:"secondary",className:"font-bold",children:i.total_items}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(dt,{className:"text-center",children:i.videos||"–"}),e.jsx(dt,{className:"text-center",children:i.pdfs||"–"}),e.jsx(dt,{className:"text-center",children:i.links||"–"}),e.jsx(dt,{className:"text-center",children:i.events||"–"}),e.jsx(dt,{className:"text-center",children:i.graphics||"–"}),e.jsx(dt,{className:"text-center",children:i.categories||"–"}),e.jsx(dt,{children:i.latest_item_date?e.jsx("span",{className:"text-sm text-muted-foreground",children:ms(new Date(i.latest_item_date),"MMM d, yyyy")}):e.jsx("span",{className:"text-muted-foreground",children:"–"})})]},i.brokerage_id))})]})})})]})})}function G4s(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 K4s=(()=>{let t=0;const s=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${s()}${t}`)})();function nw(t){const s=[];for(let r=0,n=t.length;rXp||t.height>Xp)&&(t.width>Xp&&t.height>Xp?t.width>t.height?(t.height*=Xp/t.width,t.width=Xp):(t.width*=Xp/t.height,t.height=Xp):t.width>Xp?(t.height*=Xp/t.width,t.width=Xp):(t.width*=Xp/t.height,t.height=Xp))}function rde(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 J4s(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(s=>`data:image/svg+xml;charset=utf-8,${s}`)}async function eSs(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),J4s(a)}const Ap=(t,s)=>{if(t instanceof s)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===s.name||Ap(r,s)};function tSs(t){const s=t.getPropertyValue("content");return`${t.cssText} content: '${s.replace(/'|"/g,"")}';`}function sSs(t,s){return Ylt(s).map(r=>{const n=t.getPropertyValue(r),a=t.getPropertyPriority(r);return`${r}: ${n}${a?" !important":""};`}).join(" ")}function rSs(t,s,r,n){const a=`.${t}:${s}`,o=r.cssText?tSs(r):sSs(r,n);return document.createTextNode(`${a}{${o}}`)}function Tze(t,s,r,n){const a=window.getComputedStyle(t,r),o=a.getPropertyValue("content");if(o===""||o==="none")return;const l=K4s();try{s.className=`${s.className} ${l}`}catch{return}const i=document.createElement("style");i.appendChild(rSs(l,r,a,n)),s.appendChild(i)}function nSs(t,s,r){Tze(t,s,":before",r),Tze(t,s,":after",r)}const Aze="application/font-woff",Eze="image/jpeg",aSs={woff:Aze,woff2:Aze,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Eze,jpeg:Eze,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function iSs(t){const s=/\.([^./]*?)$/g.exec(t);return s?s[1]:""}function mCe(t){const s=iSs(t).toLowerCase();return aSs[s]||""}function oSs(t){return t.split(/,/)[1]}function uwe(t){return t.search(/^(data:)/)!==-1}function lSs(t,s){return`data:${s};base64,${t}`}async function Qlt(t,s,r){const n=await fetch(t,s);if(n.status===404)throw new Error(`Resource "${n.url}" not found`);const a=await n.blob();return new Promise((o,l)=>{const i=new FileReader;i.onerror=l,i.onloadend=()=>{try{o(r({res:n,result:i.result}))}catch(c){l(c)}},i.readAsDataURL(a)})}const Tye={};function cSs(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 pCe(t,s,r){const n=cSs(t,s,r.includeQueryParams);if(Tye[n]!=null)return Tye[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let a;try{const o=await Qlt(t,r.fetchRequestInit,({res:l,result:i})=>(s||(s=l.headers.get("Content-Type")||""),oSs(i)));a=lSs(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 Tye[n]=a,a}async function dSs(t){const s=t.toDataURL();return s==="data:,"?t.cloneNode(!1):rde(s)}async function uSs(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 rde(i)}const r=t.poster,n=mCe(r),a=await pCe(r,n,s);return rde(a)}async function hSs(t,s){var r;try{if(!((r=t==null?void 0:t.contentDocument)===null||r===void 0)&&r.body)return await vme(t.contentDocument.body,s,!0)}catch{}return t.cloneNode(!1)}async function mSs(t,s){return Ap(t,HTMLCanvasElement)?dSs(t):Ap(t,HTMLVideoElement)?uSs(t,s):Ap(t,HTMLIFrameElement)?hSs(t,s):t.cloneNode(Jlt(t))}const pSs=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",Jlt=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function fSs(t,s,r){var n,a;if(Jlt(s))return s;let o=[];return pSs(t)&&t.assignedNodes?o=nw(t.assignedNodes()):Ap(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?o=nw(t.contentDocument.body.childNodes):o=nw(((a=t.shadowRoot)!==null&&a!==void 0?a:t).childNodes),o.length===0||Ap(t,HTMLVideoElement)||await o.reduce((l,i)=>l.then(()=>vme(i,r)).then(c=>{c&&s.appendChild(c)}),Promise.resolve()),s}function xSs(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):Ylt(r).forEach(o=>{let l=a.getPropertyValue(o);o==="font-size"&&l.endsWith("px")&&(l=`${Math.floor(parseFloat(l.substring(0,l.length-2)))-.1}px`),Ap(t,HTMLIFrameElement)&&o==="display"&&l==="inline"&&(l="block"),o==="d"&&s.getAttribute("d")&&(l=`path(${s.getAttribute("d")})`),n.setProperty(o,l,a.getPropertyPriority(o))})}function gSs(t,s){Ap(t,HTMLTextAreaElement)&&(s.innerHTML=t.value),Ap(t,HTMLInputElement)&&s.setAttribute("value",t.value)}function ySs(t,s){if(Ap(t,HTMLSelectElement)){const r=s,n=Array.from(r.children).find(a=>t.value===a.getAttribute("value"));n&&n.setAttribute("selected","")}}function vSs(t,s,r){return Ap(s,Element)&&(xSs(t,s,r),nSs(t,s,r),gSs(t,s),ySs(t,s)),s}async function bSs(t,s){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let o=0;omSs(n,s)).then(n=>fSs(t,n,s)).then(n=>vSs(t,n,s)).then(n=>bSs(n,s))}const ect=/url\((['"]?)([^'"]+?)\1\)/g,_Ss=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,wSs=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function jSs(t){const s=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${s})(['"]?\\))`,"g")}function NSs(t){const s=[];return t.replace(ect,(r,n,a)=>(s.push(a),r)),s.filter(r=>!uwe(r))}async function kSs(t,s,r,n,a){try{const o=r?G4s(s,r):s,l=mCe(s);let i;return a||(i=await pCe(o,l,n)),t.replace(jSs(s),`$1${i}$3`)}catch{}return t}function SSs(t,{preferredFontFormat:s}){return s?t.replace(wSs,r=>{for(;;){const[n,,a]=_Ss.exec(r)||[];if(!a)return"";if(a===s)return`src: ${n};`}}):t}function tct(t){return t.search(ect)!==-1}async function sct(t,s,r){if(!tct(t))return t;const n=SSs(t,r);return NSs(n).reduce((o,l)=>o.then(i=>kSs(i,l,s,r)),Promise.resolve(n))}async function D5(t,s,r){var n;const a=(n=s.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(a){const o=await sct(a,null,r);return s.style.setProperty(t,o,s.style.getPropertyPriority(t)),!0}return!1}async function CSs(t,s){await D5("background",t,s)||await D5("background-image",t,s),await D5("mask",t,s)||await D5("-webkit-mask",t,s)||await D5("mask-image",t,s)||await D5("-webkit-mask-image",t,s)}async function MSs(t,s){const r=Ap(t,HTMLImageElement);if(!(r&&!uwe(t.src))&&!(Ap(t,SVGImageElement)&&!uwe(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,a=await pCe(n,mCe(n),s);await new Promise((o,l)=>{t.onload=o,t.onerror=s.onImageErrorHandler?(...c)=>{try{o(s.onImageErrorHandler(...c))}catch(u){l(u)}}:l;const i=t;i.decode&&(i.decode=o),i.loading==="lazy"&&(i.loading="eager"),r?(t.srcset="",t.src=a):t.href.baseVal=a})}async function TSs(t,s){const n=nw(t.childNodes).map(a=>rct(a,s));await Promise.all(n).then(()=>t)}async function rct(t,s){Ap(t,Element)&&(await CSs(t,s),await MSs(t,s),await TSs(t,s))}function ASs(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 Pze={};async function Ize(t){let s=Pze[t];if(s!=null)return s;const n=await(await fetch(t)).text();return s={url:t,cssText:n},Pze[t]=s,s}async function Lze(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),Qlt(i,s.fetchRequestInit,({result:c})=>(r=r.replace(l,`url(${c})`),[l,c]))});return Promise.all(o).then(()=>r)}function Dze(t){if(t==null)return[];const s=[],r=/(\/\*[\s\S]*?\*\/)/gi;let n=t.replace(r,"");const a=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const c=a.exec(n);if(c===null)break;s.push(c[0])}n=n.replace(a,"");const o=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,l="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",i=new RegExp(l,"gi");for(;;){let c=o.exec(n);if(c===null){if(c=i.exec(n),c===null)break;o.lastIndex=i.lastIndex}else i.lastIndex=o.lastIndex;s.push(c[0])}return s}async function ESs(t,s){const r=[],n=[];return t.forEach(a=>{if("cssRules"in a)try{nw(a.cssRules||[]).forEach((o,l)=>{if(o.type===CSSRule.IMPORT_RULE){let i=l+1;const c=o.href,u=Ize(c).then(p=>Lze(p,s)).then(p=>Dze(p).forEach(f=>{try{a.insertRule(f,f.startsWith("@import")?i+=1:a.cssRules.length)}catch(g){console.error("Error inserting rule from remote css",{rule:f,error:g})}})).catch(p=>{console.error("Error loading remote css",p.toString())});n.push(u)}})}catch(o){const l=t.find(i=>i.href==null)||document.styleSheets[0];a.href!=null&&n.push(Ize(a.href).then(i=>Lze(i,s)).then(i=>Dze(i).forEach(c=>{l.insertRule(c,l.cssRules.length)})).catch(i=>{console.error("Error loading remote stylesheet",i)})),console.error("Error inlining remote css file",o)}}),Promise.all(n).then(()=>(t.forEach(a=>{if("cssRules"in a)try{nw(a.cssRules||[]).forEach(o=>{r.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${a.href}`,o)}}),r))}function PSs(t){return t.filter(s=>s.type===CSSRule.FONT_FACE_RULE).filter(s=>tct(s.style.getPropertyValue("src")))}async function ISs(t,s){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=nw(t.ownerDocument.styleSheets),n=await ESs(r,s);return PSs(n)}function nct(t){return t.trim().replace(/["']/g,"")}function LSs(t){const s=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(o=>{s.add(nct(o))}),Array.from(n.children).forEach(o=>{o instanceof HTMLElement&&r(o)})}return r(t),s}async function DSs(t,s){const r=await ISs(t,s),n=LSs(t);return(await Promise.all(r.filter(o=>n.has(nct(o.style.fontFamily))).map(o=>{const l=o.parentStyleSheet?o.parentStyleSheet.href:null;return sct(o.cssText,l,s)}))).join(` `)}async function OSs(t,s){const r=s.fontEmbedCSS!=null?s.fontEmbedCSS:s.skipFonts?null:await DSs(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 RSs(t,s={}){const{width:r,height:n}=Xlt(t,s),a=await vme(t,s,!0);return await OSs(a,s),await rct(a,s),ASs(a,s),await eSs(a,r,n)}async function FSs(t,s={}){const{width:r,height:n}=Xlt(t,s),a=await RSs(t,s),o=await rde(a),l=document.createElement("canvas"),i=l.getContext("2d"),c=s.pixelRatio||X4s(),u=s.canvasWidth||r,p=s.canvasHeight||n;return l.width=u*c,l.height=p*c,s.skipAutoScale||Q4s(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 zSs(t,s={}){return(await FSs(t,s)).toDataURL()}const IA=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),bme={"just-listed":"JUST LISTED","just-sold":"JUST SOLD","open-house":"OPEN HOUSE","price-drop":"PRICE DROP"},t9={"instagram-square":{width:1080,height:1080},"instagram-story":{width:1080,height:1920},"facebook-post":{width:1200,height:630}},BSs=({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})]})]}),act=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var f;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,c=(f=t.photos)==null?void 0:f[a],u=bme[s],p=[t.bedrooms?`${t.bedrooms} Bed`:null,t.bathrooms?`${t.bathrooms} Bath`:null,t.sqft?`${t.sqft.toLocaleString()} Sq Ft`:null].filter(Boolean).join(" • ");return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Georgia', 'Times New Roman', serif",color:"#FFFFFF"},children:[c&&e.jsx("img",{src:c,alt:"",crossOrigin:"anonymous",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:"linear-gradient(180deg, rgba(10,10,30,0.3) 0%, rgba(10,10,30,0.85) 100%)"}}),e.jsxs("div",{style:{position:"relative",height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between",padding:l.w*.06},children:[e.jsx("div",{children:e.jsx("div",{style:{display:"inline-block",background:"linear-gradient(135deg, #C9A84C, #E8D48B)",color:"#1A1A2E",padding:`${l.w*.012}px ${l.w*.035}px`,fontSize:l.w*.032,fontWeight:700,letterSpacing:"0.25em",textTransform:"uppercase"},children:u})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:l.w*.07,fontWeight:700,lineHeight:1.1,marginBottom:l.w*.015,textShadow:"0 2px 12px rgba(0,0,0,0.5)"},children:IA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.028,color:"#C9A84C",marginBottom:l.w*.01},children:["Sold for ",IA(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(BSs,{branding:n,dim:l})]})]})]})});act.displayName="LuxuryDarkTemplate";const $Ss=({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})]})]}),ict=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var b;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,c=(b=t.photos)==null?void 0:b[a],u=bme[s],p=r==="instagram-story",f=r==="facebook-post",g=s==="just-sold"?"#7C3AED":s==="open-house"?"#2563EB":s==="price-drop"?"#DC2626":"#059669";return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Helvetica Neue', Arial, sans-serif",color:"#1A1A1A",background:"#FFFFFF",display:"flex",flexDirection:f?"row":"column"},children:[e.jsxs("div",{style:{width:f?"55%":"100%",height:f?"100%":p?"50%":"52%",position:"relative",overflow:"hidden",flexShrink:0},children:[c&&e.jsx("img",{src:c,alt:"",crossOrigin:"anonymous",style:{width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",top:l.w*.04,left:0,background:g,color:"#FFFFFF",padding:`${l.w*.012}px ${l.w*.04}px`,fontSize:l.w*.026,fontWeight:800,letterSpacing:"0.15em"},children:u})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",padding:l.w*.05},children:[e.jsx("div",{style:{fontSize:l.w*(f?.055:.065),fontWeight:800,lineHeight:1.1,color:g,marginBottom:l.w*.012},children:IA(t.price)}),e.jsx("div",{style:{fontSize:l.w*.026,fontWeight:600,marginBottom:l.w*.006},children:t.address}),e.jsxs("div",{style:{fontSize:l.w*.02,color:"#6B7280",marginBottom:l.w*.02},children:[t.city,", ",t.state," ",t.zip]}),e.jsxs("div",{style:{display:"flex",gap:l.w*.03,marginBottom:l.w*.02},children:[t.bedrooms>0&&e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:l.w*.035,fontWeight:700},children:t.bedrooms}),e.jsx("div",{style:{fontSize:l.w*.016,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.1em"},children:"Beds"})]}),t.bathrooms>0&&e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:l.w*.035,fontWeight:700},children:t.bathrooms}),e.jsx("div",{style:{fontSize:l.w*.016,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.1em"},children:"Baths"})]}),t.sqft>0&&e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:l.w*.035,fontWeight:700},children:t.sqft.toLocaleString()}),e.jsx("div",{style:{fontSize:l.w*.016,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.1em"},children:"Sq Ft"})]})]}),s==="open-house"&&e.jsx("div",{style:{background:`${g}10`,border:`2px solid ${g}`,borderRadius:l.w*.01,padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.022,fontWeight:700,color:g,display:"inline-block",marginBottom:l.w*.015},children:"SAT & SUN • 1–4 PM"}),e.jsx($Ss,{branding:n,dim:l,accentColor:g})]})]})});ict.displayName="ModernCleanTemplate";const qSs=({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})]})]}),oct=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var g;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,c=(g=t.photos)==null?void 0:g[a],u=bme[s],p={"just-listed":"linear-gradient(135deg, #059669, #10B981)","just-sold":"linear-gradient(135deg, #7C3AED, #A855F7)","open-house":"linear-gradient(135deg, #2563EB, #3B82F6)","price-drop":"linear-gradient(135deg, #DC2626, #F43F5E)"},f=[t.bedrooms?`${t.bedrooms} BD`:null,t.bathrooms?`${t.bathrooms} BA`:null,t.sqft?`${t.sqft.toLocaleString()} SF`:null].filter(Boolean).join(" | ");return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Arial Black', 'Helvetica Neue', sans-serif",color:"#FFFFFF"},children:[c&&e.jsx("img",{src:c,alt:"",crossOrigin:"anonymous",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.4)"}}),e.jsxs("div",{style:{position:"relative",height:"100%",display:"flex",flexDirection:"column",padding:l.w*.05},children:[e.jsx("div",{style:{background:p[s],padding:`${l.w*.025}px ${l.w*.04}px`,fontSize:l.w*.055,fontWeight:900,letterSpacing:"0.08em",alignSelf:"flex-start",borderRadius:l.w*.01,boxShadow:"0 8px 32px rgba(0,0,0,0.3)",transform:"rotate(-2deg)",marginBottom:l.w*.03},children:u}),e.jsx("div",{style:{flex:1}}),e.jsxs("div",{style:{background:"rgba(0,0,0,0.65)",backdropFilter:"blur(10px)",borderRadius:l.w*.015,padding:l.w*.04},children:[e.jsx("div",{style:{fontSize:l.w*.08,fontWeight:900,lineHeight:1,marginBottom:l.w*.01},children:IA(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(qSs,{branding:n,dim:l})]})]})]})});oct.displayName="BoldColorfulTemplate";const USs=({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})]})]}),lct=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var f;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,c=(f=t.photos)==null?void 0:f[a],u=bme[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:IA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.02,color:"#8B7355",marginBottom:l.w*.01},children:["Sold: ",IA(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(USs,{branding:n,dim:l})]}),e.jsxs("div",{style:{width:p?"100%":"58%",height:p?"60%":"100%",position:"relative",overflow:"hidden",order:p?1:2},children:[c&&e.jsx("img",{src:c,alt:"",crossOrigin:"anonymous",style:{width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:l.w*.02,border:"1px solid rgba(255,255,255,0.4)",pointerEvents:"none"}})]})]})})});lct.displayName="EditorialTemplate";const VSs=[{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:"📉"}],Oze=[{value:"instagram-square",label:"Instagram Post",dimensions:"1080×1080",icon:e.jsx(Mu,{className:"h-4 w-4"})},{value:"instagram-story",label:"Instagram Story",dimensions:"1080×1920",icon:e.jsx(Mu,{className:"h-4 w-4"})},{value:"facebook-post",label:"Facebook Post",dimensions:"1200×630",icon:e.jsx(Su,{className:"h-4 w-4"})}],HSs=[{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:"📰"}],Rze=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),Fze={"luxury-dark":act,"modern-clean":ict,"bold-colorful":oct,editorial:lct};function WSs(){const[t,s]=N.useState(""),[r,n]=N.useState("address"),[a,o]=N.useState(!1),[l,i]=N.useState([]),[c,u]=N.useState(null),[p,f]=N.useState(0),[g,b]=N.useState("just-listed"),[_,j]=N.useState(["instagram-square"]),[w,k]=N.useState("luxury-dark"),[S,M]=N.useState(!1),[L,I]=N.useState(""),[O,q]=N.useState(""),[U,B]=N.useState(""),[V,Z]=N.useState(!1),[X,ee]=N.useState(!1),[Q,ie]=N.useState([]),[re,oe]=N.useState("search"),ce=N.useRef({});N.useEffect(()=>{(async()=>{const{data:{user:Te}}=await H.auth.getUser();if(!Te)return;const{data:ke}=await H.from("profiles").select("name, avatar_url, brokerages(name)").eq("id",Te.id).single();if(ke){I(ke.name||""),B(ke.avatar_url||"");const Be=ke.brokerages;q((Be==null?void 0:Be.name)||"")}})()},[]);const xe=async()=>{var Oe;if(t.trim()){o(!0),i([]);try{const{data:Te,error:ke}=await H.functions.invoke("repliers-mls-search",{body:{searchType:r,query:t.trim()}});if(ke)throw ke;if(Te.error)throw new Error(Te.error);i(Te.listings||[]),((Oe=Te.listings)==null?void 0:Oe.length)===0&&me.info("No listings found. Try a different search.")}catch(Te){me.error(Te.message||"Search failed")}finally{o(!1)}}},ge=Oe=>{var Te;u(Oe),f(0),oe("customize"),Oe.soldDate||(Te=Oe.status)!=null&&Te.toLowerCase().includes("sold")?b("just-sold"):b("just-listed")},ue=Oe=>{j(Te=>Te.includes(Oe)?Te.filter(ke=>ke!==Oe):[...Te,Oe])},pe=N.useCallback(async()=>{if(!(!c||_.length===0)){Z(!0),ie([]),oe("generate");try{await new Promise(Te=>setTimeout(Te,500));const Oe=[];for(const Te of _){const ke=`${w}-${Te}`,Be=ce.current[ke];if(!Be)continue;const nt=t9[Te],Ae=await zSs(Be,{width:nt.width,height:nt.height,pixelRatio:1,cacheBust:!0,style:{transform:"none",transformOrigin:"top left"}});Oe.push({format:Te,imageUrl:Ae})}ie(Oe),me.success(`Generated ${Oe.length} social post${Oe.length>1?"s":""}!`)}catch(Oe){me.error(Oe.message||"Generation failed")}finally{Z(!1)}}},[c,_,w,p,S,L,O,U,g]),be=async()=>{if(!(!c||_.length===0)){Z(!0),ie([]),oe("generate");try{const Oe={...c,photos:c.photos.length>0?[c.photos[p]]:[]},Te=[];for(const ke of _){const{data:Be,error:nt}=await H.functions.invoke("generate-listing-social-post",{body:{listing:Oe,postType:g,format:ke,branding:S?{enabled:!0,agentName:L,brokerage:O}:{enabled:!1}}});if(nt)throw nt;if(Be.error)throw new Error(Be.error);Te.push({format:ke,imageUrl:Be.imageUrl})}ie(Te),me.success(`Generated ${Te.length} AI post${Te.length>1?"s":""}!`)}catch(Oe){me.error(Oe.message||"AI generation failed")}finally{Z(!1)}}},Me=()=>X?be():pe(),Ne=(Oe,Te)=>{var Be;const ke=document.createElement("a");ke.href=Oe,ke.download=`${((Be=c==null?void 0:c.address)==null?void 0:Be.replace(/\s+/g,"-"))||"listing"}-${g}-${Te}.png`,document.body.appendChild(ke),ke.click(),document.body.removeChild(ke)},Pe=c?{listing:c,postType:g,format:"instagram-square",branding:S?{enabled:!0,agentName:L,brokerage:O,agentPhotoUrl:U||void 0}:{enabled:!1},selectedPhotoIndex:p}:null;return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(oh,{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:()=>oe("search"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${re==="search"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"}`,children:[e.jsx(cn,{className:"h-3.5 w-3.5"})," 1. Find Listing"]}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("button",{onClick:()=>c&&oe("customize"),disabled:!c,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${re==="customize"?"bg-primary text-primary-foreground":c?"bg-muted text-muted-foreground hover:text-foreground":"bg-muted text-muted-foreground/50 cursor-not-allowed"}`,children:[e.jsx(pn,{className:"h-3.5 w-3.5"})," 2. Customize"]}),e.jsx(da,{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 ${re==="generate"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground/50"}`,children:[e.jsx(gl,{className:"h-3.5 w-3.5"})," 3. Generate"]})]}),re==="search"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(cn,{className:"h-5 w-5 text-primary"})," Search MLS Listings ",e.jsx(aXe,{})]}),e.jsx(gr,{children:"Find a listing by MLS number or property address using Repliers.io"})]}),e.jsxs(De,{className:"space-y-4",children:[e.jsx(ba,{value:r,onValueChange:Oe=>n(Oe),children:e.jsxs(pa,{children:[e.jsxs(ns,{value:"address",children:[e.jsx(ma,{className:"h-4 w-4 mr-1.5"})," Address"]}),e.jsxs(ns,{value:"mls",children:[e.jsx(Fm,{className:"h-4 w-4 mr-1.5"})," MLS #"]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:t,onChange:Oe=>s(Oe.target.value),placeholder:r==="mls"?"Enter MLS number...":"Enter property address...",className:"flex-1",onKeyDown:Oe=>Oe.key==="Enter"&&xe()}),e.jsxs(K,{onClick:xe,disabled:a||!t.trim(),children:[a?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(cn,{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((Oe,Te)=>{var ke;return e.jsx(Ee,{className:"cursor-pointer hover:border-primary/50 hover:shadow-md transition-all group",onClick:()=>ge(Oe),children:e.jsx(De,{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:(ke=Oe.photos)!=null&&ke[0]?e.jsx("img",{src:Oe.photos[0],alt:Oe.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(bn,{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:Rze(Oe.price)}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:Oe.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Oe.city,", ",Oe.state," ",Oe.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[Oe.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(K4,{className:"h-3 w-3"})," ",Oe.bedrooms]}),Oe.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Ju,{className:"h-3 w-3"})," ",Oe.bathrooms]}),Oe.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(oS,{className:"h-3 w-3"})," ",Oe.sqft.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(tt,{variant:"outline",className:"text-[10px]",children:Oe.mlsNumber}),e.jsx(tt,{variant:"outline",className:"text-[10px]",children:Oe.status})]})]})]})})},Oe.mlsNumber||Te)})})]})]}),re==="customize"&&c&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(Ee,{className:"lg:col-span-1",children:[e.jsx(Pt,{className:"pb-3",children:e.jsx(Rt,{className:"text-base",children:"Selected Listing"})}),e.jsxs(De,{className:"space-y-3",children:[c.photos.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[4/3] rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:c.photos[p],alt:"Listing photo",className:"w-full h-full object-cover"})}),c.photos.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(Oe=>Math.max(0,Oe-1)),disabled:p===0,children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p+1," of ",c.photos.length]}),e.jsx(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(Oe=>Math.min(c.photos.length-1,Oe+1)),disabled:p===c.photos.length-1,children:e.jsx(da,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg",children:Rze(c.price)}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.city,", ",c.state," ",c.zip]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[c.bedrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:c.bedrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Beds"})]}),c.bathrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:c.bathrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Baths"})]}),c.sqft>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:c.sqft.toLocaleString()}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Sq Ft"})]})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{oe("search"),u(null)},children:[e.jsx(u1,{className:"h-3.5 w-3.5 mr-1.5"})," Choose Different Listing"]})]})]}),e.jsxs(Ee,{className:"lg:col-span-2",children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(pn,{className:"h-5 w-5 text-primary"})," Customize Your Post"]}),e.jsx(gr,{children:"Choose template, post type, format, and branding"})]}),e.jsxs(De,{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(ac,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:X?"AI Custom Generation":"Template-Based (Free)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:X?"Uses AI credits for unique designs":"Instant, no credits used"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Use AI"}),e.jsx(qr,{checked:X,onCheckedChange:ee}),X&&e.jsx(Bv,{className:"h-4 w-4 text-purple-500"})]})]}),!X&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ac,{className:"h-4 w-4"})," Template Style"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:HSs.map(Oe=>e.jsxs("button",{onClick:()=>k(Oe.value),className:`flex flex-col items-center gap-1 px-3 py-3 rounded-lg border-2 transition-all text-center ${w===Oe.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-2xl",children:Oe.preview}),e.jsx("span",{className:"text-sm font-medium",children:Oe.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:Oe.description})]},Oe.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:VSs.map(Oe=>e.jsxs("button",{onClick:()=>b(Oe.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm font-medium ${g===Oe.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-lg",children:Oe.icon})," ",Oe.label]},Oe.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:Oze.map(Oe=>e.jsxs("button",{onClick:()=>ue(Oe.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm ${_.includes(Oe.value)?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[Oe.icon,e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium",children:Oe.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:Oe.dimensions})]})]},Oe.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(to,{className:"h-4 w-4"})," Agent Branding"]}),e.jsx(qr,{checked:S,onCheckedChange:M})]}),S&&e.jsxs("div",{className:"space-y-3 pl-6 border-l-2 border-primary/20",children:[U&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:U,alt:"Agent",className:"w-12 h-12 rounded-full object-cover border-2 border-primary/30"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Profile photo will appear on the post"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Agent Name"}),e.jsx(ze,{value:L,onChange:Oe=>I(Oe.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(ze,{value:O,onChange:Oe=>q(Oe.target.value),placeholder:"XYZ Realty"})]})]})]})]}),!X&&Pe&&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*(t9[_[0]||"instagram-square"].height/t9[_[0]||"instagram-square"].width)},children:(()=>{const Oe=Fze[w],Te=_[0]||"instagram-square";return e.jsx(Oe,{...Pe,format:Te})})()})})]}),e.jsx(K,{onClick:Me,disabled:_.length===0||V,size:"lg",className:"w-full gap-2",children:V?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-5 w-5 animate-spin"})," Generating ",_.length," post",_.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[X?e.jsx(Bv,{className:"h-5 w-5"}):e.jsx(pn,{className:"h-5 w-5"}),"Generate ",_.length," Social Post",_.length>1?"s":"",X&&e.jsx(tt,{variant:"outline",className:"ml-2 text-[10px]",children:"Uses Credits"})]})})]})]})]}),re==="generate"&&e.jsxs("div",{className:"space-y-4",children:[V&&e.jsx(Ee,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(ws,{className:"h-12 w-12 animate-spin text-primary mb-4"}),e.jsx("p",{className:"text-lg font-medium",children:"Generating your social posts..."}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:X?"AI is creating your unique designs":"Rendering templates to high-res images"})]})}),Q.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Generated Posts"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>oe("customize"),children:[e.jsx(u1,{className:"h-3.5 w-3.5 mr-1.5"})," Regenerate"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Q.map((Oe,Te)=>{const ke=Oze.find(Be=>Be.value===Oe.format);return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 p-1",children:e.jsx("img",{src:Oe.imageUrl,alt:`${Oe.format} social post`,className:"w-full rounded"})}),e.jsxs(De,{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:[ke==null?void 0:ke.icon,e.jsx("span",{className:"text-sm font-medium",children:ke==null?void 0:ke.label})]}),e.jsx(tt,{variant:"outline",className:"text-[10px]",children:ke==null?void 0:ke.dimensions})]}),e.jsxs(K,{size:"sm",className:"w-full gap-1.5",onClick:()=>Ne(Oe.imageUrl,Oe.format),children:[e.jsx(yi,{className:"h-3.5 w-3.5"})," Download"]})]})]},Te)})})]})]}),re==="generate"&&!X&&c&&Pe&&e.jsx("div",{style:{position:"absolute",left:"-9999px",top:0},"aria-hidden":!0,children:_.map(Oe=>{const Te=Fze[w],ke=t9[Oe];return e.jsx("div",{style:{width:ke.width,height:ke.height},children:e.jsx(Te,{ref:Be=>{ce.current[`${w}-${Oe}`]=Be},...Pe,format:Oe})},`${w}-${Oe}`)})})]})})}function GSs(){return mt({queryKey:["lms-courses-admin"],queryFn:async()=>{const{data:t,error:s}=await H.from("lms_courses").select("*, modules:lms_modules(count), access:lms_course_access(*)").order("sort_order");if(s)throw s;return t}})}function KSs(t){return mt({queryKey:["lms-course-admin",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("lms_courses").select("*, modules:lms_modules(*, resources:lms_module_resources(*)), access:lms_course_access(*)").eq("id",t).single();if(r)throw r;return s!=null&&s.modules&&(s.modules.sort((n,a)=>n.sort_order-a.sort_order),s.modules.forEach(n=>{n.resources&&n.resources.sort((a,o)=>a.sort_order-o.sort_order)})),s},enabled:!!t})}function ZSs(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("lms_courses").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function cct(){const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("lms_courses").update({...r,updated_at:new Date().toISOString()}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-courses"]}),t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-courses-admin"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function YSs(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("lms_courses").delete().eq("id",s);if(r)throw r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function XSs(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("lms_modules").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function QSs(){const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("lms_modules").update({...r,updated_at:new Date().toISOString()}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function JSs(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("lms_modules").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function eCs(){const t=Qt();return Dt({mutationFn:async s=>{const{data:r,error:n}=await H.from("lms_module_resources").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function tCs(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("lms_module_resources").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function sCs(){const t=Qt();return Dt({mutationFn:async({courseId:s,accessRules:r})=>{const{error:n}=await H.from("lms_course_access").delete().eq("course_id",s);if(n)throw n;if(r.length>0){const a=r.map(l=>({...l,course_id:s})),{error:o}=await H.from("lms_course_access").insert(a);if(o)throw o}},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-courses"]}),t.invalidateQueries({queryKey:["lms-course"]})}})}function rCs(){return mt({queryKey:["lms-courses-agent"],queryFn:async()=>{const{data:t,error:s}=await H.from("lms_courses").select("*, modules:lms_modules(id)").eq("is_published",!0).order("sort_order");if(s)throw s;return t}})}function nCs(t){return mt({queryKey:["lms-course-agent",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("lms_courses").select("*, modules:lms_modules(*, resources:lms_module_resources(*))").eq("id",t).single();if(r)throw r;return s!=null&&s.modules&&(s.modules.sort((n,a)=>n.sort_order-a.sort_order),s.modules.forEach(n=>{n.resources&&n.resources.sort((a,o)=>a.sort_order-o.sort_order)})),s},enabled:!!t})}function dct(t){return mt({queryKey:["lms-progress",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("lms_progress").select("*").eq("course_id",t);if(r)throw r;return s},enabled:!!t})}function aCs(){const t=Qt();return Dt({mutationFn:async({courseId:s,moduleId:r,userId:n})=>{const{data:a,error:o}=await H.from("lms_progress").upsert({user_id:n,course_id:s,module_id:r,completed:!0,completed_at:new Date().toISOString()},{onConflict:"user_id,module_id"}).select().single();if(o)throw o;return a},onSuccess:()=>t.invalidateQueries({queryKey:["lms-progress"]})})}function iCs(){const{user:t}=Ds(),s=fr(),{data:r,isLoading:n}=GSs(),a=ZSs(),o=cct(),l=YSs(),[i,c]=N.useState(!1),[u,p]=N.useState(""),[f,g]=N.useState(""),[b,_]=N.useState(!0),j=async()=>{if(!(!u.trim()||!t))try{const S=await a.mutateAsync({title:u.trim(),description:f.trim()||void 0,is_sequential:b,created_by:t.id});me.success("Course created"),c(!1),p(""),g(""),_(!0),s(`/admin/lms/${S.id}`)}catch{me.error("Failed to create course")}},w=async S=>{try{await o.mutateAsync({id:S.id,is_published:!S.is_published}),me.success(S.is_published?"Course unpublished":"Course published")}catch{me.error("Failed to update course")}},k=async S=>{if(confirm("Delete this course and all its modules? This cannot be undone."))try{await l.mutateAsync(S),me.success("Course deleted")}catch{me.error("Failed to delete")}};return e.jsxs(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(Kh,{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(No,{className:"h-4 w-4 mr-2"}),"Analytics"]}),e.jsxs(K,{onClick:()=>c(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"New Course"]})]})]}),n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:[1,2,3].map(S=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Pt,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-2"})]})},S))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:r.map(S=>{var O,q;const M=((q=(O=S.modules)==null?void 0:O[0])==null?void 0:q.count)??0,L=S.access||[],I=L.length===0?"No access set":L.some(U=>U.access_type==="all")?"All agents":`${L.length} rule(s)`;return e.jsxs(Ee,{className:"group hover:shadow-md transition-all hover:border-primary/50 cursor-pointer",onClick:()=>s(`/admin/lms/${S.id}`),children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-base truncate",children:S.title}),S.description&&e.jsx(gr,{className:"mt-1 line-clamp-2",children:S.description})]}),e.jsx(tt,{variant:S.is_published?"default":"secondary",className:"ml-2 shrink-0",children:S.is_published?"Published":"Draft"})]})}),e.jsxs(De,{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(Sh,{className:"h-3.5 w-3.5"}),M," module",M!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[S.is_sequential?e.jsx(m0,{className:"h-3.5 w-3.5"}):e.jsx(mS,{className:"h-3.5 w-3.5"}),S.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pr,{className:"h-3.5 w-3.5"}),I]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsxs(K,{size:"sm",variant:"ghost",onClick:U=>{U.stopPropagation(),w(S)},children:[S.is_published?e.jsx(kp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(On,{className:"h-3.5 w-3.5 mr-1"}),S.is_published?"Unpublish":"Publish"]}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:U=>{U.stopPropagation(),k(S.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"flex-1"}),e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground"})]})]})]},S.id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(Sh,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-1",children:"No courses yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"Create your first training course to get started"}),e.jsxs(K,{onClick:()=>c(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Create Course"]})]})})]}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create New Course"}),e.jsx(Gr,{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(ze,{value:u,onChange:S=>p(S.target.value),placeholder:"e.g. LevelUp Onboarding"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Er,{value:f,onChange:S=>g(S.target.value),placeholder:"What will agents learn?",rows:3})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order"})]}),e.jsx(qr,{checked:b,onCheckedChange:_})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{onClick:j,disabled:!u.trim()||a.isPending,children:a.isPending?"Creating...":"Create Course"})]})]})})]})}function oCs(){const{courseId:t}=yo(),s=fr(),{data:r,isLoading:n}=KSs(t),a=cct(),o=XSs(),l=QSs(),i=JSs(),c=eCs(),u=tCs(),p=sCs(),{data:f}=mt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:qe}=await H.from("brokerages").select("id, name").order("name");return qe||[]}}),[g,b]=N.useState(null),[_,j]=N.useState(!1),[w,k]=N.useState({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),[S,M]=N.useState(null),[L,I]=N.useState({title:"",resource_type:"link",url:""}),[O,q]=N.useState(new Set),[U,B]=N.useState(null),[V,Z]=N.useState(0),[X,ee]=N.useState(!1),Q=N.useRef(null),ie=N.useRef(null),[re,oe]=N.useState(!1),[ce,xe]=N.useState(""),[ge,ue]=N.useState(""),[pe,be]=N.useState(""),[Me,Ne]=N.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(Ja,{className:"h-4 w-4 mr-2"})," Back to Courses"]})]})});const Pe=r.modules||[],Oe=r.access||[],Te=Oe.some(qe=>qe.access_type==="all"),ke=Oe.filter(qe=>qe.access_type==="brokerage").map(qe=>qe.brokerage_id),Be=(f||[]).filter(qe=>qe.name.toLowerCase().includes(ce.toLowerCase())),nt=qe=>{const Ze=new Set(O);Ze.has(qe)?Ze.delete(qe):Ze.add(qe),q(Ze)},Ae=async()=>{if(!U)return null;ee(!0),Z(0);try{const{data:qe,error:Ze}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:U.name}});if(Ze)throw new Error(Ze.message);const{videoId:Qe,libraryId:He}=qe,{data:Je,error:it}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Qe,libraryId:He}});if(it)throw new Error(it.message);const Lt=new XMLHttpRequest;return await new Promise((Vt,hs)=>{Lt.upload.onprogress=Ts=>{Ts.lengthComputable&&Z(Math.round(Ts.loaded/Ts.total*100))},Lt.onload=()=>Lt.status>=200&&Lt.status<300?Vt():hs(new Error(`Upload failed: ${Lt.status}`)),Lt.onerror=()=>hs(new Error("Upload failed")),Lt.open("PUT",Je.uploadUrl),Lt.setRequestHeader("AccessKey",Je.apiKey),Lt.send(U)}),`https://iframe.mediadelivery.net/embed/${He}/${Qe}`}catch(qe){return console.error("Bunny upload error:",qe),me.error("Video upload failed"),null}finally{ee(!1),Z(0)}},ft=async()=>{if(w.title.trim())try{let qe=w.video_url.trim()||void 0;if(U){const Ze=await Ae();if(!Ze)return;qe=Ze}await o.mutateAsync({course_id:r.id,title:w.title.trim(),description:w.description.trim()||void 0,video_url:qe,text_content:w.text_content.trim()||void 0,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):void 0,sort_order:Pe.length}),me.success("Module added"),j(!1),k({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),B(null)}catch{me.error("Failed to add module")}},fe=async()=>{if(g)try{let qe=w.video_url.trim()||null;if(U){const Ze=await Ae();if(!Ze)return;qe=Ze}await l.mutateAsync({id:g.id,title:w.title.trim(),description:w.description.trim()||null,video_url:qe,text_content:w.text_content.trim()||null,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):null}),me.success("Module updated"),b(null),B(null)}catch{me.error("Failed to update")}},Ve=async qe=>{if(confirm("Delete this module?"))try{await i.mutateAsync(qe),me.success("Module deleted")}catch{me.error("Failed to delete")}},at=async qe=>{if(L.title.trim())try{await c.mutateAsync({module_id:qe,title:L.title.trim(),resource_type:L.resource_type,url:L.url.trim()||void 0}),me.success("Resource added"),M(null),I({title:"",resource_type:"link",url:""})}catch{me.error("Failed to add resource")}},et=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[{access_type:"all"}]}),me.success("Access updated: All brokerages / all agents")}catch{me.error("Failed to update access")}},Ce=async qe=>{const Ze=Oe.filter(it=>it.access_type==="brokerage").map(it=>it.brokerage_id),Qe=Ze.includes(qe);let He;Qe?He=Ze.filter(it=>it!==qe):He=[...Ze,qe];const Je=He.map(it=>({access_type:"brokerage",brokerage_id:it}));try{await p.mutateAsync({courseId:r.id,accessRules:Je}),me.success(Qe?"Brokerage removed":"Brokerage added")}catch{me.error("Failed to update access")}},rt=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[]}),me.success("Access cleared")}catch{me.error("Failed")}},Ge=async(qe,Ze)=>{const Qe=Ze==="up"?qe-1:qe+1;if(!(Qe<0||Qe>=Pe.length))try{await Promise.all([l.mutateAsync({id:Pe[qe].id,sort_order:Qe}),l.mutateAsync({id:Pe[Qe].id,sort_order:qe})])}catch{me.error("Failed to reorder")}},ct=async()=>{try{await a.mutateAsync({id:r.id,title:ge,description:pe||null}),me.success("Course updated"),Ne(!1)}catch{me.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(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:r.title}),e.jsx(tt,{variant:r.is_published?"default":"secondary",children:r.is_published?"Published":"Draft"})]}),r.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:r.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[r.is_sequential?e.jsx(m0,{className:"h-3.5 w-3.5"}):e.jsx(mS,{className:"h-3.5 w-3.5"}),r.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{children:[Pe.length," module",Pe.length!==1?"s":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{ue(r.title),be(r.description||""),Ne(!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(()=>me.success(r.is_published?"Unpublished":"Published")),children:[r.is_published?e.jsx(kp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(On,{className:"h-3.5 w-3.5 mr-1"}),r.is_published?"Unpublish":"Publish"]})]})]}),e.jsxs(ba,{defaultValue:"modules",className:"w-full",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"modules",children:"Modules"}),e.jsx(ns,{value:"access",children:"Access & Permissions"}),e.jsx(ns,{value:"settings",children:"Settings"})]}),e.jsxs(bs,{value:"modules",className:"mt-6 space-y-4",children:[Pe.map((qe,Ze)=>e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>nt(qe.id),children:[e.jsx("span",{className:"flex items-center gap-1 text-muted-foreground",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("button",{onClick:Qe=>{Qe.stopPropagation(),Ge(Ze,"up")},disabled:Ze===0,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(pf,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:Qe=>{Qe.stopPropagation(),Ge(Ze,"down")},disabled:Ze===Pe.length-1,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Eo,{className:"h-3.5 w-3.5"})})]})}),e.jsx(tt,{variant:"outline",className:"shrink-0 font-mono text-xs",children:Ze+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:qe.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[qe.video_url&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(An,{className:"h-3 w-3"})," Video"]}),qe.text_content&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Sn,{className:"h-3 w-3"})," Text"]}),qe.duration_minutes&&e.jsxs("span",{children:[qe.duration_minutes," min"]}),qe.resources&&qe.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(dl,{className:"h-3 w-3"})," ",qe.resources.length," resource(s)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:Qe=>{var He;Qe.stopPropagation(),b(qe),k({title:qe.title,description:qe.description||"",video_url:qe.video_url||"",text_content:qe.text_content||"",duration_minutes:((He=qe.duration_minutes)==null?void 0:He.toString())||""})},children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:Qe=>{Qe.stopPropagation(),Ve(qe.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]}),O.has(qe.id)&&e.jsxs("div",{className:"border-t bg-muted/30 p-4 space-y-3",children:[qe.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:qe.description}),qe.video_url&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Video: "}),e.jsx("a",{href:qe.video_url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:qe.video_url})]}),qe.text_content&&e.jsx("div",{className:"text-sm bg-background rounded-md p-3 border max-h-40 overflow-auto whitespace-pre-wrap",children:qe.text_content}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Resources"}),e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>{M(qe.id),I({title:"",resource_type:"link",url:""})},children:[e.jsx($s,{className:"h-3 w-3 mr-1"})," Add Resource"]})]}),qe.resources&&qe.resources.length>0?e.jsx("div",{className:"space-y-1",children:qe.resources.map(Qe=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-background rounded p-2 border",children:[e.jsx(tt,{variant:"outline",className:"text-[10px]",children:Qe.resource_type}),e.jsx("span",{className:"flex-1 truncate",children:Qe.title}),Qe.url&&e.jsx("a",{href:Qe.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(Qe.id),children:e.jsx(Rr,{className:"h-3 w-3"})})]},Qe.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No resources yet"})]})]})]},qe.id)),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{j(!0),k({title:"",description:"",video_url:"",text_content:"",duration_minutes:""})},children:[e.jsx($s,{className:"h-4 w-4 mr-2"})," Add Module"]})]}),e.jsx(bs,{value:"access",className:"mt-6 space-y-4",children:e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Who can access this course?"})}),e.jsxs(De,{className:"space-y-5",children:[e.jsxs("div",{className:It("flex items-center gap-3 p-4 rounded-xl border-2 cursor-pointer transition-all",Te?"border-primary bg-primary/5":"border-muted hover:border-muted-foreground/30"),onClick:et,children:[e.jsx("div",{className:It("h-10 w-10 rounded-full flex items-center justify-center shrink-0",Te?"bg-primary/15 text-primary":"bg-muted text-muted-foreground"),children:e.jsx(su,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold",children:"All Brokerages / All Agents"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Every agent on the platform can access this course"})]}),e.jsx(qr,{checked:Te,onCheckedChange:et})]}),!Te&&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:ke.length===0?"No brokerages selected — agents won't see this course":`${ke.length} brokerage${ke.length!==1?"s":""} selected`})]}),ke.length>0&&e.jsx(K,{size:"sm",variant:"ghost",className:"text-xs text-muted-foreground",onClick:rt,children:"Clear all"})]}),e.jsx(ze,{placeholder:"Search brokerages...",value:ce,onChange:qe=>xe(qe.target.value),className:"h-9"}),e.jsx("div",{className:"border rounded-lg divide-y max-h-[360px] overflow-auto",children:Be.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No brokerages found"}):Be.map(qe=>{const Ze=ke.includes(qe.id);return e.jsxs("div",{className:It("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors",Ze?"bg-primary/5":"hover:bg-muted/50"),onClick:()=>Ce(qe.id),children:[e.jsx("div",{className:It("h-5 w-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors",Ze?"bg-primary border-primary":"border-muted-foreground/30"),children:Ze&&e.jsx("svg",{className:"h-3 w-3 text-primary-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsx(ka,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:qe.name}),Ze&&e.jsx(tt,{variant:"secondary",className:"text-[10px] shrink-0",children:"Active"})]},qe.id)})})]})]})]})}),e.jsxs(bs,{value:"settings",className:"mt-6 space-y-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Course Thumbnail"})}),e.jsx(De,{children:e.jsxs("div",{className:"flex items-start gap-6",children:[r.thumbnail_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:r.thumbnail_url,alt:"Course thumbnail",className:"w-48 h-28 object-cover rounded-lg border"}),e.jsx("button",{onClick:()=>a.mutateAsync({id:r.id,thumbnail_url:null}).then(()=>me.success("Thumbnail removed")),className:"absolute -top-2 -right-2 bg-destructive text-destructive-foreground rounded-full p-1 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Rr,{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(a1,{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:ie,type:"file",accept:"image/*",className:"hidden",onChange:async qe=>{var Qe;const Ze=(Qe=qe.target.files)==null?void 0:Qe[0];if(!(!Ze||!r)){oe(!0);try{const He=Ze.name.split(".").pop(),Je=`${r.id}/thumbnail.${He}`,{error:it}=await H.storage.from("lms-thumbnails").upload(Je,Ze,{upsert:!0});if(it)throw it;const{data:Lt}=H.storage.from("lms-thumbnails").getPublicUrl(Je),Vt=`${Lt.publicUrl}?t=${Date.now()}`;await a.mutateAsync({id:r.id,thumbnail_url:Vt}),me.success("Thumbnail uploaded")}catch{me.error("Failed to upload thumbnail")}finally{oe(!1),ie.current&&(ie.current.value="")}}}}),e.jsxs(K,{variant:"outline",size:"sm",disabled:re,onClick:()=>{var qe;return(qe=ie.current)==null?void 0:qe.click()},children:[re?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(li,{className:"h-4 w-4 mr-2"}),re?"Uploading...":"Upload Thumbnail"]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Course Settings"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order before advancing"})]}),e.jsx(qr,{checked:r.is_sequential,onCheckedChange:qe=>a.mutateAsync({id:r.id,is_sequential:qe}).then(()=>me.success("Updated"))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this course visible to agents with access"})]}),e.jsx(qr,{checked:r.is_published,onCheckedChange:qe=>a.mutateAsync({id:r.id,is_published:qe}).then(()=>me.success("Updated"))})]})]})]})]})]})]}),e.jsx(fs,{open:_||!!g,onOpenChange:qe=>{qe||(j(!1),b(null))},children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:g?"Edit Module":"Add Module"}),e.jsx(Gr,{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(ze,{value:w.title,onChange:qe=>k(Ze=>({...Ze,title:qe.target.value})),placeholder:"Module title"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Er,{value:w.description,onChange:qe=>k(Ze=>({...Ze,description:qe.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:It("border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors hover:border-primary/50",U?"border-primary bg-primary/5":"border-muted-foreground/25"),onClick:()=>{var qe;return(qe=Q.current)==null?void 0:qe.click()},children:[e.jsx("input",{ref:Q,type:"file",accept:"video/*",className:"hidden",onChange:qe=>{var Qe;const Ze=(Qe=qe.target.files)==null?void 0:Qe[0];Ze&&(B(Ze),k(He=>({...He,video_url:""})))}}),U?e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm",children:[e.jsx(An,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-primary",children:U.name}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:qe=>{qe.stopPropagation(),B(null)},children:e.jsx(Rr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"flex flex-col items-center gap-1 text-muted-foreground",children:[e.jsx(li,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Click to upload a video file"})]})]}),X&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(ws,{className:"h-3.5 w-3.5 animate-spin"}),e.jsxs("span",{children:["Uploading to Bunny.net... ",V,"%"]})]}),e.jsx(Bi,{value:V,className:"h-1.5"})]}),!U&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("div",{className:"flex-1 h-px bg-border"}),e.jsx("span",{children:"or paste a URL"}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx(ze,{value:w.video_url,onChange:qe=>k(Ze=>({...Ze,video_url:qe.target.value})),placeholder:"YouTube, Vimeo, or Bunny.net URL"})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Text Content"}),e.jsx(Er,{value:w.text_content,onChange:qe=>k(Ze=>({...Ze,text_content:qe.target.value})),placeholder:"Additional text content, instructions, notes...",rows:4})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Duration (minutes)"}),e.jsx(ze,{type:"number",value:w.duration_minutes,onChange:qe=>k(Ze=>({...Ze,duration_minutes:qe.target.value})),placeholder:"e.g. 15"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{j(!1),b(null),B(null)},children:"Cancel"}),e.jsxs(K,{onClick:g?fe:ft,disabled:!w.title.trim()||X,children:[X?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(qc,{className:"h-4 w-4 mr-2"}),X?"Uploading...":g?"Save Changes":"Add Module"]})]})]})}),e.jsx(fs,{open:!!S,onOpenChange:qe=>{qe||M(null)},children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Add Resource"}),e.jsx(Gr,{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(ze,{value:L.title,onChange:qe=>I(Ze=>({...Ze,title:qe.target.value})),placeholder:"Resource title"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Type"}),e.jsxs(Zs,{value:L.resource_type,onValueChange:qe=>I(Ze=>({...Ze,resource_type:qe})),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"link",children:"Link"}),e.jsx(Mt,{value:"pdf",children:"PDF"}),e.jsx(Mt,{value:"template",children:"Template"}),e.jsx(Mt,{value:"worksheet",children:"Worksheet"})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"URL"}),e.jsx(ze,{value:L.url,onChange:qe=>I(Ze=>({...Ze,url:qe.target.value})),placeholder:"https://..."})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>M(null),children:"Cancel"}),e.jsx(K,{onClick:()=>S&&at(S),disabled:!L.title.trim(),children:"Add Resource"})]})]})}),e.jsx(fs,{open:Me,onOpenChange:Ne,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Edit Course"}),e.jsx(Gr,{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(ze,{value:ge,onChange:qe=>ue(qe.target.value)})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Er,{value:pe,onChange:qe=>be(qe.target.value),rows:3})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Ne(!1),children:"Cancel"}),e.jsx(K,{onClick:ct,disabled:!ge.trim(),children:"Save"})]})]})})]})}function lCs(){return mt({queryKey:["lms-stats-overview"],queryFn:async()=>{const{data:t,error:s}=await H.rpc("get_lms_stats");if(s)throw s;return t}})}function cCs(){return mt({queryKey:["lms-stats-courses"],queryFn:async()=>{const{data:t,error:s}=await H.rpc("get_lms_course_stats");if(s)throw s;return t||[]}})}function dCs(t){return mt({queryKey:["lms-stats-agents",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.rpc("get_lms_agent_progress",{p_course_id:t});if(r)throw r;return s||[]},enabled:!!t})}function uCs(){const t=fr(),{data:s,isLoading:r}=lCs(),{data:n,isLoading:a}=cCs(),[o,l]=N.useState(null),{data:i,isLoading:c}=dCs(o),[u,p]=N.useState(""),f=n==null?void 0:n.find(_=>_.course_id===o),g=i==null?void 0:i.filter(_=>{var j,w;return!u||((j=_.agent_name)==null?void 0:j.toLowerCase().includes(u.toLowerCase()))||((w=_.email)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))}),b=[{label:"Total Courses",value:(s==null?void 0:s.total_courses)??0,icon:Sh,color:"text-primary"},{label:"Published",value:(s==null?void 0:s.published_courses)??0,icon:sa,color:"text-emerald-500"},{label:"Enrolled Agents",value:(s==null?void 0:s.total_enrollments)??0,icon:pr,color:"text-blue-500"},{label:"Modules Completed",value:(s==null?void 0:s.total_completions)??0,icon:xo,color:"text-amber-500"},{label:"Active (30d)",value:(s==null?void 0:s.active_learners)??0,icon:ul,color:"text-violet-500"},{label:"Total Modules",value:(s==null?void 0:s.total_modules)??0,icon:No,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(Ja,{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(Kh,{className:"h-7 w-7 text-primary"}),"LevelUp U — Analytics"]}),e.jsx("p",{className:"text-muted-foreground text-sm mt-0.5",children:"Track enrollment, progress, and completion across all courses"})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-6 gap-3",children:b.map(_=>e.jsx(Ee,{className:It("transition-all",r&&"animate-pulse"),children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(_.icon,{className:It("h-4 w-4",_.color)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:_.label})]}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:r?"—":_.value})]})},_.label))}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-5 gap-6",children:[e.jsxs("div",{className:"xl:col-span-2 space-y-3",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(No,{className:"h-5 w-5 text-primary"}),"Course Breakdown"]}),a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(_=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(De,{className:"p-4",children:e.jsx("div",{className:"h-16 bg-muted rounded"})})},_))}):n!=null&&n.length?e.jsx("div",{className:"space-y-2",children:n.map(_=>{const j=o===_.course_id;return e.jsx(Ee,{className:It("cursor-pointer transition-all hover:shadow-md",j?"border-primary ring-1 ring-primary/30 shadow-md":"hover:border-primary/40"),onClick:()=>l(j?null:_.course_id),children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-semibold text-sm text-foreground truncate",children:_.course_title}),e.jsx(tt,{variant:_.is_published?"default":"secondary",className:"shrink-0 text-[10px] px-1.5 py-0",children:_.is_published?"Live":"Draft"})]})}),e.jsx(da,{className:It("h-4 w-4 text-muted-foreground transition-transform shrink-0 ml-2",j&&"rotate-90")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:_.enrolled_agents}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Enrolled"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:_.total_completions}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Completed"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:_.total_modules}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Modules"})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Avg. Completion"}),e.jsxs("span",{className:"font-semibold text-foreground",children:[_.avg_completion_pct,"%"]})]}),e.jsx(Bi,{value:_.avg_completion_pct,className:"h-2"})]})]})},_.course_id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(De,{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(W_,{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(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:u,onChange:_=>p(_.target.value),placeholder:"Search agents...",className:"pl-9"})]}),c?e.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(_=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(De,{className:"p-4",children:e.jsx("div",{className:"h-12 bg-muted rounded"})})},_))}):g!=null&&g.length?e.jsx("div",{className:"space-y-2 max-h-[600px] overflow-y-auto pr-1",children:g.map((_,j)=>{const w=_.completion_pct>=100;return e.jsx(Ee,{className:It("transition-all",w&&"border-emerald-200 bg-emerald-50/30 dark:border-emerald-900/40 dark:bg-emerald-950/10"),children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:It("flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold shrink-0",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(Nn,{className:"h-9 w-9 shrink-0",children:[e.jsx($a,{src:_.avatar_url||void 0}),e.jsx(kn,{className:"text-xs bg-primary/10 text-primary",children:(_.agent_name||_.email||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:_.agent_name||_.email}),w&&e.jsxs(tt,{variant:"default",className:"text-[10px] px-1.5 py-0 bg-emerald-500 hover:bg-emerald-600 shrink-0",children:[e.jsx(sa,{className:"h-3 w-3 mr-0.5"})," Complete"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-muted-foreground mt-0.5",children:[e.jsxs("span",{children:[_.modules_completed,"/",_.total_modules," modules"]}),_.last_activity&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(_.last_activity),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"text-right shrink-0 w-20",children:[e.jsxs("p",{className:It("text-sm font-bold",w?"text-emerald-600 dark:text-emerald-400":"text-foreground"),children:[_.completion_pct,"%"]}),e.jsx(Bi,{value:_.completion_pct,className:"h-1.5 mt-1"})]})]})})},_.user_id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(De,{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(De,{className:"py-16 text-center",children:[e.jsx(pr,{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 hCs(){const{user:t}=Ds(),s=fr(),{data:r,isLoading:n}=rCs();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(Kh,{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(De,{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(mCs,{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(De,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(Sh,{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 mCs({course:t,userId:s,onClick:r}){var i;const n=((i=t.modules)==null?void 0:i.length)??0,{data:a}=dct(t.id),o=(a==null?void 0:a.filter(c=>c.completed).length)??0,l=n>0?Math.round(o/n*100):0;return e.jsxs(Ee,{className:"group cursor-pointer hover:shadow-lg transition-all hover:border-primary/50 overflow-hidden",onClick:r,children:[t.thumbnail_url?e.jsx("div",{className:"aspect-video bg-muted overflow-hidden",children:e.jsx("img",{src:t.thumbnail_url,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"})}):e.jsx("div",{className:"aspect-video bg-gradient-to-br from-primary/15 via-primary/5 to-muted flex items-center justify-center",children:e.jsx(Kh,{className:"h-10 w-10 text-primary/40"})}),e.jsxs(De,{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(Sh,{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(m0,{className:"h-3.5 w-3.5"}):e.jsx(mS,{className:"h-3.5 w-3.5"}),t.is_sequential?"In order":"Any order"]})]}),n>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground",children:[o," of ",n," completed"]}),e.jsxs("span",{className:"font-medium text-foreground",children:[l,"%"]})]}),e.jsx(Bi,{value:l,className:"h-1.5"})]}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs("span",{className:"text-xs text-primary font-medium flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[l===100?"Review":l>0?"Continue":"Start"," Course",e.jsx(da,{className:"h-3.5 w-3.5"})]})})]})]})}function pCs(){const{courseId:t}=yo(),s=fr(),{user:r}=Ds(),{data:n,isLoading:a}=nCs(t),{data:o}=dct(t),l=aCs(),[i,c]=N.useState(null),u=(n==null?void 0:n.modules)||[],p=new Set((o==null?void 0:o.filter(S=>S.completed).map(S=>S.module_id))||[]),f=p.size,g=u.length>0?Math.round(f/u.length*100):0;N.useEffect(()=>{if(u.length>0&&!i){const S=u.find(M=>!p.has(M.id));c((S==null?void 0:S.id)||u[0].id)}},[u,i,p]);const b=u.find(S=>S.id===i),_=u.findIndex(S=>S.id===i),j=(S,M)=>{if(!(n!=null&&n.is_sequential)||M===0)return!1;for(let L=0;L{if(!(!b||!r||!t))try{await l.mutateAsync({courseId:t,moduleId:b.id,userId:r.id}),me.success("Module completed! 🎉"),_{const M=S.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(M)return`https://www.youtube.com/embed/${M[1]}`;const L=S.match(/vimeo\.com\/(\d+)/);if(L)return`https://player.vimeo.com/video/${L[1]}`;const I=S.match(/(?:iframe\.mediadelivery\.net|video\.bunnycdn\.com)\/(?:play|embed)\/(\d+)\/([a-f0-9-]+)/);return I?`https://iframe.mediadelivery.net/embed/${I[1]}/${I[2]}?responsive=true`:S};return a?e.jsx(Ms,{title:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):n?e.jsx(Ms,{title:n.title,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/levelup-u"),children:e.jsx(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h1",{className:"text-xl font-bold text-foreground truncate",children:n.title}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("span",{children:[f,"/",u.length," completed"]}),e.jsxs("span",{children:[g,"%"]})]})]}),e.jsx("div",{className:"w-32",children:e.jsx(Bi,{value:g,className:"h-2"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[320px_1fr] gap-4 items-start",children:[e.jsx(Ee,{className:"lg:sticky lg:top-4",children:e.jsxs(De,{className:"p-0",children:[e.jsx("div",{className:"p-3 border-b",children:e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Modules"})}),e.jsx(Gi,{className:"max-h-[calc(100vh-280px)]",children:e.jsx("div",{className:"p-1",children:u.map((S,M)=>{const L=j(S,M),I=p.has(S.id),O=S.id===i;return e.jsxs("button",{disabled:L,onClick:()=>!L&&c(S.id),className:It("w-full flex items-center gap-3 p-3 rounded-lg text-left transition-all text-sm",O?"bg-primary/10 text-primary":"hover:bg-muted/50",L&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"shrink-0",children:L?e.jsx(Th,{className:"h-4 w-4 text-muted-foreground"}):I?e.jsx(sa,{className:"h-4 w-4 text-green-500"}):e.jsx(bd,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:It("font-medium truncate",O&&"text-primary"),children:[M+1,". ",S.title]}),S.duration_minutes&&e.jsxs("span",{className:"text-[11px] text-muted-foreground flex items-center gap-0.5 mt-0.5",children:[e.jsx(un,{className:"h-3 w-3"})," ",S.duration_minutes," min"]})]})]},S.id)})})})]})}),e.jsx("div",{className:"space-y-4",children:b?e.jsxs(e.Fragment,{children:[b.video_url&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-video bg-black",children:e.jsx("iframe",{src:k(b.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(De,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:b.title}),b.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:b.description})]}),p.has(b.id)?e.jsxs(tt,{className:"bg-green-500/15 text-green-600 border-green-500/30 shrink-0",children:[e.jsx(sa,{className:"h-3.5 w-3.5 mr-1"})," Completed"]}):e.jsxs(K,{size:"sm",onClick:w,disabled:l.isPending,children:[e.jsx(sa,{className:"h-4 w-4 mr-1"}),"Mark Complete"]})]}),b.text_content&&e.jsx("div",{className:"prose prose-sm max-w-none text-foreground border-t pt-4 whitespace-pre-wrap",children:b.text_content}),b.resources&&b.resources.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Resources"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:b.resources.map(S=>e.jsxs("a",{href:S.url||S.file_url||"#",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-sm",children:[S.resource_type==="pdf"?e.jsx(Sn,{className:"h-4 w-4 text-red-500 shrink-0"}):S.resource_type==="template"?e.jsx(Kh,{className:"h-4 w-4 text-purple-500 shrink-0"}):e.jsx(dl,{className:"h-4 w-4 text-blue-500 shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:S.title}),e.jsx(tn,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]},S.id))})]}),e.jsxs("div",{className:"flex items-center justify-between border-t pt-4",children:[e.jsxs(K,{variant:"outline",size:"sm",disabled:_===0,onClick:()=>_>0&&c(u[_-1].id),children:[e.jsx(Ja,{className:"h-3.5 w-3.5 mr-1"})," Previous"]}),_c(u[_+1].id),children:["Next ",e.jsx(da,{className:"h-3.5 w-3.5 ml-1"})]}):g===100&&e.jsx(tt,{className:"bg-green-500/15 text-green-600 border-green-500/30 text-sm px-3 py-1.5",children:"🎉 Course Complete!"})]})]})})]}):e.jsx(Ee,{children:e.jsx(De,{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(Ja,{className:"h-4 w-4 mr-2"})," Back"]})]})})}function fCs({headline:t,subtext:s,primaryColor:r,accentColor:n,heroImageUrl:a,logoUrl:o,brokerageName:l}){return e.jsxs("section",{className:"relative min-h-screen flex items-center justify-center overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0",style:{background:`linear-gradient(160deg, ${n} 0%, ${r} 50%, ${n}ee 100%)`}}),a&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center opacity-20",style:{backgroundImage:`url(${a})`}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(circle at 25% 25%, white 1px, transparent 1px), radial-gradient(circle at 75% 75%, white 1px, transparent 1px)",backgroundSize:"60px 60px"}}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-32 bg-gradient-to-t from-white to-transparent"}),e.jsxs("div",{className:"relative z-10 text-center max-w-4xl mx-auto px-6 py-24",children:[o&&e.jsx(Hs.img,{src:o,alt:l,className:"h-14 md:h-20 w-auto mx-auto mb-10 drop-shadow-2xl",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.8,delay:.2}}),e.jsx(Hs.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,delay:.3},children:e.jsx("span",{className:"inline-block text-white/70 text-sm md:text-base font-medium tracking-[0.2em] uppercase mb-6",children:"Your Next Chapter Starts Here"})}),e.jsx(Hs.h1,{className:"text-4xl md:text-6xl lg:text-7xl font-bold text-white mb-8 leading-[1.1] tracking-tight",initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:.9,delay:.5},children:t}),e.jsx(Hs.p,{className:"text-lg md:text-xl text-white/80 mb-12 max-w-2xl mx-auto leading-relaxed font-light",initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,delay:.7},children:s}),e.jsxs(Hs.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.7,delay:.9},className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsxs("a",{href:"#apply",className:"group inline-flex items-center gap-3 px-10 py-4 rounded-full text-lg font-semibold shadow-2xl transition-all duration-300 hover:scale-105 hover:shadow-3xl",style:{backgroundColor:"white",color:n},children:["Get In Touch",e.jsx(Qa,{className:"h-5 w-5 transition-transform group-hover:translate-x-1"})]}),e.jsx("a",{href:"#benefits",className:"inline-flex items-center gap-2 px-8 py-4 rounded-full text-base font-medium text-white/90 border border-white/30 backdrop-blur-sm transition-all duration-300 hover:bg-white/10 hover:border-white/50",children:"Learn More"})]})]}),e.jsx(Hs.div,{className:"absolute bottom-8 left-1/2 -translate-x-1/2 z-10",animate:{y:[0,8,0]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},children:e.jsx("div",{className:"w-6 h-10 border-2 border-white/40 rounded-full flex justify-center pt-2",children:e.jsx("div",{className:"w-1.5 h-3 bg-white/60 rounded-full"})})})]})}function bw({children:t,className:s="",delay:r=0,direction:n="up"}){const a=N.useRef(null),o=_Et(a,{once:!0,margin:"-80px"}),l={hidden:{opacity:0,y:n==="up"?40:0,x:n==="left"?-40:n==="right"?40:0},visible:{opacity:1,y:0,x:0}};return e.jsx(Hs.div,{ref:a,initial:"hidden",animate:o?"visible":"hidden",variants:l,transition:{duration:.7,delay:r,ease:[.25,.46,.45,.94]},className:s,children:t})}function xCs({benefits:t,accentColor:s,primaryColor:r}){return t.length===0?null:e.jsx("section",{id:"benefits",className:"py-24 md:py-32 px-6 bg-white",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx(bw,{children:e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("span",{className:"text-sm font-semibold tracking-[0.15em] uppercase mb-4 block",style:{color:r},children:"Why Top Agents Choose Us"}),e.jsx("h2",{className:"text-3xl md:text-5xl font-bold mb-4 tracking-tight",style:{color:s},children:"Built For Your Success"}),e.jsx("div",{className:"w-16 h-1 mx-auto rounded-full mt-6",style:{backgroundColor:r}})]})}),e.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-8",children:t.map((n,a)=>e.jsx(bw,{delay:a*.1,children:e.jsxs("div",{className:"group relative p-8 rounded-2xl border border-gray-100 bg-white hover:border-transparent hover:shadow-2xl transition-all duration-500 h-full",children:[e.jsx("div",{className:"absolute inset-0 rounded-2xl opacity-0 group-hover:opacity-100 transition-opacity duration-500",style:{background:`linear-gradient(135deg, ${r}08, ${s}05)`}}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl flex items-center justify-center text-2xl mb-5 transition-transform duration-300 group-hover:scale-110",style:{backgroundColor:`${r}12`},children:n.icon}),e.jsx("h3",{className:"text-xl font-bold mb-3 tracking-tight",style:{color:s},children:n.title}),e.jsx("p",{className:"text-gray-500 leading-relaxed text-[15px]",children:n.description})]})]})},a))})]})})}function gCs({images:t,primaryColor:s,accentColor:r}){const[n,a]=N.useState(null);return t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("section",{className:"py-24 md:py-32 px-6 bg-gray-50",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx(bw,{children:e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white border border-gray-200 mb-6",children:[e.jsx(pr,{className:"h-4 w-4",style:{color:s}}),e.jsx("span",{className:"text-sm font-medium text-gray-600",children:"Life at Our Brokerage"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl font-bold tracking-tight",style:{color:r},children:"Our Team & Culture"})]})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3 md:gap-4",children:t.map((o,l)=>e.jsx(bw,{delay:l*.08,children:e.jsxs("button",{onClick:()=>a(l),className:"relative w-full aspect-[4/3] overflow-hidden rounded-xl group cursor-pointer",children:[e.jsx("img",{src:o,alt:`Team ${l+1}`,className:"w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-all duration-500"})]})},l))})]})}),n!==null&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/90 flex items-center justify-center p-4 cursor-pointer",onClick:()=>a(null),children:[e.jsx("button",{onClick:()=>a(null),className:"absolute top-6 right-6 text-white/80 hover:text-white transition-colors",children:e.jsx(Rr,{className:"h-8 w-8"})}),e.jsx("img",{src:t[n],alt:"Gallery",className:"max-w-full max-h-[85vh] object-contain rounded-lg",onClick:o=>o.stopPropagation()})]})]})}function yCs({testimonials:t,primaryColor:s,accentColor:r}){return t.length===0?null:e.jsx("section",{className:"py-24 md:py-32 px-6 bg-white",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx(bw,{children:e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("span",{className:"text-sm font-semibold tracking-[0.15em] uppercase mb-4 block",style:{color:s},children:"Agent Testimonials"}),e.jsx("h2",{className:"text-3xl md:text-5xl font-bold tracking-tight",style:{color:r},children:"Hear From Our Agents"}),e.jsx("div",{className:"w-16 h-1 mx-auto rounded-full mt-6",style:{backgroundColor:s}})]})}),e.jsx("div",{className:"grid md:grid-cols-2 gap-8",children:t.map((n,a)=>{var o;return e.jsx(bw,{delay:a*.15,direction:a%2===0?"left":"right",children:e.jsxs("div",{className:"relative p-8 md:p-10 rounded-2xl bg-gray-50 border border-gray-100 h-full",children:[e.jsx(V_,{className:"h-8 w-8 mb-5 opacity-20",style:{color:s}}),e.jsxs("p",{className:"text-gray-700 text-lg leading-relaxed mb-8 font-light italic",children:['"',n.quote,'"']}),e.jsxs("div",{className:"flex items-center gap-4",children:[n.photo_url?e.jsx("img",{src:n.photo_url,alt:n.name,className:"h-12 w-12 rounded-full object-cover ring-2 ring-white shadow-md"}):e.jsx("div",{className:"h-12 w-12 rounded-full flex items-center justify-center text-white text-base font-bold shadow-md",style:{background:`linear-gradient(135deg, ${s}, ${r})`},children:((o=n.name)==null?void 0:o[0])||"?"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-base",style:{color:r},children:n.name}),n.role&&e.jsx("p",{className:"text-sm text-gray-500",children:n.role})]})]})]})},a)})})]})})}function vCs({form:t,setForm:s,onSubmit:r,isPending:n,primaryColor:a,accentColor:o}){return e.jsxs("section",{id:"apply",className:"py-24 md:py-32 px-6 relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 top-0 h-1/2",style:{background:`linear-gradient(160deg, ${o}, ${a})`}}),e.jsx("div",{className:"absolute inset-0 top-1/2 bg-gray-50"}),e.jsxs("div",{className:"relative z-10 max-w-xl mx-auto",children:[e.jsx(bw,{children:e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-3 tracking-tight",children:"Want to Learn More?"}),e.jsx("p",{className:"text-white/70 text-lg font-light",children:"Drop your info below and we'll share more about what makes us different."})]})}),e.jsx(bw,{delay:.2,children:e.jsxs("form",{onSubmit:l=>{l.preventDefault(),r()},className:"bg-white rounded-3xl shadow-2xl p-8 md:p-10 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-gray-700 text-sm font-medium",children:"First Name *"}),e.jsx(ze,{required:!0,value:t.first_name,onChange:l=>s(i=>({...i,first_name:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"John"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-gray-700 text-sm font-medium",children:"Last Name"}),e.jsx(ze,{value:t.last_name,onChange:l=>s(i=>({...i,last_name:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"Smith"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-gray-700 text-sm font-medium",children:"Email *"}),e.jsx(ze,{type:"email",required:!0,value:t.email,onChange:l=>s(i=>({...i,email:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"john@email.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-gray-700 text-sm font-medium",children:"Phone"}),e.jsx(ze,{value:t.phone,onChange:l=>s(i=>({...i,phone:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-gray-700 text-sm font-medium",children:"Current Brokerage"}),e.jsx(ze,{value:t.current_brokerage,onChange:l=>s(i=>({...i,current_brokerage:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"Your current brokerage name"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-gray-700 text-sm font-medium",children:"License #"}),e.jsx(ze,{value:t.license_number,onChange:l=>s(i=>({...i,license_number:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-gray-700 text-sm font-medium",children:"Years Experience"}),e.jsx(ze,{type:"number",min:"0",value:t.experience_years,onChange:l=>s(i=>({...i,experience_years:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-gray-700 text-sm font-medium",children:"Annual Production"}),e.jsx(ze,{value:t.annual_production,onChange:l=>s(i=>({...i,annual_production:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"e.g. $5M, 20 transactions"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-gray-700 text-sm font-medium",children:"Why are you interested?"}),e.jsx(Er,{value:t.why_interested,onChange:l=>s(i=>({...i,why_interested:l.target.value})),rows:3,className:"rounded-lg border-gray-200 focus:border-gray-400 transition-colors resize-none",placeholder:"Tell us about your goals and what you're looking for..."})]}),e.jsx(K,{type:"submit",className:"w-full h-13 text-base font-semibold rounded-xl group transition-all duration-300 hover:shadow-lg",style:{background:`linear-gradient(135deg, ${a}, ${o})`},disabled:n,children:n?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),"Submitting..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Send My Info",e.jsx(Qa,{className:"h-4 w-4 transition-transform group-hover:translate-x-1"})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-gray-400 pt-1",children:[e.jsx(th,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Your information is confidential and will not be shared."})]})]})})]})]})}function bCs(){const{slug:t}=yo(),{toast:s}=Ua(),[r,n]=N.useState(!1),[a,o]=N.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",experience_years:"",annual_production:"",license_number:"",why_interested:""}),{data:l,isLoading:i,error:c}=mt({queryKey:["recruit-form-brokerage",t],queryFn:async()=>{const{data:M,error:L}=await H.from("brokerages").select("id, name, recruit_form_enabled").eq("recruit_form_slug",t).single();if(L)throw L;return M},enabled:!!t}),{data:u}=mt({queryKey:["recruit-landing-public",l==null?void 0:l.id],queryFn:async()=>{const{data:M,error:L}=await H.from("recruit_landing_page_settings").select("*").eq("brokerage_id",l.id).single();if(L&&L.code!=="PGRST116")throw L;return M},enabled:!!(l!=null&&l.id)}),p=Dt({mutationFn:async()=>{const M={brokerage_id:l.id,first_name:a.first_name,last_name:a.last_name||null,email:a.email,phone:a.phone||null,current_brokerage:a.current_brokerage||null,experience_years:a.experience_years?parseInt(a.experience_years):null,annual_production:a.annual_production||null,license_number:a.license_number||null,why_interested:a.why_interested||null},{error:L}=await H.from("recruit_interest_submissions").insert(M);if(L)throw L;H.functions.invoke("recruit-lead-notify",{body:{lead:M,brokerage_id:l.id}}).catch(I=>console.error("Lead notification error:",I))},onSuccess:()=>n(!0),onError:M=>s({title:"Error",description:M.message,variant:"destructive"})});if(i)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-3 border-gray-200 border-t-gray-800"}),e.jsx("span",{className:"text-sm text-gray-400 tracking-wide",children:"Loading..."})]})});if(c||!l||!l.recruit_form_enabled)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs("div",{className:"max-w-md w-full mx-4 text-center",children:[e.jsx(ka,{className:"h-10 w-10 mx-auto text-gray-300 mb-4"}),e.jsx("p",{className:"text-gray-400 text-lg",children:"This page is not available."})]})});const f=u,g=(f==null?void 0:f.primary_color)||"#406E71",b=(f==null?void 0:f.accent_color)||"#2a4c64",_=(f==null?void 0:f.benefits)||[],j=(f==null?void 0:f.testimonials)||[],w=(f==null?void 0:f.gallery_images)||[],k=(f==null?void 0:f.hero_headline)||`Join ${l.name}`,S=(f==null?void 0:f.hero_subtext)||"Take your real estate career to the next level with a brokerage that invests in your growth.";return r?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs(Hs.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{duration:.6},className:"max-w-md w-full mx-4 text-center",children:[e.jsx("div",{className:"h-20 w-20 rounded-full flex items-center justify-center mx-auto mb-6 shadow-lg",style:{background:`linear-gradient(135deg, ${g}, ${b})`},children:e.jsx(va,{className:"h-10 w-10 text-white"})}),e.jsx("h2",{className:"text-3xl font-bold mb-3 tracking-tight",style:{color:b},children:"Thank You!"}),e.jsxs("p",{className:"text-gray-500 text-lg leading-relaxed mb-8",children:["Your interest in joining ",e.jsx("span",{className:"font-semibold",style:{color:b},children:l.name})," has been received. A member of our recruitment team will be in touch shortly."]}),e.jsx("div",{className:"w-16 h-1 mx-auto rounded-full",style:{backgroundColor:g}})]})}):e.jsxs("div",{className:"min-h-screen bg-white",style:{"--recruit-primary":g,"--recruit-accent":b},children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-40 bg-white/80 backdrop-blur-lg border-b border-gray-100/50",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6 h-14 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[(f==null?void 0:f.logo_url)&&e.jsx("img",{src:f.logo_url,alt:l.name,className:"h-8 w-auto"}),e.jsx("span",{className:"font-semibold text-sm tracking-tight",style:{color:b},children:l.name})]}),e.jsxs("a",{href:"#apply",className:"inline-flex items-center gap-2 px-5 py-2 rounded-full text-sm font-semibold text-white transition-all duration-300 hover:shadow-md hover:scale-105",style:{background:`linear-gradient(135deg, ${g}, ${b})`},children:["Apply Now ",e.jsx(Qa,{className:"h-3.5 w-3.5"})]})]})}),e.jsx(fCs,{headline:k,subtext:S,primaryColor:g,accentColor:b,heroImageUrl:f==null?void 0:f.hero_image_url,logoUrl:f==null?void 0:f.logo_url,brokerageName:l.name}),e.jsx(xCs,{benefits:_,accentColor:b,primaryColor:g}),e.jsx(gCs,{images:w,primaryColor:g,accentColor:b}),e.jsx(yCs,{testimonials:j,primaryColor:g,accentColor:b}),e.jsx(vCs,{form:a,setForm:o,onSubmit:()=>p.mutate(),isPending:p.isPending,primaryColor:g,accentColor:b}),e.jsx("footer",{className:"py-10 text-center bg-white border-t border-gray-100",children:e.jsxs("p",{className:"text-sm text-gray-400",children:["© ",new Date().getFullYear()," ",l.name,". All rights reserved."]})})]})}function _Cs(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 wCs(){var g,b,_,j;const{shareToken:t}=yo(),s=N.useRef(!1),{data:r,isLoading:n,error:a}=mt({queryKey:["public-recruit-video",t],queryFn:async()=>{var I;if(!t)throw new Error("No token");const{data:w,error:k}=await H.from("recruit_videos").select(` *, prospect:recruit_prospects(first_name, last_name), video:agent_videos(id, title, playback_url, thumbnail_url, duration_seconds, owner_user_id) `).eq("share_token",t).single();if(k)throw k;const{data:S}=await H.from("profiles").select("name, avatar_url, title").eq("id",(I=w.video)==null?void 0:I.owner_user_id).single(),{data:M}=await H.from("brokerages").select("name").eq("id",w.brokerage_id).single(),{data:L}=await H.from("recruit_landing_page_settings").select("logo_url, primary_color, accent_color, hero_headline").eq("brokerage_id",w.brokerage_id).maybeSingle();return{rv:w,profile:S,brokerage:M,settings:L}},enabled:!!t});if(N.useEffect(()=>{var w;!((w=r==null?void 0:r.rv)!=null&&w.id)||s.current||(s.current=!0,H.rpc("log_recruit_video_view",{p_recruit_video_id:r.rv.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null}).then(()=>{}))},[(g=r==null?void 0:r.rv)==null?void 0:g.id]),n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});if(a||!r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("p",{className:"text-muted-foreground",children:"This video is no longer available."})});const{rv:o,profile:l,brokerage:i,settings:c}=r,u=(c==null?void 0:c.primary_color)||"#3b82f6",p=((b=o.prospect)==null?void 0:b.first_name)||"there",f=(_=o.video)!=null&&_.playback_url?_Cs(o.video.playback_url):null;return e.jsxs(e.Fragment,{children:[e.jsx(Sc,{children:e.jsx("title",{children:i!=null&&i.name?`${i.name} — A Message For You`:"Personal Video Message"})}),e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100",children:[e.jsx("header",{className:"border-b bg-white/80 backdrop-blur-sm",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-4 flex items-center gap-3",children:[(c==null?void 0:c.logo_url)&&e.jsx("img",{src:c.logo_url,alt:"",className:"h-8 object-contain"}),e.jsx("span",{className:"font-semibold text-sm",style:{color:u},children:(i==null?void 0:i.name)||"Recruiting"})]})}),e.jsxs("main",{className:"max-w-3xl mx-auto px-4 py-8 space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground",children:["Hey ",p,", ",l==null?void 0:l.name," has a message for you"]}),o.message&&e.jsx("p",{className:"text-muted-foreground max-w-xl mx-auto",children:o.message})]}),f&&e.jsx("div",{className:"rounded-xl overflow-hidden shadow-xl bg-black",children:e.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:e.jsx("iframe",{src:f,loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,width:"100%",height:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border p-6 flex items-center gap-4",children:[l!=null&&l.avatar_url?e.jsx("img",{src:l.avatar_url,alt:"",className:"h-14 w-14 rounded-full object-cover"}):e.jsx("div",{className:"h-14 w-14 rounded-full flex items-center justify-center text-white text-lg font-bold",style:{backgroundColor:u},children:((j=l==null?void 0:l.name)==null?void 0:j.charAt(0))||"?"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold",children:l==null?void 0:l.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(l==null?void 0:l.title)||"Recruiter"," · ",i==null?void 0:i.name]})]})]}),e.jsx("div",{className:"text-center",children:e.jsxs(K,{size:"lg",className:"text-white shadow-lg hover:shadow-xl transition-shadow px-8",style:{backgroundColor:u},onClick:()=>{H.from("recruit_videos").update({cta_clicked_at:new Date().toISOString()}).eq("id",o.id).then(()=>{})},children:[e.jsx(hn,{className:"h-5 w-5 mr-2"})," Schedule a Conversation"]})})]}),e.jsx("footer",{className:"text-center py-6 text-xs text-muted-foreground",children:"Powered by LevelUp"})]})]})}function jCs(){const t=fr(),s=Qt(),{isAdmin:r}=Ds(),[n,a]=N.useState(!1),[o,l]=N.useState(null),[i,c]=N.useState(null),{data:u,isLoading:p}=mt({queryKey:["my-social-accounts"],queryFn:async()=>{const{data:{user:I},error:O}=await H.auth.getUser();if(O)throw O;if(!I)return[];const{data:q,error:U}=await H.from("social_accounts").select("*").eq("user_id",I.id).order("created_at",{ascending:!1});if(U)throw U;return q}}),f=Dt({mutationFn:async I=>{const{data:{user:O},error:q}=await H.auth.getUser();if(q)throw q;if(!O)throw new Error("Not authenticated");const{error:U}=await H.from("social_accounts").delete().eq("id",I).eq("user_id",O.id);if(U)throw U},onSuccess:()=>{s.invalidateQueries({queryKey:["my-social-accounts"]}),s.invalidateQueries({queryKey:["social-accounts-for-post"]}),me.success("Account disconnected successfully")},onError:()=>{me.error("Failed to disconnect account")}}),g=async()=>{a(!0);try{const{data:I,error:O}=await H.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(O)throw O;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),me.error("Failed to start connection. Please try again."),a(!1)}},b=async()=>{a(!0);try{const{data:I,error:O}=await H.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(O)throw O;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),me.error("Failed to start LinkedIn connection. Please try again."),a(!1)}},_=async()=>{a(!0);try{const{data:I,error:O}=await H.functions.invoke("google-business-oauth",{body:{action:"get_auth_url"}});if(O)throw O;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get Google authorization URL")}catch(I){console.error("Google OAuth error:",I),me.error("Failed to start Google connection. Please try again."),a(!1)}},j=(u==null?void 0:u.filter(I=>I.platform==="facebook"))||[],w=(u==null?void 0:u.filter(I=>I.platform==="instagram"))||[],k=(u==null?void 0:u.filter(I=>I.platform==="linkedin"))||[],S=(u==null?void 0:u.filter(I=>I.platform==="google_business"))||[],M=((u==null?void 0:u.length)||0)>0,L=async(I,O)=>{l(I),c(null);try{const{data:q,error:U}=await H.functions.invoke("meta-api-test",{body:{testType:"all",accountId:I}});if(U)throw U;c(q.results||[]),me.success(q.summary||"API tests completed")}catch(q){console.error("Meta API test error:",q),me.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(tt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(pn,{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(Ja,{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(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-amber-100 dark:bg-amber-900/30 p-4 mb-4",children:e.jsx(un,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),e.jsx(tt,{variant:"secondary",className:"mb-3 bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:"Coming Soon"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Social Connections Coming Soon!"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"We're putting the finishing touches on this feature. Soon you'll be able to connect your social accounts and post directly from Social Swag with one click."})]})}),r&&e.jsxs(e.Fragment,{children:[M&&e.jsx(Ee,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:e.jsxs(De,{className:"flex items-center gap-4 p-4",children:[e.jsx("div",{className:"rounded-full bg-green-500 p-2",children:e.jsx(xi,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-green-800 dark:text-green-200",children:"You're all set!"}),e.jsx("p",{className:"text-sm text-green-600 dark:text-green-400",children:"You can now post directly to your connected accounts from Social Swag."})]})]})}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-blue-500/10 p-3",children:e.jsx(Su,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Facebook"}),e.jsx(gr,{children:"Connect your Facebook Pages"})]})]})}),e.jsxs(De,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Go,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):j.length>0?e.jsx("div",{className:"space-y-3",children:j.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(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:I.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Su,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:I.page_name||I.platform_username||"Facebook Page"}),e.jsx(tt,{variant:I.is_active?"default":"secondary",className:"text-xs",children:I.is_active?"Connected":"Inactive"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Disconnect Facebook?"}),e.jsx(tc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:()=>f.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Facebook pages connected yet"}),e.jsxs(K,{onClick:g,disabled:n,className:"w-full gap-2",variant:j.length>0?"outline":"default",children:[n?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4"}),j.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-gradient-to-br from-purple-500/10 via-pink-500/10 to-orange-500/10 p-3",children:e.jsx(Mu,{className:"h-6 w-6 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Instagram"}),e.jsx(gr,{children:"Connect Instagram Business accounts"})]})]})}),e.jsxs(De,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Go,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.length>0?e.jsx("div",{className:"space-y-3",children:w.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(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:I.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Mu,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["@",I.platform_username||"Instagram Account"]}),e.jsx(tt,{variant:I.is_active?"default":"secondary",className:"text-xs",children:I.is_active?"Connected":"Inactive"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Disconnect Instagram?"}),e.jsx(tc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:()=>f.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Instagram accounts connected yet"}),e.jsxs(K,{onClick:g,disabled:n,className:"w-full gap-2",variant:w.length>0?"outline":"default",children:[n?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{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(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-blue-600/10 p-3",children:e.jsx(Mp,{className:"h-6 w-6 text-blue-700"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"LinkedIn"}),e.jsx(gr,{children:"Connect your LinkedIn profile"})]})]})}),e.jsxs(De,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Go,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):k.length>0?e.jsx("div",{className:"space-y-3",children:k.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(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:I.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Mp,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:I.platform_username||"LinkedIn Account"}),e.jsx(tt,{variant:I.is_active?"default":"secondary",className:"text-xs",children:I.is_active?"Connected":"Inactive"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Disconnect LinkedIn?"}),e.jsx(tc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:()=>f.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No LinkedIn account connected yet"}),e.jsxs(K,{onClick:b,disabled:n,className:"w-full gap-2",variant:k.length>0?"outline":"default",children:[n?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4"}),k.length>0?"Reconnect LinkedIn":"Connect LinkedIn"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Share content directly to your LinkedIn profile"})]})]}),e.jsxs(Ee,{className:`relative overflow-hidden ${r?"":"opacity-75"}`,children:[!r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(tt,{variant:"secondary",className:"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:"Coming Soon"})}),r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(tt,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Admin Testing"})}),e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-red-500/10 p-3",children:e.jsx(ma,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Google Business"}),e.jsx(gr,{children:"Connect your Google Business Profile"})]})]})}),e.jsxs(De,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Go,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length>0?e.jsx("div",{className:"space-y-3",children:S.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:I.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(ma,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:I.page_name||I.platform_username||"Google Business"}),e.jsx(tt,{variant:I.is_active?"default":"secondary",className:"text-xs",children:I.is_active?"Connected":"Inactive"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Disconnect Google Business?"}),e.jsx(tc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:()=>f.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:r?"No Google Business account connected yet":"Google Business Profile integration is coming soon!"}),e.jsxs(K,{onClick:r?_:void 0,disabled:!r||n,className:"w-full gap-2",variant:S.length>0?"outline":"default",children:[n?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4"}),S.length>0?"Reconnect Google Business":"Connect Google Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Post updates directly to your Google Business Profile"})]})]})]}),r&&(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(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-amber-500/10 p-3",children:e.jsx(z_,{className:"h-6 w-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(gr,{children:"Run API tests to trigger all required permissions for Meta App Review"})]})]})}),e.jsxs(De,{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(I=>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(Su,{className:"h-5 w-5 text-blue-600"}),e.jsx("span",{className:"font-medium",children:I.page_name||"Facebook Page"})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>L(I.id),disabled:o===I.id,children:o===I.id?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(z_,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${I.id}`)),w.map(I=>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(Mu,{className:"h-5 w-5 text-pink-600"}),e.jsxs("span",{className:"font-medium",children:["@",I.platform_username||"Instagram"]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>L(I.id),disabled:o===I.id,children:o===I.id?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(z_,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-ig-${I.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((I,O)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[I.status==="success"?e.jsx(sa,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):I.status==="pending"?e.jsx(ws,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):e.jsx(vc,{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:I.test}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:I.details})]})]},O))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Note: Facebook posts are auto-deleted. Instagram posts will remain and should be manually deleted. Allow up to 24 hours for Meta to register the API calls."})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"How it works"})}),e.jsx(De,{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 NCs(){const[t]=Cc(),s=fr(),[r,n]=N.useState("loading"),[a,o]=N.useState("Processing your connection...");return N.useEffect(()=>{(async()=>{var f;const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:g,error:b}=await H.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/social-connections/callback"}});if(b)throw b;if(g!=null&&g.success)n("success"),o(`Successfully connected ${((f=g.accounts)==null?void 0:f.length)||0} account(s)!`),me.success("Social accounts connected successfully!");else throw new Error((g==null?void 0:g.error)||"Unknown error")}catch(g){console.error("OAuth callback error:",g),n("error"),o(g instanceof Error?g.message:"Failed to connect accounts"),me.error("Failed to connect: "+(g instanceof Error?g.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(vc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Rt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(De,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function kCs(){const[t]=Cc(),s=fr(),[r,n]=N.useState("loading"),[a,o]=N.useState("Connecting your Google Business Profile...");return N.useEffect(()=>{(async()=>{const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:f,error:g}=await H.functions.invoke("google-business-oauth",{body:{action:"exchange_code",code:i,state:p}});if(g)throw g;if(f!=null&&f.success)n("success"),o(f.message||"Successfully connected Google Business Profile!"),me.success("Google Business Profile connected!");else throw new Error((f==null?void 0:f.error)||"Unknown error")}catch(f){console.error("Google OAuth callback error:",f),n("error"),o(f instanceof Error?f.message:"Failed to connect Google Business Profile"),me.error("Failed to connect: "+(f instanceof Error?f.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(vc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Rt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(De,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/social-connections"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function SCs(){const[t]=Cc(),s=fr(),[r,n]=N.useState("loading"),[a,o]=N.useState("Connecting your LinkedIn account...");return N.useEffect(()=>{(async()=>{var f;const i=t.get("code"),c=t.get("state"),u=t.get("error"),p=t.get("error_description");if(u){console.error("LinkedIn OAuth error:",u,p),n("error"),o(p||"Failed to connect LinkedIn account"),me.error(p||"Failed to connect LinkedIn");return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:g,error:b}=await H.functions.invoke("linkedin-oauth",{body:{action:"exchange_code",code:i,state:c,callbackPath:"/social-connections/linkedin-callback"}});if(b)throw b;if(g!=null&&g.success)n("success"),o(`Successfully connected ${((f=g.accounts)==null?void 0:f.length)||1} LinkedIn account`),me.success("LinkedIn connected successfully!");else throw new Error((g==null?void 0:g.error)||"Failed to connect LinkedIn account")}catch(g){console.error("LinkedIn callback error:",g),n("error"),o(g instanceof Error?g.message:"Failed to connect LinkedIn account"),me.error("Failed to connect LinkedIn")}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center p-4 bg-background",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4 rounded-full bg-blue-600/10 p-4 w-fit",children:[r==="loading"&&e.jsx(ws,{className:"h-8 w-8 animate-spin text-blue-600"}),r==="success"&&e.jsx(xi,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx(vc,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(Rt,{className:"flex items-center justify-center gap-2",children:[e.jsx(Mp,{className:"h-5 w-5 text-blue-600"}),r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(De,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/social-connections"),disabled:r==="loading",children:r==="success"?"Continue":"Back to Connections"})})]})})}function CCs(){const t=fr(),[s,r]=N.useState(null),{data:n,isLoading:a}=Tlt(s||void 0,!0),{data:o,isLoading:l}=uCe(!0),{cartItems:i}=bue(),c=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(ys,{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(ys,{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(vp,{className:"h-4 w-4 mr-2"}),"Cart",c>0&&e.jsx(tt,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:c})]})]}),o&&o.length>0&&e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[e.jsx(K,{variant:s===null?"default":"outline",size:"sm",onClick:()=>r(null),children:"All"}),o.map(p=>e.jsx(K,{variant:s===p.id?"default":"outline",size:"sm",onClick:()=>r(p.id),children:p.name},p.id))]}),n&&n.length>0?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:n.map(p=>{var f;return e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>u(p),children:[e.jsxs("div",{className:"aspect-square bg-muted relative",children:[p.images&&p.images.length>0?e.jsx("img",{src:((f=p.images.find(g=>g.is_primary))==null?void 0:f.image_url)||p.images[0].image_url,alt:p.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(Ml,{className:"h-12 w-12 text-muted-foreground"})}),p.category&&e.jsx(tt,{className:"absolute top-2 left-2",variant:"secondary",children:p.category.name})]}),e.jsxs(De,{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(Ml,{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 uct=N.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));uct.displayName="Breadcrumb";const hct=N.forwardRef(({className:t,...s},r)=>e.jsx("ol",{ref:r,className:It("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...s}));hct.displayName="BreadcrumbList";const Die=N.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:It("inline-flex items-center gap-1.5",t),...s}));Die.displayName="BreadcrumbItem";const hwe=N.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?u2e:"a";return e.jsx(a,{ref:n,className:It("transition-colors hover:text-foreground",s),...r})});hwe.displayName="BreadcrumbLink";const mct=N.forwardRef(({className:t,...s},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:It("font-normal text-foreground",t),...s}));mct.displayName="BreadcrumbPage";const mwe=({children:t,className:s,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:It("[&>svg]:size-3.5",s),...r,children:t??e.jsx(da,{})});mwe.displayName="BreadcrumbSeparator";function MCs(){var ee,Q;const{productId:t}=yo(),s=fr(),{data:r,isLoading:n}=Rks(t||""),{addToCart:a,cartItems:o}=bue(),[l,i]=N.useState(null),[c,u]=N.useState(1),[p,f]=N.useState(0),[g,b]=N.useState(null),[_,j]=N.useState(!1),[w,k]=N.useState(!1),S=(ee=r==null?void 0:r.variants)==null?void 0:ee.find(ie=>ie.id===l),M=((Q=r==null?void 0:r.variants)==null?void 0:Q.filter(ie=>ie.is_active))||[],L=Number((r==null?void 0:r.base_price)||0),I=S?Number(S.price_adjustment):0,O=L+I,q=Number((r==null?void 0:r.shipping_fee)||0),U=o.reduce((ie,re)=>ie+re.quantity,0),B=async ie=>{if(!ie.target.files||ie.target.files.length===0)return;j(!0);const re=ie.target.files[0],oe=re.name.split(".").pop(),ce=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${oe}`;try{const{error:xe}=await H.storage.from("marketplace").upload(ce,re);if(xe)throw xe;const{data:{publicUrl:ge}}=H.storage.from("marketplace").getPublicUrl(ce);b(ge),me.success("Artwork uploaded successfully")}catch(xe){me.error("Failed to upload artwork: "+xe.message)}finally{j(!1)}},V=()=>{if(r){if(M.length>0&&!l){me.error("Please select an option");return}a(r,S||void 0,c,g||void 0),k(!0),me.success("Added to cart!"),setTimeout(()=>k(!1),2e3)}},Z=()=>{r!=null&&r.images&&f(ie=>(ie+1)%r.images.length)},X=()=>{r!=null&&r.images&&f(ie=>(ie-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(ys,{className:"aspect-square w-full"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ys,{className:"h-8 w-3/4"}),e.jsx(ys,{className:"h-6 w-1/4"}),e.jsx(ys,{className:"h-24 w-full"}),e.jsx(ys,{className:"h-12 w-full"})]})]})}):r?e.jsxs(Ms,{title:r.name,children:[e.jsx(uct,{className:"mb-6",children:e.jsxs(hct,{children:[e.jsx(Die,{children:e.jsx(hwe,{asChild:!0,children:e.jsx(Pi,{to:"/marketplace",children:"Marketplace"})})}),r.category&&e.jsxs(e.Fragment,{children:[e.jsx(mwe,{}),e.jsx(Die,{children:e.jsx(hwe,{asChild:!0,children:e.jsx(Pi,{to:`/marketplace?category=${r.category.id}`,children:r.category.name})})})]}),e.jsx(mwe,{}),e.jsx(Die,{children:e.jsx(mct,{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:X,children:e.jsx(cl,{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:Z,children:e.jsx(da,{className:"h-6 w-6"})})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(Ml,{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((ie,re)=>e.jsx("button",{onClick:()=>f(re),className:`w-16 h-16 flex-shrink-0 rounded-md overflow-hidden border-2 ${re===p?"border-primary":"border-transparent"}`,children:e.jsx("img",{src:ie.image_url,alt:"",className:"w-full h-full object-cover"})},ie.id))}),r.video&&e.jsx(Ee,{children:e.jsxs(De,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-2",children:"Product Video"}),e.jsx("div",{className:"aspect-video",children:e.jsx("iframe",{src:r.video.video_url,className:"w-full h-full rounded-lg",allowFullScreen:!0})})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[r.category&&e.jsx(tt,{variant:"secondary",className:"mb-2",children:r.category.name}),e.jsx("h1",{className:"text-3xl font-bold mb-2",children:r.name}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-3xl font-bold",children:["$",O.toFixed(2)]}),q>0&&e.jsxs("span",{className:"text-muted-foreground",children:["+ $",q.toFixed(2)," shipping"]})]})]}),r.description&&e.jsx("div",{className:"prose prose-sm max-w-none",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})}),M.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Select Option"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:M.map(ie=>e.jsxs(K,{variant:l===ie.id?"default":"outline",onClick:()=>i(ie.id),children:[ie.name,Number(ie.price_adjustment)!==0&&e.jsxs("span",{className:"ml-1 opacity-70",children:["(",Number(ie.price_adjustment)>0?"+":"","$",Number(ie.price_adjustment).toFixed(2),")"]})]},ie.id))})]}),r.allow_artwork_upload&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Upload Your Artwork (Optional)"}),g?e.jsxs("div",{className:"relative inline-block",children:[e.jsx("img",{src:g,alt:"Your artwork",className:"h-24 w-auto rounded-lg border"}),e.jsx(K,{variant:"ghost",size:"sm",className:"absolute -top-2 -right-2",onClick:()=>b(null),children:"×"})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6",children:[e.jsx("input",{type:"file",accept:"image/*,.pdf,.ai,.eps",onChange:B,className:"hidden",id:"artwork-upload",disabled:_}),e.jsxs("label",{htmlFor:"artwork-upload",className:"flex flex-col items-center cursor-pointer",children:[e.jsx(li,{className:"h-8 w-8 text-muted-foreground mb-2"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:_?"Uploading...":"Click to upload artwork"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"Supported: JPG, PNG, PDF, AI, EPS"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Quantity"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(ie=>Math.max(1,ie-1)),children:"-"}),e.jsx(ze,{type:"number",value:c,onChange:ie=>u(Math.max(1,parseInt(ie.target.value)||1)),className:"w-20 text-center",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(ie=>ie+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(va,{className:"h-5 w-5 mr-2"}),"Added!"]}):e.jsxs(e.Fragment,{children:[e.jsx(vp,{className:"h-5 w-5 mr-2"}),"Add to Cart"]})}),e.jsxs(K,{variant:"outline",size:"lg",onClick:()=>s("/marketplace/cart"),className:"relative",children:[e.jsx(vp,{className:"h-5 w-5"}),U>0&&e.jsx(tt,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:U})]})]}),r.requires_proof_approval&&e.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-3 rounded-lg",children:"📋 This product requires proof approval before production. You'll receive a proof to review after your order is placed."})]})]})]}):e.jsx(Ms,{title:"Product Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ml,{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 TCs(){const t=fr(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:c}=bue(),[u,p]=N.useState(!1),[f,g]=N.useState(""),b=async()=>{if(s.length===0){me.error("Your cart is empty");return}p(!0);try{const{data:_,error:j}=await H.functions.invoke("marketplace-checkout",{body:{items:s.map(w=>{var k;return{product_id:w.product.id,variant_id:((k=w.variant)==null?void 0:k.id)||null,quantity:w.quantity,artwork_url:w.artworkUrl||null}}),notes:f.trim()||null}});if(j)throw j;if(_!=null&&_.url)c(),window.open(_.url,"_blank");else throw new Error("No checkout URL received")}catch(_){me.error("Checkout failed: "+_.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(g0,{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(_=>{var j,w;return e.jsx(Ee,{children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-24 h-24 flex-shrink-0 bg-muted rounded-lg overflow-hidden",children:_.product.images&&_.product.images.length>0?e.jsx("img",{src:((j=_.product.images.find(k=>k.is_primary))==null?void 0:j.image_url)||_.product.images[0].image_url,alt:_.product.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(g0,{className:"h-8 w-8 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold line-clamp-1",children:_.product.name}),_.variant&&e.jsx("p",{className:"text-sm text-muted-foreground",children:_.variant.name}),e.jsxs("p",{className:"font-medium mt-1",children:["$",a(_).toFixed(2),Number(_.product.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:["+ $",Number(_.product.shipping_fee).toFixed(2)," shipping"]})]}),_.artworkUrl&&e.jsx("div",{className:"mt-2",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:"Artwork uploaded ✓"})})]}),e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{var k;return r(_.product.id,(k=_.variant)==null?void 0:k.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var k;return n(_.product.id,(k=_.variant)==null?void 0:k.id,_.quantity-1)},disabled:_.quantity<=1,children:e.jsx(p0,{className:"h-3 w-3"})}),e.jsx(ze,{type:"number",value:_.quantity,onChange:k=>{var S;return n(_.product.id,(S=_.variant)==null?void 0:S.id,parseInt(k.target.value)||1)},className:"w-14 h-8 text-center text-sm",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var k;return n(_.product.id,(k=_.variant)==null?void 0:k.id,_.quantity+1)},children:e.jsx($s,{className:"h-3 w-3"})})]})]})]})})},`${_.product.id}-${((w=_.variant)==null?void 0:w.id)||"base"}`)}),e.jsx(K,{variant:"ghost",className:"text-destructive",onClick:c,children:"Clear Cart"})]}),e.jsx("div",{children:e.jsxs(Ee,{className:"sticky top-4",children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Order Summary"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{children:["Subtotal (",s.reduce((_,j)=>_+j.quantity,0)," items)"]}),e.jsxs("span",{children:["$",o().toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",l().toFixed(2)]})]}),e.jsx(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(Er,{id:"orderNotes",placeholder:"Add any special instructions, design notes, or comments for your order...",value:f,onChange:_=>g(_.target.value),rows:3,className:"resize-none"})]}),e.jsx(K,{className:"w-full",size:"lg",onClick:b,disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Checkout",e.jsx(Qa,{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 ACs(){const t=fr(),{data:s,isLoading:r}=Kks();return r?e.jsx(Ms,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(n=>e.jsx(ys,{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(Ml,{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(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:n.order_number}),e.jsx("span",{className:"text-muted-foreground text-sm ml-2",children:ms(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(tt,{className:dCe[n.status],children:dT[n.status]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex -space-x-2",children:[(a=n.items)==null?void 0:a.slice(0,3).map((i,c)=>e.jsxs("div",{className:"w-10 h-10 bg-muted rounded border-2 border-background flex items-center justify-center text-xs font-medium",style:{zIndex:3-c},children:[i.quantity,"×"]},i.id)),n.items&&n.items.length>3&&e.jsxs("div",{className:"w-10 h-10 bg-muted rounded border-2 border-background flex items-center justify-center text-xs font-medium",children:["+",n.items.length-3]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:((o=n.items)==null?void 0:o.length)===1?n.items[0].product_name:`${(l=n.items)==null?void 0:l.length} items`}),e.jsxs("p",{className:"font-semibold",children:["$",Number(n.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n.tracking_url&&e.jsxs(K,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),window.open(n.tracking_url,"_blank")},children:[e.jsx(tn,{className:"h-4 w-4 mr-1"}),"Track"]}),e.jsx(da,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const zze=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function ECs({currentStatus:t,statusHistory:s}){const r=zze.indexOf(t);return e.jsx("div",{className:"space-y-3",children:zze.map((n,a)=>{const o=s==null?void 0:s.find(u=>u.status===n),l=ar;return e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center ${l?"bg-green-500 text-white":i?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:l?e.jsx(sa,{className:"h-4 w-4"}):i?e.jsx(un,{className:"h-4 w-4"}):e.jsx("span",{className:"text-xs",children:a+1})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`font-medium ${c?"text-muted-foreground":""}`,children:dT[n]}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ms(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function PCs(){var k;const{orderId:t}=yo(),s=fr(),{data:r,isLoading:n,refetch:a}=Zks(t||""),o=Qks(),l=Jks(),[i,c]=N.useState(!1),[u,p]=N.useState(null),[f,g]=N.useState(""),[b,_]=N.useState(null),j=async S=>{_(S);try{await o.mutateAsync({orderId:t,itemId:S}),me.success("Proof approved!"),a()}catch{me.error("Failed to approve proof")}finally{_(null)}},w=async()=>{if(u){_(u);try{await l.mutateAsync({orderId:t,itemId:u,reason:f}),me.success("Revision requested"),c(!1),g(""),p(null),a()}catch{me.error("Failed to request revision")}finally{_(null)}}};return n?e.jsx(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(ys,{className:"h-64 w-full"}),e.jsx(ys,{className:"h-48 w-full"})]}),e.jsx(ys,{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(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{children:"Order Status"}),e.jsx(tt,{className:dCe[r.status],children:dT[r.status]})]}),e.jsx(De,{children:e.jsx(ECs,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Items"})}),e.jsx(De,{className:"space-y-4",children:(k=r.items)==null?void 0:k.map(S=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold",children:S.product_name}),S.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.variant_name}),e.jsxs("p",{className:"text-sm",children:["Qty: ",S.quantity," × $",Number(S.unit_price).toFixed(2)]})]}),e.jsxs("p",{className:"font-semibold",children:["$",(Number(S.unit_price)*S.quantity).toFixed(2)]})]}),S.artwork_url&&e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your Artwork:"}),e.jsxs("a",{href:S.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline",children:[e.jsx(F_,{className:"h-4 w-4"}),"View Artwork",e.jsx(tn,{className:"h-3 w-3"})]})]}),S.proof_url&&e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Proof Ready for Review"}),e.jsxs("a",{href:S.proof_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline mb-3",children:[e.jsx(F_,{className:"h-4 w-4"}),"View Proof",e.jsx(tn,{className:"h-3 w-3"})]}),S.proof_status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(K,{size:"sm",onClick:()=>j(S.id),disabled:b===S.id,children:[b===S.id?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(sh,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{p(S.id),c(!0)},disabled:b===S.id,children:[e.jsx(AL,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),S.proof_status==="approved"&&e.jsxs(tt,{className:"bg-green-100 text-green-800",children:[e.jsx(sa,{className:"h-3 w-3 mr-1"}),"Proof Approved"]}),S.proof_status==="rejected"&&S.proof_notes&&e.jsxs("div",{className:"mt-2",children:[e.jsx(tt,{variant:"destructive",className:"mb-2",children:"Revision Requested"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.proof_notes})]})]})]},S.id))})]}),r.shipping_name&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(PL,{className:"h-5 w-5"}),"Shipping"]})}),e.jsxs(De,{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(tn,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),e.jsx("div",{children:e.jsxs(Ee,{className:"sticky top-4",children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Order Summary"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",ms(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(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(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Request Changes"}),e.jsx(Gr,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(Er,{placeholder:"Describe the changes needed...",value:f,onChange:S=>g(S.target.value),rows:4}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(K,{onClick:w,disabled:!f.trim()||b!==null,children:[b?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Submit Request"]})]})]})})]}):e.jsx(Ms,{title:"Order Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ml,{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 ICs(){const t=fr(),[s]=Cc();return s.get("session_id"),N.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(De,{className:"pt-8 pb-6",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(sa,{className:"h-8 w-8 text-green-600"})}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Thank You for Your Order!"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Your order has been confirmed and is being processed. You'll receive an email confirmation shortly."}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 mb-6 text-left",children:[e.jsxs("h3",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ml,{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(Qa,{className:"h-4 w-4 ml-2"})]}),e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function LCs(){const{user:t}=Ds(),[s,r]=N.useState("store"),[n,a]=N.useState(null),[o,l]=N.useState(null),[i,c]=N.useState(!1),[u,p]=N.useState(5),[f,g]=N.useState(""),[b,_]=N.useState(!1),[j,w]=N.useState(!1),[k,S]=N.useState(""),[M,L]=N.useState(null),[I,O]=N.useState(!1),{hasSubmittedReview:q,submitReview:U,markPostedToGoogle:B}=OYe(),{data:V}=Elt(),{data:Z,isLoading:X}=Alt(),{data:ee,isLoading:Q}=i4s(n),{data:ie,isLoading:re}=o4s(t==null?void 0:t.id),{data:oe=0}=c4s(t==null?void 0:t.id),ce=d4s(),xe=new Set((ie==null?void 0:ie.map(Pe=>Pe.item_id))||[]),ge=async()=>{if(o)try{const Pe=await ce.mutateAsync(o.id);o.item_type==="reelflow_credits"?me.success(`🎬 ${o.max_quantity} ReelFlow credits added to your balance!`):me.success(`Successfully purchased "${o.name}"!`),l(null)}catch(Pe){me.error(Pe.message||"Failed to purchase item")}},ue=async()=>{if(!f.trim()){me.error("Please write a review");return}_(!0);const Pe=await U(u,f);_(!1),Pe.success?(me.success("Thank you for your review! You earned 25 points!"),S(f),w(!0),g(""),p(5)):me.error(Pe.error||"Failed to submit review")},pe=()=>{navigator.clipboard.writeText(k),me.success("Review copied to clipboard!")},be=()=>{B(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},Me=()=>{w(!1),c(!1),S("")};return X||Q||re?e.jsx(Ms,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{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(Pe=>e.jsx(ys,{className:"h-64"},Pe))})]})}):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(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(Jn,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your Spendable Points"}),e.jsx("p",{className:"text-3xl font-bold text-primary",children:oe.toLocaleString()})]})]}),e.jsxs("div",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(xo,{className:"h-4 w-4"}),e.jsx("span",{children:"Earn points by attending events"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(eh,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{children:"Streak bonuses add extra points!"})]})]})]})})}),e.jsx(gf,{open:I,onOpenChange:O,children:e.jsxs(Ee,{className:"border-primary/20",children:[e.jsx(yf,{asChild:!0,children:e.jsx(Pt,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(xo,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-base",children:"How to Earn Points"}),e.jsx(gr,{children:"See all the ways you can earn spendable points"})]})]}),I?e.jsx(pf,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(Eo,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(vf,{children:e.jsx(De,{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(Pe=>Pe.is_active).map(Pe=>{const Oe=Te=>{switch(Te){case"event_attendance":return e.jsx(hn,{className:"h-5 w-5"});case"leave_review":return e.jsx(Jn,{className:"h-5 w-5"});case"add_listing":return e.jsx(bn,{className:"h-5 w-5"});case"first_contact":return e.jsx(pr,{className:"h-5 w-5"});case"first_video":return e.jsx(An,{className:"h-5 w-5"});case"first_community_post":return e.jsx(so,{className:"h-5 w-5"});default:return e.jsx(ko,{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:Oe(Pe.action_key)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:Pe.action_name}),Pe.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Pe.description})]}),e.jsxs(tt,{variant:"secondary",className:"font-bold shrink-0",children:["+",Pe.points]})]},Pe.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(eh,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"Streak Bonuses"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Attend consecutive weeks for bonus points!"})]}),e.jsx(tt,{variant:"outline",className:"font-bold shrink-0 border-orange-500/50 text-orange-600",children:"+Bonus"})]})]})})})]})}),!q&&e.jsx(Ee,{className:"bg-gradient-to-r from-yellow-500/10 to-orange-500/10 border-yellow-500/20",children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-yellow-500/20 flex items-center justify-center",children:e.jsx(so,{className:"h-6 w-6 text-yellow-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Earn 25 Free Points!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Leave a quick review and earn 25 spendable points"})]})]}),e.jsxs(K,{onClick:()=>c(!0),className:"bg-yellow-600 hover:bg-yellow-700",children:[e.jsx(Jn,{className:"h-4 w-4 mr-2"}),"Leave Review"]})]})})}),e.jsxs(ba,{value:s,onValueChange:r,children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"store",className:"flex items-center gap-2",children:[e.jsx(g0,{className:"h-4 w-4"}),"Store"]}),e.jsxs(ns,{value:"my-rewards",className:"flex items-center gap-2",children:[e.jsx(Ml,{className:"h-4 w-4"}),"My Rewards",ie&&ie.length>0&&e.jsx(tt,{variant:"secondary",className:"ml-1",children:ie.length})]})]}),e.jsxs(bs,{value:"store",className:"mt-6",children:[Z&&Z.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"}),Z.map(Pe=>e.jsxs(K,{variant:n===Pe.id?"default":"outline",size:"sm",onClick:()=>a(Pe.id),children:[Pe.icon&&`${Pe.icon} `,Pe.name]},Pe.id))]}),!ee||ee.length===0?e.jsx(Ee,{children:e.jsx(De,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(ko,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No items available"}),e.jsx("p",{className:"text-sm",children:"Check back later for new rewards!"})]})})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ee.map(Pe=>{const Oe=Pe.item_type==="reelflow_credits",Te=!Oe&&xe.has(Pe.id),ke=!Oe&&Pe.max_quantity!==null&&Pe.current_quantity===0,Be=oe>=Pe.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:()=>L(Pe),children:[Pe.preview_image_url?e.jsxs("div",{className:"aspect-video relative overflow-hidden bg-muted",children:[e.jsx("img",{src:Pe.preview_image_url,alt:Pe.name,className:"w-full h-full object-cover"}),Te&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(tt,{className:"bg-green-500 text-white",children:[e.jsx(sa,{className:"h-3 w-3 mr-1"}),"Owned"]})}),ke&&!Te&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(tt,{variant:"destructive",children:"Sold Out"})})]}):e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[e.jsx(ko,{className:"h-12 w-12 text-muted-foreground/50"}),Te&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(tt,{className:"bg-green-500 text-white",children:[e.jsx(sa,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),e.jsxs(Pt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(Rt,{className:"text-lg",children:Pe.name}),e.jsxs(tt,{variant:"secondary",className:"font-bold shrink-0",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),Pe.points_cost]})]}),Pe.category&&e.jsxs(tt,{variant:"outline",className:"w-fit",children:[Pe.category.icon&&`${Pe.category.icon} `,Pe.category.name]})]}),e.jsxs(De,{children:[e.jsx(gr,{className:"mb-4 line-clamp-2",children:Pe.description||"No description available"}),Pe.max_quantity!==null&&!Te&&!Oe&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[Pe.current_quantity," of ",Pe.max_quantity," remaining"]}),Oe&&e.jsxs("p",{className:"text-xs text-violet-600 font-medium mb-3",children:["🎬 Grants ",Pe.max_quantity," ReelFlow credits per purchase"]}),Te?e.jsx(K,{className:"w-full",onClick:nt=>{nt.stopPropagation(),Pe.file_url&&Mye(Pe.file_url,Pe.name)},disabled:!Pe.file_url,children:Pe.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Access"]})}):e.jsx(K,{className:"w-full",onClick:nt=>{nt.stopPropagation(),l(Pe)},disabled:ke||!Be,children:ke?"Sold Out":Be?e.jsxs(e.Fragment,{children:[e.jsx(g0,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${Pe.points_cost-oe} more pts`})]})]},Pe.id)})})]}),e.jsx(bs,{value:"my-rewards",className:"mt-6",children:!ie||ie.length===0?e.jsx(Ee,{children:e.jsx(De,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(Ml,{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:ie.map(Pe=>{var Oe,Te,ke,Be,nt,Ae,ft;return e.jsxs(Ee,{className:"overflow-hidden",children:[(Oe=Pe.item)!=null&&Oe.preview_image_url?e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted",children:e.jsx("img",{src:Pe.item.preview_image_url,alt:((Te=Pe.item)==null?void 0:Te.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(ko,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs(Pt,{className:"pb-2",children:[e.jsx(Rt,{className:"text-lg",children:((ke=Pe.item)==null?void 0:ke.name)||"Unknown Item"}),e.jsxs(gr,{className:"text-xs",children:["Purchased for ",Pe.points_spent," points • ",new Date(Pe.purchased_at).toLocaleDateString()]})]}),e.jsx(De,{children:((Be=Pe.item)==null?void 0:Be.item_type)==="reelflow_credits"?e.jsxs(K,{className:"w-full",variant:"outline",disabled:!0,children:[e.jsx(sa,{className:"h-4 w-4 mr-2 text-green-500"}),(nt=Pe.item)==null?void 0:nt.max_quantity," Credits Applied"]}):e.jsx(K,{className:"w-full",onClick:()=>{var fe,Ve;(fe=Pe.item)!=null&&fe.file_url&&Mye(Pe.item.file_url,(Ve=Pe.item)==null?void 0:Ve.name)},disabled:!((Ae=Pe.item)!=null&&Ae.file_url),children:((ft=Pe.item)==null?void 0:ft.item_type)==="file"?e.jsxs(e.Fragment,{children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},Pe.id)})})})]})]}),e.jsx(kc,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Confirm Purchase"}),e.jsxs(tc,{children:['Are you sure you want to purchase "',o==null?void 0:o.name,'" for ',o==null?void 0:o.points_cost," points?",(o==null?void 0:o.item_type)==="reelflow_credits"&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("br",{}),"🎬 ",e.jsxs("strong",{children:[o==null?void 0:o.max_quantity," ReelFlow credits"]})," will be added to your balance instantly."]}),e.jsx("br",{}),e.jsx("br",{}),"You currently have ",e.jsxs("strong",{children:[oe," points"]}),". After this purchase, you'll have"," ",e.jsxs("strong",{children:[oe-((o==null?void 0:o.points_cost)||0)," points"]})," remaining."]})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:ge,disabled:ce.isPending,children:ce.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(fs,{open:i,onOpenChange:Pe=>{!Pe&&j?Me():c(Pe)},children:e.jsx(ps,{children:j?e.jsxs(e.Fragment,{children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-5 w-5 text-green-500"}),"Thank You for Your Review!"]}),e.jsx(Gr,{children:"Would you also share your review on Google? It helps other agents discover LevelUp!"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-muted p-4 rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your review:"}),e.jsxs("p",{className:"text-sm italic",children:['"',k,'"']})]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:pe,children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(qn,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(K,{variant:"outline",onClick:Me,children:"Maybe Later"}),e.jsxs(K,{onClick:be,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Leave a Review"}),e.jsx(Gr,{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(Pe=>e.jsx("button",{type:"button",onClick:()=>p(Pe),className:"focus:outline-none",children:e.jsx(Jn,{className:`h-8 w-8 transition-colors ${u>=Pe?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400"}`})},Pe))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Review"}),e.jsx(Er,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:f,onChange:Pe=>g(Pe.target.value),rows:4})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{onClick:ue,disabled:b,className:"bg-yellow-600 hover:bg-yellow-700",children:b?"Submitting...":"Submit & Earn 25 Points"})]})]})})}),e.jsx(fs,{open:!!M,onOpenChange:()=>L(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[M==null?void 0:M.name,e.jsxs(tt,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),M==null?void 0:M.points_cost]})]}),(M==null?void 0:M.category)&&e.jsxs(tt,{variant:"outline",className:"w-fit",children:[M.category.icon&&`${M.category.icon} `,M.category.name]})]}),(M==null?void 0:M.preview_image_url)&&e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted rounded-lg",children:e.jsx("img",{src:M.preview_image_url,alt:M.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:(M==null?void 0:M.description)||"No description available"}),(M==null?void 0:M.item_type)==="reelflow_credits"&&e.jsxs("p",{className:"text-sm text-violet-600 font-medium",children:["🎬 Grants ",M==null?void 0:M.max_quantity," ReelFlow credits per purchase"]}),(M==null?void 0:M.item_type)!=="reelflow_credits"&&(M==null?void 0:M.max_quantity)!==null&&!xe.has((M==null?void 0:M.id)||"")&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[M==null?void 0:M.current_quantity," of ",M==null?void 0:M.max_quantity," remaining"]})]}),e.jsx(qn,{children:M&&M.item_type!=="reelflow_credits"&&xe.has(M.id)?e.jsx(K,{className:"w-full",onClick:()=>{M.file_url&&Mye(M.file_url,M.name)},disabled:!M.file_url,children:M.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Access"]})}):M&&e.jsx(K,{className:"w-full",onClick:()=>{L(null),l(M)},disabled:M.item_type!=="reelflow_credits"&&M.max_quantity!==null&&M.current_quantity===0||oe{const{user:t}=Ds(),s=Qt(),r=mt({queryKey:["smart-presentations",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:p}=await H.from("smart_presentations").select("*").eq("owner_user_id",t.id).neq("status","archived").order("created_at",{ascending:!1});if(p)throw p;return u||[]},enabled:!!t}),n=mt({queryKey:["smart-presentation-templates",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:p}=await H.from("smart_presentation_templates").select("*").eq("is_active",!0).order("created_at",{ascending:!0});if(p)throw p;return u||[]},enabled:!!t}),a=Dt({mutationFn:async u=>{const{data:p,error:f}=await H.from("smart_presentations").insert({owner_user_id:t.id,...u}).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),o=Dt({mutationFn:async({id:u,...p})=>{const{data:f,error:g}=await H.from("smart_presentations").update(p).eq("id",u).select().single();if(g)throw g;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),l=Dt({mutationFn:async u=>{const{data:p,error:f}=await H.from("smart_presentations").update({status:"published",published_at:new Date().toISOString()}).eq("id",u).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),me.success("Presentation published!")}}),i=Dt({mutationFn:async u=>{const{error:p}=await H.from("smart_presentations").update({status:"archived"}).eq("id",u);if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),me.success("Presentation archived")}}),c=Dt({mutationFn:async u=>{const{error:p}=await H.from("smart_presentation_templates").insert({owner_user_id:t.id,name:u.title+" Template",description:"Created from "+u.title,template_type:"custom",icon:"📄",sections:u.sections,cta_config:{type:u.cta_type,label:u.cta_label},is_system:!1});if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentation-templates"]}),me.success("Saved as template!")}});return{presentations:r.data||[],templates:n.data||[],isLoading:r.isLoading,templatesLoading:n.isLoading,createPresentation:a,updatePresentation:o,publishPresentation:l,archivePresentation:i,saveAsTemplate:c}},DCs=()=>{const t=fr(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=pct(),o=i=>i.status==="draft"?e.jsx(tt,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?e.jsx(tt,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?e.jsx(tt,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):e.jsx(tt,{variant:"secondary",className:"text-xs",children:"Not Opened"}),l=i=>{const c=`https://presentations.relevelup.com/${i}`;navigator.clipboard.writeText(c),me.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($s,{className:"h-4 w-4"}),"Create Presentation"]})]}),r?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(i=>e.jsx(ys,{className:"h-20 w-full rounded-lg"},i))}):s.length===0?e.jsx(Ee,{children:e.jsxs(De,{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(Jg,{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($s,{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(De,{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(Sn,{className:"h-5 w-5 text-primary"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold truncate",children:i.title}),o(i)]}),e.jsxs("div",{className:"flex items-center gap-x-3 gap-y-0.5 flex-wrap text-sm text-muted-foreground mt-0.5",children:[i.client_name&&e.jsx("span",{children:i.client_name}),e.jsxs("span",{children:["Created ",ms(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(On,{className:"h-3 w-3"})," ",i.view_count," view",i.view_count!==1?"s":""]}),i.cta_clicked_count>0&&e.jsx("span",{className:"text-emerald-600 font-medium",children:"CTA clicked"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap sm:flex-nowrap sm:shrink-0",children:[i.status==="published"&&i.share_token&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>l(i.share_token),children:[e.jsx(gi,{className:"h-3.5 w-3.5 mr-1"}),"Copy Link"]}),i.status==="published"&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}?edit=true`),children:"Edit"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}`),children:i.status==="draft"?"Edit":"View"}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(mx,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[i.status==="published"&&i.share_token&&e.jsxs(Ma,{onClick:()=>window.open(`https://presentations.relevelup.com/${i.share_token}`,"_blank"),children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),e.jsxs(Ma,{onClick:()=>a.mutate(i),children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),e.jsxs(Ma,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[e.jsx(NM,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},Bze={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."}]},OCs=[{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 RCs(t){const s=Bze[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries(Bze))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return OCs}function FCs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=N.useState(!1),[o,l]=N.useState("script"),[i,c]=N.useState(0),[u,p]=N.useState(0),{canRecord:f}=Uat(),g=SC(),[b,_]=N.useState(""),[j,w]=N.useState(!1),[k,S]=N.useState(!0),[M,L]=N.useState(!1),[I,O]=N.useState(null),q=RCs(t),U=()=>{l("script"),c(0),p(0),_(""),w(!1),S(!0),L(!1),O(null)},B=Q=>{!Q&&(o==="uploading"||o==="processing")||(a(Q),Q||U())},V=Q=>{O(Q),_(q[Q].text),w(!1)},Z=()=>{l("record"),S(b.trim().length>0)},X=()=>{_(""),S(!1),l("record")},ee=N.useCallback(async(Q,ie)=>{l("uploading");try{const re=t||"Presentation Video",{videoId:oe,uploadUrl:ce,libraryId:xe}=await pR(re),{apiKey:ge}=await fR(oe),ue=new XMLHttpRequest;ue.upload.onprogress=Pe=>{Pe.lengthComputable&&c(Pe.loaded/Pe.total*100)},await new Promise((Pe,Oe)=>{ue.onload=()=>ue.status>=200&&ue.status<300?Pe():Oe(new Error("Upload failed")),ue.onerror=()=>Oe(new Error("Upload failed")),ue.open("PUT",ce),ue.setRequestHeader("AccessKey",ge),ue.send(Q)}),l("processing");let pe=0;const be=Date.now(),Me=9e4;let Ne=null;for(;pe<4;){if(await new Promise(Oe=>setTimeout(Oe,3e3)),Date.now()-be>Me){const Oe=Q.size/1048576,Te=`https://iframe.mediadelivery.net/embed/${xe}/${oe}?responsive=true`;await g.mutateAsync({bunny_video_id:oe,playback_url:Te,file_size_mb:Oe,title:re,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(Te),me.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const Pe=await _A(oe);if(pe=Pe.status,p(Pe.encodeProgress||0),pe===4)Ne={playbackUrl:Pe.directPlayUrl,thumbnailUrl:Pe.thumbnailUrl,previewUrl:Pe.previewUrl||null,duration:Pe.length||ie,fileSizeMb:(Pe.storageSize||Q.size)/(1024*1024)};else if(pe===5||pe===6)throw new Error("Video processing failed")}if(!Ne)throw new Error("No video data");await g.mutateAsync({bunny_video_id:oe,contact_id:s||void 0,playback_url:Ne.playbackUrl,thumbnail_url:Ne.thumbnailUrl,preview_url:Ne.previewUrl,duration_seconds:Ne.duration,file_size_mb:Ne.fileSizeMb,title:re,status:"ready",touch_type:"presentation"}),r(Ne.playbackUrl),me.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(re){console.error("Recording upload error:",re),me.error("Failed to process video. Please try again."),l("record")}},[t,s,r,g]);return e.jsxs(fs,{open:n,onOpenChange:B,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Record a video",children:[e.jsx(An,{className:"h-3.5 w-3.5"}),"Record"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto !top-[5%] !translate-y-0 sm:!top-[5%] sm:!translate-y-0",children:[e.jsx(_s,{children:e.jsxs(vs,{children:[o==="script"&&`Prepare your script for "${t}"`,o==="record"&&`Record video for "${t}"`,o==="uploading"&&"Uploading...",o==="processing"&&"Processing...",o==="done"&&"Done!"]})}),o==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a starter script below, edit it to make it yours, or skip and speak freely."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starter Scripts"}),e.jsx("div",{className:"grid gap-2",children:q.map((Q,ie)=>e.jsxs("button",{onClick:()=>V(ie),className:It("text-left p-3 rounded-lg border transition-all hover:bg-accent/50",I===ie?"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(Sn,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:Q.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 ml-5.5",children:Q.text})]},ie))})]}),b&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Your Script"}),!j&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>w(!0),className:"h-7 text-xs gap-1",children:[e.jsx(Ra,{className:"h-3 w-3"}),"Edit"]})]}),j?e.jsx(Er,{value:b,onChange:Q=>_(Q.target.value),rows:5,placeholder:"Type your script here...",className:"text-sm"}):e.jsx("div",{className:"p-3 rounded-lg bg-muted/50 text-sm text-foreground leading-relaxed",children:b})]}),!b&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Or Write Your Own"}),e.jsx(Er,{value:b,onChange:Q=>{_(Q.target.value),O(null)},rows:4,placeholder:"Type your own script here...",className:"text-sm"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:X,className:"text-muted-foreground",children:"Skip — no teleprompter"}),e.jsx(K,{onClick:Z,disabled:!1,children:b.trim()?"Continue with Script":"Continue Without Script"})]})]}),!f&&o==="record"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-8 text-center",children:[e.jsx(Ku,{className:"h-10 w-10 text-destructive"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You've reached your video storage limit. Delete some videos to free up space."})]}):o==="record"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Record up to 60 seconds. Saved to your library & auto-attached."}),b.trim()&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>S(!k),className:"h-7 text-xs gap-1",children:[k?e.jsx(kp,{className:"h-3 w-3"}):e.jsx(On,{className:"h-3 w-3"}),k?"Hide Script":"Show Script"]})]}),e.jsx(gme,{maxDurationSeconds:60,onRecordingComplete:ee,onRecordingStateChange:L,onError:Q=>me.error(Q),teleprompterContent:b.trim()?e.jsx(ilt,{text:b,isVisible:k,onToggleVisibility:()=>S(!k),isRecording:M,startCountdown:!1}):void 0}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>l("script"),className:"text-xs text-muted-foreground",children:"← Back to script"})]}):o==="uploading"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(ws,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(Bi,{value:i,className:"h-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Uploading... ",Math.round(i),"%"]})]})]}):o==="processing"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(ws,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(Bi,{value:u,className:"h-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Processing... ",Math.round(u),"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"This usually takes less than a minute"})]})]}):o==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[e.jsx(xi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Video attached!"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved to your video library"})]}):null]})]})}function zCs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=N.useState(!1),[o,l]=N.useState(null),[i,c]=N.useState("idle"),[u,p]=N.useState(0),f=N.useRef(null),g=SC(),{data:b}=Hhe(),_=(b==null?void 0:b.total_storage_mb)||0,w=((b==null?void 0:b.max_storage_mb)||1024)-_,k=()=>{l(null),c("idle"),p(0)},S=q=>{!q&&i!=="idle"&&i!=="done"||(a(q),q||k())},M=q=>{var V;const U=(V=q.target.files)==null?void 0:V[0];if(!U)return;if(!U.type.startsWith("video/")){me.error("Please select a video file");return}const B=U.size/(1024*1024);if(B>500){me.error("Video file must be less than 500MB");return}if(B>w){me.error(`Not enough storage. You have ${w.toFixed(1)} MB remaining.`);return}l(U)},L=N.useCallback(async()=>{if(o){c("creating"),p(0);try{const q=t||o.name,{data:U,error:B}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:q,isAgentVideo:!0}});if(B)throw new Error(B.message);const{videoId:V,libraryId:Z}=U;c("uploading");const{data:X,error:ee}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:V,isAgentVideo:!0}});if(ee)throw new Error(ee.message);await new Promise((re,oe)=>{const ce=new XMLHttpRequest;ce.upload.addEventListener("progress",xe=>{xe.lengthComputable&&p(Math.round(xe.loaded/xe.total*100))}),ce.addEventListener("load",()=>ce.status>=200&&ce.status<300?re():oe(new Error(`Upload failed (${ce.status})`))),ce.addEventListener("error",()=>oe(new Error("Upload failed"))),ce.open("PUT",X.uploadUrl),ce.setRequestHeader("AccessKey",X.apiKey),ce.send(o)}),c("processing");const Q=o.size/(1024*1024),ie=`https://iframe.mediadelivery.net/embed/${Z}/${V}`;await g.mutateAsync({bunny_video_id:V,playback_url:ie,file_size_mb:Q,title:q,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(ie),c("done"),me.success("Video uploaded & attached to section!"),setTimeout(()=>a(!1),1200)}catch(q){console.error("Upload error:",q),me.error(q instanceof Error?q.message:"Failed to upload video"),c("idle")}}},[o,t,s,r,g]),I=()=>{switch(i){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${u}%`;case"processing":return"Saving video...";case"done":return"Done!";default:return""}},O=i!=="idle"&&i!=="done";return e.jsxs(fs,{open:n,onOpenChange:S,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Upload a video file",children:[e.jsx(li,{className:"h-3.5 w-3.5"}),"Upload"]})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsx(_s,{children:e.jsxs(vs,{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(An,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(o.size/(1024*1024)).toFixed(1)," MB"]})]}),!O&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(null),children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>{var q;return(q=f.current)==null?void 0:q.click()},children:[e.jsx(li,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select a video file"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, MOV, WebM (max 500MB)"})]}),e.jsx("input",{ref:f,type:"file",accept:"video/*",className:"hidden",onChange:M,disabled:O}),O&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:I()})]}),e.jsx(Bi,{value:i==="uploading"?u:i==="processing"?100:10})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),disabled:O,children:"Cancel"}),e.jsx(K,{onClick:L,disabled:!o||O,children:O?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const $ze=[{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"}],qze=()=>{const t=fr(),{id:s}=yo(),{user:r}=Ds(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=pct(),{isGmailConnected:c,gmailEmail:u}=Wx(),[p,f]=N.useState(!1),[g,b]=N.useState("client"),[_,j]=N.useState(!1),[w,k]=N.useState(""),[S,M]=N.useState([]),[L,I]=N.useState(!1),[O,q]=N.useState(null),[U,B]=N.useState(!1),[V,Z]=N.useState(""),[X,ee]=N.useState(""),[Q,ie]=N.useState(""),[re,oe]=N.useState("buyer"),[ce,xe]=N.useState(""),[ge,ue]=N.useState(null),[pe,be]=N.useState(""),[Me,Ne]=N.useState([]),[Pe,Oe]=N.useState("schedule_call"),[Te,ke]=N.useState("Schedule a Call"),[Be,nt]=N.useState(""),[Ae,ft]=N.useState(""),[fe,Ve]=N.useState(null),[at,et]=N.useState(s||null),[Ce,rt]=N.useState(null),[Ge,ct]=N.useState(!1),qe=async(xt,Es)=>{if(!r)return;const ur=5*1024*1024;if(xt.size>ur){me.error("Image must be under 5MB");return}if(!xt.type.startsWith("image/")){me.error("Please upload an image file");return}Ve(Es);try{const Mr=xt.name.split(".").pop()||"jpg",Lr=`${r.id}/${Date.now()}.${Mr}`,{error:fn}=await H.storage.from("listing-photos").upload(Lr,xt);if(fn)throw fn;const{data:{publicUrl:ki}}=H.storage.from("listing-photos").getPublicUrl(Lr);Lt(Es,{image_url:ki}),me.success("Image uploaded")}catch{me.error("Failed to upload image")}finally{Ve(null)}};N.useEffect(()=>{s&&Ze(s)},[s]);const Ze=async xt=>{const{data:Es,error:ur}=await H.from("smart_presentations").select("*").eq("id",xt).single();if(ur||!Es)return;const Mr=Es;if(j(!0),be(Mr.title),Z(Mr.client_name||""),xe(Mr.property_address||""),Ne(Mr.sections||[]),Oe(Mr.cta_type||"schedule_call"),ke(Mr.cta_label||"Schedule a Call"),nt(Mr.cta_url||""),ft(Mr.heading||""),rt(Mr.share_token),ct(Mr.status==="published"),et(Mr.id),b("builder"),Mr.contact_id){const{data:Lr}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",Mr.contact_id).maybeSingle();Lr&&(q(Lr),ee(Lr.email||""),ie(Lr.phone||""))}};N.useEffect(()=>{if(!r||w.length<1){M([]);return}const xt=setTimeout(async()=>{I(!0);const{data:Es}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone, lead_source").eq("owner_user_id",r.id).or(`first_name.ilike.%${w}%,last_name.ilike.%${w}%,email.ilike.%${w}%`).limit(10);M(Es||[]),I(!1)},300);return()=>clearTimeout(xt)},[w,r]);const Qe=xt=>{q(xt),Z(`${xt.first_name} ${xt.last_name||""}`.trim()),ee(xt.email||""),ie(xt.phone||""),B(!1)},He=async()=>{if(!V.trim()){me.error("Client name is required");return}const xt=V.trim().split(" "),Es=xt[0],ur=xt.slice(1).join(" ")||null,{data:Mr,error:Lr}=await H.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:Es,last_name:ur,email:X||null,phone:Q||null,lead_source:"Smart Presentation"}).select().single();if(Lr){me.error("Failed to create client");return}q(Mr),me.success("Client created & saved to Agent OS"),b("template")},Je=xt=>{ue(xt);const Es=(xt.sections||[]).map(ur=>({...ur,is_visible:!0,video_url:"",text:""}));if(Ne(Es),be(xt.name+(V?` for ${V}`:"")),xt.cta_config){const ur=xt.cta_config;Oe(ur.type||"schedule_call"),ke(ur.label||"Schedule a Call")}b("builder")},it=()=>{Ne([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),be(V?`Presentation for ${V}`:"New Presentation"),b("builder")},Lt=(xt,Es)=>{Ne(ur=>ur.map((Mr,Lr)=>Lr===xt?{...Mr,...Es}:Mr))},Vt=xt=>{Lt(xt,{is_visible:!Me[xt].is_visible})},hs=()=>{Ne(xt=>[...xt,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},Ts=xt=>{Ne(Es=>Es.filter((ur,Mr)=>Mr!==xt))},Cs=async()=>{if(!pe.trim()){me.error("Title is required");return}try{if(at){const xt=await l.mutateAsync({id:at,title:pe,sections:Me,client_name:V,property_address:ce||null,cta_type:Pe,cta_label:Te,cta_url:Be||null,heading:Ae||null});me.success("Saved")}else{const xt=await o.mutateAsync({title:pe,contact_id:(O==null?void 0:O.id)||void 0,client_name:V,property_address:ce||void 0,template_id:(ge==null?void 0:ge.id)||void 0,sections:Me,cta_type:Pe,cta_label:Te,cta_url:Be||void 0,heading:Ae||void 0});et(xt.id),rt(xt.share_token),me.success("Presentation created!")}}catch(xt){console.error("Failed to save presentation:",xt);const Es=(xt==null?void 0:xt.message)||(xt==null?void 0:xt.toString())||"Unknown error";me.error(`Failed to save: ${Es}`)}},cs=async()=>{try{await Cs();const xt=at;if(xt){const Es=await i.mutateAsync(xt);rt(Es.share_token),ct(!0),b("share")}}catch(xt){console.error("Failed to publish presentation:",xt),me.error(`Failed to publish: ${(xt==null?void 0:xt.message)||"Unknown error"}`)}},er=Ce?`https://presentations.relevelup.com/${Ce}`:"";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(Ja,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-serif font-bold text-foreground",children:_?"Edit Presentation":"Create Smart Presentation"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[g==="client"&&"Who is this presentation for?",g==="template"&&"Choose a starting template",g==="builder"&&"Customize your presentation",g==="share"&&"Share with your client"]})]})]}),!_&&e.jsx("div",{className:"flex items-center gap-2",children:["client","template","builder","share"].map((xt,Es)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:It("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",g===xt?"bg-primary text-primary-foreground":Es<["client","template","builder","share"].indexOf(g)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:Es<["client","template","builder","share"].indexOf(g)?e.jsx(va,{className:"h-4 w-4"}):Es+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:xt}),Es<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},xt))}),g==="client"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>{q(null),Z(""),ee(""),ie(""),B(!1),b("template")},className:"w-full group flex items-center justify-between gap-4 rounded-xl border border-dashed border-primary/30 bg-primary/5 hover:bg-primary/10 transition-all p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Bn,{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(Qa,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors shrink-0"})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(cn,{className:"h-4 w-4 text-muted-foreground"}),"Select Existing Client"]})}),e.jsxs(De,{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:w,onChange:xt=>k(xt.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[L&&e.jsx(ys,{className:"h-12 w-full"}),S.map(xt=>e.jsxs("button",{onClick:()=>Qe(xt),className:It("w-full text-left p-3 rounded-lg border transition-colors",(O==null?void 0:O.id)===xt.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[xt.first_name," ",xt.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:xt.email||xt.phone||"No contact info"})]},xt.id)),!w&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Start typing to search your contacts"}),w&&S.length===0&&!L&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No clients found"})]}),O&&e.jsxs(K,{onClick:()=>b("template"),className:"w-full gap-2",children:["Continue with ",O.first_name,e.jsx(Qa,{className:"h-4 w-4"})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(Tl,{className:"h-4 w-4 text-muted-foreground"}),"Add New Client"]})}),e.jsxs(De,{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(ze,{value:V,onChange:xt=>{Z(xt.target.value),B(!0),q(null)},placeholder:"Sarah & Mike Johnson"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Email"}),e.jsx(ze,{value:X,onChange:xt=>ee(xt.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Phone"}),e.jsx(ze,{value:Q,onChange:xt=>ie(xt.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Client Type"}),e.jsxs(Zs,{value:re,onValueChange:oe,children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"}),e.jsx(Mt,{value:"recruit",children:"Recruit"}),e.jsx(Mt,{value:"other",children:"Other"})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Property Address"}),e.jsx(ze,{value:ce,onChange:xt=>xe(xt.target.value),placeholder:"Optional"})]})]}),U&&V&&e.jsxs(K,{onClick:He,className:"w-full gap-2",children:["Create Client & Continue",e.jsx(Qa,{className:"h-4 w-4"})]})]})]})]})]}),g==="template"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(ba,{defaultValue:"system",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"mine",children:"My Core Templates"}),e.jsx(ns,{value:"system",children:"LevelUp Smart Templates"}),e.jsx(ns,{value:"blank",children:"+ Start Blank"})]}),e.jsx(bs,{value:"mine",className:"mt-4",children:a?e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[1,2].map(xt=>e.jsx(ys,{className:"h-32"},xt))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(xt=>!xt.is_system).length===0?e.jsx("p",{className:"text-muted-foreground col-span-2 text-center py-8",children:"You haven't saved any templates yet. Create a presentation and save it as a template!"}):n.filter(xt=>!xt.is_system).map(xt=>e.jsx(Uze,{template:xt,onSelect:Je},xt.id))})}),e.jsx(bs,{value:"system",className:"mt-4",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(xt=>xt.is_system).map(xt=>e.jsx(Uze,{template:xt,onSelect:Je},xt.id))})}),e.jsx(bs,{value:"blank",className:"mt-4",children:e.jsx(Ee,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start with a blank canvas and add your own sections."}),e.jsx(K,{onClick:it,children:"Start from Scratch"})]})})})]}),e.jsxs(K,{variant:"outline",onClick:()=>b("client"),className:"gap-2",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back"]})]}),g==="builder"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{children:e.jsxs(De,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Presentation Title"}),e.jsx(ze,{value:pe,onChange:xt=>be(xt.target.value)})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Page Heading"}),e.jsx(ze,{value:Ae,onChange:xt=>ft(xt.target.value),placeholder:V?`Welcome, ${V}!`:"e.g. Welcome! or Your Custom Listing Plan"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:['The main heading visitors see. Leave blank for "Welcome, ',"",'!"']})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Client Name"}),e.jsx(ze,{value:V,onChange:xt=>Z(xt.target.value)})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Property Address"}),e.jsx(ze,{value:ce,onChange:xt=>xe(xt.target.value),placeholder:"Optional"})]})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sections"}),e.jsx(K,{variant:"outline",size:"sm",onClick:hs,children:"+ Add Section"})]}),e.jsx("div",{className:"space-y-3",children:Me.map((xt,Es)=>e.jsx(Ee,{className:It(!xt.is_visible&&"opacity-50"),children:e.jsx(De,{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(Cu,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),e.jsx("span",{className:"text-lg",children:xt.icon})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ze,{value:xt.title,onChange:ur=>Lt(Es,{title:ur.target.value}),className:"font-semibold border-none p-0 h-auto text-base focus-visible:ring-0 bg-transparent"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Vt(Es),children:xt.is_visible?e.jsx(On,{className:"h-4 w-4"}):e.jsx(kp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ts(Es),className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})]})]}),e.jsx(ze,{value:xt.description||"",onChange:ur=>Lt(Es,{description:ur.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(ze,{value:xt.video_url||"",onChange:ur=>Lt(Es,{video_url:ur.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx(FCs,{sectionTitle:xt.title,contactId:O==null?void 0:O.id,onVideoReady:ur=>Lt(Es,{video_url:ur})}),e.jsx(zCs,{sectionTitle:xt.title,contactId:O==null?void 0:O.id,onVideoReady:ur=>Lt(Es,{video_url:ur})}),e.jsx(oCe,{userId:r==null?void 0:r.id,onSelect:ur=>Lt(Es,{video_url:ur})})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),xt.image_url?e.jsxs("div",{className:"relative mt-1 rounded-lg overflow-hidden border border-border bg-muted/30 group",children:[e.jsx("img",{src:xt.image_url,alt:"",className:"w-full max-h-40 object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>Lt(Es,{image_url:""}),children:e.jsx(Rr,{className:"h-3.5 w-3.5"})})]}):e.jsxs("label",{className:"mt-1 flex items-center gap-2 cursor-pointer rounded-lg border border-dashed border-border hover:border-primary/50 p-3 transition-colors",children:[fe===Es?e.jsx(ws,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(a1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:fe===Es?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:fe===Es,onChange:ur=>{var Lr;const Mr=(Lr=ur.target.files)==null?void 0:Lr[0];Mr&&qe(Mr,Es),ur.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Text (optional)"}),e.jsx(my,{content:xt.text||"",onChange:ur=>Lt(Es,{text:ur}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},Es))})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Call to Action"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"CTA Type"}),e.jsxs(Zs,{value:Pe,onValueChange:xt=>{Oe(xt);const Es=$ze.find(ur=>ur.value===xt);Es&&ke(Es.label)},children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:$ze.map(xt=>e.jsx(Mt,{value:xt.value,children:xt.label},xt.value))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Button Label"}),e.jsx(ze,{value:Te,onChange:xt=>ke(xt.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(ze,{value:Be,onChange:xt=>nt(xt.target.value),placeholder:"https://calendly.com/..."}),!Be&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Without a URL, clients will see a contact form — their info gets added to your contacts and you'll receive an email notification."})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[!_&&e.jsxs(K,{variant:"outline",onClick:()=>b("template"),className:"gap-2",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back"]}),e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsx(K,{variant:"outline",onClick:Cs,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(K,{onClick:cs,disabled:i.isPending,className:"gap-2",children:[e.jsx(Bn,{className:"h-4 w-4"}),Ge?"Update & Reshare":"Publish & Share"]})]})]})]}),g==="share"&&Ce&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{children:e.jsxs(De,{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(va,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Your Presentation is Live!"}),e.jsxs("p",{className:"text-muted-foreground mb-6 max-w-md",children:["Share this link with ",V||"your client",". You'll be notified when they view it."]}),e.jsxs("div",{className:"flex items-center gap-2 w-full max-w-lg",children:[e.jsx(ze,{value:er,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(K,{onClick:()=>{navigator.clipboard.writeText(er),me.success("Link copied!")},children:e.jsx(gi,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-3 mt-6",children:[e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{const xt=`Hi ${V||""}! I put together something for you — check it out: ${er}`;navigator.clipboard.writeText(xt),me.success("Message copied!")},children:[e.jsx(so,{className:"h-4 w-4"}),"Copy Text Message"]}),e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{c?f(!0):window.open(`mailto:${X||""}?subject=${encodeURIComponent(pe)}&body=${encodeURIComponent(`Hi ${(O==null?void 0:O.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${er} Looking forward to connecting!`)}`)},children:[e.jsx(cr,{className:"h-4 w-4"}),"Send Email"]})]}),c&&e.jsx(qw,{open:p,onOpenChange:f,contact:O?{id:O.id,first_name:O.first_name,last_name:O.last_name,email:X||O.email||""}:X?{id:"",first_name:(V==null?void 0:V.split(" ")[0])||"",last_name:(V==null?void 0:V.split(" ").slice(1).join(" "))||"",email:X}:void 0,defaultSubject:pe,defaultBody:`Hi ${(O==null?void 0:O.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${er} Looking forward to connecting!`,gmailEmail:u})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(K,{variant:"outline",onClick:()=>b("builder"),children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(K,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},Uze=({template:t,onSelect:s})=>e.jsx(Ee,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(De,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-2xl",children:t.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold",children:t.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(tt,{variant:"outline",className:"text-xs capitalize",children:t.template_type}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(t.sections||[]).length," sections"]})]})]})]}),e.jsx(K,{className:"w-full mt-4",size:"sm",onClick:()=>s(t),children:"Use Template"})]})}),BCs=()=>{var j;const{shareToken:t}=yo(),[s,r]=N.useState(null),[n,a]=N.useState(!0),[o,l]=N.useState(0),[i,c]=N.useState(!1);N.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),N.useEffect(()=>{t&&u()},[t]);const u=async()=>{const{data:w,error:k}=await H.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(k||!w){c(!0),a(!1);return}const{data:S}=await H.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",w.owner_user_id).single();let M;if(S!=null&&S.brokerage_id){const{data:I}=await H.from("brokerages").select("name").eq("id",S.brokerage_id).single();M=(I==null?void 0:I.name)||void 0}let L=null;if(w.contact_id){const{data:I}=await H.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",w.contact_id).single();L=I}r({...w,owner_name:S==null?void 0:S.name,owner_email:S==null?void 0:S.email,owner_phone:S==null?void 0:S.phone,owner_avatar:S==null?void 0:S.avatar_url,owner_title:(S==null?void 0:S.title)||void 0,brokerage_name:M,contact_name:L?[L.first_name,L.last_name].filter(Boolean).join(" "):void 0,contact_email:(L==null?void 0:L.email)||void 0,contact_phone:(L==null?void 0:L.phone)||void 0}),a(!1);try{await H.rpc("log_presentation_view",{p_presentation_id:w.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await H.rpc("log_presentation_view",{p_presentation_id:s.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}s.cta_url&&window.open(s.cta_url,"_blank")}};if(n)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[e.jsx(ys,{className:"h-12 w-3/4 mx-auto"}),e.jsx(ys,{className:"h-64 w-full"}),e.jsx(ys,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!s)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const f=s.sections.filter(w=>w.is_visible!==!1),g=f[o],b=w=>{const k=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(k)return`https://www.youtube.com/embed/${k[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const L=w.replace("/play/","/embed/"),I=L.includes("?")?"&":"?";return`${L}${I}responsive=true`}if(w.includes("iframe.mediadelivery.net")){if(w.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const I=w.includes("?")?"&":"?";return`${w}${I}responsive=true`}return""}const S=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(S)return`https://www.loom.com/embed/${S[1]}`;const M=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return M?`https://iframe.mediadelivery.net/embed/${M[1]}/${M[2]}?responsive=true`:w},_=!!((j=s.cta_url)!=null&&j.trim());return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})]})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[g!=null&&g.video_url&&b(g.video_url)?e.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:b(g.video_url),className:"absolute inset-0 w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,loading:"lazy"})}):g!=null&&g.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:g.image_url,alt:g.title,className:"w-full h-auto object-cover",loading:"lazy"})}):e.jsxs("div",{className:"aspect-video bg-gradient-to-br from-blue-50 to-slate-100 rounded-xl flex flex-col items-center justify-center shadow-lg",children:[e.jsx("span",{className:"text-5xl mb-3",children:g==null?void 0:g.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:g==null?void 0:g.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:g==null?void 0:g.description})]}),(g==null?void 0:g.text)&&e.jsx("div",{className:"mt-4 p-4 bg-white rounded-lg border text-gray-700 text-sm leading-relaxed prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:g.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:f.map((w,k)=>e.jsx("button",{onClick:()=>l(k),className:It("w-full text-left p-4 rounded-xl border transition-all",o===k?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(k+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children: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})]})]})},k))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),_?e.jsxs(K,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(tn,{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(lGe,{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 $Cs({openHouseId:t,enableSurvey:s,onToggleSurvey:r}){const{data:n,isLoading:a}=Vkt(t),o=Kkt(),l=Zkt(),i=Ykt(),c=Xkt(),[u,p]=N.useState(""),[f,g]=N.useState("rating"),b=async k=>{r(k),k&&(!n||n.length===0)&&await c.mutateAsync(t)},_=async()=>{if(!u.trim())return;const k=(n==null?void 0:n.reduce((S,M)=>Math.max(S,M.sort_order),0))??0;await o.mutateAsync({open_house_id:t,question_type:f,question_text:u.trim(),sort_order:k+1}),p("")},j=async k=>{await l.mutateAsync({id:k.id,open_house_id:t,is_active:!k.is_active})},w=async k=>{await i.mutateAsync({id:k.id,open_house_id:t})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(ve,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(R_,{className:"h-4 w-4"}),"Property Feedback Survey"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show a quick feedback survey after visitors sign in"})]}),e.jsx(qr,{checked:s,onCheckedChange:b})]}),s&&e.jsx("div",{className:"space-y-3 pt-2 border-t border-border",children:a?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2",children:n==null?void 0:n.map(k=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-muted/20",children:[e.jsx(Cu,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm truncate",children:k.question_text}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:k.question_type.replace("_"," ")})]}),e.jsx(qr,{checked:k.is_active,onCheckedChange:()=>j(k),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>w(k),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]},k.id))}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Add Question"}),e.jsx(ze,{value:u,onChange:k=>p(k.target.value),placeholder:"e.g. How did you hear about this listing?",className:"mt-1 h-9 text-sm",onKeyDown:k=>k.key==="Enter"&&_()})]}),e.jsxs(Zs,{value:f,onValueChange:g,children:[e.jsx(Ws,{className:"w-28 h-9 text-xs",children:e.jsx(Xs,{})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"rating",children:"Rating"}),e.jsx(Mt,{value:"open_text",children:"Text"})]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:_,disabled:!u.trim()||o.isPending,className:"h-9",children:e.jsx($s,{className:"h-3.5 w-3.5"})})]})]})})]})}function qCs({open:t,onOpenChange:s,openHouse:r}){const n=dGe(),{user:a}=Ds(),o=N.useRef(null),[l,i]=N.useState(r.auto_forward_to_card??!1),[c,u]=N.useState(r.disclosure_pdf_url??""),[p,f]=N.useState(r.enable_survey??!1),[g,b]=N.useState(!1),[_,j]=N.useState(!1),w=async M=>{var U;const L=(U=M.target.files)==null?void 0:U[0];if(!L||!a)return;if(L.size>20*1024*1024){wn({title:"File must be under 20MB",variant:"destructive"});return}if(L.type!=="application/pdf"){wn({title:"Only PDF files are accepted",variant:"destructive"});return}b(!0);const I=`${a.id}/disclosures/${r.id}-${Date.now()}.pdf`,{error:O}=await H.storage.from("open-house-photos").upload(I,L,{upsert:!0});if(O){wn({title:"Upload failed",description:O.message,variant:"destructive"}),b(!1);return}const{data:q}=H.storage.from("open-house-photos").getPublicUrl(I);u(q.publicUrl),b(!1),wn({title:"PDF uploaded!"})},k=()=>{u(""),o.current&&(o.current.value="")},S=async()=>{j(!0);try{await n.mutateAsync({id:r.id,auto_forward_to_card:l,disclosure_pdf_url:c||null,enable_survey:p}),wn({title:"Settings saved!"}),s(!1)}catch{wn({title:"Failed to save",variant:"destructive"})}finally{j(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Guest Book Settings"}),e.jsx(Gr,{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(qr,{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"}),c?e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:[e.jsx(Sn,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm truncate flex-1",children:"Disclosure PDF uploaded"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:k,children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsx("button",{type:"button",onClick:()=>{var M;return(M=o.current)==null?void 0:M.click()},disabled:g,className:"w-full h-24 rounded-xl border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:g?e.jsx(ws,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload PDF (max 20MB)"})]})})]}),e.jsx($Cs,{openHouseId:r.id,enableSurvey:p,onToggleSurvey:f}),e.jsx(K,{onClick:S,disabled:_,className:"w-full",children:_?"Saving...":"Save Settings"})]})]})})}const fct={5:"Excellent",4:"Good",3:"Neutral",2:"Bad",1:"Very Bad"};function UCs({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:fct[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 VCs({openHouseId:t}){const{data:s,isLoading:r}=Gkt(t),{data:n}=cGe(t),a=N.useMemo(()=>{const f={};return n==null||n.forEach(g=>{f[g.id]=g}),f},[n]);if(r||!s)return null;const{questions:o,responses:l}=s;if(o.length===0)return null;const i=o.filter(f=>f.question_type==="rating"),c=o.filter(f=>f.question_type!=="rating"),u=[...new Set(l.map(f=>f.visitor_id))],p=u.length;return p===0?e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(R_,{className:"h-4 w-4"}),"Survey Results"]})}),e.jsx(De,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No survey responses yet."})})]}):e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(R_,{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(De,{children:e.jsxs(ba,{defaultValue:"summary",children:[e.jsxs(pa,{className:"mb-4",children:[e.jsxs(ns,{value:"summary",className:"text-xs gap-1",children:[e.jsx(No,{className:"h-3.5 w-3.5"})," Summary"]}),e.jsxs(ns,{value:"individual",className:"text-xs gap-1",children:[e.jsx(to,{className:"h-3.5 w-3.5"})," Per Visitor"]})]}),e.jsxs(bs,{value:"summary",className:"space-y-6",children:[i.map(f=>e.jsx(UCs,{question:f,responses:l},f.id)),c.map(f=>{const g=l.filter(b=>b.question_id===f.id&&b.text_value);return g.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-sm font-medium",children:f.question_text}),e.jsx("div",{className:"space-y-1.5 max-h-40 overflow-y-auto",children:g.map(b=>{const _=a[b.visitor_id];return e.jsxs("div",{className:"text-sm p-2 bg-muted/30 rounded-lg",children:[e.jsxs("span",{className:"text-muted-foreground text-xs",children:[_?`${_.first_name} ${_.last_name||""}`.trim():"Visitor",":"]}),e.jsx("p",{className:"mt-0.5",children:b.text_value})]},b.id)})})]},f.id)})]}),e.jsx(bs,{value:"individual",className:"space-y-4",children:u.map(f=>{const g=a[f],b=l.filter(_=>_.visitor_id===f);return e.jsxs("div",{className:"p-3 rounded-lg border border-border space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium",children:[g?`${g.first_name} ${g.last_name||""}`.trim():"Unknown Visitor",(g==null?void 0:g.email)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:g.email})]}),e.jsx("div",{className:"space-y-1",children:b.map(_=>{const j=o.find(w=>w.id===_.question_id);return j?e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:j.question_text}),e.jsx("span",{className:"font-medium",children:_.rating_value!=null?fct[_.rating_value]||_.rating_value:_.text_value})]},_.id):null})})]},f)})})]})})]})}const pwe="guestbook.relevelup.com";function HCs(){const{data:t,isLoading:s}=Bkt(),r=$kt(),n=dGe(),a=qkt(),[o,l]=N.useState(!1),[i,c]=N.useState(null),{user:u}=Ds(),p=ci(),[f,g]=N.useState(null),[b,_]=N.useState(null),[j,w]=N.useState(!1),k=N.useRef(null),[S,M]=N.useState({property_address:"",city:"",state:"",zip:"",event_date:ms(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),L=U=>{var V;const B=(V=U.target.files)==null?void 0:V[0];if(B){if(B.size>5*1024*1024){wn({title:"Photo must be under 5MB",variant:"destructive"});return}g(B),_(URL.createObjectURL(B))}},I=()=>{g(null),_(null),k.current&&(k.current.value="")},O=async()=>{if(!S.property_address){wn({title:S.event_type==="community"?"Event name is required":"Address is required",variant:"destructive"});return}let U;if(f&&u){w(!0);const B=f.name.split(".").pop(),V=`${p}/${Date.now()}.${B}`,{error:Z}=await H.storage.from("open-house-photos").upload(V,f,{upsert:!0});if(Z){wn({title:"Photo upload failed",description:Z.message,variant:"destructive"}),w(!1);return}const{data:X}=H.storage.from("open-house-photos").getPublicUrl(V);U=X.publicUrl,w(!1)}await r.mutateAsync({...S,photo_url:U}),l(!1),M({property_address:"",city:"",state:"",zip:"",event_date:ms(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),I()},q=U=>{navigator.clipboard.writeText(`https://${pwe}/${U}`),wn({title:"Link copied!"})};return e.jsxs(Ms,{title:"Guest Book",children:[e.jsx(Sc,{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(fs,{open:o,onOpenChange:l,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"New Open House"]})}),e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create Open House"}),e.jsx(Gr,{children:"Set up a new open house sign-in page"})]}),e.jsxs("div",{className:"space-y-4 pt-2 overflow-y-auto flex-1 pr-1",children:[e.jsx("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:e.jsxs("div",{className:"flex gap-1 flex-1",children:[e.jsx("button",{type:"button",onClick:()=>M(U=>({...U,event_type:"property"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${S.event_type==="property"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Single Property"}),e.jsx("button",{type:"button",onClick:()=>M(U=>({...U,event_type:"community"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${S.event_type==="community"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Community Event"})]})}),e.jsxs("div",{children:[e.jsx(ve,{children:S.event_type==="community"?"Event Name *":"Property Address *"}),e.jsx(ze,{value:S.property_address,onChange:U=>M(B=>({...B,property_address:U.target.value})),placeholder:S.event_type==="community"?"Spring Festival at Riverside Estates":"123 Main Street"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"City"}),e.jsx(ze,{value:S.city,onChange:U=>M(B=>({...B,city:U.target.value})),placeholder:"Austin"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"State"}),e.jsx(ze,{value:S.state,onChange:U=>M(B=>({...B,state:U.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"ZIP"}),e.jsx(ze,{value:S.zip,onChange:U=>M(B=>({...B,zip:U.target.value})),placeholder:"78701"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Date"}),e.jsx(ze,{type:"date",value:S.event_date,onChange:U=>M(B=>({...B,event_date:U.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Start Time"}),e.jsx(ze,{type:"time",value:S.start_time,onChange:U=>M(B=>({...B,start_time:U.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"End Time"}),e.jsx(ze,{type:"time",value:S.end_time,onChange:U=>M(B=>({...B,end_time:U.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Welcome Message"}),e.jsx(Er,{value:S.agent_greeting,onChange:U=>M(B=>({...B,agent_greeting:U.target.value})),placeholder:"Welcome! Please sign in below."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:S.event_type==="community"?"Event Photo":"Property Photo"}),e.jsx("input",{ref:k,type:"file",accept:"image/*",onChange:L,className:"hidden"}),b?e.jsxs("div",{className:"relative mt-1 rounded-xl overflow-hidden border border-border",children:[e.jsx("img",{src:b,alt:"Property preview",className:"w-full h-40 object-cover"}),e.jsx("button",{type:"button",onClick:I,className:"absolute top-2 right-2 bg-black/60 hover:bg-black/80 text-white rounded-full p-1 transition-colors",children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var U;return(U=k.current)==null?void 0:U.click()},className:"mt-1 w-full h-32 rounded-xl border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(a1,{className:"h-6 w-6"}),e.jsxs("span",{className:"text-sm",children:["Add a ",S.event_type==="community"?"cover":"property"," photo"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Max 5MB"})]})]}),e.jsx(K,{onClick:O,disabled:r.isPending||j,className:"w-full",children:j?"Uploading photo...":r.isPending?"Creating...":S.event_type==="community"?"Create Community Event":"Create Open House"})]})]})]})]}),s?e.jsx("div",{className:"grid gap-4",children:[1,2].map(U=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Pt,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-48"}),e.jsx("div",{className:"h-4 bg-muted rounded w-32 mt-2"})]})},U))}):t!=null&&t.length?e.jsx("div",{className:"space-y-4",children:t.map(U=>e.jsx(WCs,{openHouse:U,isExpanded:i===U.id,onToggle:()=>c(i===U.id?null:U.id),onCopyLink:()=>q(U.slug||""),onToggleActive:()=>n.mutate({id:U.id,is_active:!U.is_active}),onDelete:()=>a.mutate(U.id)},U.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(De,{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(c1,{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($s,{className:"h-4 w-4 mr-2"}),"Create Your First Open House"]})]})})]})]})}function WCs({openHouse:t,isExpanded:s,onToggle:r,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=cGe(s?t.id:void 0),{data:i}=mt({queryKey:["agent-profile-flyer",t.agent_id],queryFn:async()=>{const{data:I,error:O}=await H.from("profiles").select("name, avatar_url, phone, title, brokerages:brokerage_id(name)").eq("id",t.agent_id).single();if(O)throw O;const q=I.brokerages;return{...I,brokerage_name:(q==null?void 0:q.name)||null}},enabled:!!t.agent_id}),[c,u]=N.useState(!1),[p,f]=N.useState(!1),[g,b]=N.useState(!1),_=N.useRef(null),j=`https://${pwe}/${t.slug}`,w=I=>{if(!I)return"";const[O,q]=I.split(":"),U=parseInt(O),B=U>=12?"PM":"AM";return`${U>12?U-12:U||12}:${q} ${B}`},k=()=>{if(!(l!=null&&l.length))return;const I=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],O=l.map(Z=>[Z.first_name,Z.last_name||"",Z.email||"",Z.phone||"",Z.visitor_intent||"",Z.wants_market_updates?"Yes":"No",(Z.message||"").replace(/"/g,'""'),ms(new Date(Z.created_at),"MM/dd/yyyy h:mm a")]),q=[I,...O].map(Z=>Z.map(X=>`"${X}"`).join(",")).join(` `),U=new Blob([q],{type:"text/csv"}),B=URL.createObjectURL(U),V=document.createElement("a");V.href=B,V.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-visitors.csv`,V.click(),URL.revokeObjectURL(B)},S=N.useCallback(()=>{if(!_.current)return;const I=_.current.querySelector("svg");if(!I)return;const O=new XMLSerializer().serializeToString(I),q=document.createElement("canvas");q.width=1024,q.height=1024;const U=q.getContext("2d"),B=new Image;B.onload=()=>{U==null||U.drawImage(B,0,0,1024,1024);const V=document.createElement("a");V.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-qr.png`,V.href=q.toDataURL("image/png"),V.click()},B.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(O)))},[t.property_address]),M=N.useCallback(()=>{var Ae;if(!_.current)return;const I=_.current.querySelector("svg");if(!I)return;const O=new XMLSerializer().serializeToString(I),q="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(O))),U=ms(new Date(t.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy"),B=t.start_time?`${w(t.start_time)}${t.end_time?" – "+w(t.end_time):""}`:"",V=[t.city,t.state].filter(Boolean).join(", "),Z=t.agent_greeting||"Welcome! Please sign in below.",X=!!t.photo_url,ee=!!i,Q=X||ee,ie=X&&ee,re=ie?"0.35in 0.75in 0.3in":"0.55in 0.75in 0.45in",oe=ie?"28px":"34px",ce=ie?"0.2in 0.75in":Q?"0.3in 0.75in":"0.4in 0.75in",xe=Q?"0.15in":"0.3in",ge=Q?"0.15in":"0.3in",ue=ie?"14px 36px":"22px 44px",pe=ie?"20px":"24px",be=Q?"0.2in":"0.35in",Me=ie?"1.8in":"2.4in",Ne=Q?"0.15in":"0.3in",Pe=ie?"140px":Q?"160px":"200px",Oe=ie?"16px":"24px",Te=ie?"10px 20px":"16px 28px",ke=ie?"44px":"56px",Be="0.15in",nt=window.open("","_blank");nt&&(nt.document.write(` Open House – ${t.property_address}
${t.event_type==="community"?"Community Event":"Open House"}
${t.property_address}
${V?`
${V}${t.zip?" "+t.zip:""}
`:""}
Date
${U}
${B?`
Time
${B}
`:""}
${Z}
${i?`
${i.avatar_url?`${i.name}`:`
${((Ae=i.name)==null?void 0:Ae.charAt(0))||"A"}
`}
Hosted By
${i.name}
${i.title?`
${i.title}
`:""} ${i.brokerage_name?`
${i.brokerage_name}
`:""} ${i.phone?`
${i.phone}
`:""}
`:""} ${t.photo_url?`Property`:""}
QR Code
Scan to Sign In
Point your phone camera at the QR code
`),nt.document.close(),setTimeout(()=>{nt.focus(),nt.print()},500))},[t,j,i]),L=async()=>{b(!0);try{const{error:I}=await H.functions.invoke("guestbook-email-link",{body:{openHouseId:t.id}});if(I)throw I;wn({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(I){wn({title:"Failed to send",description:I.message,variant:"destructive"})}finally{b(!1)}};return e.jsxs(Ee,{className:`transition-all ${t.is_active?"border-primary/30":"opacity-75"}`,children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-base leading-snug break-words",children:t.property_address}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 flex-wrap",children:[e.jsx(tt,{variant:t.is_active?"default":"secondary",className:"shrink-0 text-[11px]",children:t.is_active?"Active":"Inactive"}),t.agent_name&&e.jsxs(tt,{variant:"outline",className:"shrink-0 gap-1 text-[11px] bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300 border-blue-200 dark:border-blue-800",children:[e.jsx(to,{className:"h-3 w-3"}),t.agent_name]}),t.event_type==="community"&&e.jsxs(tt,{variant:"outline",className:"shrink-0 gap-1 text-[11px]",children:[e.jsx(ka,{className:"h-3 w-3"}),"Community"]})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,className:"shrink-0 -mr-2 -mt-1",children:s?e.jsx(pf,{className:"h-4 w-4"}):e.jsx(Eo,{className:"h-4 w-4"})})]}),e.jsxs(gr,{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs",children:[t.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(t.event_date+"T00:00:00"),"MMM d, yyyy")]}),t.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),w(t.start_time),t.end_time?` – ${w(t.end_time)}`:""]}),e.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[e.jsx(pr,{className:"h-3 w-3"}),t.visitor_count," visitors"]})]}),e.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto pb-1 -mx-1 px-1 scrollbar-hide",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>window.location.href=`/mission-control/guest-book/live/${t.id}`,title:"Go Live",className:"shrink-0 gap-1.5 text-emerald-600 border-emerald-200 hover:bg-emerald-50 dark:text-emerald-400 dark:border-emerald-800 dark:hover:bg-emerald-900/20 h-8 text-xs",children:[e.jsx(d1,{className:"h-3.5 w-3.5"}),"Live"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:n,title:"Copy link",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(gi,{className:"h-3.5 w-3.5"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>u(!0),title:"QR Code",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(c1,{className:"h-3.5 w-3.5"}),"QR"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>f(!0),title:"Settings",className:"shrink-0 h-8 text-xs",children:e.jsx(Xo,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>window.open(j,"_blank"),title:"Preview",className:"shrink-0 h-8 text-xs",children:e.jsx(tn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:a,title:t.is_active?"Deactivate":"Activate",className:"shrink-0 h-8 text-xs",children:t.is_active?e.jsx(kp,{className:"h-3.5 w-3.5"}):e.jsx(On,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:o,title:"Delete",className:"shrink-0 h-8 text-xs text-destructive border-destructive/30 hover:bg-destructive/10",children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})}),s&&e.jsxs(De,{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://",pwe,"/",t.slug]})]}),l!=null&&l.length?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:[l.length," Visitor",l.length!==1?"s":""]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:k,className:"h-7 text-xs gap-1",children:[e.jsx(yi,{className:"h-3 w-3"}),"Export CSV"]})]}),e.jsx("div",{className:"rounded-lg border overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-muted/30 text-xs text-muted-foreground",children:[e.jsx("th",{className:"text-left p-2 font-medium",children:"Name"}),e.jsx("th",{className:"text-left p-2 font-medium hidden sm:table-cell",children:"Contact"}),e.jsx("th",{className:"text-left p-2 font-medium hidden md:table-cell",children:"Intent"}),e.jsx("th",{className:"text-left p-2 font-medium",children:"Time"})]})}),e.jsx("tbody",{children:l.map(I=>e.jsxs("tr",{className:"border-t border-border/50",children:[e.jsxs("td",{className:"p-2 font-medium",children:[I.first_name,I.last_name?` ${I.last_name}`:""]}),e.jsxs("td",{className:"p-2 text-muted-foreground hidden sm:table-cell",children:[I.email&&e.jsx("div",{className:"truncate max-w-[180px]",children:I.email}),I.phone&&e.jsx("div",{className:"text-xs",children:I.phone})]}),e.jsx("td",{className:"p-2 hidden md:table-cell",children:I.visitor_intent&&e.jsx(tt,{variant:"outline",className:"text-xs capitalize",children:I.visitor_intent})}),e.jsx("td",{className:"p-2 text-xs text-muted-foreground",children:ms(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(VCs,{openHouseId:t.id})})]}),e.jsx(fs,{open:c,onOpenChange:u,children:e.jsxs(ps,{className:"sm:max-w-sm",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"QR Code"}),e.jsx(Gr,{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(kR,{value:j,size:240,level:"H"})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:j}),e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:S,children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:M,children:[e.jsx(vL,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(K,{variant:"default",className:"w-full",onClick:L,disabled:g,children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),g?"Sending...":"Email Link to Me"]})]})]})}),e.jsx(qCs,{open:p,onOpenChange:f,openHouse:t})]})}function GCs(){const{slug:t}=yo();return t?e.jsx(OZe,{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 xct({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=Ds(),l=SC(),i=N.useRef(null),c=N.useRef(null),[u,p]=N.useState(!1),[f,g]=N.useState(!1),[b,_]=N.useState(0),j=async k=>{if(o){p(!0);try{const S=k.name.split(".").pop()||"jpg",M=`${o.id}/card-${Date.now()}.${S}`,{error:L}=await H.storage.from("listing-photos").upload(M,k);if(L)throw L;const{data:{publicUrl:I}}=H.storage.from("listing-photos").getPublicUrl(M);r(I),me.success("Photo uploaded")}catch(S){me.error(S.message||"Failed to upload photo")}finally{p(!1)}}},w=async k=>{if(o){if(k.size>500*1024*1024){me.error("Video must be under 500MB");return}g(!0),_(0);try{const{videoId:S,libraryId:M}=await pR(`Card Video - ${Date.now()}`),{uploadUrl:L,apiKey:I}=await fR(S);await new Promise((U,B)=>{const V=new XMLHttpRequest;V.upload.addEventListener("progress",Z=>{Z.lengthComputable&&_(Math.round(Z.loaded/Z.total*100))}),V.addEventListener("load",()=>{V.status>=200&&V.status<300?U():B(new Error("Upload failed"))}),V.addEventListener("error",()=>B(new Error("Upload failed"))),V.open("PUT",L),V.setRequestHeader("AccessKey",I),V.send(k)});const O=`https://iframe.mediadelivery.net/embed/${M}/${S}`;n(O);const q=parseFloat((k.size/(1024*1024)).toFixed(2));await l.mutateAsync({bunny_video_id:S,playback_url:`https://iframe.mediadelivery.net/play/${M}/${S}`,file_size_mb:q,title:"Card Video",status:"processing",touch_type:"video",contact_id:a||void 0}),me.success("Video uploaded & added to your library")}catch(S){me.error(S.message||"Failed to upload video")}finally{g(!1),_(0)}}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Media (optional)"}),e.jsxs(ba,{defaultValue:"photo",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2",children:[e.jsxs(ns,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(gl,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(ns,{value:"video",className:"gap-1.5 text-xs",children:[e.jsx(An,{className:"h-3.5 w-3.5"}),"Video"]})]}),e.jsxs(bs,{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(Rr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var k;return(k=i.current)==null?void 0:k.click()},disabled:u,className:"w-full h-32 border-2 border-dashed border-border rounded-lg flex flex-col items-center justify-center gap-2 text-muted-foreground hover:border-primary/40 hover:bg-accent/50 transition-colors",children:u?e.jsx(ws,{className:"h-6 w-6 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(kx,{className:"h-6 w-6"}),e.jsx("span",{className:"text-xs",children:"Upload a photo"})]})}),e.jsx("input",{ref:i,type:"file",accept:"image/*",className:"hidden",onChange:k=>{var M;const S=(M=k.target.files)==null?void 0:M[0];S&&j(S),k.target.value=""}})]}),e.jsxs(bs,{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(Rr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var k;return(k=c.current)==null?void 0:k.click()},disabled:f,className:"w-full h-32 border-2 border-dashed border-border rounded-lg flex flex-col items-center justify-center gap-2 text-muted-foreground hover:border-primary/40 hover:bg-accent/50 transition-colors",children:f?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(ws,{className:"h-6 w-6 animate-spin"}),e.jsxs("span",{className:"text-xs",children:["Uploading... ",b,"%"]}),e.jsx("div",{className:"w-32 h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${b}%`}})})]}):e.jsxs(e.Fragment,{children:[e.jsx(li,{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(lCe,{contactId:a,onVideoReady:k=>n(k)})}),e.jsx("input",{ref:c,type:"file",accept:"video/*",className:"hidden",onChange:k=>{var M;const S=(M=k.target.files)==null?void 0:M[0];S&&w(S),k.target.value=""}}),e.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1.5 text-center",children:"Videos are also saved to your Video Library"})]})]})]})}const KCs=[{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 ZCs({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:KCs.map((s,r)=>e.jsxs(Hs.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:r*.04,duration:.25},onClick:()=>t(s.type),className:`group relative flex flex-col items-start gap-1 p-3.5 rounded-xl border bg-gradient-to-br ${s.gradient} hover:shadow-md hover:scale-[1.02] active:scale-[0.98] transition-all text-left`,children:[e.jsx("span",{className:"text-2xl",children:s.emoji}),e.jsx("span",{className:"text-sm font-semibold text-foreground",children:s.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground leading-tight",children:s.description})]},s.type))})}const RE={home_anniversary:{title:["Happy Home","Anniversary"],icon:"🏡",emojis:["🏡","✨","🎉","❤️","🎊","🏠"],defaultMessage:"Wishing you many more wonderful years of memories in your beautiful home. Thank you for letting me be part of your journey."},just_listed:{title:["Just","Listed!"],icon:"🏠",emojis:["🏠","📋","🔑","⭐","🎯","✨"],defaultMessage:"Exciting news — this beautiful property just hit the market! Contact me for a private showing."},just_sold:{title:["Just","Sold!"],icon:"🎉",emojis:["🎉","🏡","🔑","🥂","🎊","💰"],defaultMessage:"Another successful closing! Congratulations to the new homeowners. It was a pleasure making this happen."},congratulations:{title:["Congratulations!",""],icon:"🏆",emojis:["🎉","🥳","🏆","⭐","🎊","✨"],defaultMessage:"What an incredible milestone! I'm so happy for you. Wishing you all the best in this exciting new chapter."},birthday:{title:["Happy","Birthday!"],icon:"🎂",emojis:["🎂","🎈","🎁","🥳","🎉","🧁"],defaultMessage:"Wishing you the happiest of birthdays! May this year bring you joy, laughter, and everything you've been dreaming of."},holiday:{title:["Happy","Holidays!"],icon:"🎄",emojis:["🎄","❄️","🎁","⭐","🕯️","🎅"],defaultMessage:"Wishing you and your family a season filled with warmth, joy, and cherished moments. Happy Holidays!"},thank_you:{title:["Thank","You!"],icon:"💐",emojis:["💐","🙏","❤️","⭐","✨","🤝"],defaultMessage:"Thank you so much for your trust and confidence. It truly means the world to me. I'm always here for you!"},thinking_of_you:{title:["Thinking","Of You"],icon:"💭",emojis:["💭","❤️","🌸","☀️","🦋","💫"],defaultMessage:"Just wanted to reach out and let you know I'm thinking of you. I hope you're doing well — don't hesitate to reach out anytime!"}};function Vze({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=Ds(),c=Qt(),[u,p]=N.useState(!1),[f,g]=N.useState("type"),[b,_]=N.useState(""),[j,w]=N.useState(null),[k,S]=N.useState(!1),[M,L]=N.useState("home_anniversary"),[I,O]=N.useState(""),[q,U]=N.useState(""),[B,V]=N.useState(""),[Z,X]=N.useState(""),[ee,Q]=N.useState("elegant"),[ie,re]=N.useState(null),[oe,ce]=N.useState(null),xe=N.useState(!1);!xe[0]&&t&&s&&(xe[1](!0),p(!0),L(s),r&&w(r),n&&O(n),a&&U(a),o&&V(o),g(n?"details":"contact"));const{data:ge}=mt({queryKey:["contacts-for-card",i==null?void 0:i.id,b],queryFn:async()=>{let Be=H.from("innercircle_contacts").select("id, first_name, last_name, address, city, state, home_anniversary, email, phone").eq("owner_user_id",i.id).order("first_name").limit(20);b&&(Be=Be.or(`first_name.ilike.%${b}%,last_name.ilike.%${b}%`));const{data:nt,error:Ae}=await Be;if(Ae)throw Ae;return nt},enabled:!!(i!=null&&i.id)&&u}),{data:ue}=mt({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:Be,error:nt}=await H.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(nt)throw nt;return Be},enabled:!!(i!=null&&i.id)}),pe=Be=>{w(Be.id),O(`${Be.first_name}${Be.last_name?" "+Be.last_name:""}`),U([Be.address,Be.city,Be.state].filter(Boolean).join(", ")),V(Be.home_anniversary||""),g("details")},be=Be=>{L(Be),g("contact")},Me=async()=>{var Be;if(!(!i||!ue)){S(!0);try{const nt={owner_user_id:i.id,contact_id:j,card_type:M,template:ee,recipient_name:I,property_address:q||null,home_anniversary_date:B||null,custom_message:Z||null,property_photo_url:ie||null,video_url:oe||null,agent_name:ue.name||"Agent",agent_photo_url:ue.avatar_url,agent_phone:ue.phone,agent_email:ue.email,agent_brokerage:((Be=ue.brokerage)==null?void 0:Be.name)||null},{error:Ae}=await H.from("sendable_cards").insert(nt);if(Ae)throw Ae;me.success("Card created! Copy the link to share it."),c.invalidateQueries({queryKey:["sendable-cards"]}),Ne()}catch(nt){me.error(nt.message||"Failed to create card")}finally{S(!1)}}},Ne=()=>{p(!1),g("type"),L("home_anniversary"),_(""),w(null),O(""),U(""),V(""),X(""),Q("elegant"),re(null),ce(null)},Pe={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"},Oe=RE[M],Te=M==="home_anniversary",ke=["home_anniversary","just_listed","just_sold"].includes(M);return e.jsxs(fs,{open:u,onOpenChange:Be=>{Be?p(!0):(Ne(),l==null||l(!1))},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Create Card"]})}),e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:f==="type"?"What type of card?":f==="contact"?`${Pe[M]} — Choose a Contact`:`${Pe[M]} — Customize`})}),f==="type"&&e.jsx(ZCs,{onSelect:be}),f==="contact"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>g("type"),children:[e.jsx(Ja,{className:"h-3.5 w-3.5"})," Back to card types"]}),e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search contacts...",value:b,onChange:Be=>_(Be.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[ge==null?void 0:ge.map(Be=>e.jsxs("button",{onClick:()=>pe(Be),className:"w-full flex items-center gap-3 p-3 rounded-lg hover:bg-accent text-left transition-colors",children:[e.jsx("div",{className:"h-9 w-9 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(to,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[Be.first_name," ",Be.last_name]}),Be.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(bn,{className:"h-3 w-3"}),Be.address]})]}),Be.home_anniversary&&M==="home_anniversary"&&e.jsx("span",{className:"text-[10px] text-emerald-600 bg-emerald-500/10 px-2 py-0.5 rounded-full shrink-0",children:"Anniversary set"})]},Be.id)),(ge==null?void 0:ge.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No contacts found"})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{g("details")},children:"Skip — enter details manually"})})]}),f==="details"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>g("contact"),children:[e.jsx(Ja,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Recipient Name"}),e.jsx(ze,{value:I,onChange:Be=>O(Be.target.value),placeholder:"John & Jane Smith"})]}),ke&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Property Address"}),e.jsx(ze,{value:q,onChange:Be=>U(Be.target.value),placeholder:"123 Main St, Austin, TX"})]}),Te&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Home Anniversary Date"}),e.jsx(ze,{type:"date",value:B,onChange:Be=>V(Be.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Personal Message (optional)"}),e.jsx(Er,{value:Z,onChange:Be=>X(Be.target.value),placeholder:Oe.defaultMessage,rows:3})]}),e.jsx(xct,{photoUrl:ie,videoUrl:oe,onPhotoChange:re,onVideoChange:ce,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:Be,label:nt,gradient:Ae})=>e.jsxs("button",{onClick:()=>Q(Be),className:`p-2 rounded-lg border-2 transition-all text-center ${ee===Be?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-10 rounded-md mb-1.5 ${Ae}`}),e.jsx("span",{className:"text-[10px] font-medium",children:nt})]},Be))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>g("contact"),className:"flex-1",children:"Back"}),e.jsx(K,{onClick:Me,disabled:!I||k,className:"flex-1 gap-2",children:k?"Creating...":"Create Card"})]})]})]})]})}const YCs={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 XCs({card:t}){const{user:s}=Ds(),{isGmailConnected:r}=Wx(),n=Qt(),[a,o]=N.useState(!1),[l,i]=N.useState("");N.useEffect(()=>{a&&t.contact_id&&!l&&H.from("innercircle_contacts").select("email").eq("id",t.contact_id).maybeSingle().then(({data:j})=>{j!=null&&j.email&&i(j.email)})},[a,t.contact_id]);const c={home_anniversary:`🏡 Happy Home Anniversary, ${t.recipient_name}!`,just_listed:`🏠 Just Listed — Check This Out, ${t.recipient_name}!`,just_sold:`🎉 Just Sold! Congrats, ${t.recipient_name}!`,congratulations:`🏆 Congratulations, ${t.recipient_name}!`,birthday:`🎂 Happy Birthday, ${t.recipient_name}!`,holiday:`🎄 Happy Holidays, ${t.recipient_name}!`,thank_you:`💐 Thank You, ${t.recipient_name}!`,thinking_of_you:`💭 Thinking of You, ${t.recipient_name}!`},[u,p]=N.useState(c[t.card_type]||`A Special Card for ${t.recipient_name}!`),[f,g]=N.useState(""),b=`https://cardstudio.relevelup.com/c/${t.share_token}`,_=Dt({mutationFn:async()=>{var M;if(!l)throw new Error("Recipient email is required");const j=`
${f?`

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


`:""}

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

${t.property_address?`

${t.property_address}

`:""}
`,{data:w}=await H.auth.getSession(),k=(M=w==null?void 0:w.session)==null?void 0:M.access_token,S=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/gmail-send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${k}`},body:JSON.stringify({to:l,subject:u,body:j,contactId:t.contact_id||void 0})});if(!S.ok){const L=await S.json();throw new Error(L.error||"Failed to send")}return S.json()},onSuccess:async()=>{await H.from("sendable_cards").update({sent_at:new Date().toISOString(),sent_via:"gmail"}).eq("id",t.id),n.invalidateQueries({queryKey:["sendable-cards"]}),me.success(`Card sent to ${l}!`),o(!1)},onError:j=>{me.error(j.message||"Failed to send email")}});return r?e.jsxs(fs,{open:a,onOpenChange:o,children:[e.jsx(qi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Bn,{className:"h-3 w-3"})})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{type:"email",value:l,onChange:j=>i(j.target.value),placeholder:"recipient@email.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Subject"}),e.jsx(ze,{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(Er,{value:f,onChange:j=>g(j.target.value),placeholder:"Add a warm personal note before the card link...",rows:3})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 text-xs text-muted-foreground",children:["The email will include a beautiful button linking to your card at:",e.jsx("br",{}),e.jsx("span",{className:"font-mono text-foreground",children:b})]}),e.jsx(K,{onClick:()=>_.mutate(),disabled:!l||_.isPending,className:"w-full gap-2",children:_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Bn,{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(Bn,{className:"h-3 w-3"})})}function QCs({card:t}){const s=Qt(),[r,n]=N.useState(!1),[a,o]=N.useState(!1),[l,i]=N.useState(t.recipient_name),[c,u]=N.useState(t.property_address||""),[p,f]=N.useState(t.home_anniversary_date||""),[g,b]=N.useState(t.custom_message||""),[_,j]=N.useState(t.template),[w,k]=N.useState(t.property_photo_url),[S,M]=N.useState(t.video_url||null),L=O=>{O&&(i(t.recipient_name),u(t.property_address||""),f(t.home_anniversary_date||""),b(t.custom_message||""),j(t.template),k(t.property_photo_url),M(t.video_url||null)),n(O)},I=async()=>{if(!l.trim()){me.error("Recipient name is required");return}o(!0);try{const{error:O}=await H.from("sendable_cards").update({recipient_name:l.trim(),property_address:c.trim()||null,home_anniversary_date:p||null,custom_message:g.trim()||null,template:_,property_photo_url:w||null,video_url:S||null}).eq("id",t.id);if(O)throw O;s.invalidateQueries({queryKey:["sendable-cards"]}),me.success("Card updated"),n(!1)}catch(O){me.error(O.message||"Failed to update card")}finally{o(!1)}};return e.jsxs(fs,{open:r,onOpenChange:L,children:[e.jsx(qi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Ra,{className:"h-3 w-3"})})}),e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{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(ze,{value:l,onChange:O=>i(O.target.value),placeholder:"John & Jane Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Property Address"}),e.jsx(ze,{value:c,onChange:O=>u(O.target.value),placeholder:"123 Main St, Austin, TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Home Anniversary Date"}),e.jsx(ze,{type:"date",value:p,onChange:O=>f(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Personal Message (optional)"}),e.jsx(Er,{value:g,onChange:O=>b(O.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(xct,{photoUrl:w,videoUrl:S,onPhotoChange:k,onVideoChange:M,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(O=>e.jsxs("button",{onClick:()=>j(O),className:`p-3 rounded-lg border-2 transition-all text-center ${_===O?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-12 rounded-md mb-2 ${O==="elegant"?"bg-gradient-to-br from-slate-100 to-slate-200 dark:from-slate-800 dark:to-slate-700":O==="bold"?"bg-gradient-to-br from-violet-500 to-fuchsia-500":"bg-gradient-to-br from-amber-200 to-orange-300"}`}),e.jsx("span",{className:"text-xs font-medium capitalize",children:O})]},O))})]}),e.jsx(K,{onClick:I,disabled:!l.trim()||a,className:"w-full gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function JCs(){const{user:t}=Ds(),s=Qt(),[r,n]=N.useState(""),[a,o]=Cc(),l=a.get("cardType"),i=a.get("contactId"),c=a.get("name"),u=a.get("address"),p=a.get("date"),f=!!l,{data:g,isLoading:b}=mt({queryKey:["sendable-cards",t==null?void 0:t.id],queryFn:async()=>{const{data:M,error:L}=await H.from("sendable_cards").select("*").eq("owner_user_id",t.id).order("created_at",{ascending:!1});if(L)throw L;return M},enabled:!!(t!=null&&t.id)}),_=Dt({mutationFn:async M=>{const{error:L}=await H.from("sendable_cards").delete().eq("id",M);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["sendable-cards"]}),me.success("Card deleted")}}),j=M=>{const L=`https://cardstudio.relevelup.com/c/${M}`;navigator.clipboard.writeText(L),me.success("Share link copied!")},w=g==null?void 0:g.filter(M=>{var L;return!r||M.recipient_name.toLowerCase().includes(r.toLowerCase())||((L=M.property_address)==null?void 0:L.toLowerCase().includes(r.toLowerCase()))}),k={elegant:"Elegant",bold:"Bold",warm:"Warm"},S={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"};return e.jsx(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(Vze,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:c||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search cards...",value:r,onChange:M=>n(M.target.value),className:"pl-9"})]}),b?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(M=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(De,{className:"p-4",children:[e.jsx("div",{className:"h-40 bg-muted rounded-lg mb-3"}),e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]})},M))}):w!=null&&w.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w.map(M=>e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-shadow",children:[e.jsxs("div",{className:`aspect-[16/10] flex items-center justify-center relative overflow-hidden ${M.template==="elegant"?"bg-gradient-to-br from-slate-50 via-slate-100 to-slate-200 dark:from-slate-900 dark:via-slate-800 dark:to-slate-700":M.template==="bold"?"bg-gradient-to-br from-violet-600 via-fuchsia-500 to-pink-500":"bg-gradient-to-br from-amber-100 via-orange-200 to-rose-200 dark:from-amber-900 dark:via-orange-800 dark:to-rose-800"}`,children:[M.template==="elegant"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"absolute top-0 left-0 w-full h-full opacity-10",children:[e.jsx("div",{className:"absolute top-3 left-3 w-16 h-16 border-t-2 border-l-2 border-primary/40 rounded-tl-lg"}),e.jsx("div",{className:"absolute bottom-3 right-3 w-16 h-16 border-b-2 border-r-2 border-primary/40 rounded-br-lg"})]}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-32 h-32 rounded-full border border-primary/10"})]}),M.template==="bold"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute -top-8 -right-8 w-32 h-32 rounded-full bg-white/10 blur-sm"}),e.jsx("div",{className:"absolute -bottom-6 -left-6 w-24 h-24 rounded-full bg-white/10 blur-sm"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,rgba(255,255,255,0.15)_0%,transparent_70%)]"})]}),M.template==="warm"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute -top-4 -left-4 w-28 h-28 rounded-full bg-orange-400/15 blur-md"}),e.jsx("div",{className:"absolute -bottom-6 -right-6 w-32 h-32 rounded-full bg-rose-400/15 blur-md"})]}),e.jsxs("div",{className:"text-center px-4 relative z-10",children:[e.jsx("div",{className:"text-3xl mb-1.5 opacity-80",children:M.card_type==="home_anniversary"?"🏡":M.card_type==="birthday"?"🎂":M.card_type==="just_sold"?"🎉":M.card_type==="just_listed"?"🏠":M.card_type==="thank_you"?"💐":M.card_type==="congratulations"?"🏆":M.card_type==="holiday"?"🎄":M.card_type==="thinking_of_you"?"💭":"✉️"}),e.jsx("p",{className:`text-[10px] uppercase tracking-[0.2em] mb-1 ${M.template==="bold"?"text-white/70":"text-muted-foreground"}`,children:S[M.card_type]||M.card_type}),e.jsx("p",{className:`font-semibold text-base ${M.template==="bold"?"text-white":"text-foreground"}`,children:M.recipient_name}),M.property_address&&e.jsx("p",{className:`text-xs mt-1 ${M.template==="bold"?"text-white/60":"text-muted-foreground"}`,children:M.property_address})]}),e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsx(tt,{variant:M.template==="bold"?"outline":"secondary",className:`text-[10px] ${M.template==="bold"?"border-white/30 text-white/80":""}`,children:k[M.template]||M.template})})]}),e.jsxs(De,{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(On,{className:"h-3 w-3"}),M.view_count," views"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Uc(new Date(M.created_at),{addSuffix:!0})})]}),M.sent_at&&e.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",ms(new Date(M.sent_at),"MMM d, yyyy")," via ",M.sent_via]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1 gap-1 text-xs",onClick:()=>j(M.share_token),children:[e.jsx(gi,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(QCs,{card:M}),e.jsx(XCs,{card:M}),e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${M.share_token}`,"_blank"),children:e.jsx(tn,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive gap-1 text-xs",onClick:()=>_.mutate(M.id),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]})]},M.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(De,{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(cr,{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(Vze,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:c||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]})})]})})}function uI({delay:t,x:s,y:r,size:n}){return e.jsx(Hs.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 e3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,b=RE[s];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-blue-50/30 to-white dark:from-slate-950 dark:to-slate-900 flex items-center justify-center p-4 overflow-hidden relative",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx(Hs.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(Hs.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(uI,{delay:0,x:"15%",y:"20%",size:8}),e.jsx(uI,{delay:1,x:"80%",y:"30%",size:6}),e.jsx(uI,{delay:2,x:"60%",y:"70%",size:10}),e.jsx(uI,{delay:.5,x:"25%",y:"80%",size:7}),e.jsx(uI,{delay:1.5,x:"70%",y:"15%",size:5})]}),e.jsxs(Hs.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(Hs.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(Hs.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(Hs.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(Hs.div,{className:"absolute inset-0 rounded-2xl border-2 border-slate-200/50 dark:border-slate-600/50",animate:{scale:[1,1.15,1],opacity:[.5,0,.5]},transition:{duration:2.5,repeat:1/0,ease:"easeInOut"}}),e.jsx("span",{className:"text-4xl",children:b.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(Hs.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(Hs.h1,{className:"text-4xl font-light text-slate-800 dark:text-slate-100 mb-1 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.5,delay:.7},children:b.title[0]}),b.title[1]&&e.jsx(Hs.h2,{className:"text-4xl font-bold text-slate-800 dark:text-slate-100 mb-8 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.5,delay:.85},children:b.title[1]}),e.jsxs(Hs.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(Hs.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(Hs.div,{className:"mb-6 rounded-xl overflow-hidden shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.15,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),g&&e.jsx(Hs.div,{className:"mb-6 rounded-xl overflow-hidden shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Hs.p,{className:"text-sm text-slate-500 dark:text-slate-400 leading-relaxed max-w-xs mx-auto mb-8 italic",initial:{opacity:0},animate:{opacity:1},transition:{duration:.6,delay:1.3},children:o||b.defaultMessage}),e.jsxs(Hs.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(Hs.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-slate-200 dark:ring-slate-700 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-full bg-gradient-to-br from-slate-200 to-blue-100 dark:from-slate-700 dark:to-slate-600 flex items-center justify-center shadow-md",children:e.jsx("span",{className:"text-sm font-semibold text-slate-600 dark:text-slate-300",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 dark:text-slate-200",children:l}),p&&e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-4",children:[c&&e.jsxs(Hs.a,{href:`tel:${c}`,className:"flex items-center gap-1.5 px-4 py-2 rounded-full bg-slate-100 dark:bg-slate-800 text-xs font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors shadow-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Hs.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(cr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Hs.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 Aye({delay:t,x:s,y:r,color:n,size:a}){return e.jsx(Hs.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 hI({delay:t,x:s,y:r}){return e.jsx(Hs.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 Hze={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 t3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,b=RE[s],_=Hze[s]||Hze.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-br ${_.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx(Aye,{delay:0,x:"10%",y:"10%",color:_.orbs[0],size:200}),e.jsx(Aye,{delay:1,x:"70%",y:"60%",color:_.orbs[1],size:180}),e.jsx(Aye,{delay:2,x:"50%",y:"20%",color:_.orbs[2],size:150}),e.jsx(hI,{delay:0,x:"20%",y:"25%"}),e.jsx(hI,{delay:.8,x:"75%",y:"15%"}),e.jsx(hI,{delay:1.6,x:"85%",y:"65%"}),e.jsx(hI,{delay:2.4,x:"10%",y:"75%"}),e.jsx(hI,{delay:.4,x:"45%",y:"85%"}),e.jsxs(Hs.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(Hs.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(Hs.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(Hs.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(Hs.div,{className:"absolute inset-0 rounded-2xl bg-gradient-to-br from-violet-500 to-fuchsia-500",animate:{scale:[1,1.3,1],opacity:[.6,0,.6]},transition:{duration:2,repeat:1/0,ease:"easeInOut"}}),e.jsx("span",{className:"text-4xl relative z-10",children:b.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(Hs.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(Hs.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(Hs.h1,{className:"text-5xl font-black text-transparent bg-clip-text bg-gradient-to-r from-violet-200 via-white to-fuchsia-200 mb-2 leading-tight",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.7},children:b.title[0]}),b.title[1]&&e.jsx(Hs.h2,{className:"text-5xl font-black text-transparent bg-clip-text bg-gradient-to-r from-fuchsia-300 via-violet-200 to-purple-300 mb-2 leading-tight",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.85},children:b.title[1]}),e.jsx(Hs.div,{className:"text-3xl mb-4",initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.4,delay:1,type:"spring",stiffness:300},children:b.emojis.slice(0,3).join("")}),e.jsxs(Hs.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(bn,{className:"h-3.5 w-3.5"}),n]})]}),f&&e.jsx(Hs.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10 shadow-lg",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),g&&e.jsx(Hs.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10 shadow-lg",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.25,duration:.5},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Hs.div,{className:"bg-white/5 rounded-2xl p-5 border border-white/10 mb-8 backdrop-blur-sm",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsx("p",{className:"text-sm text-violet-100/80 leading-relaxed",children:o||b.defaultMessage})}),e.jsxs(Hs.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(Hs.img,{src:i,alt:l,className:"h-12 w-12 rounded-xl object-cover ring-2 ring-violet-500/40 shadow-lg",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-xl bg-gradient-to-br from-violet-500 to-fuchsia-500 flex items-center justify-center shadow-lg",children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-bold text-white",children:l}),p&&e.jsx("p",{className:"text-xs text-violet-300/60",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-5",children:[c&&e.jsxs(Hs.a,{href:`tel:${c}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r from-violet-500/30 to-fuchsia-500/30 text-xs font-semibold text-white hover:from-violet-500/50 hover:to-fuchsia-500/50 transition-all border border-white/15 shadow-lg",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Call Me"]}),u&&e.jsxs(Hs.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(cr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Hs.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 s3s({emoji:t,delay:s,x:r,duration:n}){return e.jsx(Hs.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 Wze={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 r3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,b=RE[s],_=Wze[s]||Wze.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${_.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[b.emojis.map((j,w)=>e.jsx(s3s,{emoji:j,delay:w*1.2,x:`${15+w*14}%`,duration:5+w%3},w)),e.jsx(Hs.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(Hs.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(Hs.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(Hs.div,{className:`h-28 bg-gradient-to-r ${_.header} relative overflow-hidden`,children:[e.jsx(Hs.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(Hs.div,{className:"absolute top-3 left-10 text-5xl",animate:{rotate:[0,10,-5,0],y:[0,-3,0]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},children:b.emojis[0]}),e.jsx(Hs.div,{className:"absolute top-2 right-14 text-3xl",animate:{scale:[1,1.3,1],rotate:[0,15,0]},transition:{duration:2,repeat:1/0,ease:"easeInOut",delay:.5},children:b.emojis[1]}),e.jsx(Hs.div,{className:"absolute bottom-2 left-1/2 -translate-x-1/2 text-3xl",animate:{y:[0,-5,0],scale:[1,1.1,1]},transition:{duration:2.5,repeat:1/0,ease:"easeInOut",delay:1},children:b.emojis[2]})]}),e.jsxs("div",{className:"px-8 py-8 text-center -mt-10 relative",children:[e.jsx(Hs.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(Hs.div,{animate:{scale:[1,1.2,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},children:e.jsx("span",{className:"text-3xl",children:b.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(Hs.div,{className:"mb-3",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{delay:.6},children:e.jsxs("span",{className:`inline-flex items-baseline gap-1.5 ${_.accent}`,children:[e.jsx(Hs.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(Hs.h1,{className:`text-3xl font-bold ${_.accent} mb-1`,initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.9},children:[b.title.join(" ")," ",b.emojis[4]]}),e.jsxs(Hs.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.1},children:[e.jsx("p",{className:`text-lg font-semibold ${_.text} mb-1`,children:r}),n&&e.jsxs("p",{className:`text-sm ${_.text} opacity-70 flex items-center justify-center gap-1 mb-5`,children:[e.jsx(ma,{className:"h-3 w-3"}),n]})]}),f&&e.jsx(Hs.div,{className:"mb-5 rounded-2xl overflow-hidden border border-amber-200 shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),g&&e.jsx(Hs.div,{className:"mb-5 rounded-2xl overflow-hidden border border-amber-200 shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.25,duration:.5},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Hs.div,{className:"bg-gradient-to-br from-amber-50 to-orange-50 rounded-2xl p-5 mb-6 border border-amber-100 shadow-inner",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsxs("p",{className:`text-sm ${_.text} leading-relaxed italic`,children:['"',o||b.defaultMessage,'"']})}),e.jsxs(Hs.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(Hs.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-amber-200 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${_.header} flex items-center justify-center shadow-md`,children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:`text-sm font-bold ${_.accent}`,children:l}),p&&e.jsx("p",{className:`text-xs ${_.text} opacity-60`,children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[c&&e.jsxs(Hs.a,{href:`tel:${c}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${_.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Hs.a,{href:`mailto:${u}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${_.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Hs.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 s9({delay:t,x:s,y:r,size:n,color:a}){return e.jsx(Hs.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 Eye({delay:t,x:s,y:r,size:n}){return e.jsx(Hs.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 Gze={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 n3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,b=RE[s],_=Gze[s]||Gze.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(s9,{delay:0,x:"5%",y:"10%",size:300,color:_.mesh[0]}),e.jsx(s9,{delay:2,x:"60%",y:"50%",size:250,color:_.mesh[1]}),e.jsx(s9,{delay:4,x:"30%",y:"70%",size:200,color:_.mesh[2]}),e.jsx(s9,{delay:1,x:"80%",y:"15%",size:180,color:_.mesh[0]}),e.jsx(Eye,{delay:0,x:"15%",y:"20%",size:100}),e.jsx(Eye,{delay:3,x:"70%",y:"60%",size:140}),e.jsx(Eye,{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(Hs.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(Hs.div,{className:`relative rounded-[28px] overflow-hidden backdrop-blur-2xl bg-white/[0.06] border border-white/[0.12] shadow-2xl ${_.glow}`,initial:{scale:.92},animate:{scale:1},transition:{duration:.6,delay:.2,type:"spring",stiffness:120},children:[e.jsx("div",{className:"relative h-[2px] bg-gradient-to-r from-transparent via-white/20 to-transparent overflow-hidden",children:e.jsx(Hs.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(Hs.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(Hs.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(Hs.span,{className:"text-5xl",animate:{scale:[1,1.08,1]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},children:b.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(Hs.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(Hs.span,{className:"text-3xl font-black text-white",initial:{opacity:0},animate:{opacity:1},transition:{delay:.8},children:a}),e.jsx("span",{className:`text-[10px] font-bold uppercase tracking-[0.2em] ${_.accent}`,children:a===1?"Year":"Years"})]}),e.jsx(Hs.h1,{className:"text-4xl font-extralight text-white/90 mb-1 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.6,delay:.7},children:b.title[0]}),b.title[1]&&e.jsx(Hs.h2,{className:"text-4xl font-bold text-white mb-6 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.6,delay:.85},children:b.title[1]}),e.jsxs(Hs.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(ma,{className:"h-3 w-3"})," ",n]})]}),e.jsx(Hs.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(Hs.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.15,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),g&&e.jsx(Hs.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Hs.div,{className:"bg-white/[0.04] rounded-2xl p-5 border border-white/[0.08] mb-8 backdrop-blur-sm",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsxs("p",{className:"text-sm text-white/60 leading-relaxed italic",children:['"',o||b.defaultMessage,'"']})}),e.jsxs(Hs.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(Hs.img,{src:i,alt:l,className:"h-12 w-12 rounded-2xl object-cover ring-1 ring-white/10",whileHover:{scale:1.08}}):e.jsx("div",{className:"h-12 w-12 rounded-2xl bg-white/[0.08] border border-white/[0.1] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-semibold text-white/60",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-white/80",children:l}),p&&e.jsx("p",{className:"text-xs text-white/30",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[c&&e.jsxs(Hs.a,{href:`tel:${c}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-white/[0.06] border border-white/[0.1] text-xs font-medium text-white/70 hover:bg-white/[0.12] transition-colors backdrop-blur-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Hs.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(cr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Hs.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 Pye({delay:t,x:s,angle:r,color:n}){return e.jsx(Hs.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 r9({delay:t,x:s}){return e.jsx(Hs.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 Kze={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 a3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,b=RE[s],_=Kze[s]||Kze.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${_.gradient} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,rgba(255,255,255,0.04)_0%,transparent_60%)]"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_bottom,rgba(0,0,0,0.6)_0%,transparent_60%)]"}),e.jsx(Pye,{delay:0,x:"20%",angle:15,color:_.stripe}),e.jsx(Pye,{delay:2,x:"75%",angle:-12,color:_.stripe}),e.jsx(Pye,{delay:4,x:"50%",angle:5,color:_.stripe}),e.jsx(r9,{delay:0,x:"30%"}),e.jsx(r9,{delay:1.5,x:"60%"}),e.jsx(r9,{delay:3,x:"45%"}),e.jsx(r9,{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(Hs.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0},animate:{opacity:1},transition:{duration:1.2},children:[e.jsx(Hs.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(Hs.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(Hs.div,{className:`h-20 w-20 mx-auto rounded-2xl bg-gradient-to-br ${_.accent} flex items-center justify-center shadow-2xl`,animate:{boxShadow:["0 0 40px rgba(255,255,255,0.05)","0 0 80px rgba(255,255,255,0.1)","0 0 40px rgba(255,255,255,0.05)"]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},children:e.jsx("span",{className:"text-4xl",children:b.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(Hs.div,{className:"mb-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:.7},children:[e.jsx(Hs.span,{className:`text-6xl font-black bg-gradient-to-r ${_.accent} bg-clip-text text-transparent`,initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},transition:{delay:.9,type:"spring"},children:a}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.4em] text-white/30 mt-1",children:a===1?"Year":"Years"})]}),e.jsx("div",{className:"overflow-hidden mb-2",children:e.jsx(Hs.h1,{className:"text-5xl font-thin text-white/90 tracking-wide",initial:{y:"100%"},animate:{y:0},transition:{duration:.7,delay:.8,ease:[.16,1,.3,1]},children:b.title[0]})}),b.title[1]&&e.jsx("div",{className:"overflow-hidden mb-8",children:e.jsx(Hs.h2,{className:`text-5xl font-black bg-gradient-to-r ${_.accent} bg-clip-text text-transparent`,initial:{y:"100%"},animate:{y:0},transition:{duration:.7,delay:.95,ease:[.16,1,.3,1]},children:b.title[1]})}),e.jsxs(Hs.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(ma,{className:"h-3 w-3"})," ",n]})]}),e.jsxs(Hs.div,{className:"flex items-center justify-center gap-3 my-8",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2},children:[e.jsx(Hs.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(Hs.span,{className:"text-white/10 text-xs",animate:{rotate:[0,360]},transition:{duration:20,repeat:1/0,ease:"linear"},children:"✦"}),e.jsx(Hs.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(Hs.div,{className:"mb-8 rounded-2xl overflow-hidden ring-1 ring-white/5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.3,duration:.6},children:[e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-950/30 to-transparent pointer-events-none"})]}),g&&e.jsx(Hs.div,{className:"mb-8 rounded-2xl overflow-hidden ring-1 ring-white/5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.35,duration:.6},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Hs.p,{className:"text-sm text-white/40 leading-relaxed max-w-xs mx-auto mb-10 font-light",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.4,duration:.8},children:o||b.defaultMessage}),e.jsxs(Hs.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(Hs.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-white/10 shadow-xl",whileHover:{scale:1.1}}):e.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${_.accent} flex items-center justify-center shadow-xl`,children:e.jsx("span",{className:"text-sm font-bold text-slate-900",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium text-white/70",children:l}),p&&e.jsx("p",{className:"text-[11px] text-white/25",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[c&&e.jsxs(Hs.a,{href:`tel:${c}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${_.accent} text-xs font-semibold text-slate-900 shadow-lg`,whileHover:{scale:1.05,boxShadow:"0 10px 40px rgba(255,255,255,0.15)"},whileTap:{scale:.95},children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Hs.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(cr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})}),e.jsx(Hs.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 gct(){const{shareToken:t}=yo(),{data:s,isLoading:r,error:n}=mt({queryKey:["public-sendable-card",t],queryFn:async()=>{const{data:l,error:i}=await H.from("sendable_cards").select("*").eq("share_token",t).single();if(i)throw i;return l},enabled:!!t});if(N.useEffect(()=>{t&&H.rpc("log_sendable_card_view",{p_share_token:t}).then(({error:l})=>{l&&console.error("Error tracking view:",l)})},[t]),r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"animate-pulse space-y-4 text-center",children:[e.jsx("div",{className:"h-8 w-48 bg-muted rounded mx-auto"}),e.jsx("div",{className:"h-4 w-32 bg-muted rounded mx-auto"})]})});if(n||!s)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Card not found"}),e.jsx("p",{className:"text-muted-foreground",children:"This card may have been removed or the link is invalid."})]})});const a=s.home_anniversary_date?Math.floor((Date.now()-Dl(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(t3s,{...o});case"warm":return e.jsx(r3s,{...o});case"glass":return e.jsx(n3s,{...o});case"cinematic":return e.jsx(a3s,{...o});case"elegant":default:return e.jsx(e3s,{...o})}}function i3s(){const t=ci();return mt({queryKey:["drip-settings",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("drip_settings").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function o3s(){const t=ci(),s=Qt();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n}=await H.from("drip_settings").select("id").eq("user_id",t).maybeSingle();if(n){const{data:a,error:o}=await H.from("drip_settings").update(r).eq("user_id",t).select().single();if(o)throw o;return a}else{const{data:a,error:o}=await H.from("drip_settings").insert({user_id:t,is_globally_enabled:r.is_globally_enabled??!1,append_signature:r.append_signature??!0}).select().single();if(o)throw o;return a}},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-settings"]})}})}function l3s(){const t=fr(),{isGmailConnected:s,gmailEmail:r}=Wx(),{data:n,isLoading:a}=i3s(),o=o3s(),[l,i]=N.useState(!1),[c,u]=N.useState(!0),[p,f]=N.useState(!1);N.useEffect(()=>{n&&(i(n.is_globally_enabled),u(n.append_signature))},[n]);const g=async _=>{if(_&&!s){me.error("Connect your Gmail account first before enabling Smart Drips");return}i(_);try{await o.mutateAsync({is_globally_enabled:_}),me.success(_?"Smart Drips enabled globally":"Smart Drips paused globally")}catch{i(!_),me.error("Failed to update settings")}},b=async _=>{u(_);try{await o.mutateAsync({append_signature:_}),me.success(_?"Signature will be appended to drip emails":"Signature disabled for drip emails")}catch{u(!_),me.error("Failed to update settings")}};return e.jsxs(fs,{open:p,onOpenChange:f,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Xo,{className:"h-3.5 w-3.5"}),"Settings"]})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-5 w-5 text-primary"}),"Smart Drip Settings"]}),e.jsx(Gr,{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(cr,{className:`h-4 w-4 ${s?"text-emerald-600":"text-destructive"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s?"Gmail Connected":"Gmail Not Connected"}),r&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r})]})]}),s?e.jsxs(tt,{variant:"outline",className:"gap-1 text-emerald-600 border-emerald-200 bg-emerald-500/10 text-[10px]",children:[e.jsx(sa,{className:"h-3 w-3"}),"Active"]}):e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs gap-1",onClick:()=>{f(!1),t("/mission-control/integrations")},children:[e.jsx(tn,{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(yL,{className:`h-4 w-4 ${l?"text-emerald-600":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Enable Smart Drips"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l?"Active drips will send when deals move stages":"All drips are paused — nothing will send"})]})]}),e.jsx(qr,{checked:l,onCheckedChange:g,disabled:a||o.isPending})]}),e.jsx(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 ${c?"bg-primary/10":"bg-muted"}`,children:e.jsx(Jy,{className:`h-4 w-4 ${c?"text-primary":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Append Email Signature"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c?"Your signature from Profile settings will be added":"Drip emails will send without a signature"})]})]}),e.jsx(qr,{checked:c,onCheckedChange:b,disabled:a||o.isPending})]}),c&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>{f(!1),t("/profile")},children:[e.jsx(Jy,{className:"h-3 w-3 mr-1"}),"Edit your email signature in Profile settings"]})]})]})]})}function c3s(){const t=ci();return mt({queryKey:["drip-templates",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("drip_templates").select("*").or(`owner_user_id.eq.${t},is_starter.eq.true`).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function d3s(){const t=ci();return mt({queryKey:["drip-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function u3s(){const t=ci(),s=Qt();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("drip_templates").insert({owner_user_id:t,stage_id:r.stage_id,title:r.title||"",subject:r.subject||"",body:r.body||"",video_url:r.video_url||null,channel:r.channel||"email",delay_type:r.delay_type||"instant",delay_minutes:r.delay_minutes||0,is_enabled:!1,deal_type:r.deal_type||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-templates"]})}})}function h3s(){const t=Qt();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("drip_templates").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function m3s(){const t=Qt();return Dt({mutationFn:async s=>{const{error:r}=await H.from("drip_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function p3s(){const t=ci(),s=Qt();return Dt({mutationFn:async({templateId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await H.from("drip_templates").select("*").eq("id",r).single();if(o)throw o;const{data:l,error:i}=await H.from("drip_templates").insert({owner_user_id:t,stage_id:n,title:a.title,subject:a.subject,body:a.body,video_url:a.video_url,channel:a.channel,delay_type:a.delay_type,delay_minutes:a.delay_minutes,is_enabled:!1,is_starter:!1,deal_type:a.deal_type}).select().single();if(i)throw i;return l},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-templates"]})}})}const f3s=[{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 x3s(){const t=ci(),{data:s,isLoading:r}=c3s(),{data:n,isLoading:a}=d3s(),o=u3s(),l=h3s(),i=m3s(),c=p3s(),[u,p]=N.useState(null),[f,g]=N.useState(null),b=(s==null?void 0:s.filter(I=>!I.is_starter&&I.owner_user_id===t))||[],_=(s==null?void 0:s.filter(I=>I.is_starter))||[],j=I=>b.filter(O=>O.stage_id===I),w=async I=>{try{await l.mutateAsync({id:I.id,is_enabled:!I.is_enabled}),me.success(I.is_enabled?"Drip disabled":"Drip enabled")}catch{me.error("Failed to update")}},k=async I=>{try{const O=n==null?void 0:n.find(q=>q.id===I);await o.mutateAsync({stage_id:I,title:`${(O==null?void 0:O.name)||"Stage"} follow-up`,subject:"",body:"",channel:"email",delay_type:"instant",delay_minutes:0}),p(I),me.success("Drip template created")}catch{me.error("Failed to create template")}},S=async I=>{try{await i.mutateAsync(I),me.success("Template deleted")}catch{me.error("Failed to delete")}},M=async I=>{if(!n||n.length===0){me.error("No pipeline stages found");return}const O=n[0].id;try{await c.mutateAsync({templateId:I,stageId:O}),me.success("Template copied to your drips!")}catch{me.error("Failed to copy template")}},L=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(Zh,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Smart Drips"}),e.jsx(tt,{variant:"outline",className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 border-amber-500 text-amber-600 bg-amber-500/10",children:"Beta"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Automatically send personalized emails when deals move through your pipeline."})]}),e.jsx(l3s,{})]}),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(cL,{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(ba,{defaultValue:"my-drips",children:[e.jsxs(pa,{className:"grid grid-cols-2 w-full max-w-xs mb-6",children:[e.jsx(ns,{value:"my-drips",children:"My Drips"}),e.jsxs(ns,{value:"starters",children:["Starter Templates",_.length>0&&e.jsx(tt,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",children:_.length})]})]}),e.jsx(bs,{value:"my-drips",children:L?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(I=>e.jsx(ys,{className:"h-16 w-full rounded-xl"},I))}):!n||n.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(Zh,{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(I=>!I.is_won_stage&&!I.is_lost_stage).map(I=>{const O=j(I.id),q=u===I.id,U=O.some(B=>B.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>p(q?null:I.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:I.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:I.name}),O.length>0&&e.jsxs(tt,{variant:"outline",className:`text-[10px] ${U?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[O.length," drip",O.length!==1?"s":"",U&&" · Active"]}),q?e.jsx(Eo,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})]}),q&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:O.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No drip set for this stage"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>k(I.id),disabled:o.isPending,children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1.5"}),"Create Drip"]})]}):e.jsxs(e.Fragment,{children:[O.map(B=>e.jsx(Zze,{template:B,isEditing:f===B.id,onToggleEdit:()=>g(f===B.id?null:B.id),onToggleEnabled:()=>w(B),onUpdate:V=>l.mutateAsync({id:B.id,...V}),onDelete:()=>S(B.id),userId:t||""},B.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>k(I.id),children:[e.jsx($s,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},I.id)}),n.filter(I=>I.is_won_stage||I.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(I=>I.is_won_stage||I.is_lost_stage).map(I=>{const O=j(I.id),q=u===I.id,U=O.some(B=>B.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden mb-2",children:[e.jsxs("button",{onClick:()=>p(q?null:I.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:I.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:I.name}),O.length>0&&e.jsxs(tt,{variant:"outline",className:`text-[10px] ${U?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[O.length," drip",O.length!==1?"s":"",U&&" · Active"]}),q?e.jsx(Eo,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})]}),q&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:O.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No drip set for this stage"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>k(I.id),disabled:o.isPending,children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1.5"})," Create Drip"]})]}):e.jsxs(e.Fragment,{children:[O.map(B=>e.jsx(Zze,{template:B,isEditing:f===B.id,onToggleEdit:()=>g(f===B.id?null:B.id),onToggleEnabled:()=>w(B),onUpdate:V=>l.mutateAsync({id:B.id,...V}),onDelete:()=>S(B.id),userId:t||""},B.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>k(I.id),children:[e.jsx($s,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},I.id)})]})]})}),e.jsx(bs,{value:"starters",children:_.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(pn,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No Starter Templates Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Admin-created starter templates will appear here. You'll be able to copy them into your own drips."})]}):e.jsx("div",{className:"space-y-3",children:_.map(I=>e.jsx(g3s,{template:I,onCopy:()=>M(I.id),isCopying:c.isPending},I.id))})})]})]})})}function Zze({template:t,isEditing:s,onToggleEdit:r,onToggleEnabled:n,onUpdate:a,onDelete:o,userId:l}){const[i,c]=N.useState(t.title),[u,p]=N.useState(t.subject),[f,g]=N.useState(t.body),[b,_]=N.useState(t.video_url||""),[j,w]=N.useState(t.channel),[k,S]=N.useState(t.delay_type),[M,L]=N.useState(t.delay_minutes),[I,O]=N.useState(!1),q=async()=>{O(!0);try{await a({title:i,subject:u,body:f,video_url:b||null,channel:j,delay_type:k,delay_minutes:M}),me.success("Drip saved"),r()}catch{me.error("Failed to save")}finally{O(!1)}},U=B=>{g(V=>V+B)};return e.jsxs("div",{className:"border rounded-lg bg-background overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",role:"button",onClick:r,children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.title||"Untitled drip"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.channel==="sms"?e.jsx(so,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(cr,{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(An,{className:"h-3 w-3 text-primary"})]})]}),e.jsx(qr,{checked:t.is_enabled,onCheckedChange:n})]}),s&&e.jsxs("div",{className:"border-t p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs font-medium",children:"Title (internal)"}),e.jsx(ze,{value:i,onChange:B=>c(B.target.value),className:"mt-1 h-8 text-sm",placeholder:"e.g. Buyer intro video"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ve,{className:"text-xs font-medium",children:"Channel"}),e.jsx("div",{className:"flex gap-1 mt-1",children:["email","sms"].map(B=>e.jsxs("button",{onClick:()=>w(B),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${j===B?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[B==="sms"?e.jsx(so,{className:"h-3 w-3"}):e.jsx(cr,{className:"h-3 w-3"}),B==="sms"?"SMS":"Email"]},B))})]}),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:()=>S("instant"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${k==="instant"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:"Instant"}),e.jsxs("button",{onClick:()=>S("scheduled"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${k==="scheduled"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[e.jsx(un,{className:"h-3 w-3 mr-1 inline"}),"Delay"]})]})]})]}),k==="scheduled"&&e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs font-medium",children:"Delay"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(ze,{type:"number",min:1,value:M>=60?Math.round(M/60):M,onChange:B=>{const V=parseInt(B.target.value)||0;L(M>=60?V*60:V)},className:"h-8 w-20 text-sm"}),e.jsx("div",{className:"flex gap-1",children:[{label:"Minutes",mins:M<60?M:30},{label:"Hours",mins:M>=60?M:60},{label:"Days",mins:M>=1440?M:1440}].map(B=>e.jsx("button",{className:`px-2 py-1 rounded text-xs border transition-colors ${B.label==="Minutes"&&M<60||B.label==="Hours"&&M>=60&&M<1440||B.label==="Days"&&M>=1440?"bg-primary/10 text-primary border-primary/30":"text-muted-foreground border-input"}`,onClick:()=>{B.label==="Minutes"?L(30):B.label==="Hours"?L(60):L(1440)},children:B.label},B.label))})]})]}),j==="email"&&e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs font-medium",children:"Subject Line"}),e.jsx(ze,{value:u,onChange:B=>p(B.target.value),className:"mt-1 h-8 text-sm",placeholder:"e.g. Next steps for your home purchase"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx(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:B=>{B.target.value&&U(B.target.value),B.target.value=""},children:[e.jsx("option",{value:"",children:"Merge variable..."}),f3s.map(B=>e.jsx("option",{value:B.key,children:B.label},B.key))]})]})]}),e.jsx("textarea",{value:f,onChange:B=>g(B.target.value),placeholder:j==="sms"?"Hey {{client_first_name}}, great talking with you today! Here's a quick video about what's next...":`Hi {{client_first_name}}, It was great meeting with you! Here's a video about what to expect next...`,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[100px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs font-medium",children:"Attached Video"}),b?e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 text-xs text-muted-foreground truncate bg-muted/50 rounded px-2 py-1.5 border border-input",children:[e.jsx(An,{className:"h-3 w-3 inline mr-1 text-primary"}),b.length>50?b.slice(0,50)+"...":b]}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive",onClick:()=>_(""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(lCe,{onVideoReady:B=>_(B)}),e.jsx(oCe,{userId:l,onSelect:B=>_(B),triggerSize:"sm",triggerClassName:"gap-1.5 flex-1"}),e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const B=prompt("Paste a YouTube or Loom URL:");B&&_(B)},children:[e.jsx(Bo,{className:"h-3 w-3"})," Paste URL"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive",onClick:o,children:[e.jsx(Nr,{className:"h-3 w-3 mr-1"})," Delete"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",className:"text-xs",onClick:r,children:"Cancel"}),e.jsx(K,{size:"sm",className:"text-xs",onClick:q,disabled:I,children:I?"Saving...":"Save Drip"})]})]})]})]})}function g3s({template:t,onCopy:s,isCopying:r}){const[n,a]=N.useState(!1),o=t.body.replace(/<[^>]+>/g,""),l=t.deal_type==="buyer"?"Buyer":t.deal_type==="seller"?"Seller":null,i=t.delay_type==="instant"?"Sends instantly":t.delay_minutes>=1440?`Sends after ${Math.round(t.delay_minutes/1440)} day${Math.round(t.delay_minutes/1440)!==1?"s":""}`:t.delay_minutes>=60?`Sends after ${Math.round(t.delay_minutes/60)} hour${Math.round(t.delay_minutes/60)!==1?"s":""}`:`Sends after ${t.delay_minutes} min`;return e.jsxs("div",{className:"border rounded-xl overflow-hidden transition-all hover:shadow-sm",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-start gap-3 p-4 text-left hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm",children:t.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:t.subject}),!n&&e.jsx("p",{className:"text-xs text-muted-foreground/70 line-clamp-1 mt-1",children:o})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 pt-0.5",children:[l&&e.jsx(tt,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:l}),e.jsxs(tt,{variant:"outline",className:"text-[10px] gap-1",children:[t.channel==="sms"?e.jsx(so,{className:"h-3 w-3"}):e.jsx(cr,{className:"h-3 w-3"}),t.channel==="sms"?"SMS":"Email"]}),e.jsxs(tt,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),t.delay_type==="instant"?"Instant":i.replace("Sends ","")]}),n?e.jsx(Eo,{className:"h-4 w-4 text-muted-foreground ml-1"}):e.jsx(da,{className:"h-4 w-4 text-muted-foreground ml-1"})]})]}),n&&e.jsxs("div",{className:"border-t bg-muted/10 p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase font-semibold text-muted-foreground tracking-wider mb-1",children:"Subject Line"}),e.jsx("p",{className:"text-sm font-medium",children:t.subject})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase font-semibold text-muted-foreground tracking-wider mb-1",children:"Email Body"}),e.jsx("div",{className:"text-sm text-foreground/80 bg-background rounded-lg border p-4 prose prose-sm max-w-none [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:my-0.5 [&_p]:my-2 [&_a]:text-primary [&_a]:underline",dangerouslySetInnerHTML:{__html:t.body}})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(un,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:i})]}),e.jsxs(K,{onClick:c=>{c.stopPropagation(),s()},size:"sm",className:"w-full gap-1.5",disabled:r,children:[e.jsx(gi,{className:"h-3.5 w-3.5"}),"Use This Template"]})]})]})}const yct=()=>{const t=zd();return N.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",t.pathname)},[t.pathname]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gray-100",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),e.jsx("p",{className:"mb-4 text-xl text-gray-600",children:"Oops! Page not found"}),e.jsx("a",{href:"/",className:"text-blue-500 underline hover:text-blue-700",children:"Return to Home"})]})})};function y3s(){return N.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs(O2e,{children:[e.jsx(ks,{path:"/c/:shareToken",element:e.jsx(gct,{})}),e.jsx(ks,{path:"*",element:e.jsx(yct,{})})]})}const Iye={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function vct({slugOverride:t}){const s=yo(),r=t||s.slug,[n,a]=N.useState("types"),[o,l]=N.useState(null),[i,c]=N.useState(null),[u,p]=N.useState(null),[f,g]=N.useState(new Date),[b,_]=N.useState({name:"",email:"",phone:"",message:""}),[j,w]=N.useState(!1),{data:k,isLoading:S}=mt({queryKey:["public-booking-settings",r],queryFn:async()=>{const{data:Q,error:ie}=await H.from("agent_booking_settings").select("*").eq("slug",r).eq("is_active",!0).single();if(ie)throw ie;return Q},enabled:!!r}),{data:M}=mt({queryKey:["public-booking-profile",k==null?void 0:k.user_id],queryFn:async()=>{const{data:Q,error:ie}=await H.from("profiles").select("name, avatar_url, email, phone, title, bio").eq("id",k.user_id).single();if(ie)throw ie;return Q},enabled:!!(k!=null&&k.user_id)}),{data:L=[]}=mt({queryKey:["public-booking-types",k==null?void 0:k.user_id],queryFn:async()=>{const{data:Q,error:ie}=await H.from("agent_booking_types").select("id, name, description, duration_minutes, color, icon, qualification_enabled").eq("user_id",k.user_id).eq("is_active",!0).order("sort_order");if(ie)throw ie;return Q},enabled:!!(k!=null&&k.user_id)}),{data:I=[]}=mt({queryKey:["public-availability",k==null?void 0:k.user_id],queryFn:async()=>{const{data:Q,error:ie}=await H.from("agent_availability_slots").select("day_of_week, start_time, end_time").eq("user_id",k.user_id).eq("is_active",!0);if(ie)throw ie;return Q},enabled:!!(k!=null&&k.user_id)}),{data:O=[]}=mt({queryKey:["public-blocked-dates",k==null?void 0:k.user_id],queryFn:async()=>{const{data:Q,error:ie}=await H.from("agent_blocked_dates").select("blocked_date").eq("user_id",k.user_id);if(ie)throw ie;return Q.map(re=>re.blocked_date)},enabled:!!(k!=null&&k.user_id)}),{data:q=[]}=mt({queryKey:["public-existing-bookings",k==null?void 0:k.user_id,i],queryFn:async()=>{if(!i)return[];const Q=ms(i,"yyyy-MM-dd"),{data:ie,error:re}=await H.from("bookings").select("start_time, end_time").eq("agent_user_id",k.user_id).eq("booking_date",Q).eq("status","confirmed");if(re)throw re;return ie},enabled:!!(k!=null&&k.user_id)&&!!i}),U=N.useMemo(()=>[...new Set(I.map(Q=>Q.day_of_week))],[I]),B=Q=>{const ie=$m(new Date),re=El(ie,(k==null?void 0:k.max_advance_days)||30),oe=El(ie,0);return US(Q,oe)||qS(Q,re)||O.includes(ms(Q,"yyyy-MM-dd"))?!1:U.includes(Q.getDay())},V=N.useMemo(()=>{if(!i||!o||!k)return[];const Q=I.filter(ge=>ge.day_of_week===i.getDay()),ie=o.duration_minutes,re=k.buffer_minutes||0,oe=[],ce=new Date,xe=(k.min_notice_hours||2)*60*60*1e3;for(const ge of Q){const[ue,pe]=ge.start_time.split(":").map(Number),[be,Me]=ge.end_time.split(":").map(Number);let Ne=UL(qL(i,ue),pe);const Pe=UL(qL(i,be),Me);for(;aM(Ne,ie)<=Pe;){const Oe=ms(Ne,"HH:mm"),Te=ms(aM(Ne,ie),"HH:mm");Ne.getTime()-ce.getTime()>=xe&&(q.some(Be=>{const nt=Be.start_time.slice(0,5),Ae=Be.end_time.slice(0,5);return Oent})||oe.push(Oe)),Ne=aM(Ne,ie+re)}}return oe},[i,o,I,k,q]),Z=N.useMemo(()=>{const Q=f.getFullYear(),ie=f.getMonth(),re=new Date(Q,ie,1),oe=new Date(Q,ie+1,0),ce=re.getDay(),xe=[];for(let ge=0;ge{if(!(!o||!i||!u||!b.name||!k)){w(!0);try{const Q=ms(aM(UL(qL(new Date,parseInt(u.split(":")[0])),parseInt(u.split(":")[1])),o.duration_minutes),"HH:mm"),{error:ie}=await H.from("bookings").insert({agent_user_id:k.user_id,booking_type_id:o.id,booking_date:ms(i,"yyyy-MM-dd"),start_time:u,end_time:Q,guest_name:b.name,guest_email:b.email||null,guest_phone:b.phone||null,guest_message:b.message||null});if(ie)throw ie;H.functions.invoke("booking-notify",{body:{agentUserId:k.user_id,guestName:b.name,guestEmail:b.email||null,guestPhone:b.phone||null,guestMessage:b.message||null,bookingTypeName:o.name,bookingDate:ms(i,"yyyy-MM-dd"),startTime:u,endTime:Q,durationMinutes:o.duration_minutes,meetingLink:k.meeting_link||null}}).catch(re=>console.error("Booking notify error:",re)),a("confirmed")}catch(Q){me.error("Failed to book: "+Q.message)}finally{w(!1)}}},ee=Q=>{const[ie,re]=Q.split(":").map(Number),oe=ie>=12?"PM":"AM";return`${ie%12||12}:${re.toString().padStart(2,"0")} ${oe}`};return S?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8] flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-[#406E71] border-t-transparent"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading booking page..."})]})}):k?e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8]",children:[e.jsx("div",{className:"h-1.5 bg-gradient-to-r from-[#406E71] via-[#5a9a9d] to-[#2a4c64]"}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-6 sm:py-10",children:[e.jsxs("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden mb-6",children:[e.jsx("div",{className:"relative bg-gradient-to-r from-[#406E71] to-[#2a4c64] px-6 pt-6 pb-12",children:e.jsxs("div",{className:"absolute inset-0 opacity-10",children:[e.jsx("div",{className:"absolute top-2 right-8 w-20 h-20 rounded-full border-2 border-white/30"}),e.jsx("div",{className:"absolute bottom-4 left-12 w-10 h-10 rounded-full border border-white/20"})]})}),e.jsx("div",{className:"relative -mt-10 px-6",children:e.jsxs("div",{className:"flex items-end gap-4",children:[M!=null&&M.avatar_url?e.jsx("img",{src:M.avatar_url,alt:(M==null?void 0:M.name)||"Agent",className:"w-20 h-20 sm:w-24 sm:h-24 rounded-2xl object-cover border-4 border-white shadow-md"}):e.jsx("div",{className:"w-20 h-20 sm:w-24 sm:h-24 rounded-2xl bg-gradient-to-br from-[#406E71] to-[#2a4c64] border-4 border-white shadow-md flex items-center justify-center",children:e.jsx(to,{className:"h-10 w-10 text-white"})}),e.jsxs("div",{className:"pb-1.5",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-slate-800 leading-tight",children:(M==null?void 0:M.name)||"Agent"}),(M==null?void 0:M.title)&&e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:M.title})]})]})}),e.jsxs("div",{className:"px-6 py-4 flex flex-wrap gap-2",children:[(M==null?void 0:M.phone)&&e.jsxs("a",{href:`tel:${M.phone}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[#406E71]/8 hover:bg-[#406E71]/15 text-[#406E71] text-xs font-medium transition-colors",children:[e.jsx(Un,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:M.phone}),e.jsx("span",{className:"sm:hidden",children:"Call"})]}),(M==null?void 0:M.email)&&e.jsxs("a",{href:`mailto:${M.email}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[#2a4c64]/8 hover:bg-[#2a4c64]/15 text-[#2a4c64] text-xs font-medium transition-colors",children:[e.jsx(cr,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:M.email}),e.jsx("span",{className:"sm:hidden",children:"Email"})]})]})]}),e.jsx("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden",children:e.jsxs("div",{className:"p-5 sm:p-6",children:[n==="types"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-slate-800",children:"Select a meeting type"}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Choose the type of meeting you'd like to schedule"})]}),e.jsx("div",{className:"space-y-2.5",children:L.map(Q=>e.jsx("button",{onClick:()=>{l(Q),a("date")},className:"w-full text-left group",children:e.jsx("div",{className:"relative rounded-xl border border-slate-150 p-4 transition-all duration-200 hover:shadow-md hover:border-[#406E71]/30 hover:-translate-y-0.5 active:translate-y-0",style:{borderLeftWidth:"3px",borderLeftColor:Q.color},children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("span",{className:"text-2xl shrink-0 mt-0.5",children:Iye[Q.icon]||"📅"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm text-slate-800 group-hover:text-[#406E71] transition-colors",children:Q.name}),Q.description&&e.jsx("p",{className:"text-xs text-slate-500 mt-0.5 line-clamp-2",children:Q.description})]})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2.5 py-1 rounded-full bg-slate-100 text-slate-600 text-xs font-medium",children:[e.jsx(un,{className:"h-3 w-3"}),Q.duration_minutes,"m"]})]})})},Q.id))})]}),n==="date"&&o&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>{a("types"),c(null),p(null)},className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(Ja,{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:Iye[o.icon]||"📅"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-semibold text-sm text-slate-800",children:o.name})}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-500 font-medium",children:[e.jsx(un,{className:"h-3 w-3"}),o.duration_minutes," min"]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:ms(f,"MMMM yyyy")}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{className:"h-8 w-8 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100 hover:text-slate-800 transition-colors",onClick:()=>g(new Date(f.getFullYear(),f.getMonth()-1)),children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsx("button",{className:"h-8 w-8 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100 hover:text-slate-800 transition-colors",onClick:()=>g(new Date(f.getFullYear(),f.getMonth()+1)),children:e.jsx(da,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-0.5 text-center",children:[["Su","Mo","Tu","We","Th","Fr","Sa"].map(Q=>e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-slate-400 font-semibold py-2",children:Q},Q)),Z.map((Q,ie)=>{if(!Q)return e.jsx("div",{},`pad-${ie}`);const re=B(Q),oe=i&&Cl(Q,i),ce=Cl(Q,new Date);return e.jsx("button",{disabled:!re,onClick:()=>{c(Q),p(null)},className:`h-10 w-10 mx-auto rounded-xl text-sm font-medium transition-all duration-150 ${oe?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-105":re?"hover:bg-[#406E71]/10 text-slate-700 hover:text-[#406E71]":"text-slate-200 cursor-not-allowed"} ${ce&&!oe?"ring-1 ring-[#406E71]/40":""}`,children:Q.getDate()},Q.toISOString())})]})]}),i&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dd,{className:"h-4 w-4 text-[#406E71]"}),e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:ms(i,"EEEE, MMMM d")})]}),V.length===0?e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(un,{className:"h-8 w-8 text-slate-300 mx-auto"}),e.jsx("p",{className:"text-sm text-slate-400",children:"No available times on this day"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Try selecting a different date"})]}):e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2 max-h-52 overflow-y-auto pr-1 custom-scrollbar",children:V.map(Q=>{const ie=u===Q;return e.jsx("button",{onClick:()=>p(Q),className:`px-3 py-2.5 rounded-xl text-sm font-medium transition-all duration-150 ${ie?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-[1.02]":"bg-slate-50 text-slate-700 hover:bg-[#406E71]/10 hover:text-[#406E71] border border-slate-150"}`,children:ee(Q)},Q)})}),u&&e.jsx(K,{className:"w-full h-12 rounded-xl bg-[#406E71] hover:bg-[#365c5e] text-white font-semibold shadow-md shadow-[#406E71]/20 transition-all hover:shadow-lg",onClick:()=>a("form"),children:"Continue to Details"})]})]}),n==="form"&&o&&i&&u&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>a("date"),className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(Ja,{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:Iye[o.icon]||"📅"}),e.jsx("p",{className:"font-semibold text-sm text-slate-800",children:o.name})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-slate-600",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Dd,{className:"h-3.5 w-3.5 text-[#406E71]"}),ms(i,"EEE, MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3.5 w-3.5 text-[#406E71]"}),ee(u)," · ",o.duration_minutes," min"]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-semibold text-slate-700",children:"Full Name *"}),e.jsx(ze,{value:b.name,onChange:Q=>_({...b,name:Q.target.value}),placeholder:"Jane Smith",className:"h-11 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-semibold text-slate-700",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(cr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(ze,{type:"email",value:b.email,onChange:Q=>_({...b,email:Q.target.value}),placeholder:"jane@email.com",className:"h-11 pl-9 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-semibold text-slate-700",children:"Phone"}),e.jsxs("div",{className:"relative",children:[e.jsx(Un,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(ze,{type:"tel",value:b.phone,onChange:Q=>_({...b,phone:Q.target.value}),placeholder:"(555) 123-4567",className:"h-11 pl-9 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-semibold text-slate-700",children:"Message (optional)"}),e.jsx(Er,{value:b.message,onChange:Q=>_({...b,message:Q.target.value}),placeholder:"Anything you'd like the agent to know ahead of time?",rows:3,className:"rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20 resize-none"})]})]}),e.jsx(K,{className:"w-full h-12 rounded-xl bg-[#406E71] hover:bg-[#365c5e] text-white font-semibold shadow-md shadow-[#406E71]/20 transition-all hover:shadow-lg disabled:opacity-60",onClick:X,disabled:!b.name||j,children:j?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}),"Booking..."]}):"Confirm Booking"})]}),n==="confirmed"&&e.jsxs("div",{className:"text-center space-y-5 py-6",children:[e.jsxs("div",{className:"relative mx-auto w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-emerald-100 animate-ping opacity-30"}),e.jsx("div",{className:"relative w-20 h-20 rounded-full bg-gradient-to-br from-emerald-400 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-200",children:e.jsx(sa,{className:"h-10 w-10 text-white"})})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-slate-800",children:"You're booked!"}),e.jsxs("p",{className:"text-slate-500 mt-1.5",children:[o==null?void 0:o.name," with ",(M==null?void 0:M.name)||"your agent"]})]}),e.jsx("div",{className:"inline-flex items-center gap-3 px-5 py-3 rounded-xl bg-slate-50 border border-slate-100",children:e.jsxs("div",{className:"text-left text-sm",children:[e.jsx("p",{className:"font-semibold text-slate-800",children:i&&ms(i,"EEEE, MMMM d, yyyy")}),e.jsxs("p",{className:"text-slate-500",children:[u&&ee(u)," · ",o==null?void 0:o.duration_minutes," min"]})]})}),e.jsx("p",{className:"text-sm text-slate-400 max-w-xs mx-auto",children:"A confirmation with meeting details will be sent to you shortly."}),((M==null?void 0:M.phone)||(M==null?void 0:M.email))&&e.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider font-semibold",children:"Contact"}),e.jsxs("div",{className:"flex gap-3",children:[(M==null?void 0:M.phone)&&e.jsxs("a",{href:`tel:${M.phone}`,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-full bg-[#406E71]/10 text-[#406E71] text-xs font-medium hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Call"]}),(M==null?void 0:M.email)&&e.jsxs("a",{href:`mailto:${M.email}`,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-full bg-[#2a4c64]/10 text-[#2a4c64] text-xs font-medium hover:bg-[#2a4c64]/20 transition-colors",children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]})}),e.jsx("p",{className:"text-center text-[10px] text-slate-300 mt-6 font-medium tracking-wide uppercase",children:"Powered by LevelUp"})]})]}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8] flex items-center justify-center p-4",children:e.jsxs("div",{className:"max-w-sm w-full text-center space-y-4",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-2xl bg-slate-100 flex items-center justify-center",children:e.jsx(Dd,{className:"h-8 w-8 text-slate-400"})}),e.jsx("h2",{className:"text-lg font-semibold text-slate-700",children:"Page Not Available"}),e.jsx("p",{className:"text-sm text-slate-500",children:"This booking page doesn't exist or is currently inactive."})]})})}function v3s(){const s=zd().pathname.slice(1).split("/")[0];return N.useEffect(()=>{document.body.classList.add("booking-page");const r=()=>{['[id*="lc_text_widget"]','[id*="lc_text-widget"]','[class*="lc-text-widget"]','[class*="lc_text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("booking-page"),n.forEach(clearTimeout)}},[]),s?e.jsx(vct,{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 b3s(){const s=zd().pathname.slice(1);return N.useEffect(()=>{document.body.classList.add("connect-page");const r=()=>{['[id*="lc_text_widget"]','[id*="lc_text-widget"]','[class*="lc-text-widget"]','[class*="lc_text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("connect-page"),n.forEach(clearTimeout)}},[]),!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-slate-100 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Connect"}),e.jsx("p",{className:"text-slate-500",children:"Stay connected with your real estate professional."}),e.jsx("p",{className:"text-slate-400 text-sm mt-2",children:"Visit a specific agent link to get started."})]})}):e.jsx(BYe,{slugOverride:s})}function bct({slugOverride:t}){const{slug:s}=yo(),r=t||s,[n,a]=N.useState(!1),[o,l]=N.useState({}),[i,c]=N.useState(0),[u,p]=N.useState(!1),{data:f,isLoading:g}=mt({queryKey:["public-landing-page",r],queryFn:async()=>{const{data:q,error:U}=await H.from("landing_pages").select("*").eq("slug",r).eq("is_published",!0).single();if(U)throw U;return q},enabled:!!r}),{data:b=[]}=mt({queryKey:["public-landing-page-fields",f==null?void 0:f.id],queryFn:async()=>{const{data:q,error:U}=await H.from("landing_page_fields").select("*").eq("page_id",f.id).order("sort_order");if(U)throw U;return q},enabled:!!(f!=null&&f.id)});N.useEffect(()=>{f!=null&&f.id&&H.from("landing_pages").update({view_count:(f.view_count||0)+1}).eq("id",f.id).then(()=>{})},[f==null?void 0:f.id]);const _=Dt({mutationFn:async()=>{const q=b.find(Q=>Q.field_type==="text"&&Q.label.toLowerCase().includes("name")),U=b.find(Q=>Q.field_type==="email"),B=b.find(Q=>Q.field_type==="phone"),V=q?String(o[q.label]||""):null,Z=U?String(o[U.label]||""):null,X=B?String(o[B.label]||""):null,{error:ee}=await H.from("landing_page_submissions").insert([{page_id:f.id,answers:JSON.parse(JSON.stringify(o)),contact_name:V,contact_email:Z,contact_phone:X,referrer:document.referrer||null,user_agent:navigator.userAgent,utm_source:new URLSearchParams(window.location.search).get("utm_source"),utm_medium:new URLSearchParams(window.location.search).get("utm_medium"),utm_campaign:new URLSearchParams(window.location.search).get("utm_campaign")}]);if(ee)throw ee;H.functions.invoke("landing-page-lead-notify",{body:{page_id:f.id,contact_name:V,contact_email:Z,contact_phone:X,answers:o}}).catch(Q=>console.error("Landing page lead notification error:",Q))},onSuccess:()=>a(!0)}),j=q=>{q.preventDefault(),!(b.filter(B=>B.is_required&&!o[B.label]).length>0)&&_.mutate()};if(g)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-gray-400 border-t-transparent"})});if(!f)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-700",children:"Page Not Found"}),e.jsx("p",{className:"text-gray-500 mt-2",children:"This page doesn't exist or is no longer available."})]})});const w=f.primary_color||"#406E71",k=f.accent_color||"#2a4c64",S=f,M=f.page_type==="lead_magnet",L=f.page_type==="just_listed"||f.page_type==="just_sold",I=Array.isArray(S.property_photos)?S.property_photos:[],O=S.lead_magnet_file_url||S.lead_magnet_external_url;if(n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:`linear-gradient(135deg, ${w}, ${k})`},children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl p-8 max-w-md mx-4 text-center",children:[e.jsx(sa,{className:"h-16 w-16 mx-auto mb-4",style:{color:w}}),e.jsx("h2",{className:"text-2xl font-bold mb-2",children:M?"Your download is ready!":"Submitted!"}),e.jsx("p",{className:"text-gray-600",children:f.success_message}),M&&O&&e.jsxs("a",{href:O,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 mt-6 px-6 py-3 rounded-lg text-white font-semibold transition-transform hover:scale-105",style:{backgroundColor:w},children:[e.jsx(yi,{className:"h-5 w-5"}),"Download ",S.lead_magnet_file_name||"Your File"]}),f.agent_name&&e.jsxs("div",{className:"mt-6 pt-4 border-t",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Contact"}),e.jsx("p",{className:"font-semibold",children:f.agent_name}),f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:w},children:[e.jsx(Un,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:w},children:[e.jsx(cr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})});if(L){const q=U=>{const B=parseFloat(U.replace(/[^0-9.]/g,""));return isNaN(B)?U:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(B)};return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[u&&I.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(Rr,{className:"h-8 w-8"})}),e.jsx("button",{onClick:U=>{U.stopPropagation(),c(B=>B===0?I.length-1:B-1)},className:"absolute left-4 top-1/2 -translate-y-1/2 bg-white/10 hover:bg-white/20 text-white rounded-full p-3 transition-colors z-10",children:e.jsx(cl,{className:"h-6 w-6"})}),e.jsx("img",{src:I[i],alt:`Property photo ${i+1}`,className:"max-h-[90vh] max-w-[90vw] object-contain rounded-lg",onClick:U=>U.stopPropagation()}),e.jsx("button",{onClick:U=>{U.stopPropagation(),c(B=>B===I.length-1?0:B+1)},className:"absolute right-4 top-1/2 -translate-y-1/2 bg-white/10 hover:bg-white/20 text-white rounded-full p-3 transition-colors z-10",children:e.jsx(da,{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," / ",I.length]})]}),I.length>0&&e.jsxs("div",{className:"relative max-w-6xl mx-auto px-4 pt-6",children:[e.jsx("div",{className:"absolute top-10 left-8 z-10 px-4 py-1.5 rounded-full text-white font-bold text-sm uppercase tracking-wider shadow-lg",style:{backgroundColor:S.property_status==="just_sold"?"#e74c3c":w},children:S.property_status==="just_sold"?"🎉 Just Sold":"🏡 Just Listed"}),I.length===1?e.jsxs("div",{className:"rounded-2xl overflow-hidden cursor-pointer group",onClick:()=>{c(0),p(!0)},children:[e.jsx("img",{src:I[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(G_,{className:"h-4 w-4"})," View"]})]}):I.length===2?e.jsx("div",{className:"grid grid-cols-2 gap-2 rounded-2xl overflow-hidden",children:I.slice(0,2).map((U,B)=>e.jsx("div",{className:"cursor-pointer group relative",onClick:()=>{c(B),p(!0)},children:e.jsx("img",{src:U,alt:`Property ${B+1}`,className:"w-full h-[45vh] object-cover group-hover:scale-105 transition-transform duration-500"})},B))}):e.jsxs("div",{className:"grid grid-cols-4 gap-2 rounded-2xl overflow-hidden",style:{height:"55vh"},children:[e.jsx("div",{className:"col-span-2 row-span-2 cursor-pointer group relative",onClick:()=>{c(0),p(!0)},children:e.jsx("img",{src:I[0],alt:"Property main",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),I.slice(1,5).map((U,B)=>e.jsxs("div",{className:"cursor-pointer group relative",onClick:()=>{c(B+1),p(!0)},children:[e.jsx("img",{src:U,alt:`Property ${B+2}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}),B===3&&I.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center text-white font-bold text-lg",children:["+",I.length-5," more"]})]},B))]}),I.length>2&&e.jsxs("button",{onClick:()=>{c(0),p(!0)},className:"absolute bottom-4 right-8 bg-white shadow-lg hover:shadow-xl text-gray-800 px-4 py-2 rounded-lg text-sm font-medium flex items-center gap-2 transition-shadow",children:[e.jsx(G_,{className:"h-4 w-4"})," View all ",I.length," photos"]})]}),I.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}, ${k})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[f.logo_url&&e.jsx("img",{src:f.logo_url,alt:"Logo",className:"h-12 w-auto mx-auto mb-6"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold",children:f.hero_headline}),f.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:f.hero_subtext})]})}),e.jsx("div",{className:"max-w-4xl mx-auto px-4 py-8",children:e.jsxs("div",{className:"grid md:grid-cols-5 gap-6",children:[e.jsx("div",{className:"md:col-span-3 space-y-6",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 md:p-8",children:[S.property_price&&e.jsx("p",{className:"text-3xl md:text-4xl font-bold mb-2",style:{color:w},children:q(S.property_price)}),S.property_address&&e.jsxs("p",{className:"text-gray-600 flex items-center gap-1.5 mb-5 text-lg",children:[e.jsx(ma,{className:"h-5 w-5 shrink-0"})," ",S.property_address]}),e.jsxs("div",{className:"flex gap-6 mb-5 py-4 border-y border-gray-100",children:[S.property_beds&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(Im,{className:"h-5 w-5",style:{color:w}})," ",S.property_beds]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bedrooms"})]}),S.property_baths&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(Ju,{className:"h-5 w-5",style:{color:w}})," ",S.property_baths]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bathrooms"})]}),S.property_sqft&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(x0,{className:"h-5 w-5",style:{color:w}})," ",Number(S.property_sqft).toLocaleString()]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Sq Ft"})]})]}),S.property_description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-800 mb-2",children:"About This Property"}),e.jsx("p",{className:"text-gray-600 leading-relaxed whitespace-pre-line",children:S.property_description})]})]})}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 sticky top-6",children:[e.jsx("h2",{className:"text-lg font-bold mb-1",style:{color:w},children:S.property_status==="just_sold"?"Want results like this?":"Interested in this property?"}),e.jsx("p",{className:"text-gray-500 text-sm mb-4",children:"Fill out the form and I'll be in touch!"}),f.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-5 pb-4 border-b",children:[f.agent_photo_url&&e.jsx("img",{src:f.agent_photo_url,alt:f.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:f.agent_name}),e.jsxs("div",{className:"flex flex-col gap-0.5 text-xs text-gray-500",children:[f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Un,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(cr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:j,className:"space-y-3",children:[b.map(U=>e.jsxs("div",{children:[e.jsxs(ve,{className:"text-xs font-medium",children:[U.label,U.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),Yze(U,o,l)]},U.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},disabled:_.isPending,children:_.isPending?"Submitting...":"Submit"}),_.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${w}, ${k})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[f.logo_url&&e.jsx("img",{src:f.logo_url,alt:"Logo",className:"h-12 w-auto mx-auto mb-6"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold",children:f.hero_headline}),f.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:f.hero_subtext}),M&&S.lead_magnet_file_name&&e.jsxs("div",{className:"mt-6 inline-flex items-center gap-2 bg-white/20 backdrop-blur px-4 py-2 rounded-full text-sm",children:[e.jsx(yi,{className:"h-4 w-4"}),"Free Download: ",S.lead_magnet_file_name]})]})}),e.jsx("div",{className:"max-w-2xl mx-auto px-4 -mt-8",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 md:p-8",children:[M&&e.jsx("p",{className:"text-sm text-gray-500 mb-4 text-center",children:"Fill out the form below to get your free download!"}),f.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-6 pb-4 border-b",children:[f.agent_photo_url&&e.jsx("img",{src:f.agent_photo_url,alt:f.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:f.agent_name}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-500",children:[f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Un,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(cr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[b.map(q=>e.jsxs("div",{children:[e.jsxs(ve,{className:"text-sm font-medium",children:[q.label,q.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),Yze(q,o,l)]},q.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},disabled:_.isPending,children:_.isPending?"Submitting...":M?"Get My Free Download":"Submit"}),_.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}function Yze(t,s,r,n){const a=s[t.label]||"",o=Array.isArray(t.options)?t.options:[];switch(t.field_type){case"text":case"email":case"phone":return e.jsx(ze,{type:t.field_type==="email"?"email":t.field_type==="phone"?"tel":"text",value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),placeholder:t.placeholder||"",className:"mt-1"});case"textarea":return e.jsx(Er,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),placeholder:t.placeholder||"",rows:3,className:"mt-1"});case"select":return e.jsxs(Zs,{value:String(a),onValueChange:l=>r(i=>({...i,[t.label]:l})),children:[e.jsx(Ws,{className:"mt-1",children:e.jsx(Xs,{placeholder:"Select..."})}),e.jsx(Gs,{children:o.map(l=>e.jsx(Mt,{value:l,children:l},l))})]});case"multiselect":return e.jsx("div",{className:"mt-1 space-y-2",children:o.map(l=>{const i=Array.isArray(a)?a:[];return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Oo,{checked:i.includes(l),onCheckedChange:c=>{const u=c?[...i,l]:i.filter(p=>p!==l);r(p=>({...p,[t.label]:u}))}}),e.jsx("span",{className:"text-sm",children:l})]},l)})});case"toggle":return e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsx(qr,{checked:!!a,onCheckedChange:l=>r(i=>({...i,[t.label]:l?"Yes":"No"}))}),e.jsx("span",{className:"text-sm text-gray-600",children:a?"Yes":"No"})]});default:return e.jsx(ze,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),className:"mt-1"})}}function _3s(){const s=zd().pathname.slice(1).split("/")[0];return N.useEffect(()=>{document.body.classList.add("landing-page-public");const r=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("landing-page-public"),n.forEach(clearTimeout)}},[]),s?e.jsx(bct,{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 _ct=[{type:"hero",enabled:!0},{type:"featured_listings",enabled:!0},{type:"new_listings",enabled:!1},{type:"open_houses",enabled:!1},{type:"my_listings",enabled:!1},{type:"city_pages",enabled:!1},{type:"featured_areas",enabled:!0},{type:"about",enabled:!0},{type:"testimonials",enabled:!0},{type:"cta_banner",enabled:!0}],WMs={hero:"Hero Section",featured_listings:"Featured Listings",featured_areas:"Featured Areas",about:"About Me",testimonials:"Testimonials",cta_banner:"Call To Action",new_listings:"New Listings Carousel",open_houses:"Open Houses Carousel",my_listings:"My Listings Carousel",city_pages:"City Pages Grid"};function w3s(t){const s=t.theme_config||{};return{themeTier:t.theme_tier||"basic",brandColor:t.brand_color||"#0f172a",accentColor:t.accent_color||"#3b82f6",fontFamily:t.font_family||"Inter",heroImageUrl:t.hero_image_url||null,homepageModules:Array.isArray(t.homepage_modules)&&t.homepage_modules.length?t.homepage_modules:_ct,testimonials:Array.isArray(t.testimonials)?t.testimonials:[],featuredListingIds:t.featured_listing_ids||[],searchCities:Array.isArray(s.searchCities)?s.searchCities:[],searchZipCodes:Array.isArray(s.searchZipCodes)?s.searchZipCodes:[],searchCounties:Array.isArray(s.searchCounties)?s.searchCounties:[]}}function j3s(){const s=window.location.hostname.match(/^([^.]+)\.thelocalmove\.com$/i);return s?s[1]:null}function N3s(){const t=j3s(),{data:s,isLoading:r,error:n}=mt({queryKey:["lead-site",t],queryFn:async()=>{var p;if(!t)return null;const{data:a,error:o}=await H.from("lead_sites").select("*").eq("subdomain_slug",t).eq("is_active",!0).maybeSingle();if(o)throw o;if(!a)return null;const{data:l}=await H.from("profiles").select("id, name, avatar_url, email, phone, title, bio").eq("id",a.agent_id).single();let i=null;if(a.show_team_logo)if(a.team_logo_url)i=a.team_logo_url;else{const{data:f}=await H.from("team_members").select("team_id, teams(avatar_url, name)").eq("user_id",a.agent_id).limit(1).maybeSingle();f&&((p=f.teams)!=null&&p.avatar_url)&&(i=f.teams.avatar_url)}const c={id:a.id,agentId:a.agent_id,subdomainSlug:a.subdomain_slug,mlsProviderId:a.mls_provider_id,siteTitle:a.site_title,siteTagline:a.site_tagline,leadRegistrationMode:a.lead_registration_mode||"disabled",registrationTriggerCount:a.registration_trigger_count??1,themeConfig:a.theme_config||{},isActive:a.is_active,brokerageLegalName:a.brokerage_legal_name||null,brokerageLicenseNumber:a.brokerage_license_number||null,agentLicenseNumber:a.agent_license_number||null,mlsDisclaimerText:a.mls_disclaimer_text||null,mlsLogoUrl:a.mls_logo_url||null,equalHousingEnabled:a.equal_housing_enabled??!0,faviconUrl:a.favicon_url||null,ogImageUrl:a.og_image_url||null,showTeamLogo:a.show_team_logo??!1,teamLogoUrl:i,agent:l?{id:l.id,full_name:l.name||"",avatar_url:l.avatar_url,email:l.email,phone:l.phone,title:l.title,bio:l.bio}:void 0},u=w3s(a);return{siteConfig:c,themeConfig:u}},enabled:!!t});return{siteConfig:(s==null?void 0:s.siteConfig)??null,themeConfig:(s==null?void 0:s.themeConfig)??null,isLoading:r,error:n,slug:t}}async function _me(t,s){try{await H.functions.invoke("lead-site-notify",{body:{lead:s,lead_site_id:t}})}catch(r){console.warn("Lead notification failed:",r)}}const wct=N.createContext(null);function wme(){const t=N.useContext(wct);if(!t)throw new Error("useLeadSiteAuth must be used within LeadSiteAuthProvider");return t}function k3s({siteConfig:t,children:s}){const[r,n]=N.useState(null),[a,o]=N.useState(null),[l,i]=N.useState(!0);N.useEffect(()=>{const{data:{subscription:f}}=H.auth.onAuthStateChange(async(g,b)=>{const _=(b==null?void 0:b.user)??null;if(n(_),_){const{data:j}=await H.from("lead_site_consumer_profiles").select("id, name, phone").eq("user_id",_.id).eq("lead_site_id",t.id).maybeSingle();j&&o({...j,email:_.email||""})}else o(null);i(!1)});return H.auth.getSession().then(({data:{session:g}})=>{n((g==null?void 0:g.user)??null),g!=null&&g.user?H.from("lead_site_consumer_profiles").select("id, name, phone").eq("user_id",g.user.id).eq("lead_site_id",t.id).maybeSingle().then(({data:b})=>{b&&o({...b,email:g.user.email||""}),i(!1)}):i(!1)}),()=>f.unsubscribe()},[t.id]);const c=N.useCallback(async f=>{const g=f.email.toLowerCase().trim(),b=f.phone.replace(/\D/g,""),{data:_,error:j}=await H.auth.signUp({email:g,password:b,options:{data:{full_name:f.name,consumer_site_id:t.id},emailRedirectTo:window.location.origin}});if(j){if(j.message.includes("already registered")){await u(g,b);return}throw j}if(_.user){const{error:w}=await H.from("lead_site_consumer_profiles").insert({user_id:_.user.id,lead_site_id:t.id,name:f.name.trim(),phone:f.phone.trim()});w&&console.warn("Consumer profile insert error:",w);const{error:k}=await H.from("lead_site_leads").insert({lead_site_id:t.id,name:f.name.trim(),email:g,phone:f.phone.trim(),message:"Created account on website",source_page:window.location.pathname,lead_type:"website_registration",metadata:{registered:!0,has_account:!0}});k&&console.error("Lead insert error (CRM sync may not trigger):",k),_me(t.id,{name:f.name.trim(),email:g,phone:f.phone.trim(),lead_type:"website_registration",message:"Created account on website",source_page:window.location.pathname})}},[t.id]),u=N.useCallback(async(f,g)=>{const b=g.replace(/\D/g,""),{error:_}=await H.auth.signInWithPassword({email:f.toLowerCase().trim(),password:b});if(_)throw _},[]),p=N.useCallback(async()=>{await H.auth.signOut(),n(null),o(null)},[]);return e.jsx(wct.Provider,{value:{user:r,profile:a,isLoading:l,signUp:c,signIn:u,signOut:p},children:s})}function jct({open:t,mode:s,siteConfig:r,onComplete:n,onSkip:a}){var O;const{signUp:o,signIn:l}=wme(),[i,c]=N.useState(!1),[u,p]=N.useState(""),[f,g]=N.useState(""),[b,_]=N.useState(""),[j,w]=N.useState(!1),[k,S]=N.useState(""),M=s==="required",L=((O=r.agent)==null?void 0:O.full_name)||"the agent",I=async q=>{var B;if(q.preventDefault(),S(""),!f.trim()||!b.trim()){S("Email and phone number are required.");return}if(!i&&!u.trim()){S("Name is required.");return}if(b.replace(/\D/g,"").length<7){S("Please enter a valid phone number.");return}w(!0);try{i?await l(f,b):await o({name:u,email:f,phone:b}),n()}catch(V){(B=V==null?void 0:V.message)!=null&&B.includes("Invalid login")?S("Invalid email or phone number. Please try again."):S((V==null?void 0:V.message)||"Something went wrong. Please try again.")}finally{w(!1)}};return e.jsx(fs,{open:t,onOpenChange:M?void 0:q=>{q||a()},children:e.jsxs(ps,{className:"sm:max-w-md",onPointerDownOutside:M?q=>q.preventDefault():void 0,onEscapeKeyDown:M?q=>q.preventDefault():void 0,children:[e.jsxs(_s,{children:[e.jsx(vs,{className:"text-xl",children:i?"Welcome Back":M?"Create a Free Account to Continue":"Save Your Search & Get Updates"}),e.jsx(Gr,{children:i?"Sign in with your email and phone number.":`Create a free account to save favorites, get alerts, and connect with ${L}.`})]}),e.jsxs("form",{onSubmit:I,className:"space-y-3 mt-2",children:[!i&&e.jsx("input",{type:"text",required:!0,placeholder:"Your name",value:u,onChange:q=>p(q.target.value),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("input",{type:"email",required:!0,placeholder:"Email address",value:f,onChange:q=>g(q.target.value),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsxs("div",{children:[e.jsx("input",{type:"tel",required:!0,placeholder:"Phone number",value:b,onChange:q=>_(q.target.value),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:i?"Your phone number is your password":"Your phone number will be used as your password"})]}),k&&e.jsx("p",{className:"text-red-600 text-sm",children:k}),e.jsx("button",{type:"submit",disabled:j,className:"w-full py-2.5 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors",children:j?i?"Signing in...":"Creating account...":i?"Sign In":"Create Account"}),e.jsx("button",{type:"button",onClick:()=>{c(!i),S("")},className:"w-full text-center text-sm text-blue-600 hover:text-blue-700",children:i?"Don't have an account? Sign up":"Already have an account? Sign in"}),!M&&!i&&e.jsx("button",{type:"button",onClick:a,className:"w-full py-2 text-gray-500 text-sm hover:text-gray-700 transition-colors",children:"Skip for now"})]}),e.jsx("p",{className:"text-xs text-gray-400 text-center mt-1",children:"By registering you agree to receive property updates. You can unsubscribe anytime."})]})})}function fCe({siteConfig:t,pagePath:s}){const r=t.agent;if(!r)return null;const n=`https://${t.subdomainSlug}.thelocalmove.com`,a={"@context":"https://schema.org","@type":"RealEstateAgent","@id":`${n}/#agent`,name:r.full_name,url:n,image:r.avatar_url||void 0,email:r.email,telephone:r.phone||void 0,jobTitle:r.title||"Real Estate Agent",description:r.bio||`${r.full_name} is a trusted real estate professional.`,...t.brokerageLegalName&&{worksFor:{"@type":"RealEstateAgent",name:t.brokerageLegalName}}},o={"@context":"https://schema.org","@type":"WebSite","@id":`${n}/#website`,name:t.siteTitle||`${r.full_name} Real Estate`,url:n,publisher:{"@id":`${n}/#agent`},potentialAction:{"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:`${n}/search?q={search_term_string}`},"query-input":"required name=search_term_string"}};return e.jsxs(Sc,{children:[e.jsx("script",{type:"application/ld+json",children:JSON.stringify(a)}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(o)})]})}function xCe({items:t,siteConfig:s}){const r=`https://${s.subdomainSlug}.thelocalmove.com`,n={"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:t.map((a,o)=>({"@type":"ListItem",position:o+1,name:a.name,item:`${r}${a.path}`}))};return e.jsx(Sc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function S3s({listing:t,siteConfig:s}){var a;const r=`https://${s.subdomainSlug}.thelocalmove.com`,n={"@context":"https://schema.org","@type":"SingleFamilyResidence",name:`${t.address}, ${t.city}, ${t.state} ${t.zip}`,url:`${r}/listing/${t.mlsNumber}`,image:((a=t.photos)==null?void 0:a[0])||void 0,numberOfRooms:t.bedrooms,numberOfBathroomsTotal:t.bathrooms,floorSize:t.sqft?{"@type":"QuantitativeValue",value:t.sqft,unitCode:"FTK"}:void 0,address:{"@type":"PostalAddress",streetAddress:t.address,addressLocality:t.city,addressRegion:t.state,postalCode:t.zip},...t.latitude&&t.longitude&&{geo:{"@type":"GeoCoordinates",latitude:t.latitude,longitude:t.longitude}},offers:{"@type":"Offer",price:t.price,priceCurrency:"USD",availability:t.status==="Active"?"https://schema.org/InStock":"https://schema.org/SoldOut"},...t.yearBuilt&&{yearBuilt:t.yearBuilt}};return e.jsx(Sc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function C3s({faqs:t}){if(!t.length)return null;const s={"@context":"https://schema.org","@type":"FAQPage",mainEntity:t.map(r=>({"@type":"Question",name:r.question,acceptedAnswer:{"@type":"Answer",text:r.answer}}))};return e.jsx(Sc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(s)})})}function M3s({title:t,description:s,publishedAt:r,imageUrl:n,slug:a,siteConfig:o}){const l=`https://${o.subdomainSlug}.thelocalmove.com`,i=o.agent,c={"@context":"https://schema.org","@type":"Article",headline:t,description:s,url:`${l}/blog/${a}`,datePublished:r,...n&&{image:n},author:i?{"@type":"Person",name:i.full_name,url:l}:void 0,publisher:{"@type":"Organization",name:o.siteTitle||(i==null?void 0:i.full_name)||"Agent",url:l}};return e.jsx(Sc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(c)})})}const Xze="ls_visitor_geo",T3s=1e3*60*60;function A3s(t){return t==="/"?"home":t==="/search"?"search":t==="/sell"?"sell":t==="/blog"?"blog":t.startsWith("/listing/")?"listing":t.startsWith("/homes-for-sale-in-")?"city":t==="/dashboard"?"dashboard":"other"}function E3s(t,s){switch(s){case"home":return"Home";case"search":return"Search";case"sell":return"Sell Your Home";case"blog":return"Blog";case"listing":return`Listing ${t.split("/listing/")[1]||""}`;case"city":return t.replace("/homes-for-sale-in-","").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");case"dashboard":return"My Dashboard";default:return t}}async function P3s(){try{const t=localStorage.getItem(Xze);if(t){const s=JSON.parse(t);if(Date.now()-s.ts{o.current||(o.current=!0,P3s().then(l=>{a.current=l}))},[]),N.useEffect(()=>{if(!(t!=null&&t.id))return;const l=r.pathname;if(l===n.current)return;n.current=l;const i=A3s(l),c=E3s(l,i),u=localStorage.getItem(`ls_visitor_fp_${t.id}`)||null,p=a.current;H.from("lead_site_page_views").insert({lead_site_id:t.id,page_type:i,page_path:l,page_title:c,visitor_fingerprint:u,auth_user_id:s||null,visitor_city:(p==null?void 0:p.city)||null,visitor_region:(p==null?void 0:p.region)||null,visitor_country:(p==null?void 0:p.country)||null,visitor_lat:(p==null?void 0:p.lat)||null,visitor_lng:(p==null?void 0:p.lng)||null}).then(({error:f})=>{f&&console.error("[PageTracking] insert failed:",f.message)})},[r.pathname,t==null?void 0:t.id,s])}function L3s({children:t,siteConfig:s}){var Z,X,ee,Q,ie,re,oe,ce,xe;const r=zd(),n=fr(),[a,o]=N.useState(!1),[l,i]=N.useState(!1),[c,u]=N.useState(!1),[p,f]=N.useState([]),g=N.useRef(null),{user:b,profile:_,signOut:j}=wme();I3s(s,b==null?void 0:b.id);const w=((Z=s.agent)==null?void 0:Z.full_name)||"Agent",k=s.siteTitle||`${w} Real Estate`,S=r.pathname==="/search",M=r.pathname==="/",L=s.leadRegistrationMode!=="disabled";N.useEffect(()=>{(async()=>{const{data:ue}=await H.from("lead_site_city_pages").select("city_name, city_slug").eq("site_id",s.id).eq("is_published",!0).order("sort_order",{ascending:!0});f(ue||[])})()},[s.id]),N.useEffect(()=>{const ge=ue=>{g.current&&!g.current.contains(ue.target)&&u(!1)};return document.addEventListener("mousedown",ge),()=>document.removeEventListener("mousedown",ge)},[]);const I=[{to:"/",label:"Home"},{to:"/search",label:"Search"},{to:"/sell",label:"Sell"},{to:"/blog",label:"Blog"},{to:"/community",label:"Community"},{to:"/about",label:"About"},{to:"/contact",label:"Contact"}],O=M?"bg-transparent text-white":"bg-white/95 backdrop-blur text-gray-900 border-b border-gray-100 shadow-sm",q=s.siteTitle||`${w} - Real Estate`,U=s.siteTagline||`Browse homes and listings with ${w}`,B=s.ogImageUrl||((X=s.agent)==null?void 0:X.avatar_url)||"",V=`https://${s.subdomainSlug||""}.thelocalmove.com`;return e.jsxs("div",{className:`flex flex-col ${S?"h-screen overflow-hidden":"min-h-screen"} bg-white`,children:[e.jsx(fCe,{siteConfig:s,pagePath:r.pathname}),e.jsxs(Sc,{children:[e.jsx("title",{children:q}),e.jsx("meta",{name:"description",content:U}),e.jsx("meta",{property:"og:title",content:q}),e.jsx("meta",{property:"og:description",content:U}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:V+r.pathname}),B&&e.jsx("meta",{property:"og:image",content:B}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:q}),e.jsx("meta",{name:"twitter:description",content:U}),B&&e.jsx("meta",{name:"twitter:image",content:B}),s.faviconUrl&&e.jsx("link",{rel:"icon",href:s.faviconUrl,type:"image/png"}),e.jsx("link",{rel:"canonical",href:`${V}${r.pathname}`})]}),e.jsxs("header",{className:`${M?"absolute":"sticky"} top-0 left-0 right-0 z-50 transition-all ${O}`,children:[e.jsx("div",{className:"max-w-7xl mx-auto px-6 lg:px-8",children:e.jsxs("div",{className:"flex items-center justify-between h-20",children:[e.jsxs(Pi,{to:"/",className:"flex items-center gap-3",children:[((ee=s.agent)==null?void 0:ee.avatar_url)&&e.jsx("img",{src:s.agent.avatar_url,alt:w,className:"h-10 w-10 rounded-full object-cover ring-2 ring-white/20"}),e.jsx("div",{children:e.jsx("span",{className:"font-bold text-lg leading-none tracking-tight",children:k})})]}),e.jsxs("nav",{className:"hidden md:flex items-center gap-1",children:[I.map(ge=>e.jsx(Pi,{to:ge.to,className:`px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${r.pathname===ge.to?M?"bg-white/15 text-white":"bg-gray-100 text-gray-900":M?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:ge.label},ge.to)),p.length>0&&e.jsxs("div",{ref:g,className:"relative",children:[e.jsxs("button",{onClick:()=>u(!c),className:`flex items-center gap-1 px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${r.pathname.startsWith("/homes-for-sale-in-")?M?"bg-white/15 text-white":"bg-gray-100 text-gray-900":M?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:["Cities ",e.jsx(Eo,{className:`h-3.5 w-3.5 transition-transform ${c?"rotate-180":""}`})]}),c&&e.jsx("div",{className:"absolute top-full right-0 mt-2 w-52 bg-white rounded-xl shadow-xl border border-gray-100 py-2 z-50 animate-in fade-in slide-in-from-top-2 duration-150",children:p.map(ge=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${ge.city_slug}`),u(!1)},className:"w-full text-left px-4 py-2.5 text-sm text-gray-700 hover:bg-gray-50 hover:text-gray-900 transition-colors",children:ge.city_name},ge.city_slug))})]}),b?e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsxs(Pi,{to:"/account",className:`flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${M?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[e.jsx(ni,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:"Saved"})]}),e.jsxs(Pi,{to:"/account",className:`flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${M?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[e.jsx(to,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:((Q=_==null?void 0:_.name)==null?void 0:Q.split(" ")[0])||"Account"})]})]}):L?e.jsx("button",{onClick:()=>i(!0),className:`ml-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${M?"bg-white/15 text-white hover:bg-white/25":"bg-blue-600 text-white hover:bg-blue-700"}`,children:"Sign In"}):null]}),e.jsx("button",{onClick:()=>o(!a),className:`md:hidden p-2 rounded-lg ${M?"text-white hover:bg-white/10":"text-gray-600 hover:bg-gray-100"}`,children:a?e.jsx(Rr,{className:"h-5 w-5"}):e.jsx(OM,{className:"h-5 w-5"})})]})}),a&&e.jsx("div",{className:`md:hidden border-t ${M?"border-white/10 bg-black/80 backdrop-blur":"border-gray-100 bg-white"}`,children:e.jsxs("div",{className:"px-4 py-3 space-y-1",children:[I.map(ge=>e.jsx(Pi,{to:ge.to,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===ge.to?M?"bg-white/15 text-white":"bg-gray-100 text-gray-900":M?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:ge.label},ge.to)),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`px-3 pt-3 pb-1 text-xs font-semibold uppercase tracking-wider ${M?"text-white/40":"text-gray-400"}`,children:"Cities"}),p.map(ge=>e.jsx(Pi,{to:`/homes-for-sale-in-${ge.city_slug}`,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===`/homes-for-sale-in-${ge.city_slug}`?M?"bg-white/15 text-white":"bg-gray-100 text-gray-900":M?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:ge.city_name},ge.city_slug))]}),b?e.jsxs(e.Fragment,{children:[e.jsx(Pi,{to:"/account",onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${M?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:"My Account"}),e.jsx("button",{onClick:async()=>{await j(),o(!1)},className:`block w-full text-left px-3 py-2.5 rounded-lg text-sm font-medium ${M?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:"Sign Out"})]}):L?e.jsx("button",{onClick:()=>{i(!0),o(!1)},className:`block w-full text-left px-3 py-2.5 rounded-lg text-sm font-medium ${M?"text-white/70 hover:bg-white/10":"text-blue-600 hover:bg-blue-50"}`,children:"Sign In / Register"}):null]})})]}),e.jsx("main",{className:"flex-1 min-h-0 flex flex-col",children:t}),!S&&e.jsx("footer",{className:"bg-gray-950 text-gray-400",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 lg:px-8 py-16",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-12",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[((ie=s.agent)==null?void 0:ie.avatar_url)&&e.jsx("img",{src:s.agent.avatar_url,alt:w,className:"h-16 w-16 rounded-2xl object-cover ring-2 ring-white/10"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-white text-lg tracking-tight",children:w}),e.jsx("p",{className:"text-sm text-gray-500",children:((re=s.agent)==null?void 0:re.title)||"Real Estate Professional"})]})]}),((oe=s.agent)==null?void 0:oe.phone)&&e.jsx("p",{className:"text-sm mt-3",children:e.jsxs("a",{href:`tel:${s.agent.phone}`,className:"hover:text-white transition-colors flex items-center gap-2",children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," ",s.agent.phone]})}),((ce=s.agent)==null?void 0:ce.email)&&e.jsx("p",{className:"text-sm mt-1",children:e.jsxs("a",{href:`mailto:${s.agent.email}`,className:"hover:text-white transition-colors flex items-center gap-2",children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," ",s.agent.email]})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-white mb-4 text-sm tracking-wider uppercase",children:"Quick Links"}),e.jsx("ul",{className:"space-y-3 text-sm",children:I.map(ge=>e.jsx("li",{children:e.jsx(Pi,{to:ge.to,className:"hover:text-white transition-colors",children:ge.label})},ge.to))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-white mb-4 text-sm tracking-wider uppercase",children:"Get In Touch"}),e.jsx("p",{className:"text-sm text-gray-500 leading-relaxed mb-4",children:"Ready to find your dream home? Get in touch today for a personalized consultation."}),e.jsx(Pi,{to:"/contact",className:"inline-block px-5 py-2.5 bg-white text-gray-900 text-sm font-semibold rounded-lg hover:bg-gray-100 transition-colors",children:"Contact Me"})]})]}),e.jsxs("div",{className:"mt-14 pt-6 border-t border-gray-800/50",children:[s.showTeamLogo&&s.teamLogoUrl&&e.jsx("div",{className:"flex items-center justify-center mb-6",children:e.jsx("img",{src:s.teamLogoUrl,alt:"Team",className:"h-12 w-auto object-contain"})}),s.brokerageLegalName&&e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-xs text-gray-500 mb-3",children:[e.jsxs("span",{children:[w," · ",s.brokerageLegalName]}),s.agentLicenseNumber&&e.jsx("span",{children:s.agentLicenseNumber}),s.brokerageLicenseNumber&&e.jsxs("span",{children:["Brokerage #",s.brokerageLicenseNumber]})]}),s.mlsDisclaimerText&&e.jsxs("div",{className:"flex items-start justify-center gap-3 mb-4",children:[s.mlsLogoUrl&&e.jsx("img",{src:s.mlsLogoUrl,alt:"MLS",className:"h-8 w-auto flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-gray-600 leading-relaxed max-w-3xl text-center",children:s.mlsDisclaimerText})]}),e.jsxs("div",{className:"flex items-center justify-center gap-4 text-xs text-gray-600",children:[s.equalHousingEnabled&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"h-5 w-5 text-gray-500",children:e.jsx("path",{d:"M12 2L2 8v2h20V8L12 2zm0 2.5L18.5 8h-13L12 4.5zM4 12v8h4v-6h8v6h4v-8H4zm6 8v-4h4v4h-4z"})}),e.jsx("span",{children:"Equal Housing Opportunity"})]}),e.jsxs("span",{children:["© ",new Date().getFullYear()," ",w,". Powered by LevelUp."]})]})]})]})}),!S&&((xe=s.agent)==null?void 0:xe.avatar_url)&&e.jsx(D3s,{agent:s.agent}),l&&e.jsx(jct,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1)})]})}function D3s({agent:t}){var a;const[s,r]=N.useState(!1),n=fr();return t?e.jsx("div",{className:"fixed bottom-6 right-6 z-40",children:s?e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl border border-gray-200 w-72 overflow-hidden animate-in slide-in-from-bottom-4 fade-in duration-200",children:[e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("img",{src:t.avatar_url,alt:t.full_name,className:"h-12 w-12 rounded-full object-cover ring-2 ring-gray-100"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-gray-900 text-sm",children:t.full_name}),e.jsx("p",{className:"text-xs text-gray-500",children:t.title||"Real Estate Professional"})]})]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"Have questions about a property or the area? I'm here to help!"}),e.jsxs("div",{className:"space-y-2",children:[t.phone&&e.jsxs("a",{href:`tel:${t.phone}`,className:"flex items-center gap-2 w-full px-3 py-2 bg-gray-50 hover:bg-gray-100 rounded-xl text-sm text-gray-700 transition-colors",children:[e.jsx(Un,{className:"h-4 w-4 text-gray-400"}),t.phone]}),t.email&&e.jsxs("a",{href:`mailto:${t.email}`,className:"flex items-center gap-2 w-full px-3 py-2 bg-gray-50 hover:bg-gray-100 rounded-xl text-sm text-gray-700 transition-colors",children:[e.jsx(cr,{className:"h-4 w-4 text-gray-400"}),"Email Me"]}),e.jsx("button",{onClick:()=>{r(!1),n("/contact")},className:"w-full px-3 py-2.5 bg-blue-600 hover:bg-blue-700 text-white text-sm font-semibold rounded-xl transition-colors",children:"Send a Message"})]})]}),e.jsx("button",{onClick:()=>r(!1),className:"absolute top-3 right-3 p-1 text-gray-400 hover:text-gray-600 rounded-full hover:bg-gray-100",children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("button",{onClick:()=>r(!0),className:"group flex items-center gap-3 bg-white pl-1.5 pr-5 py-1.5 rounded-full shadow-xl border border-gray-200 hover:shadow-2xl transition-all hover:scale-105",children:[e.jsx("img",{src:t.avatar_url,alt:t.full_name,className:"h-10 w-10 rounded-full object-cover ring-2 ring-blue-100"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-xs font-bold text-gray-900 leading-none",children:(a=t.full_name)==null?void 0:a.split(" ")[0]}),e.jsx("p",{className:"text-[10px] text-blue-600 font-medium mt-0.5",children:"Chat with me →"})]})]})}):null}const O3s={city:{icon:ma,label:"City"},zip:{icon:B_,label:"ZIP Code"},county:{icon:i1,label:"County"}};function Nct({suggestions:t,cities:s,value:r,onChange:n,onSelect:a,placeholder:o,className:l,inputClassName:i}){const[c,u]=N.useState(!1),p=N.useRef(null),f=t.length>0?t:(s||[]).map(w=>({label:w,type:"city"})),g=r.trim()?f.filter(w=>w.label.toLowerCase().includes(r.toLowerCase())).slice(0,10):f.slice(0,10),b=g.reduce((w,k)=>(w[k.type]||(w[k.type]=[]),w[k.type].push(k),w),{}),_=c&&g.length>0;N.useEffect(()=>{const w=k=>{p.current&&!p.current.contains(k.target)&&u(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);const j=["city","zip","county"];return e.jsxs("div",{ref:p,className:`relative ${l||""}`,children:[e.jsx("input",{type:"text",value:r,onChange:w=>{n(w.target.value),u(!0)},onFocus:()=>u(!0),placeholder:o,className:i,autoComplete:"off"}),_&&e.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden z-50 max-h-[360px] overflow-y-auto",children:j.map(w=>{const k=b[w];if(!k||k.length===0)return null;const S=O3s[w],M=S.icon;return e.jsxs("div",{children:[e.jsxs("div",{className:"px-4 pt-2.5 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400",children:[S.label,"s"]}),k.map(L=>e.jsxs("button",{type:"button",onMouseDown:I=>{I.preventDefault(),a(L.label),u(!1)},className:"w-full flex items-center gap-3 px-4 py-2.5 text-left text-sm text-gray-800 hover:bg-blue-50 transition-colors",children:[e.jsx(M,{className:"h-4 w-4 text-gray-400 shrink-0"}),e.jsx("span",{className:"font-medium",children:L.label})]},`${w}-${L.label}`))]},w)})})]})}function R3s({siteId:t,accentColor:s}){const r=fr(),{data:n}=mt({queryKey:["public-featured-areas",t],queryFn:async()=>{const{data:o,error:l}=await H.from("lead_site_featured_areas").select("*").eq("lead_site_id",t).eq("is_published",!0).order("sort_order",{ascending:!0});if(l)throw l;return o}});if(!(n!=null&&n.length))return null;const a=o=>{const l=new URLSearchParams;o.search_query&&l.set("q",o.search_query),o.search_county&&l.set("county",o.search_county),r(`/search?${l.toString()}`)};return e.jsx("section",{className:"py-20",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-gray-400 mb-2 font-medium",children:"Explore"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:"Featured Areas"})]}),e.jsx("div",{className:"space-y-8",children:n.map((o,l)=>e.jsxs(Hs.div,{initial:{opacity:0,y:30},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.6,delay:l*.1},onClick:()=>a(o),className:"group grid grid-cols-1 lg:grid-cols-2 gap-0 bg-white rounded-3xl overflow-hidden shadow-sm hover:shadow-2xl transition-all duration-500 cursor-pointer border border-gray-100",children:[e.jsxs("div",{className:"relative h-64 lg:h-80 overflow-hidden",children:[e.jsx("img",{src:o.image_url||"https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800&q=80",alt:o.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/30 to-transparent"}),o.badge_text&&e.jsx("span",{className:"absolute top-5 left-5 px-4 py-1.5 text-xs font-bold uppercase tracking-wider text-white rounded-full",style:{backgroundColor:s},children:o.badge_text})]}),e.jsxs("div",{className:"flex flex-col justify-center p-8 lg:p-12",children:[o.subtitle&&e.jsx("p",{className:"text-sm font-medium uppercase tracking-wider text-gray-400 mb-2",children:o.subtitle}),e.jsx("h3",{className:"text-2xl lg:text-3xl font-bold text-gray-900 mb-4 group-hover:text-gray-700 transition-colors",children:o.title}),o.description&&e.jsx("p",{className:"text-gray-600 leading-relaxed mb-6 line-clamp-3 lg:line-clamp-none",children:o.description}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:"inline-flex items-center gap-2 px-5 py-2.5 text-sm font-semibold text-white rounded-xl transition-all group-hover:opacity-90",style:{backgroundColor:s},children:[e.jsx(ma,{className:"h-4 w-4"}),"View Properties",e.jsx(Qa,{className:"h-4 w-4 group-hover:translate-x-1 transition-transform"})]})})]})]},o.id))})]})})}function Lye({siteConfig:t,accentColor:s,sectionTitle:r,cities:n,count:a=12,mode:o}){const l=fr(),[i,c]=N.useState([]),[u,p]=N.useState(!0),f=N.useRef(null),[g,b]=N.useState(!1),[_,j]=N.useState(!1);N.useEffect(()=>{(async()=>{var I;try{const O="https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-search",q={leadSiteId:t.id,pageSize:a};if(n){const B=n.split(",").map(V=>V.trim()).filter(Boolean);B.length>0&&(q.query=B[0],q.filterCities=B)}o==="open_houses"&&(q.openHousesOnly=!0),o==="my_listings"&&(q.agentListings=!0,q.agentId=t.agentId),o==="new_listings"&&(q.sortBy="newest");const U=await fetch(O,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify(q),signal:AbortSignal.timeout(15e3)});if(U.ok){const B=await U.json();c(((I=B.listings)==null?void 0:I.slice(0,a))||[])}}catch{}finally{p(!1)}})()},[t.id,n,a,o,t.agentId]);const w=()=>{const L=f.current;L&&(b(L.scrollLeft>10),j(L.scrollLeft{const L=f.current;if(L)return w(),L.addEventListener("scroll",w,{passive:!0}),window.addEventListener("resize",w),()=>{L.removeEventListener("scroll",w),window.removeEventListener("resize",w)}},[i]);const k=L=>{const I=f.current;if(!I)return;const O=340;I.scrollBy({left:L==="left"?-O*2:O*2,behavior:"smooth"})},S={new_listings:"New on the Market",open_houses:"Open Houses",my_listings:"My Active Listings"},M={new_listings:"The latest properties just listed",open_houses:"Tour these homes in person",my_listings:"Properties I'm currently representing"};return u?e.jsx("section",{className:"py-16 md:py-20 overflow-hidden",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("div",{className:"h-4 w-20 bg-gray-200 rounded mx-auto mb-3 animate-pulse"}),e.jsx("div",{className:"h-8 w-72 bg-gray-200 rounded mx-auto mb-2 animate-pulse"}),e.jsx("div",{className:"h-4 w-56 bg-gray-200 rounded mx-auto animate-pulse"})]}),e.jsx("div",{className:"flex gap-5",children:[1,2,3,4].map(L=>e.jsxs("div",{className:"min-w-[320px] rounded-2xl overflow-hidden bg-gray-100",children:[e.jsx("div",{className:"h-56 bg-gray-200 animate-pulse"}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsx("div",{className:"h-5 bg-gray-200 rounded w-24 animate-pulse"}),e.jsx("div",{className:"h-4 bg-gray-200 rounded w-40 animate-pulse"})]})]},L))})]})}):i.length?e.jsx("section",{className:"py-16 md:py-20 overflow-hidden",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6",children:[e.jsxs("div",{className:"flex items-end justify-between mb-10",children:[e.jsxs("div",{children:[e.jsx(Hs.p,{initial:{opacity:0,y:10},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-sm tracking-[0.2em] uppercase font-semibold mb-2",style:{color:s},children:o==="open_houses"?"Open Houses":o==="my_listings"?"My Listings":"Just Listed"}),e.jsx(Hs.h2,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:.05},className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:r||S[o]}),e.jsx(Hs.p,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},transition:{delay:.1},className:"text-gray-500 mt-1.5",children:M[o]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[e.jsx("button",{onClick:()=>k("left"),disabled:!g,className:"p-3 rounded-full border border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300 transition-all disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(cl,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>k("right"),disabled:!_,className:"p-3 rounded-full border border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300 transition-all disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(da,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative -mx-6",children:[e.jsxs("div",{ref:f,className:"flex gap-5 overflow-x-auto scrollbar-hide px-6 snap-x snap-mandatory",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[i.map((L,I)=>{var O,q,U,B;return e.jsx(Hs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.4,delay:I*.05},onClick:()=>l(`/listing/${L.mlsNumber}`),className:"group min-w-[300px] sm:min-w-[320px] max-w-[340px] flex-shrink-0 snap-start cursor-pointer",children:e.jsxs("div",{className:"bg-white rounded-2xl overflow-hidden shadow-[0_2px_20px_-4px_rgba(0,0,0,0.08)] hover:shadow-[0_8px_40px_-8px_rgba(0,0,0,0.15)] transition-all duration-500 h-full flex flex-col",children:[e.jsxs("div",{className:"relative h-56 overflow-hidden",children:[e.jsx("img",{src:((O=L.photos)==null?void 0:O[0])||"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=600&q=75",alt:L.address,className:"w-full h-full object-cover group-hover:scale-[1.06] transition-transform duration-700 ease-out"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/50 via-transparent to-transparent"}),e.jsx("div",{className:"absolute top-3 left-3 px-3 py-1 rounded-full text-[11px] font-bold tracking-wide uppercase text-white backdrop-blur-md",style:{backgroundColor:`${s}cc`},children:o==="open_houses"?"Open House":L.status||"Active"}),e.jsx("div",{className:"absolute bottom-3 left-3",children:e.jsxs("p",{className:"text-2xl font-bold text-white drop-shadow-lg",children:["$",(q=L.price)==null?void 0:q.toLocaleString()]})}),((U=L.photos)==null?void 0:U.length)>1&&e.jsxs("div",{className:"absolute bottom-3 right-3 px-2.5 py-1 bg-black/40 backdrop-blur-sm rounded-full text-[11px] text-white font-medium",children:[L.photos.length," photos"]})]}),e.jsxs("div",{className:"p-4 flex-1 flex flex-col",children:[e.jsx("p",{className:"text-gray-900 font-semibold text-[15px] leading-snug mb-1 truncate",children:L.address}),e.jsxs("p",{className:"text-gray-500 text-sm mb-3 truncate",children:[L.city,", ",L.state," ",L.zip]}),e.jsxs("div",{className:"flex items-center gap-4 mt-auto pt-3 border-t border-gray-100",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(Im,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:L.bedrooms})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(Ju,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:L.bathrooms})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(oS,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"text-sm font-medium",children:[(B=L.sqft)==null?void 0:B.toLocaleString()," sqft"]})]})]})]})]})},L.mlsNumber)}),e.jsx(Hs.div,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},onClick:()=>l("/search"),className:"min-w-[200px] flex-shrink-0 snap-start cursor-pointer flex items-center justify-center",children:e.jsxs("div",{className:"text-center group",children:[e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center mx-auto mb-3 transition-transform group-hover:scale-110",style:{backgroundColor:`${s}15`},children:e.jsx(Qa,{className:"h-6 w-6",style:{color:s}})}),e.jsx("p",{className:"text-sm font-semibold text-gray-700 group-hover:text-gray-900 transition-colors",children:"View All"})]})})]}),e.jsx("div",{className:"absolute right-0 top-0 bottom-0 w-12 bg-gradient-to-l from-white to-transparent pointer-events-none md:hidden"})]})]})}):null}function F3s({siteId:t,accentColor:s,sectionTitle:r}){const n=fr(),[a,o]=N.useState([]),[l,i]=N.useState(!0);if(N.useEffect(()=>{(async()=>{const{data:p}=await H.from("lead_site_city_pages").select("city_name, city_slug, description, hero_image_url").eq("site_id",t).eq("is_published",!0).order("sort_order",{ascending:!0});o(p||[]),i(!1)})()},[t]),l)return e.jsx("section",{className:"py-16 md:py-20",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("div",{className:"h-4 w-20 bg-gray-200 rounded mx-auto mb-3 animate-pulse"}),e.jsx("div",{className:"h-8 w-64 bg-gray-200 rounded mx-auto animate-pulse"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5",children:[1,2,3].map(u=>e.jsx("div",{className:"h-48 bg-gray-100 rounded-2xl animate-pulse"},u))})]})});if(!a.length)return null;const c=["https://images.unsplash.com/photo-1449824913935-59a10b8d2000?w=600&q=75","https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?w=600&q=75","https://images.unsplash.com/photo-1444723121867-7a241cacace9?w=600&q=75","https://images.unsplash.com/photo-1480714378408-67cf0d13bc1b?w=600&q=75","https://images.unsplash.com/photo-1514565131-fce0801e5785?w=600&q=75","https://images.unsplash.com/photo-1519999482648-25049ddd37b1?w=600&q=75"];return e.jsx("section",{className:"py-16 md:py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsxs(Hs.div,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.2em] uppercase font-semibold mb-3",style:{color:s},children:"Explore Areas"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:r||"Browse by City"}),e.jsx("p",{className:"text-gray-500 mt-2 max-w-xl mx-auto",children:"Discover homes in the communities we serve"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5",children:a.map((u,p)=>e.jsxs(Hs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:p*.06},onClick:()=>n(`/homes-for-sale-in-${u.city_slug}`),className:"group relative h-52 rounded-2xl overflow-hidden cursor-pointer shadow-sm hover:shadow-xl transition-all duration-500",children:[e.jsx("img",{src:u.hero_image_url||c[p%c.length],alt:`Homes in ${u.city_name}`,className:"absolute inset-0 w-full h-full object-cover group-hover:scale-110 transition-transform duration-700 ease-out",loading:"lazy"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-5 flex items-end justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-white font-bold text-xl tracking-tight mb-1",children:u.city_name}),u.description&&e.jsxs("p",{className:"text-white/70 text-sm line-clamp-1 max-w-[240px]",children:[u.description.split(` `)[0].slice(0,80),"..."]})]}),e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center bg-white/20 backdrop-blur-sm group-hover:bg-white/30 transition-colors flex-shrink-0",children:e.jsx(Qa,{className:"h-5 w-5 text-white"})})]})]},u.city_slug))})]})})}function z3s({siteConfig:t,themeConfig:s}){var p;const r=fr(),[n,a]=N.useState(""),o=((p=t.agent)==null?void 0:p.full_name)||"Your Agent",l=(s==null?void 0:s.homepageModules)??_ct,i=(s==null?void 0:s.brandColor)||"#0f172a",c=(s==null?void 0:s.accentColor)||"#3b82f6",u=f=>{f.preventDefault(),n.trim()&&r(`/search?q=${encodeURIComponent(n.trim())}`)};return e.jsx("div",{children:l.map((f,g)=>{if(!f.enabled)return null;const b=f.config||{};switch(f.type){case"hero":return e.jsx($3s,{agentName:o,tagline:b.headline||t.siteTagline,subtitle:b.subtitle,heroImageUrl:s==null?void 0:s.heroImageUrl,brandColor:i,accentColor:c,searchQuery:n,setSearchQuery:a,onSearch:u,searchPlaceholder:b.searchPlaceholder,themeConfig:s},g);case"featured_listings":return e.jsx(q3s,{siteConfig:t,accentColor:c,sectionTitle:b.sectionTitle,count:b.count},g);case"featured_areas":return e.jsx(R3s,{siteId:t.id,accentColor:c},g);case"about":return e.jsx(U3s,{siteConfig:t,accentColor:c,config:b},g);case"testimonials":return e.jsx(V3s,{testimonials:b.testimonials||(s==null?void 0:s.testimonials)||[],brandColor:i,sectionTitle:b.sectionTitle},g);case"cta_banner":return e.jsx(H3s,{agentName:o,accentColor:c,brandColor:i,config:b},g);case"new_listings":return e.jsx(Lye,{siteConfig:t,accentColor:c,mode:"new_listings",sectionTitle:b.sectionTitle,cities:b.cities,count:b.count},g);case"open_houses":return e.jsx(Lye,{siteConfig:t,accentColor:c,mode:"open_houses",sectionTitle:b.sectionTitle,cities:b.cities,count:b.count},g);case"my_listings":return e.jsx(Lye,{siteConfig:t,accentColor:c,mode:"my_listings",sectionTitle:b.sectionTitle,count:b.count},g);case"city_pages":return e.jsx(F3s,{siteId:t.id,accentColor:c,sectionTitle:b.sectionTitle},g);default:return null}})})}function B3s(t){if(!t)return[];const s=[];return(t.searchCities||[]).forEach(r=>s.push({label:r,type:"city"})),(t.searchZipCodes||[]).forEach(r=>s.push({label:r,type:"zip"})),(t.searchCounties||[]).forEach(r=>s.push({label:r,type:"county"})),s}function $3s({agentName:t,tagline:s,subtitle:r,heroImageUrl:n,brandColor:a,accentColor:o,searchQuery:l,setSearchQuery:i,onSearch:c,searchPlaceholder:u,themeConfig:p}){const f=fr(),g=n||"https://images.unsplash.com/photo-1600596542815-ffad4c1539a9?w=1920&q=80";return e.jsxs("section",{className:"relative min-h-[85vh] flex items-center justify-center overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("img",{src:g,alt:"",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/60 via-black/40 to-black/70"})]}),e.jsxs("div",{className:"relative z-10 max-w-4xl mx-auto px-6 text-center",children:[e.jsx(Hs.p,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6},className:"text-white/70 text-sm tracking-[0.3em] uppercase mb-4 font-medium",children:"Welcome"}),e.jsx(Hs.h1,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.7,delay:.1},className:"text-4xl sm:text-5xl md:text-6xl lg:text-7xl font-bold text-white leading-[1.1] tracking-tight mb-6",children:s||`Find Your Perfect Home with ${t}`}),e.jsx(Hs.p,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6,delay:.2},className:"text-white/70 text-lg md:text-xl max-w-2xl mx-auto mb-10",children:r||"Expert guidance. Local knowledge. Personalized service."}),e.jsx(Hs.form,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6,delay:.35},onSubmit:c,className:"max-w-2xl mx-auto",children:e.jsxs("div",{className:"flex bg-white/10 backdrop-blur-md border border-white/20 rounded-2xl p-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-white/50 z-10"}),(()=>{const b=B3s(p);return b.length>0?e.jsx(Nct,{suggestions:b,value:l,onChange:i,onSelect:_=>{i(_),f(`/search?q=${encodeURIComponent(_)}`)},placeholder:u||"Search by city, zip, county, or address...",className:"flex-1",inputClassName:"w-full pl-12 pr-4 py-4 bg-transparent text-white placeholder:text-white/40 focus:outline-none text-lg"}):e.jsx("input",{type:"text",value:l,onChange:_=>i(_.target.value),placeholder:u||"Search by city, zip, county, or address...",className:"w-full pl-12 pr-4 py-4 bg-transparent text-white placeholder:text-white/40 focus:outline-none text-lg"})})()]}),e.jsx("button",{type:"submit",className:"px-8 py-4 rounded-xl font-semibold text-white transition-all hover:opacity-90",style:{backgroundColor:o},children:"Search"})]})}),e.jsx(Hs.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.6,delay:.5},className:"flex flex-wrap gap-3 justify-center mt-8",children:["Browse All Listings","Get In Touch"].map((b,_)=>e.jsx("button",{onClick:()=>f(_===0?"/search":"/contact"),className:"px-5 py-2.5 text-sm text-white/80 border border-white/20 rounded-full hover:bg-white/10 hover:text-white transition-all",children:b},b))})]})]})}function q3s({siteConfig:t,accentColor:s,sectionTitle:r,count:n}){const a=fr(),[o,l]=N.useState([]),[i,c]=N.useState(!0);return N.useEffect(()=>{(async()=>{var p;try{const g=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-search",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({siteId:t.id,params:{pageSize:n||6,page:1}})});if(g.ok){const b=await g.json();l(((p=b.listings)==null?void 0:p.slice(0,6))||[])}}catch{}finally{c(!1)}})()},[t.id]),i?e.jsx("section",{className:"py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("div",{className:"h-8 bg-gray-200 rounded w-64 mx-auto mb-3 animate-pulse"}),e.jsx("div",{className:"h-4 bg-gray-200 rounded w-96 mx-auto animate-pulse"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[1,2,3].map(u=>e.jsxs("div",{className:"bg-white rounded-2xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"h-64 bg-gray-200 animate-pulse"}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsx("div",{className:"h-5 bg-gray-200 rounded w-24 animate-pulse"}),e.jsx("div",{className:"h-4 bg-gray-200 rounded w-48 animate-pulse"})]})]},u))})]})}):o.length?e.jsx("section",{className:"py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-gray-400 mb-2 font-medium",children:"Properties"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:r||"Featured Listings"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:o.map(u=>{var p,f,g;return e.jsxs(Hs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5},onClick:()=>a(`/listing/${u.mlsNumber}`),className:"group bg-white rounded-2xl overflow-hidden shadow-sm hover:shadow-xl transition-all duration-300 cursor-pointer",children:[e.jsxs("div",{className:"relative h-64 overflow-hidden",children:[e.jsx("img",{src:((p=u.photos)==null?void 0:p[0])||"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=600&q=75",alt:u.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}),e.jsx("div",{className:"absolute top-3 left-3 px-3 py-1 bg-white/90 backdrop-blur rounded-full text-xs font-semibold text-gray-900",children:u.status})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("p",{className:"text-2xl font-bold text-gray-900 mb-1",children:["$",(f=u.price)==null?void 0:f.toLocaleString()]}),e.jsxs("p",{className:"text-gray-500 text-sm mb-3 truncate",children:[u.address,", ",u.city]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-400",children:[e.jsxs("span",{children:[u.bedrooms," Beds"]}),e.jsx("span",{className:"w-1 h-1 bg-gray-300 rounded-full"}),e.jsxs("span",{children:[u.bathrooms," Baths"]}),e.jsx("span",{className:"w-1 h-1 bg-gray-300 rounded-full"}),e.jsxs("span",{children:[(g=u.sqft)==null?void 0:g.toLocaleString()," Sqft"]})]})]})]},u.mlsNumber)})}),e.jsx("div",{className:"text-center mt-10",children:e.jsxs("button",{onClick:()=>a("/search"),className:"inline-flex items-center gap-2 px-6 py-3 text-sm font-semibold rounded-full border border-gray-300 text-gray-700 hover:bg-gray-100 transition-colors",children:["View All Properties ",e.jsx(Qa,{className:"h-4 w-4"})]})})]})}):null}function U3s({siteConfig:t,accentColor:s,config:r}){const n=fr(),a=t.agent;return a?e.jsx("section",{className:"py-20",children:e.jsx("div",{className:"max-w-7xl mx-auto px-6",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-16 items-center",children:[a.avatar_url&&e.jsx(Hs.div,{initial:{opacity:0,x:-30},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.6},children:e.jsx("img",{src:a.avatar_url,alt:a.full_name,className:"w-full max-w-md mx-auto rounded-3xl object-cover shadow-2xl aspect-[3/4]"})}),e.jsxs(Hs.div,{initial:{opacity:0,x:30},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.6},children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-gray-400 mb-3 font-medium",children:(r==null?void 0:r.sectionTitle)||"About"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight mb-2",children:(r==null?void 0:r.headline)||a.full_name}),e.jsx("p",{className:"text-gray-400 font-medium mb-6",children:(r==null?void 0:r.customTitle)||a.title||"Real Estate Professional"}),e.jsx("p",{className:"text-gray-600 leading-relaxed text-lg mb-8",children:(()=>{const o=(r==null?void 0:r.customBio)||a.bio;return o?o.substring(0,400)+(o.length>400?"...":""):"Dedicated to providing exceptional real estate service with deep local market expertise."})()}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{onClick:()=>n("/contact"),className:"px-6 py-3 text-white font-semibold rounded-xl transition-all hover:opacity-90",style:{backgroundColor:s},children:"Get In Touch"}),e.jsx("button",{onClick:()=>n("/about"),className:"px-6 py-3 border border-gray-300 text-gray-700 font-semibold rounded-xl hover:bg-gray-50 transition-colors",children:"Read More"})]})]})]})})}):null}function V3s({testimonials:t,brandColor:s,sectionTitle:r}){const[n,a]=N.useState(0),o=t.length?t:[{name:"Happy Client",quote:"An amazing experience from start to finish. Truly a trusted advisor who goes above and beyond.",role:"Buyer"},{name:"Satisfied Seller",quote:"Professional, knowledgeable, and always available. Made the selling process smooth and stress-free.",role:"Seller"},{name:"First-Time Buyer",quote:"Guided us through every step with patience and expertise. Could not have asked for a better agent.",role:"Buyer"}];return o.length?e.jsx("section",{className:"py-20 text-white",style:{backgroundColor:s},children:e.jsxs("div",{className:"max-w-4xl mx-auto px-6 text-center",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-white/50 mb-3 font-medium",children:"Testimonials"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold tracking-tight mb-12",children:r||"What Clients Say"}),e.jsxs("div",{className:"relative",children:[e.jsx(V_,{className:"h-10 w-10 text-white/20 mx-auto mb-6"}),e.jsxs(Hs.blockquote,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-xl md:text-2xl font-light leading-relaxed text-white/90 mb-8 italic",children:['"',o[n].quote,'"']},n),e.jsx("p",{className:"font-semibold text-lg",children:o[n].name}),o[n].role&&e.jsx("p",{className:"text-white/50 text-sm mt-1",children:o[n].role})]}),o.length>1&&e.jsxs("div",{className:"flex items-center justify-center gap-4 mt-10",children:[e.jsx("button",{onClick:()=>a((n-1+o.length)%o.length),className:"p-2 rounded-full border border-white/20 hover:bg-white/10 transition-colors",children:e.jsx(cl,{className:"h-5 w-5"})}),e.jsx("div",{className:"flex gap-2",children:o.map((l,i)=>e.jsx("button",{onClick:()=>a(i),className:`w-2 h-2 rounded-full transition-all ${i===n?"bg-white w-6":"bg-white/30"}`},i))}),e.jsx("button",{onClick:()=>a((n+1)%o.length),className:"p-2 rounded-full border border-white/20 hover:bg-white/10 transition-colors",children:e.jsx(da,{className:"h-5 w-5"})})]})]})}):null}function H3s({agentName:t,accentColor:s,brandColor:r,config:n}){const a=fr();return e.jsx("section",{className:"py-20",children:e.jsx("div",{className:"max-w-5xl mx-auto px-6",children:e.jsxs("div",{className:"rounded-3xl p-12 md:p-16 text-white text-center",style:{backgroundColor:r},children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold tracking-tight mb-4",children:(n==null?void 0:n.headline)||"Ready to Make Your Move?"}),e.jsx("p",{className:"text-white/70 text-lg max-w-2xl mx-auto mb-8",children:(n==null?void 0:n.subtitle)||"Whether you're buying, selling, or just exploring — let's connect and find the right path for you."}),e.jsxs("div",{className:"flex flex-wrap gap-4 justify-center",children:[e.jsx("button",{onClick:()=>a("/search"),className:"px-8 py-4 text-white font-semibold rounded-xl transition-all hover:opacity-90",style:{backgroundColor:s},children:(n==null?void 0:n.primaryButtonText)||"Browse Listings"}),e.jsx("button",{onClick:()=>a("/contact"),className:"px-8 py-4 bg-white/10 border border-white/25 font-semibold rounded-xl hover:bg-white/20 transition-colors",children:(n==null?void 0:n.secondaryButtonText)||`Contact ${t}`})]})]})})})}const W3s=t=>t>=1e6?`$${(t/1e6).toFixed(1)}M`:t>=1e3?`$${Math.round(t/1e3)}K`:`$${t}`,n9=t=>{if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"){const s=Number.parseFloat(t);return Number.isFinite(s)?s:null}return null},G3s=t=>[t.address,t.city,t.state,t.zip].filter(Boolean).join(", ");function kct({listings:t,onListingClick:s,hoveredMlsNumber:r}){const n=N.useRef(null),a=N.useRef(null),o=N.useRef(new Map),l=N.useRef(null),i=N.useRef(new Map),[c,u]=N.useState(null),[p,f]=N.useState({});N.useEffect(()=>{(async()=>{const{data:j}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();j!=null&&j.value&&u(j.value)})()},[]),N.useEffect(()=>{if(!(!n.current||!c||a.current))return Ao.accessToken=c,a.current=new Ao.Map({container:n.current,style:"mapbox://styles/mapbox/streets-v12",zoom:4,center:[-98.5795,39.8283]}),a.current.addControl(new Ao.NavigationControl,"top-right"),()=>{var _;(_=a.current)==null||_.remove(),a.current=null}},[c]);const g=N.useMemo(()=>t.map(_=>{var k,S;const j=n9(_.latitude)??((k=p[_.mlsNumber])==null?void 0:k.lat)??null,w=n9(_.longitude)??((S=p[_.mlsNumber])==null?void 0:S.lng)??null;return j===null||w===null?null:{listing:_,latitude:j,longitude:w}}).filter(_=>_!==null),[t,p]);N.useEffect(()=>{if(!c||t.length===0)return;const _=t.filter(k=>!(n9(k.latitude)!==null&&n9(k.longitude)!==null)&&!i.current.has(k.mlsNumber));if(_.length===0)return;let j=!1;return(async()=>{const k=await Promise.all(_.map(async M=>{var I,O;const L=G3s(M);if(!L)return{mlsNumber:M.mlsNumber,coords:null};try{const q=await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(L)}.json?access_token=${encodeURIComponent(c)}&limit=1&country=US&types=address,place,postcode`);if(!q.ok)return{mlsNumber:M.mlsNumber,coords:null};const U=await q.json(),[B,V]=((O=(I=U==null?void 0:U.features)==null?void 0:I[0])==null?void 0:O.center)??[];return!Number.isFinite(V)||!Number.isFinite(B)?{mlsNumber:M.mlsNumber,coords:null}:{mlsNumber:M.mlsNumber,coords:{lat:V,lng:B}}}catch{return{mlsNumber:M.mlsNumber,coords:null}}}));if(j)return;const S={};k.forEach(({mlsNumber:M,coords:L})=>{i.current.set(M,L),L&&(S[M]=L)}),Object.keys(S).length>0&&f(M=>({...M,...S}))})(),()=>{j=!0}},[t,c]);const b=N.useCallback(_=>{var k;const j=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_.price),w=(k=_.photos)!=null&&k[0]?``:`
`;return`
${w}
${j}
${_.address}
${_.bedrooms} bd ${_.bathrooms} ba ${_.sqft>0?`${_.sqft.toLocaleString()} sqft`:""}
`},[]);return N.useEffect(()=>{if(!a.current||!c||(o.current.forEach(j=>j.remove()),o.current.clear(),g.length===0))return;const _=new Ao.LngLatBounds;g.forEach(({listing:j,latitude:w,longitude:k})=>{const S=document.createElement("div");S.style.cssText="cursor: pointer;";const M=document.createElement("div");M.className="lead-site-map-pill",M.setAttribute("data-mls",j.mlsNumber),M.innerHTML=`${W3s(j.price)}`,M.style.cssText=` background: white; border: 2px solid #2563eb; border-radius: 20px; padding: 2px 8px; font-size: 12px; font-weight: 700; color: #1e3a5f; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.15); white-space: nowrap; transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease; font-family: system-ui, -apple-system, sans-serif; pointer-events: auto; `,M.addEventListener("mouseenter",()=>{M.style.background="#2563eb",M.style.color="white",M.style.transform="scale(1.1)"}),M.addEventListener("mouseleave",()=>{r!==j.mlsNumber&&(M.style.background="white",M.style.color="#1e3a5f",M.style.transform="scale(1)")}),S.appendChild(M);const L=new Ao.Marker({element:S,anchor:"bottom"}).setLngLat([k,w]).addTo(a.current);S.addEventListener("click",I=>{var q;I.stopPropagation(),(q=l.current)==null||q.remove();const O=new Ao.Popup({offset:25,closeButton:!0,maxWidth:"240px",className:"lead-site-map-popup"}).setLngLat([k,w]).setHTML(b(j)).addTo(a.current);setTimeout(()=>{const U=O.getElement(),B=U==null?void 0:U.querySelector("[data-mls]");B&&(B.addEventListener("click",()=>{s(j.mlsNumber)}),B.style.cursor="pointer")},50),l.current=O}),o.current.set(j.mlsNumber,L),_.extend([k,w])});try{_.isEmpty()||a.current.fitBounds(_,{padding:60,maxZoom:14})}catch{}},[g,c,b,s]),N.useEffect(()=>{o.current.forEach((_,j)=>{const w=_.getElement().querySelector(".lead-site-map-pill");w&&(j===r?(w.style.background="#2563eb",w.style.color="white",w.style.transform="scale(1.15)",w.style.zIndex="10"):(w.style.background="white",w.style.color="#1e3a5f",w.style.transform="scale(1)",w.style.zIndex="1"))})},[r]),c?e.jsx("div",{ref:n,className:"w-full h-full"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-100 text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(K3s,{className:"h-10 w-10 mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Map not configured"})]})})}function K3s({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"}),e.jsx("circle",{cx:"12",cy:"10",r:"3"})]})}const Z3s=50;function Y3s({siteConfig:t}){var ue;const s=t.themeConfig||{},r=[...(s.searchCities||[]).map(pe=>({label:pe,type:"city"})),...(s.searchZipCodes||[]).map(pe=>({label:pe,type:"zip"})),...(s.searchCounties||[]).map(pe=>({label:pe,type:"county"}))],n=fr(),[a,o]=Cc(),[l,i]=N.useState(!1),[c,u]=N.useState("list"),[p,f]=N.useState(null),g=a.get("q")||"",b=a.get("county")||"",_=a.get("minPrice")||"",j=a.get("maxPrice")||"",w=a.get("beds")||"",k=a.get("baths")||"",S=a.get("propertyType")||"",M=a.get("minSqft")||"",L=a.get("maxSqft")||"",[I,O]=N.useState(g),[q,U]=N.useState(!0),{data:B,isLoading:V,fetchNextPage:Z,hasNextPage:X,isFetchingNextPage:ee}=oUe({queryKey:["lead-site-search",t.id,g,b,_,j,w,k,S,M,L,q],queryFn:async({pageParam:pe=1})=>{const{data:be,error:Me}=await H.functions.invoke("lead-site-search",{body:{leadSiteId:t.id,query:g||void 0,county:b||void 0,minPrice:_?parseInt(_):void 0,maxPrice:j?parseInt(j):void 0,minBeds:w?parseInt(w):void 0,minBaths:k?parseInt(k):void 0,propertyType:S||void 0,minSqft:M?parseInt(M):void 0,maxSqft:L?parseInt(L):void 0,limit:Z3s,page:pe}});if(Me)throw Me;return be},getNextPageParam:(pe,be)=>{if(be.reduce((Ne,Pe)=>Ne+Pe.listings.length,0)pe.listings))??[],ie=((ue=B==null?void 0:B.pages[0])==null?void 0:ue.total)??0,re=N.useCallback(pe=>{pe.preventDefault();const be=new URLSearchParams;I&&be.set("q",I),b&&be.set("county",b),_&&be.set("minPrice",_),j&&be.set("maxPrice",j),w&&be.set("beds",w),k&&be.set("baths",k),S&&be.set("propertyType",S),M&&be.set("minSqft",M),L&&be.set("maxSqft",L),o(be),U(!0)},[I,b,_,j,w,k,S,M,L,o]),oe=N.useCallback((pe,be)=>{const Me=new URLSearchParams(a);be?Me.set(pe,be):Me.delete(pe),o(Me),U(!0)},[a,o]),ce=pe=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(pe),xe=N.useCallback(pe=>{n(`/listing/${pe}`)},[n]),ge=Q.length>0;return e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsx("div",{className:"bg-white border-b border-gray-200 z-40 shrink-0",children:e.jsxs("div",{className:"px-4 sm:px-6 py-3",children:[e.jsxs("form",{onSubmit:re,className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 z-10"}),r.length>0?e.jsx(Nct,{suggestions:r,value:I,onChange:O,onSelect:pe=>{O(pe);const be=new URLSearchParams(a);be.set("q",pe),o(be),U(!0)},placeholder:"City, zip, county, or address...",inputClassName:"w-full pl-10 pr-4 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"}):e.jsx("input",{type:"text",value:I,onChange:pe=>O(pe.target.value),placeholder:"City, zip, county, or address...",className:"w-full pl-10 pr-4 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),e.jsx("button",{type:"submit",className:"px-5 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 transition-colors",children:"Search"}),e.jsx("button",{type:"button",onClick:()=>i(!l),className:`px-3 py-2.5 border rounded-lg text-sm transition-colors ${l?"bg-blue-50 border-blue-300 text-blue-700":"border-gray-300 text-gray-600 hover:bg-gray-50"}`,children:e.jsx(H_,{className:"h-4 w-4"})})]}),l&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-3 pb-1",children:[e.jsx("input",{value:b,onChange:pe=>oe("county",pe.target.value),placeholder:"County",className:"px-3 py-2 border border-gray-300 rounded-lg text-sm min-w-[140px]"}),e.jsxs("select",{value:w,onChange:pe=>oe("beds",pe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"Beds"}),e.jsx("option",{value:"1",children:"1+"}),e.jsx("option",{value:"2",children:"2+"}),e.jsx("option",{value:"3",children:"3+"}),e.jsx("option",{value:"4",children:"4+"}),e.jsx("option",{value:"5",children:"5+"})]}),e.jsxs("select",{value:k,onChange:pe=>oe("baths",pe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"Baths"}),e.jsx("option",{value:"1",children:"1+"}),e.jsx("option",{value:"2",children:"2+"}),e.jsx("option",{value:"3",children:"3+"}),e.jsx("option",{value:"4",children:"4+"})]}),e.jsxs("select",{value:S,onChange:pe=>oe("propertyType",pe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm min-w-[160px]",children:[e.jsx("option",{value:"",children:"Property Type"}),e.jsx("option",{value:"Residential",children:"Residential"}),e.jsx("option",{value:"Condo",children:"Condo"}),e.jsx("option",{value:"Townhouse",children:"Townhouse"}),e.jsx("option",{value:"Multi",children:"Multi-Family"}),e.jsx("option",{value:"Land",children:"Land"}),e.jsx("option",{value:"Farm",children:"Farm"}),e.jsx("option",{value:"Commercial",children:"Commercial"})]}),e.jsxs("select",{value:_,onChange:pe=>oe("minPrice",pe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"Min Price"}),e.jsx("option",{value:"100000",children:"$100k"}),e.jsx("option",{value:"200000",children:"$200k"}),e.jsx("option",{value:"300000",children:"$300k"}),e.jsx("option",{value:"500000",children:"$500k"}),e.jsx("option",{value:"750000",children:"$750k"}),e.jsx("option",{value:"1000000",children:"$1M"})]}),e.jsxs("select",{value:j,onChange:pe=>oe("maxPrice",pe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"Max Price"}),e.jsx("option",{value:"200000",children:"$200k"}),e.jsx("option",{value:"300000",children:"$300k"}),e.jsx("option",{value:"500000",children:"$500k"}),e.jsx("option",{value:"750000",children:"$750k"}),e.jsx("option",{value:"1000000",children:"$1M"}),e.jsx("option",{value:"2000000",children:"$2M"})]}),e.jsx("input",{type:"number",value:M,onChange:pe=>oe("minSqft",pe.target.value),placeholder:"Min sqft",className:"px-3 py-2 border border-gray-300 rounded-lg text-sm w-[120px]"}),e.jsx("input",{type:"number",value:L,onChange:pe=>oe("maxSqft",pe.target.value),placeholder:"Max sqft",className:"px-3 py-2 border border-gray-300 rounded-lg text-sm w-[120px]"})]}),ge&&e.jsxs("div",{className:"flex lg:hidden mt-2 gap-1",children:[e.jsxs("button",{onClick:()=>u("list"),className:`flex-1 flex items-center justify-center gap-1.5 py-2 text-xs font-medium rounded-lg transition-colors ${c==="list"?"bg-blue-600 text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Mh,{className:"h-3.5 w-3.5"})," List"]}),e.jsxs("button",{onClick:()=>u("map"),className:`flex-1 flex items-center justify-center gap-1.5 py-2 text-xs font-medium rounded-lg transition-colors ${c==="map"?"bg-blue-600 text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(i1,{className:"h-3.5 w-3.5"})," Map"]})]})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:q?V?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-blue-600 border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500",children:"Searching listings..."})]})}):ge?e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:` w-full lg:w-[65%] overflow-y-auto border-r border-gray-200 bg-gray-50 shrink-0 ${c==="map"?"hidden lg:block":"block"} `,children:[e.jsxs("div",{className:"px-4 py-3 border-b border-gray-200 bg-white flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-gray-700 font-semibold",children:[g?`${g} Real Estate`:"All Listings"," · ",ie," listing",ie!==1?"s":""," found"]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Showing ",Q.length," of ",ie]})]}),e.jsx("div",{className:"p-3 grid grid-cols-1 sm:grid-cols-2 gap-3",children:Q.map(pe=>{var be;return e.jsxs("button",{onClick:()=>n(`/listing/${pe.mlsNumber}`),onMouseEnter:()=>f(pe.mlsNumber),onMouseLeave:()=>f(null),className:`w-full bg-white rounded-xl border overflow-hidden hover:shadow-lg transition-all text-left group flex flex-col ${p===pe.mlsNumber?"border-blue-400 shadow-lg ring-1 ring-blue-200":"border-gray-200"}`,children:[e.jsxs("div",{className:"relative w-full aspect-[4/3] bg-gray-200 overflow-hidden",children:[(be=pe.photos)!=null&&be[0]?e.jsx("img",{src:pe.photos[0],alt:pe.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",onError:Me=>{const Ne=Me.target;Ne.style.display="none"}}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-400",children:e.jsx(ma,{className:"h-8 w-8"})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("span",{className:"px-2 py-0.5 bg-white/90 backdrop-blur text-[11px] font-semibold rounded text-gray-700",children:pe.status})}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-3",children:[e.jsx("p",{className:"text-xl font-bold text-white drop-shadow-md",children:ce(pe.price)}),e.jsxs("p",{className:"text-xs text-white/90 mt-0.5 truncate drop-shadow-sm",children:[pe.address,", ",pe.city,", ",pe.state]})]})]}),e.jsxs("div",{className:"px-3 py-2.5 flex items-center gap-4 text-xs text-gray-600 border-t border-gray-100",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Im,{className:"h-3.5 w-3.5"})," ",pe.bedrooms," bd"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ju,{className:"h-3.5 w-3.5"})," ",pe.bathrooms," ba"]}),pe.sqft>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(x0,{className:"h-3.5 w-3.5"})," ",pe.sqft.toLocaleString()," sqft"]})]})]},pe.mlsNumber)})}),X&&e.jsx("div",{className:"flex justify-center py-6",children:e.jsx("button",{onClick:()=>Z(),disabled:ee,className:"px-6 py-3 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50 flex items-center gap-2",children:ee?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Loading more..."]}):`Load More Listings (${Q.length} of ${ie})`})})]}),e.jsx("div",{className:` lg:w-[35%] min-w-0 ${c==="list"?"hidden lg:block":"block w-full"} `,children:e.jsx(kct,{listings:Q,onListingClick:xe,hoveredMlsNumber:p})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Rr,{className:"h-12 w-12 text-gray-300 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-semibold text-gray-700 mb-2",children:"No Results"}),e.jsx("p",{className:"text-gray-500",children:"Try a different search term or adjust your filters."})]})}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(cn,{className:"h-12 w-12 text-gray-300 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-semibold text-gray-700 mb-2",children:"Search for Properties"}),e.jsx("p",{className:"text-gray-500",children:"Enter a city, zip code, county, or address — or click Search to browse all listings."})]})})})]})}const Dye="ls_visitor_";function X3s(t,s){const[r,n]=N.useState(0),[a,o]=N.useState(!1),[l,i]=N.useState(!1),c=t==null?void 0:t.id,u=(t==null?void 0:t.leadRegistrationMode)??"disabled",p=(t==null?void 0:t.registrationTriggerCount)??1;N.useEffect(()=>{if(!c)return;const j=parseInt(localStorage.getItem(`${Dye}views_${c}`)||"0",10);n(j)},[c]);const f=N.useCallback((j,w,k)=>{if(!c||u==="disabled")return;const S=r+1;n(S),localStorage.setItem(`${Dye}views_${c}`,String(S)),H.from("lead_site_property_views").insert({lead_site_id:c,mls_number:j,auth_user_id:w||null,visitor_fingerprint:localStorage.getItem(`${Dye}fp_${c}`)||null,property_address:(k==null?void 0:k.propertyAddress)||null,photo_url:(k==null?void 0:k.photoUrl)||null}).then(),!s&&!l&&S>=p&&o(!0)},[c,u,r,s,l,p]);N.useEffect(()=>{s&&a&&o(!1)},[s,a]);const g=N.useCallback(()=>{o(!1),i(!0)},[]),b=N.useCallback(()=>{o(!1)},[]),_=u==="required"&&!s&&r>=p;return{viewCount:r,showRegistration:a,isGated:_,mode:u,recordView:f,dismissRegistration:g,completeRegistration:b,setShowRegistration:o}}function Q3s({photos:t}){const[s,r]=N.useState(!1),[n,a]=N.useState(0);if(!t||t.length===0)return null;const o=c=>{a(c),r(!0)},l=()=>a(c=>(c+1)%t.length),i=()=>a(c=>(c-1+t.length)%t.length);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative group",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-1.5 rounded-xl overflow-hidden",children:[e.jsx("div",{className:"md:col-span-2 md:row-span-2 aspect-[4/3] cursor-pointer relative overflow-hidden",onClick:()=>o(0),children:e.jsx("img",{src:t[0],alt:"",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})}),t.slice(1,5).map((c,u)=>e.jsxs("div",{className:"aspect-[4/3] cursor-pointer relative overflow-hidden hidden md:block",onClick:()=>o(u+1),children:[e.jsx("img",{src:c,alt:"",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),u===3&&t.length>5&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsxs("span",{className:"text-white text-lg font-semibold",children:["+",t.length-5," more"]})})]},u))]}),t.length>1&&e.jsxs("button",{onClick:()=>o(0),className:"absolute bottom-3 right-3 flex items-center gap-1.5 px-3 py-1.5 bg-white/90 backdrop-blur-sm text-gray-800 text-sm font-medium rounded-lg shadow hover:bg-white transition-colors",children:[e.jsx(sL,{className:"h-4 w-4"}),"View all ",t.length," photos"]})]}),s&&e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 text-white",children:[e.jsxs("span",{className:"text-sm font-medium",children:[n+1," / ",t.length]}),e.jsx("button",{onClick:()=>r(!1),className:"p-2 hover:bg-white/10 rounded-full transition-colors",children:e.jsx(Rr,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex-1 flex items-center justify-center px-4 relative min-h-0",children:[e.jsx("img",{src:t[n],alt:"",className:"max-w-full max-h-full object-contain"}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:i,className:"absolute left-2 top-1/2 -translate-y-1/2 p-2 bg-white/10 hover:bg-white/20 rounded-full text-white transition-colors",children:e.jsx(cl,{className:"h-6 w-6"})}),e.jsx("button",{onClick:l,className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 bg-white/10 hover:bg-white/20 rounded-full text-white transition-colors",children:e.jsx(da,{className:"h-6 w-6"})})]})]}),e.jsx("div",{className:"px-4 py-3 overflow-x-auto",children:e.jsx("div",{className:"flex gap-2 justify-center",children:t.map((c,u)=>e.jsx("button",{onClick:()=>a(u),className:`w-16 h-12 rounded overflow-hidden shrink-0 border-2 transition-all ${u===n?"border-white opacity-100":"border-transparent opacity-50 hover:opacity-75"}`,children:e.jsx("img",{src:c,alt:"",className:"w-full h-full object-cover"})},u))})})]})]})}function J3s({listing:t}){var n,a;const s=[];t.lotSize&&s.push({label:"Lot Size",value:t.lotSize,icon:e.jsx(p1,{className:"h-4 w-4"})}),t.garageSpaces&&s.push({label:"Garage",value:`${t.garageSpaces} spaces`,icon:e.jsx(SM,{className:"h-4 w-4"})}),t.stories&&s.push({label:"Stories",value:`${t.stories}`,icon:e.jsx(IM,{className:"h-4 w-4"})}),t.heating&&s.push({label:"Heating",value:t.heating,icon:e.jsx(TL,{className:"h-4 w-4"})}),t.cooling&&s.push({label:"Cooling",value:t.cooling,icon:e.jsx(n0,{className:"h-4 w-4"})}),t.fireplace&&s.push({label:"Fireplace",value:"Yes",icon:e.jsx(eh,{className:"h-4 w-4"})}),t.pool&&s.push({label:"Pool",value:t.pool,icon:e.jsx(RL,{className:"h-4 w-4"})}),t.basement&&s.push({label:"Basement",value:t.basement,icon:e.jsx(IM,{className:"h-4 w-4"})}),t.parking&&s.push({label:"Parking",value:t.parking,icon:e.jsx(SM,{className:"h-4 w-4"})});const r=[];if(t.hoaFee){const o=t.hoaFrequency?`/${t.hoaFrequency.toLowerCase()}`:"/mo";r.push({label:"HOA Fee",value:`$${t.hoaFee.toLocaleString()}${o}`})}if(t.taxAmount){const o=t.taxYear?` (${t.taxYear})`:"";r.push({label:"Annual Taxes",value:`$${t.taxAmount.toLocaleString()}${o}`})}if(t.sqft>0&&t.price>0&&r.push({label:"Price / Sq Ft",value:`$${Math.round(t.price/t.sqft).toLocaleString()}`}),t.listDate){const o=Math.floor((Date.now()-new Date(t.listDate).getTime())/864e5);o>=0&&o<9999&&r.push({label:"Days on Market",value:`${o}`})}return s.length===0&&r.length===0?null:e.jsxs("div",{className:"space-y-6",children:[r.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Financial Details"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:r.map(o=>e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-gray-500 mb-0.5",children:o.label}),e.jsxs("p",{className:"font-semibold text-gray-900 flex items-center gap-1",children:[e.jsx(nc,{className:"h-3.5 w-3.5 text-gray-400"}),o.value.replace("$","")]})]},o.label))})]}),s.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Property Details"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-x-6 gap-y-3",children:s.map(o=>e.jsxs("div",{className:"flex items-center gap-2 py-2 border-b border-gray-100",children:[e.jsx("span",{className:"text-gray-400",children:o.icon}),e.jsx("span",{className:"text-sm text-gray-500",children:o.label}),e.jsx("span",{className:"text-sm font-medium text-gray-900 ml-auto",children:o.value})]},o.label))})]}),((n=t.features)==null?void 0:n.length)>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Features"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.features.map((o,l)=>e.jsx("span",{className:"px-2.5 py-1 bg-blue-50 text-blue-700 text-xs rounded-full font-medium",children:o},l))})]}),((a=t.appliances)==null?void 0:a.length)>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Appliances"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.appliances.map((o,l)=>e.jsx("span",{className:"px-2.5 py-1 bg-gray-100 text-gray-700 text-xs rounded-full font-medium",children:o},l))})]})]})}function e5s({latitude:t,longitude:s,address:r}){const n=N.useRef(null),a=N.useRef(null),o=N.useMemo(()=>{const l=Number(t),i=Number(s);return!Number.isFinite(l)||!Number.isFinite(i)?null:{lat:l,lng:i}},[t,s]);return N.useEffect(()=>{if(!n.current||a.current||!o)return;Ao.accessToken="pk.eyJ1IjoibGV2ZWx1cHJlIiwiYSI6ImNtOGZwMGNrYzBjNjIyanF5c2RwNTFhOXMifQ.sTe5rOhf_2nkqgr8Z_0e4Q";const l=new Ao.Map({container:n.current,style:"mapbox://styles/mapbox/streets-v12",center:[o.lng,o.lat],zoom:14,interactive:!0});return l.addControl(new Ao.NavigationControl({showCompass:!1}),"top-right"),new Ao.Marker({color:"#2563eb"}).setLngLat([o.lng,o.lat]).setPopup(new Ao.Popup({offset:25}).setText(r)).addTo(l),a.current=l,()=>{l.remove(),a.current=null}},[o,r]),o?e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Location"}),e.jsx("div",{ref:n,className:"w-full h-64 rounded-xl overflow-hidden border border-gray-200"})]}):null}function t5s({listPrice:t}){const[s,r]=N.useState(20),[n,a]=N.useState(6.5),[o,l]=N.useState(30),i=N.useMemo(()=>{const f=t*(1-s/100),g=n/100/12,b=o*12;return g===0?f/b:f*g*Math.pow(1+g,b)/(Math.pow(1+g,b)-1)},[t,s,n,o]),c=t*(s/100),u=t-c,p=f=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(f);return e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(YI,{className:"h-5 w-5 text-blue-600"}),e.jsx("h3",{className:"font-semibold text-gray-900",children:"Mortgage Calculator"})]}),e.jsxs("div",{className:"text-center mb-5",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Estimated Monthly Payment"}),e.jsx("p",{className:"text-3xl font-bold text-gray-900",children:p(i)})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-gray-600",children:"Down Payment"}),e.jsxs("span",{className:"font-medium text-gray-900",children:[s,"% (",p(c),")"]})]}),e.jsx("input",{type:"range",min:0,max:50,step:5,value:s,onChange:f=>r(Number(f.target.value)),className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-blue-600"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-gray-600",children:"Interest Rate"}),e.jsxs("span",{className:"font-medium text-gray-900",children:[n,"%"]})]}),e.jsx("input",{type:"range",min:2,max:12,step:.25,value:n,onChange:f=>a(Number(f.target.value)),className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-blue-600"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-gray-600",children:"Loan Term"}),e.jsxs("span",{className:"font-medium text-gray-900",children:[o," years"]})]}),e.jsx("div",{className:"flex gap-2",children:[15,20,30].map(f=>e.jsxs("button",{onClick:()=>l(f),className:`flex-1 py-1.5 text-sm font-medium rounded-lg border transition-colors ${o===f?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,children:[f," yr"]},f))})]}),e.jsxs("div",{className:"pt-3 border-t border-gray-100 space-y-1.5 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"Loan Amount"}),e.jsx("span",{className:"font-medium",children:p(u)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"Total Interest"}),e.jsx("span",{className:"font-medium",children:p(i*o*12-u)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"Total Cost"}),e.jsx("span",{className:"font-medium",children:p(i*o*12+c)})]})]})]})]})}function s5s({siteConfig:t,currentListing:s}){const r=fr(),{data:n}=mt({queryKey:["similar-listings",t.id,s.mlsNumber],queryFn:async()=>{const{data:o,error:l}=await H.functions.invoke("lead-site-search",{body:{leadSiteId:t.id,query:s.city,minPrice:Math.round(s.price*.75),maxPrice:Math.round(s.price*1.25),minBeds:Math.max(0,s.bedrooms-1),propertyType:s.propertyType||void 0}});if(l)throw l;return((o==null?void 0:o.listings)||[]).filter(c=>c.mlsNumber!==s.mlsNumber).slice(0,6)},enabled:!!s.city});if(!n||n.length===0)return null;const a=o=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(o);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Similar Listings Nearby"}),e.jsxs("button",{onClick:()=>r("/search"),className:"text-sm text-blue-600 hover:text-blue-700 flex items-center gap-0.5",children:["View all ",e.jsx(da,{className:"h-4 w-4"})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:n.map(o=>{var l;return e.jsxs("div",{onClick:()=>r(`/listing/${o.mlsNumber}`),className:"bg-white border border-gray-200 rounded-xl overflow-hidden cursor-pointer hover:shadow-md transition-shadow group",children:[e.jsx("div",{className:"aspect-[16/10] overflow-hidden",children:(l=o.photos)!=null&&l[0]?e.jsx("img",{src:o.photos[0],alt:"",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full bg-gray-100 flex items-center justify-center text-gray-400 text-sm",children:"No photo"})}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"font-bold text-gray-900",children:a(o.price)}),e.jsxs("p",{className:"text-sm text-gray-500 truncate",children:[o.address,", ",o.city]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Im,{className:"h-3.5 w-3.5"})," ",o.bedrooms]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ju,{className:"h-3.5 w-3.5"})," ",o.bathrooms]}),o.sqft>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(x0,{className:"h-3.5 w-3.5"})," ",o.sqft.toLocaleString()]})]})]})]},o.mlsNumber)})})]})}function r5s({siteConfig:t}){var L,I,O;const{mlsNumber:s}=yo(),r=fr(),[n,a]=N.useState(!1),[o,l]=N.useState({name:"",email:"",phone:"",message:""}),[i,c]=N.useState(!1),{user:u}=wme(),p=X3s(t,!!u),[f,g]=N.useState(!1);N.useEffect(()=>{!u||!s||H.from("lead_site_saved_listings").select("id").eq("user_id",u.id).eq("lead_site_id",t.id).eq("mls_number",s).maybeSingle().then(({data:q})=>g(!!q))},[u,s,t.id]);const b=async()=>{var q;!u||!s||(f?(await H.from("lead_site_saved_listings").delete().eq("user_id",u.id).eq("lead_site_id",t.id).eq("mls_number",s),g(!1),me.success("Removed from saved")):(await H.from("lead_site_saved_listings").insert({user_id:u.id,lead_site_id:t.id,mls_number:s,property_address:_?`${_.address}, ${_.city}, ${_.state}`:null,photo_url:((q=_==null?void 0:_.photos)==null?void 0:q[0])||null}),g(!0),me.success("Saved to favorites")))},{data:_,isLoading:j,error:w}=mt({queryKey:["lead-site-listing",t.id,s],queryFn:async()=>{const q=new AbortController,U=window.setTimeout(()=>q.abort(),15e3);try{const B=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-listing",{method:"POST",headers:{"Content-Type":"application/json",apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({leadSiteId:t.id,mlsNumber:s}),signal:q.signal}),V=await B.json().catch(()=>null);if(!B.ok)throw console.error("Lead site listing fetch error:",V),new Error((V==null?void 0:V.error)||"Failed to load listing");return console.log("Lead site listing data received:",!!V,V==null?void 0:V.mlsNumber),V}finally{window.clearTimeout(U)}},enabled:!!s});N.useEffect(()=>{var q;s&&t&&_&&p.recordView(s,u==null?void 0:u.id,{propertyAddress:_.address?`${_.address}, ${_.city}, ${_.state}`:void 0,photoUrl:((q=_.photos)==null?void 0:q[0])||void 0})},[s,t==null?void 0:t.id,_==null?void 0:_.address]);const k=async q=>{q.preventDefault(),c(!0);try{await H.from("lead_site_leads").insert({lead_site_id:t.id,name:o.name,email:o.email,phone:o.phone||null,message:o.message||`Interested in listing ${s}`,source_page:`/listing/${s}`,lead_type:"listing_inquiry",metadata:{mlsNumber:s}}),_me(t.id,{name:o.name,email:o.email,phone:o.phone||null,message:o.message||`Interested in listing ${s}`,lead_type:"listing_inquiry",source_page:`/listing/${s}`,mls_number:s}),me.success("Message sent! The agent will be in touch."),l({name:"",email:"",phone:"",message:""}),a(!1)}catch{me.error("Something went wrong. Please try again.")}finally{c(!1)}},S=async()=>{const q=window.location.href;if(navigator.share)try{await navigator.share({title:(_==null?void 0:_.address)||"Property Listing",url:q})}catch{}else await navigator.clipboard.writeText(q),me.success("Link copied to clipboard")},M=q=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(q);return j?e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-blue-600 border-t-transparent"})}):_?e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6 relative",children:[e.jsx(S3s,{listing:_,siteConfig:t}),e.jsx(xCe,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Search",path:"/search"},{name:`${_.address}, ${_.city}`,path:`/listing/${_.mlsNumber}`}]}),e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("button",{onClick:()=>r(-1),className:"flex items-center gap-2 text-gray-600 hover:text-gray-900 text-sm",children:[e.jsx(Ja,{className:"h-4 w-4"})," Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:S,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-gray-600 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors",children:[e.jsx(_d,{className:"h-4 w-4"})," Share"]}),u&&e.jsxs("button",{onClick:b,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm border rounded-lg transition-colors ${f?"bg-red-50 text-red-600 border-red-200":"text-gray-600 border-gray-200 hover:bg-gray-50"}`,children:[e.jsx(ni,{className:`h-4 w-4 ${f?"fill-current":""}`}),f?"Saved":"Save"]})]})]}),e.jsx(Q3s,{photos:_.photos||[]}),e.jsxs("div",{className:p.isGated?"filter blur-sm pointer-events-none select-none":"",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8 mt-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-3xl font-bold text-gray-900",children:M(_.price)}),e.jsxs("p",{className:"text-gray-600 mt-1 flex items-center gap-1",children:[e.jsx(ma,{className:"h-4 w-4"}),_.address,", ",_.city,", ",_.state," ",_.zip]})]}),e.jsx("span",{className:"px-3 py-1 bg-green-100 text-green-800 text-sm font-semibold rounded-full shrink-0",children:_.status})]}),e.jsxs("p",{className:"text-xs text-gray-400",children:["MLS# ",_.mlsNumber]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-6 py-4 border-y border-gray-200",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Im,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"font-semibold",children:_.bedrooms}),e.jsx("span",{className:"text-gray-500 text-sm",children:"beds"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ju,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"font-semibold",children:_.bathrooms}),e.jsx("span",{className:"text-gray-500 text-sm",children:"baths"})]}),_.sqft>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x0,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"font-semibold",children:_.sqft.toLocaleString()}),e.jsx("span",{className:"text-gray-500 text-sm",children:"sqft"})]}),_.yearBuilt&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"font-semibold",children:_.yearBuilt}),e.jsx("span",{className:"text-gray-500 text-sm",children:"built"})]}),_.propertyType&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bn,{className:"h-4 w-4 text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-600",children:_.propertyType}),_.propertySubType&&e.jsxs("span",{className:"text-xs text-gray-400",children:["• ",_.propertySubType]})]})]}),_.virtualTourUrl&&e.jsxs("a",{href:_.virtualTourUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-50 text-blue-700 rounded-lg text-sm font-medium hover:bg-blue-100 transition-colors",children:[e.jsx(tn,{className:"h-4 w-4"})," Take a Virtual Tour"]}),_.description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-2",children:"About This Property"}),e.jsx("p",{className:"text-gray-600 text-sm leading-relaxed whitespace-pre-line",children:_.description})]}),e.jsx(J3s,{listing:_}),_.latitude&&_.longitude&&e.jsx(e5s,{latitude:_.latitude,longitude:_.longitude,address:`${_.address}, ${_.city}`})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-6 sticky top-24",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[((L=t.agent)==null?void 0:L.avatar_url)&&e.jsx("img",{src:t.agent.avatar_url,alt:"",className:"w-12 h-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-gray-900",children:(I=t.agent)==null?void 0:I.full_name}),e.jsx("p",{className:"text-sm text-gray-500",children:((O=t.agent)==null?void 0:O.title)||"Real Estate Agent"})]})]}),n?e.jsxs("form",{onSubmit:k,className:"space-y-3",children:[e.jsx("input",{type:"text",required:!0,placeholder:"Your name",value:o.name,onChange:q=>l(U=>({...U,name:q.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("input",{type:"email",required:!0,placeholder:"Email",value:o.email,onChange:q=>l(U=>({...U,email:q.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("input",{type:"tel",placeholder:"Phone (optional)",value:o.phone,onChange:q=>l(U=>({...U,phone:q.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("textarea",{placeholder:"Message",value:o.message,onChange:q=>l(U=>({...U,message:q.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 h-20 resize-none"}),e.jsx("button",{type:"submit",disabled:i,className:"w-full py-2.5 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors",children:i?"Sending...":"Send Message"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("button",{onClick:()=>a(!0),className:"w-full py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors",children:"Ask About This Property"}),e.jsx("button",{onClick:()=>a(!0),className:"w-full py-3 border border-gray-300 text-gray-700 font-medium rounded-lg hover:bg-gray-50 transition-colors",children:"Schedule a Showing"})]})]}),_.price>0&&e.jsx(t5s,{listPrice:_.price})]})]}),e.jsx("div",{className:"mt-12 mb-6",children:e.jsx(s5s,{siteConfig:t,currentListing:_})})]}),e.jsx(jct,{open:p.showRegistration,mode:p.mode,siteConfig:t,onComplete:p.completeRegistration,onSkip:p.dismissRegistration})]}):e.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-20 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-700",children:w?"Error loading listing":"Listing not found"}),w&&e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Please try again in a moment."}),e.jsx("button",{onClick:()=>r("/search"),className:"mt-4 text-blue-600 hover:underline",children:"Back to search"})]})}function n5s({siteConfig:t}){const s=fr(),r=t.agent;return e.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-16",children:[e.jsxs("div",{className:"text-center mb-12",children:[(r==null?void 0:r.avatar_url)&&e.jsx("img",{src:r.avatar_url,alt:r.full_name,className:"w-32 h-32 rounded-2xl object-cover mx-auto mb-6 shadow-lg"}),e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:(r==null?void 0:r.full_name)||"About"}),e.jsx("p",{className:"text-lg text-gray-500",children:(r==null?void 0:r.title)||"Real Estate Professional"})]}),(r==null?void 0:r.bio)&&e.jsx("div",{className:"prose prose-gray max-w-none mb-12",children:e.jsx("p",{className:"text-gray-600 leading-relaxed whitespace-pre-line",children:r.bio})}),e.jsxs("div",{className:"bg-blue-50 rounded-2xl p-8 text-center",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 mb-2",children:"Ready to get started?"}),e.jsx("p",{className:"text-gray-600 mb-6",children:"Whether you're buying or selling, I'm here to help you every step of the way."}),e.jsxs("div",{className:"flex gap-3 justify-center",children:[e.jsx("button",{onClick:()=>s("/contact"),className:"px-6 py-3 bg-blue-600 text-white font-semibold rounded-lg hover:bg-blue-700 transition-colors",children:"Contact Me"}),e.jsx("button",{onClick:()=>s("/search"),className:"px-6 py-3 border border-gray-300 text-gray-700 font-semibold rounded-lg hover:bg-white transition-colors",children:"Search Listings"})]})]})]})}function a5s({siteConfig:t}){const[s,r]=N.useState({name:"",email:"",phone:"",message:""}),[n,a]=N.useState(!1),o=async i=>{i.preventDefault(),a(!0);try{await H.from("lead_site_leads").insert({lead_site_id:t.id,name:s.name,email:s.email,phone:s.phone||null,message:s.message,source_page:"/contact",lead_type:"contact"}),_me(t.id,{name:s.name,email:s.email,phone:s.phone||null,message:s.message,lead_type:"contact",source_page:"/contact"}),me.success("Message sent! We'll be in touch soon."),r({name:"",email:"",phone:"",message:""})}catch{me.error("Something went wrong. Please try again.")}finally{a(!1)}},l=t.agent;return e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-16",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"Get In Touch"}),e.jsx("p",{className:"text-gray-500",children:"Have a question or ready to start your home search? Reach out!"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-12",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[(l==null?void 0:l.avatar_url)&&e.jsx("img",{src:l.avatar_url,alt:"",className:"w-16 h-16 rounded-xl object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg text-gray-900",children:l==null?void 0:l.full_name}),e.jsx("p",{className:"text-gray-500",children:(l==null?void 0:l.title)||"Real Estate Agent"})]})]}),e.jsxs("div",{className:"space-y-4",children:[(l==null?void 0:l.email)&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center",children:e.jsx(cr,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Email"}),e.jsx("a",{href:`mailto:${l.email}`,className:"text-gray-900 hover:text-blue-600",children:l.email})]})]}),(l==null?void 0:l.phone)&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-green-100 rounded-lg flex items-center justify-center",children:e.jsx(Un,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Phone"}),e.jsx("a",{href:`tel:${l.phone}`,className:"text-gray-900 hover:text-blue-600",children:l.phone})]})]})]})]}),e.jsxs("form",{onSubmit:o,className:"bg-white border border-gray-200 rounded-xl p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Name *"}),e.jsx("input",{type:"text",required:!0,value:s.name,onChange:i=>r(c=>({...c,name:i.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Email *"}),e.jsx("input",{type:"email",required:!0,value:s.email,onChange:i=>r(c=>({...c,email:i.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Phone"}),e.jsx("input",{type:"tel",value:s.phone,onChange:i=>r(c=>({...c,phone:i.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Message *"}),e.jsx("textarea",{required:!0,value:s.message,onChange:i=>r(c=>({...c,message:i.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 h-28 resize-none",placeholder:"Tell me about what you're looking for..."})]}),e.jsx("button",{type:"submit",disabled:n,className:"w-full py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors",children:n?"Sending...":"Send Message"})]})]})]})}function i5s({siteConfig:t}){const s=fr(),{user:r,profile:n,signOut:a}=wme(),[o,l]=N.useState("saved"),[i,c]=N.useState([]),[u,p]=N.useState([]),[f,g]=N.useState({name:"",phone:"",email:""}),[b,_]=N.useState(!1);N.useEffect(()=>{if(!r){s("/");return}j(),n&&g({name:n.name,phone:n.phone||"",email:n.email})},[r,n]);const j=async()=>{if(!r)return;const{data:M}=await H.from("lead_site_saved_listings").select("*").eq("user_id",r.id).eq("lead_site_id",t.id).order("saved_at",{ascending:!1});c(M||[]);const{data:L}=await H.from("lead_site_property_views").select("*").eq("auth_user_id",r.id).eq("lead_site_id",t.id).order("viewed_at",{ascending:!1}).limit(50),I=new Set,O=(L||[]).filter(q=>I.has(q.mls_number)?!1:(I.add(q.mls_number),!0));p(O)},w=async M=>{await H.from("lead_site_saved_listings").delete().eq("user_id",r.id).eq("lead_site_id",t.id).eq("mls_number",M),c(L=>L.filter(I=>I.mls_number!==M)),me.success("Removed from saved")},k=async M=>{M.preventDefault(),_(!0);try{await H.from("lead_site_consumer_profiles").update({name:f.name,phone:f.phone||null}).eq("user_id",r.id).eq("lead_site_id",t.id),me.success("Profile updated")}catch{me.error("Failed to update profile")}finally{_(!1)}};if(!r)return null;const S=[{key:"saved",label:"Saved Listings",icon:ni,count:i.length},{key:"viewed",label:"Recently Viewed",icon:un,count:u.length},{key:"profile",label:"My Profile",icon:to}];return e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"My Account"}),e.jsxs("p",{className:"text-gray-500 text-sm mt-1",children:["Welcome back, ",(n==null?void 0:n.name)||"there","!"]})]}),e.jsxs("button",{onClick:async()=>{await a(),s("/")},className:"flex items-center gap-2 text-sm text-gray-500 hover:text-gray-700 px-3 py-2 rounded-lg hover:bg-gray-100 transition-colors",children:[e.jsx(iS,{className:"h-4 w-4"})," Sign Out"]})]}),e.jsx("div",{className:"flex gap-1 border-b border-gray-200 mb-6",children:S.map(M=>{const L=M.icon;return e.jsxs("button",{onClick:()=>l(M.key),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors ${o===M.key?"border-blue-600 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[e.jsx(L,{className:"h-4 w-4"}),M.label,"count"in M&&typeof M.count=="number"&&e.jsx("span",{className:"ml-1 text-xs bg-gray-100 text-gray-600 px-1.5 py-0.5 rounded-full",children:M.count})]},M.key)})}),o==="saved"&&e.jsx("div",{children:i.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(ni,{className:"h-10 w-10 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"No saved listings yet"}),e.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"Browse properties and tap the heart to save them."}),e.jsx("button",{onClick:()=>s("/search"),className:"mt-4 px-5 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700",children:"Search Properties"})]}):e.jsx("div",{className:"space-y-3",children:i.map(M=>e.jsxs("div",{className:"flex items-center justify-between p-4 bg-white border border-gray-200 rounded-xl hover:bg-gray-50 transition-colors",children:[e.jsxs("button",{onClick:()=>s(`/listing/${M.mls_number}`),className:"flex items-center gap-3 flex-1 text-left",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-gray-900",children:["MLS# ",M.mls_number]}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Saved ",new Date(M.saved_at).toLocaleDateString()]})]}),e.jsx(da,{className:"h-4 w-4 text-gray-400 ml-auto"})]}),e.jsx("button",{onClick:()=>w(M.mls_number),className:"p-2 text-gray-400 hover:text-red-500 ml-2",children:e.jsx(Nr,{className:"h-4 w-4"})})]},M.mls_number))})}),o==="viewed"&&e.jsx("div",{children:u.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(un,{className:"h-10 w-10 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"No recently viewed properties"}),e.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"Properties you view will appear here."})]}):e.jsx("div",{className:"space-y-3",children:u.map(M=>e.jsxs("button",{onClick:()=>s(`/listing/${M.mls_number}`),className:"flex items-center justify-between w-full p-4 bg-white border border-gray-200 rounded-xl hover:bg-gray-50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-gray-900",children:["MLS# ",M.mls_number]}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Viewed ",new Date(M.viewed_at).toLocaleDateString()]})]}),e.jsx(da,{className:"h-4 w-4 text-gray-400"})]},M.id))})}),o==="profile"&&e.jsx("div",{className:"max-w-md",children:e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Name"}),e.jsx("input",{type:"text",value:f.name,onChange:M=>g(L=>({...L,name:M.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Email"}),e.jsx("input",{type:"email",value:f.email,disabled:!0,className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm bg-gray-50 text-gray-500"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Email cannot be changed"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Phone"}),e.jsx("input",{type:"tel",value:f.phone,onChange:M=>g(L=>({...L,phone:M.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"This is also used as your password"})]}),e.jsx("button",{type:"submit",disabled:b,className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50",children:b?"Saving...":"Save Changes"})]})})]})}function Qze({siteConfig:t}){var p;const s=fr(),{slug:r}=yo(),[n,a]=N.useState("all"),{data:o,isLoading:l}=mt({queryKey:["public-blog-posts",t.id,n],queryFn:async()=>{let f=H.from("lead_site_blog_posts").select("*").eq("lead_site_id",t.id).eq("is_published",!0).order("published_at",{ascending:!1});n!=="all"&&(f=f.eq("post_type",n));const{data:g,error:b}=await f;if(b)throw b;return g},enabled:!r}),{data:i,isLoading:c}=mt({queryKey:["public-blog-post",t.id,r],queryFn:async()=>{const{data:f,error:g}=await H.from("lead_site_blog_posts").select("*").eq("lead_site_id",t.id).eq("slug",r).eq("is_published",!0).maybeSingle();if(g)throw g;return f},enabled:!!r});if(r)return c?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-gray-900 border-t-transparent"})}):i?e.jsxs("div",{className:"min-h-screen bg-white",children:[e.jsx(M3s,{title:i.title,description:i.excerpt||i.title,publishedAt:i.published_at||i.created_at,imageUrl:i.cover_image_url,slug:i.slug,siteConfig:t}),e.jsx(xCe,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Blog",path:"/blog"},{name:i.title,path:`/blog/${i.slug}`}]}),i.cover_image_url&&e.jsxs("div",{className:"h-72 md:h-96 w-full relative",children:[e.jsx("img",{src:i.cover_image_url,alt:i.title,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/50 to-transparent"})]}),e.jsxs("article",{className:"max-w-3xl mx-auto px-6 py-12",children:[e.jsxs("button",{onClick:()=>s("/blog"),className:"flex items-center gap-1.5 text-sm text-gray-500 hover:text-gray-900 mb-6 transition-colors",children:[e.jsx(Ja,{className:"h-4 w-4"})," All Posts"]}),e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:`text-xs font-medium px-2.5 py-1 rounded-full ${i.post_type==="neighborhood_guide"?"bg-emerald-50 text-emerald-700":"bg-blue-50 text-blue-700"}`,children:i.post_type==="neighborhood_guide"?"📍 Neighborhood Guide":"📝 Blog"}),i.neighborhood&&e.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"})," ",i.neighborhood]})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-4",children:i.title}),i.published_at&&e.jsx("p",{className:"text-sm text-gray-400 mb-8",children:new Date(i.published_at).toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),e.jsx("div",{className:"prose prose-lg max-w-none prose-headings:text-gray-900 prose-p:text-gray-700 prose-a:text-blue-600",dangerouslySetInnerHTML:{__html:i.content}})]})]}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Post Not Found"}),e.jsx("button",{onClick:()=>s("/blog"),className:"text-blue-600 hover:underline",children:"← Back to blog"})]})});const u=((p=t.agent)==null?void 0:p.full_name)||"Your Agent";return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"bg-gradient-to-br from-gray-900 to-gray-800 text-white py-20 px-6",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",children:"Local Insights"}),e.jsxs("p",{className:"text-lg text-gray-300 max-w-2xl mx-auto",children:["Neighborhood guides, market insights, and local expertise from ",u,"."]})]})}),e.jsx("div",{className:"max-w-4xl mx-auto px-6 -mt-6 mb-8",children:e.jsx("div",{className:"bg-white rounded-2xl shadow-lg p-2 flex gap-1",children:[{value:"all",label:"All Posts"},{value:"blog_post",label:"Blog"},{value:"neighborhood_guide",label:"Neighborhoods"}].map(f=>e.jsx("button",{onClick:()=>a(f.value),className:`flex-1 py-2.5 px-4 rounded-xl text-sm font-medium transition-all ${n===f.value?"bg-gray-900 text-white shadow-md":"text-gray-600 hover:bg-gray-100"}`,children:f.label},f.value))})}),e.jsx("div",{className:"max-w-4xl mx-auto px-6 pb-20",children:l?e.jsx("div",{className:"text-center py-12",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-gray-900 border-t-transparent mx-auto"})}):o!=null&&o.length?e.jsx("div",{className:"grid gap-6",children:o.map((f,g)=>e.jsx(Hs.article,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:g*.05},onClick:()=>s(`/blog/${f.slug}`),className:"bg-white rounded-2xl overflow-hidden shadow-sm hover:shadow-xl transition-all cursor-pointer group border border-gray-100",children:e.jsxs("div",{className:"flex flex-col sm:flex-row",children:[f.cover_image_url&&e.jsx("div",{className:"sm:w-64 h-48 sm:h-auto flex-shrink-0",children:e.jsx("img",{src:f.cover_image_url,alt:f.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),e.jsxs("div",{className:"flex-1 p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:`text-xs font-medium px-2.5 py-1 rounded-full ${f.post_type==="neighborhood_guide"?"bg-emerald-50 text-emerald-700":"bg-blue-50 text-blue-700"}`,children:f.post_type==="neighborhood_guide"?"📍 Neighborhood Guide":"📝 Blog"}),f.neighborhood&&e.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"})," ",f.neighborhood]})]}),e.jsx("h2",{className:"text-xl font-bold text-gray-900 group-hover:text-blue-600 transition-colors mb-2",children:f.title}),f.excerpt&&e.jsx("p",{className:"text-gray-600 text-sm line-clamp-2 mb-3",children:f.excerpt}),f.published_at&&e.jsx("p",{className:"text-xs text-gray-400",children:new Date(f.published_at).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})})]})]})},f.id))}):e.jsx("div",{className:"text-center py-20",children:e.jsx("p",{className:"text-gray-400 text-lg",children:"No posts yet. Check back soon!"})})})]})}function o5s({siteConfig:t}){var a;const s=((a=t.agent)==null?void 0:a.full_name)||"Your Agent",{data:r}=mt({queryKey:["public-lead-site-events",t.id],queryFn:async()=>{const{data:o,error:l}=await H.from("lead_site_events").select("*").eq("lead_site_id",t.id).eq("is_published",!0).gte("event_date",new Date().toISOString()).order("event_date",{ascending:!0});if(l)throw l;return o}}),{data:n}=mt({queryKey:["public-lead-site-businesses",t.id],queryFn:async()=>{const{data:o,error:l}=await H.from("lead_site_businesses").select("*").eq("lead_site_id",t.id).eq("is_published",!0).order("sort_order",{ascending:!0});if(l)throw l;return o}});return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"bg-gradient-to-br from-gray-900 to-gray-800 text-white py-20 px-6",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",children:"Community"}),e.jsxs("p",{className:"text-lg text-gray-300 max-w-2xl mx-auto",children:["Local events, favorite spots, and everything that makes this area special — curated by ",s,"."]})]})}),e.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-16 space-y-20",children:[r&&r.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-blue-100 flex items-center justify-center",children:e.jsx(hn,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:"Upcoming Events"}),e.jsx("p",{className:"text-sm text-gray-500",children:"What's happening in the community"})]})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:r.map((o,l)=>e.jsxs(Hs.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:l*.05},className:"bg-white rounded-2xl overflow-hidden shadow-sm hover:shadow-lg transition-all border border-gray-100 group",children:[o.image_url&&e.jsx("div",{className:"h-40 overflow-hidden",children:e.jsx("img",{src:o.image_url,alt:o.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),e.jsx("div",{className:"p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-blue-50 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-[10px] font-bold text-blue-600 uppercase leading-none",children:ms(new Date(o.event_date),"MMM")}),e.jsx("span",{className:"text-xl font-bold text-blue-600 leading-none mt-0.5",children:ms(new Date(o.event_date),"d")})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-bold text-gray-900 text-lg mb-1",children:o.title}),o.description&&e.jsx("p",{className:"text-sm text-gray-600 line-clamp-2 mb-2",children:o.description}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-gray-500",children:[o.location&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"})," ",o.location]}),e.jsx("span",{children:ms(new Date(o.event_date),"h:mm a")})]}),o.external_url&&e.jsxs("a",{href:o.external_url,target:"_blank",rel:"noopener",className:"inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 mt-3 font-medium",children:["Learn More ",e.jsx(tn,{className:"h-3 w-3"})]})]})]})})]},o.id))})]}),n&&n.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-amber-100 flex items-center justify-center",children:e.jsx(BM,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-2xl font-bold text-gray-900",children:[s,"'s Local Picks"]}),e.jsx("p",{className:"text-sm text-gray-500",children:"Places I love and recommend in the area"})]})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:n.map((o,l)=>e.jsxs(Hs.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:l*.05},className:"bg-white rounded-2xl overflow-hidden shadow-sm hover:shadow-lg transition-all border border-gray-100 group",children:[o.image_url?e.jsx("div",{className:"h-36 overflow-hidden",children:e.jsx("img",{src:o.image_url,alt:o.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}):e.jsx("div",{className:"h-24 bg-gradient-to-br from-amber-50 to-orange-50 flex items-center justify-center",children:e.jsx(BM,{className:"h-8 w-8 text-amber-300"})}),e.jsxs("div",{className:"p-4",children:[o.category&&e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-amber-600 mb-1 block",children:o.category}),e.jsx("h3",{className:"font-bold text-gray-900 mb-1",children:o.name}),o.description&&e.jsx("p",{className:"text-sm text-gray-600 line-clamp-2 mb-3",children:o.description}),e.jsx("div",{className:"flex flex-wrap items-center gap-3 text-xs text-gray-500",children:o.address&&e.jsxs("span",{className:"flex items-center gap-1 truncate",children:[e.jsx(ma,{className:"h-3 w-3 flex-shrink-0"})," ",o.address]})}),e.jsxs("div",{className:"flex items-center gap-3 mt-3",children:[o.phone&&e.jsxs("a",{href:`tel:${o.phone}`,className:"text-xs text-blue-600 hover:text-blue-700 flex items-center gap-1",children:[e.jsx(Un,{className:"h-3 w-3"})," Call"]}),o.website_url&&e.jsxs("a",{href:o.website_url,target:"_blank",rel:"noopener",className:"text-xs text-blue-600 hover:text-blue-700 flex items-center gap-1",children:[e.jsx(su,{className:"h-3 w-3"})," Website"]})]})]})]},o.id))})]}),(!r||r.length===0)&&(!n||n.length===0)&&e.jsx("div",{className:"text-center py-20",children:e.jsx("p",{className:"text-gray-400 text-lg",children:"Community content coming soon!"})})]})]})}function l5s({siteConfig:t,themeConfig:s}){var Z,X,ee,Q;const r=fr(),[n]=Cc(),a=((Z=t.agent)==null?void 0:Z.full_name)||"Your Agent",o=a.split(" ")[0],l=(s==null?void 0:s.accentColor)||((X=t.themeConfig)==null?void 0:X.accentColor)||"#3b82f6",[i,c]=N.useState({name:"",email:"",phone:"",address:"",timeline:"",message:""}),[u,p]=N.useState(!1),[f,g]=N.useState(!1),[b,_]=N.useState(null),[j,w]=N.useState(!0),[k,S]=N.useState("");N.useEffect(()=>{(async()=>{const re=n.get("city");if(re){S(re);return}const{data:oe}=await H.from("lead_site_city_pages").select("city_name").eq("site_id",t.id).eq("is_published",!0).order("sort_order",{ascending:!0}).limit(1);oe!=null&&oe[0]&&S(oe[0].city_name)})()},[t.id,n]),N.useEffect(()=>{if(!k){w(!1);return}(async()=>{w(!0);try{const{data:re,error:oe}=await H.functions.invoke("lead-site-seller-stats",{body:{leadSiteId:t.id,city:k}});!oe&&re&&_(re)}catch(re){console.warn("Failed to load seller stats:",re)}finally{w(!1)}})()},[t.id,k]);const M=async ie=>{ie.preventDefault(),p(!0);try{await H.from("lead_site_leads").insert({lead_site_id:t.id,name:i.name,email:i.email,phone:i.phone||null,message:i.message||null,source_page:"/sell",lead_type:"seller",metadata:{address:i.address,timeline:i.timeline}}),_me(t.id,{name:i.name,email:i.email,phone:i.phone||null,message:`Seller Lead — ${i.address||"Address not provided"} Timeline: ${i.timeline||"Not specified"} ${i.message||""}`,lead_type:"seller",source_page:"/sell"}),g(!0),me.success("Your request has been submitted!")}catch{me.error("Something went wrong. Please try again.")}finally{p(!1)}},L=ie=>ie>=1e6?`$${(ie/1e6).toFixed(1)}M`:`$${Math.round(ie/1e3)}K`,I=`https://${t.subdomainSlug}.thelocalmove.com`,O=`Sell Your Home | ${a}`,q=`Thinking of selling your home? Get a free market analysis from ${a}. See recent sales, market trends, and what your home could be worth.`,U=(b==null?void 0:b.marketCondition)==="seller"?"It's a Seller's Market":(b==null?void 0:b.marketCondition)==="buyer"?"It's a Buyer's Market":"The Market Is Balanced",B=(b==null?void 0:b.marketCondition)==="seller"?"Demand exceeds supply. Sellers have the advantage with faster sales and stronger offers.":(b==null?void 0:b.marketCondition)==="buyer"?"More inventory than buyers. Pricing strategy and presentation are critical.":"Supply and demand are relatively even. Well-priced homes sell quickly.",V=[{step:"1",title:"Free Home Valuation",desc:"Get a data-driven market analysis of your home's current value."},{step:"2",title:"Strategic Pricing",desc:"Price your home to attract maximum interest and competitive offers."},{step:"3",title:"Professional Marketing",desc:"Professional photos, virtual tours, targeted digital marketing, and MLS exposure."},{step:"4",title:"Showings & Offers",desc:"Coordinate showings, review offers, and negotiate the best terms for you."},{step:"5",title:"Close & Celebrate",desc:"Navigate inspections, appraisals, and closing with expert guidance."}];return e.jsxs("div",{className:"min-h-screen bg-white",children:[e.jsxs(Sc,{children:[e.jsx("title",{children:O}),e.jsx("meta",{name:"description",content:q}),e.jsx("meta",{property:"og:title",content:O}),e.jsx("meta",{property:"og:description",content:q}),e.jsx("link",{rel:"canonical",href:`${I}/sell`})]}),e.jsx(fCe,{siteConfig:t,pagePath:"/sell"}),e.jsxs("section",{className:"relative bg-gray-950 text-white overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-20",style:{background:`radial-gradient(ellipse at 30% 40%, ${l}44, transparent 60%), radial-gradient(ellipse at 70% 60%, ${l}22, transparent 50%)`}}),e.jsx("div",{className:"relative max-w-7xl mx-auto px-6 lg:px-8 py-24 md:py-32",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-16 items-center",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-sm font-medium mb-6",style:{backgroundColor:`${l}20`,color:l},children:[e.jsx(ul,{className:"h-4 w-4"}),(b==null?void 0:b.marketCondition)==="seller"?"Seller's Market":"Free Home Valuation"]}),e.jsxs("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold tracking-tight leading-[1.1] mb-6",children:["What's Your Home ",e.jsx("span",{style:{color:l},children:"Really Worth?"})]}),e.jsxs("p",{className:"text-lg md:text-xl text-gray-400 leading-relaxed mb-8 max-w-lg",children:["Get a complimentary, data-driven market analysis from ",o,". See what homes in your area are actually selling for — not just what they're listed at."]}),e.jsxs("div",{className:"flex flex-wrap gap-6 text-sm text-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4",style:{color:l}})," No obligation"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4",style:{color:l}})," Real MLS data"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4",style:{color:l}})," Expert guidance"]})]})]}),e.jsx("div",{className:"bg-white rounded-2xl p-8 shadow-2xl text-gray-900",children:f?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{backgroundColor:`${l}15`},children:e.jsx(sa,{className:"h-8 w-8",style:{color:l}})}),e.jsx("h3",{className:"text-xl font-bold mb-2",children:"You're All Set!"}),e.jsxs("p",{className:"text-gray-500 mb-6",children:[o," will review your information and send you a personalized market analysis within 24 hours."]}),e.jsxs("button",{onClick:()=>r("/search"),className:"text-sm font-medium flex items-center gap-1 mx-auto",style:{color:l},children:["Browse current listings ",e.jsx(Qa,{className:"h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-xl font-bold mb-1",children:"Get Your Free Home Valuation"}),e.jsxs("p",{className:"text-sm text-gray-500 mb-6",children:[o," will send you a personalized market analysis."]}),e.jsxs("form",{onSubmit:M,className:"space-y-3.5",children:[e.jsx("input",{type:"text",required:!0,placeholder:"Your property address *",value:i.address,onChange:ie=>c(re=>({...re,address:ie.target.value})),className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:border-transparent",style:{"--tw-ring-color":l}}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("input",{type:"text",required:!0,placeholder:"Full name *",value:i.name,onChange:ie=>c(re=>({...re,name:ie.target.value})),className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:border-transparent",style:{"--tw-ring-color":l}}),e.jsx("input",{type:"tel",placeholder:"Phone",value:i.phone,onChange:ie=>c(re=>({...re,phone:ie.target.value})),className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:border-transparent",style:{"--tw-ring-color":l}})]}),e.jsx("input",{type:"email",required:!0,placeholder:"Email address *",value:i.email,onChange:ie=>c(re=>({...re,email:ie.target.value})),className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:border-transparent",style:{"--tw-ring-color":l}}),e.jsxs("select",{value:i.timeline,onChange:ie=>c(re=>({...re,timeline:ie.target.value})),className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:border-transparent text-gray-700",style:{"--tw-ring-color":l},children:[e.jsx("option",{value:"",children:"When are you looking to sell?"}),e.jsx("option",{value:"asap",children:"As soon as possible"}),e.jsx("option",{value:"1-3months",children:"1–3 months"}),e.jsx("option",{value:"3-6months",children:"3–6 months"}),e.jsx("option",{value:"6-12months",children:"6–12 months"}),e.jsx("option",{value:"just-curious",children:"Just curious about my value"})]}),e.jsx("textarea",{placeholder:"Anything else you'd like us to know?",value:i.message,onChange:ie=>c(re=>({...re,message:ie.target.value})),className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:border-transparent h-20 resize-none",style:{"--tw-ring-color":l}}),e.jsx("button",{type:"submit",disabled:u,className:"w-full py-3.5 text-white font-semibold rounded-xl transition-all hover:opacity-90 disabled:opacity-50 text-sm",style:{backgroundColor:l},children:u?"Submitting...":"Get My Free Valuation"}),e.jsxs("p",{className:"text-[11px] text-gray-400 text-center",children:["By submitting, you agree to be contacted by ",o," about your property."]})]})]})})]})})]}),b&&!j&&e.jsx("section",{className:"py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 lg:px-8",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-semibold uppercase tracking-wider mb-4 bg-green-100 text-green-700",children:[e.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})," Live MLS Data"]}),e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:[k," Market Snapshot"]}),e.jsx("p",{className:"text-gray-500 mt-3 max-w-2xl mx-auto",children:"Real-time data from the MLS — see exactly what's happening in your market right now."})]}),e.jsxs("div",{className:"mb-10 rounded-2xl p-6 text-center",style:{backgroundColor:b.marketCondition==="seller"?"#f0fdf4":b.marketCondition==="buyer"?"#fef2f2":"#eff6ff"},children:[e.jsx("h3",{className:"text-xl font-bold mb-1",style:{color:b.marketCondition==="seller"?"#15803d":b.marketCondition==="buyer"?"#b91c1c":"#1d4ed8"},children:U}),e.jsx("p",{className:"text-sm text-gray-600 max-w-xl mx-auto",children:B}),e.jsxs("p",{className:"text-xs text-gray-400 mt-2",children:[b.monthsOfInventory," months of inventory · ",b.activeCount," active · ",b.soldCount," sold (6 mo)"]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 md:gap-6",children:[{icon:nc,label:"Median Sold Price",value:b.medianSoldPrice>0?L(b.medianSoldPrice):"—",color:"#10b981"},{icon:un,label:"Avg Days on Market",value:b.avgDaysOnMarket>0?`${b.avgDaysOnMarket} days`:"—",color:"#f59e0b"},{icon:uS,label:"Sale-to-List Ratio",value:b.listToSaleRatio>0?`${b.listToSaleRatio}%`:"—",color:"#8b5cf6"},{icon:No,label:"Avg Price / Sq Ft",value:b.avgPricePerSqft>0?`$${b.avgPricePerSqft}`:"—",color:"#3b82f6"}].map(ie=>e.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 p-5 text-center shadow-sm",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center mx-auto mb-3",style:{backgroundColor:`${ie.color}12`},children:e.jsx(ie.icon,{className:"h-5 w-5",style:{color:ie.color}})}),e.jsx("p",{className:"text-2xl md:text-3xl font-bold text-gray-900",children:ie.value}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:ie.label})]},ie.label))})]})}),(b==null?void 0:b.recentlySold)&&b.recentlySold.length>0&&e.jsx("section",{className:"py-20",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 lg:px-8",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:"What Sellers Are Getting"}),e.jsxs("p",{className:"text-gray-500 mt-3",children:["Recently sold homes in ",k," — real prices, real results."]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6",children:b.recentlySold.map((ie,re)=>{var oe,ce,xe;return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 overflow-hidden shadow-sm hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"aspect-[16/10] bg-gray-100 relative",children:[(oe=ie.photos)!=null&&oe[0]?e.jsx("img",{src:ie.photos[0],alt:ie.address,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(bn,{className:"h-10 w-10"})}),e.jsx("div",{className:"absolute top-3 left-3 px-3 py-1 bg-red-600 text-white text-xs font-bold rounded-full",children:"SOLD"})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[e.jsxs("p",{className:"text-xl font-bold text-gray-900",children:["$",(ce=ie.soldPrice)==null?void 0:ce.toLocaleString()]}),ie.listPrice>0&&ie.soldPrice>0&&e.jsxs("span",{className:`text-xs font-semibold ${ie.soldPrice>=ie.listPrice?"text-green-600":"text-red-500"}`,children:[ie.soldPrice>=ie.listPrice?"+":"",((ie.soldPrice-ie.listPrice)/ie.listPrice*100).toFixed(1),"%"]})]}),e.jsxs("p",{className:"text-sm text-gray-600 mb-2 flex items-center gap-1",children:[e.jsx(ma,{className:"h-3.5 w-3.5 text-gray-400 flex-shrink-0"}),ie.address,", ",ie.city]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500",children:[e.jsxs("span",{children:[ie.bedrooms," bed"]}),e.jsx("span",{className:"text-gray-300",children:"•"}),e.jsxs("span",{children:[ie.bathrooms," bath"]}),e.jsx("span",{className:"text-gray-300",children:"•"}),e.jsxs("span",{children:[(xe=ie.sqft)==null?void 0:xe.toLocaleString()," sqft"]}),ie.daysOnMarket>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-300",children:"•"}),e.jsxs("span",{children:[ie.daysOnMarket," DOM"]})]})]})]})]},ie.mlsNumber||re)})})]})}),e.jsx("section",{className:"py-20 bg-gray-950 text-white",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-6 lg:px-8",children:[e.jsxs("div",{className:"text-center mb-14",children:[e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold tracking-tight",children:["How Selling With ",o," Works"]}),e.jsx("p",{className:"text-gray-400 mt-3 max-w-xl mx-auto",children:"A clear, proven process from listing to closing — no surprises."})]}),e.jsx("div",{className:"space-y-0",children:V.map((ie,re)=>e.jsxs("div",{className:"relative flex gap-6 pb-10 last:pb-0",children:[ree.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${l}12`},children:e.jsx(ie.icon,{className:"h-5 w-5",style:{color:l}})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-0.5",children:ie.title}),e.jsx("p",{className:"text-sm text-gray-500 leading-relaxed",children:ie.desc})]})]},ie.title))})]}),e.jsx("div",{className:"flex justify-center",children:(ee=t.agent)!=null&&ee.avatar_url?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:t.agent.avatar_url,alt:a,className:"w-72 h-72 md:w-80 md:h-80 rounded-2xl object-cover shadow-xl"}),e.jsxs("div",{className:"absolute -bottom-4 -right-4 bg-white rounded-xl shadow-lg p-4 border border-gray-100",children:[e.jsx("p",{className:"text-xs text-gray-500 mb-0.5",children:"Your local expert"}),e.jsx("p",{className:"font-bold text-gray-900",children:a}),e.jsx("p",{className:"text-xs text-gray-500",children:((Q=t.agent)==null?void 0:Q.title)||"REALTOR®"})]})]}):e.jsx("div",{className:"w-72 h-72 rounded-2xl bg-gray-100 flex items-center justify-center",children:e.jsx(bn,{className:"h-16 w-16 text-gray-300"})})})]})})}),e.jsx("section",{className:"py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 lg:px-8",children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900 text-center mb-10 tracking-tight",children:"Frequently Asked Questions"}),e.jsx(c5s,{agentName:o,city:k,accentColor:l})]})}),e.jsx("section",{className:"py-20 bg-gray-950 text-white",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 text-center",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4 tracking-tight",children:"Ready to Find Out What Your Home Is Worth?"}),e.jsxs("p",{className:"text-gray-400 mb-8 text-lg",children:["Get your free, no-obligation market analysis from ",o," today."]}),e.jsxs("div",{className:"flex flex-wrap gap-4 justify-center",children:[e.jsx("button",{onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),className:"px-8 py-3.5 text-white font-semibold rounded-xl transition-colors text-lg",style:{backgroundColor:l},children:"Get My Free Valuation"}),e.jsxs("button",{onClick:()=>r("/contact"),className:"px-8 py-3.5 border border-white/20 text-white hover:bg-white/10 font-semibold rounded-xl transition-colors text-lg",children:["Contact ",o]})]})]})})]})}function c5s({agentName:t,city:s,accentColor:r}){const[n,a]=N.useState(null),o=s||"your area",l=[{q:`How do I know what my home is worth in ${o}?`,a:`${t} provides a complimentary Comparative Market Analysis (CMA) using current MLS data — recent sales, active listings, and market trends in ${o}. This gives you an accurate, data-driven estimate of your home's value.`},{q:"How long does it take to sell a home?",a:`The timeline varies based on market conditions, pricing, and property condition. In ${o}, well-priced homes typically sell within the average days-on-market for the area. ${t} will give you a realistic timeline based on current data.`},{q:"What should I do to prepare my home for sale?",a:`${t} will walk through your home and provide a personalized checklist — from decluttering and minor repairs to staging recommendations. The goal is to maximize your home's appeal without over-investing.`},{q:"How much does it cost to sell a home?",a:"Typical costs include agent commissions, closing costs (1-3% of sale price), and any agreed-upon repairs or concessions. Your net proceeds depend on your sale price, mortgage payoff, and these costs. We'll provide a detailed net sheet upfront."},{q:"Should I make repairs before listing?",a:`It depends on the repair and the market. ${t} will help you identify high-ROI improvements versus things that won't meaningfully impact your sale price. In a strong seller's market, fewer repairs may be needed.`},{q:`What's the best time of year to sell in ${o}?`,a:`While spring and summer tend to see more buyer activity, ${o}'s market has its own patterns. ${t} can show you seasonal trends from MLS data to help you choose the optimal listing window.`}],i={"@context":"https://schema.org","@type":"FAQPage",mainEntity:l.map(c=>({"@type":"Question",name:c.q,acceptedAnswer:{"@type":"Answer",text:c.a}}))};return e.jsxs(e.Fragment,{children:[e.jsx(Sc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(i)})}),e.jsx("div",{className:"space-y-3",children:l.map((c,u)=>e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(n===u?null:u),className:"w-full flex items-center justify-between px-6 py-4 text-left",children:[e.jsx("span",{className:"font-medium text-gray-900 text-sm pr-4",children:c.q}),e.jsx(da,{className:`h-4 w-4 text-gray-400 flex-shrink-0 transition-transform ${n===u?"rotate-90":""}`})]}),n===u&&e.jsx("div",{className:"px-6 pb-5 text-sm text-gray-600 leading-relaxed border-t border-gray-100 pt-4",children:c.a})]},u))})]})}function d5s(t,s,r){return[{question:`What is the housing market like in ${t}, ${s}?`,answer:`The ${t} real estate market offers a diverse range of properties from single-family homes to condos. Contact ${r} for a personalized market analysis with the latest pricing trends, inventory levels, and neighborhood insights.`},{question:`What are the best neighborhoods in ${t}?`,answer:`${t} has many desirable neighborhoods, each with unique character, school districts, and amenities. ${r} can help you identify the best fit based on your lifestyle, commute, and budget. Explore the community guide for detailed neighborhood profiles.`},{question:`How much does a home cost in ${t}, ${s}?`,answer:`Home prices in ${t} vary by neighborhood, property type, and condition. Browse current listings to see real-time pricing, or reach out to ${r} for a free home valuation if you're considering selling.`},{question:`Is ${t} a good place to buy a home?`,answer:`${t} offers strong community amenities, quality schools, and a growing local economy that make it attractive for homebuyers. ${r} can walk you through market conditions and help you determine if now is the right time to buy.`},{question:`How do I find a real estate agent in ${t}?`,answer:`${r} is a local ${t} real estate expert specializing in buying, selling, and investment properties. With deep knowledge of the area's neighborhoods, pricing trends, and school districts, ${r} provides personalized guidance throughout your real estate journey.`},{question:`What are the property taxes in ${t}, ${s}?`,answer:`Property tax rates in ${t} vary by county and school district. ${r} can provide specific tax information for any property you're interested in, helping you understand the full cost of homeownership in the area.`}]}function u5s({city:t,state:s="",agentName:r,accentColor:n="#3b82f6"}){const a=d5s(t,s,r),[o,l]=N.useState(null);return e.jsxs("section",{className:"py-16 bg-gray-50",children:[e.jsx(C3s,{faqs:a}),e.jsxs("div",{className:"max-w-3xl mx-auto px-6",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-gray-400 mb-2 font-medium text-center",children:"Common Questions"}),e.jsxs("h2",{className:"text-3xl font-bold text-gray-900 tracking-tight text-center mb-10",children:["Frequently Asked Questions About ",t]}),e.jsx("div",{className:"space-y-3",children:a.map((i,c)=>{const u=o===c;return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden transition-shadow hover:shadow-sm",children:[e.jsxs("button",{onClick:()=>l(u?null:c),className:"w-full flex items-center justify-between px-6 py-5 text-left",children:[e.jsx("span",{className:"font-semibold text-gray-900 pr-4",children:i.question}),u?e.jsx(pf,{className:"h-5 w-5 text-gray-400 flex-shrink-0"}):e.jsx(Eo,{className:"h-5 w-5 text-gray-400 flex-shrink-0"})]}),u&&e.jsx("div",{className:"px-6 pb-5",children:e.jsx("p",{className:"text-gray-600 leading-relaxed",children:i.answer})})]},c)})})]})]})}function h5s({cityName:t,citySlug:s,agentName:r,total:n,medianPrice:a,avgDom:o,accentColor:l,heroImageUrl:i}){const c=fr();return e.jsxs("section",{className:"relative min-h-[480px] flex items-center justify-center overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-cover bg-center",style:{backgroundImage:`url(${i||"https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?w=1600&q=80"})`}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/60 via-black/50 to-black/70"}),e.jsxs("div",{className:"relative z-10 max-w-4xl mx-auto px-6 py-20 text-center text-white",children:[e.jsxs("nav",{className:"flex items-center justify-center gap-2 text-sm text-white/60 mb-6",children:[e.jsx(Pi,{to:"/",className:"hover:text-white transition-colors",children:"Home"}),e.jsx("span",{children:"›"}),e.jsx(Pi,{to:"/search",className:"hover:text-white transition-colors",children:"Search"}),e.jsx("span",{children:"›"}),e.jsx("span",{className:"text-white",children:t})]}),e.jsxs(Hs.h1,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"text-4xl md:text-5xl lg:text-6xl font-bold mb-4 tracking-tight",children:["Homes for Sale in ",t]}),e.jsxs(Hs.p,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:.1},className:"text-lg text-white/80 max-w-2xl mx-auto mb-8",children:["Browse available properties in ",t," with ",r,", your local real estate expert."]}),e.jsxs(Hs.div,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:.2},className:"flex flex-wrap items-center justify-center gap-4 mb-8",children:[n>0&&e.jsxs("div",{className:"px-5 py-2.5 bg-white/10 backdrop-blur-md rounded-full border border-white/20",children:[e.jsx("span",{className:"text-2xl font-bold",children:n.toLocaleString()}),e.jsx("span",{className:"text-sm text-white/70 ml-2",children:"Active Listings"})]}),a&&a>0&&e.jsxs("div",{className:"px-5 py-2.5 bg-white/10 backdrop-blur-md rounded-full border border-white/20",children:[e.jsxs("span",{className:"text-2xl font-bold",children:["$",(a/1e3).toFixed(0),"K"]}),e.jsx("span",{className:"text-sm text-white/70 ml-2",children:"Median Price"})]}),o&&o>0&&e.jsxs("div",{className:"px-5 py-2.5 bg-white/10 backdrop-blur-md rounded-full border border-white/20",children:[e.jsx("span",{className:"text-2xl font-bold",children:Math.round(o)}),e.jsx("span",{className:"text-sm text-white/70 ml-2",children:"Avg Days on Market"})]})]}),e.jsxs(Hs.button,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},onClick:()=>c(`/search?q=${encodeURIComponent(t)}`),className:"inline-flex items-center gap-2 px-7 py-3.5 text-white font-semibold rounded-xl transition-colors text-lg",style:{backgroundColor:l},children:[e.jsx(cn,{className:"h-5 w-5"}),"Search All ",t," Listings"]})]})]})}function m5s({cityName:t,description:s,highlights:r,agentName:n,accentColor:a}){return!s&&r.length===0?null:e.jsx("section",{className:"py-16 md:py-20 bg-white",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsxs(Hs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase font-semibold mb-3",style:{color:a},children:"Discover the Area"}),e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:["Why Live in ",t,"?"]})]}),s&&e.jsx(Hs.div,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:.1},className:"max-w-3xl mx-auto mb-14",children:e.jsx("div",{className:"text-gray-600 leading-relaxed text-[17px] space-y-4",children:s.split(` `).map((o,l)=>e.jsx("p",{children:o},l))})}),r.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5",children:r.map((o,l)=>e.jsxs(Hs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:l*.06},className:"group bg-gray-50 hover:bg-white rounded-2xl p-6 border border-gray-100 hover:border-gray-200 hover:shadow-lg transition-all duration-300",children:[e.jsx("span",{className:"text-3xl mb-3 block",children:o.icon}),e.jsx("h3",{className:"font-bold text-gray-900 text-lg mb-1.5",children:o.title}),e.jsx("p",{className:"text-gray-500 text-sm leading-relaxed",children:o.text})]},l))})]})})}function p5s({listings:t,cityName:s,accentColor:r}){const n=fr(),a=N.useRef(null),[o,l]=N.useState(!1),[i,c]=N.useState(!1),u=()=>{const f=a.current;f&&(l(f.scrollLeft>10),c(f.scrollLeft{const f=a.current;if(f)return u(),f.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u),()=>{f.removeEventListener("scroll",u),window.removeEventListener("resize",u)}},[t]);const p=f=>{const g=a.current;g&&g.scrollBy({left:f==="left"?-680:680,behavior:"smooth"})};return t.length?e.jsx("section",{className:"py-16 md:py-20 overflow-hidden bg-white",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6",children:[e.jsxs("div",{className:"flex items-end justify-between mb-10",children:[e.jsxs("div",{children:[e.jsx(Hs.p,{initial:{opacity:0,y:10},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-sm tracking-[0.2em] uppercase font-semibold mb-2",style:{color:r},children:"Featured Properties"}),e.jsxs(Hs.h2,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:.05},className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:[s," Listings"]}),e.jsx(Hs.p,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},transition:{delay:.1},className:"text-gray-500 mt-1.5",children:"Currently available properties on the market"})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[e.jsx("button",{onClick:()=>p("left"),disabled:!o,className:"p-3 rounded-full border border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300 transition-all disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(cl,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>p("right"),disabled:!i,className:"p-3 rounded-full border border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300 transition-all disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(da,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative -mx-6",children:[e.jsxs("div",{ref:a,className:"flex gap-5 overflow-x-auto scrollbar-hide px-6 snap-x snap-mandatory",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[t.map((f,g)=>{var b,_,j;return e.jsx(Hs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.4,delay:g*.05},onClick:()=>n(`/listing/${f.mlsNumber}`),className:"group min-w-[300px] sm:min-w-[320px] max-w-[340px] flex-shrink-0 snap-start cursor-pointer",children:e.jsxs("div",{className:"bg-white rounded-2xl overflow-hidden shadow-[0_2px_20px_-4px_rgba(0,0,0,0.08)] hover:shadow-[0_8px_40px_-8px_rgba(0,0,0,0.15)] transition-all duration-500 h-full flex flex-col",children:[e.jsxs("div",{className:"relative h-56 overflow-hidden",children:[e.jsx("img",{src:((b=f.photos)==null?void 0:b[0])||"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=600&q=75",alt:`${f.address}, ${f.city}`,className:"w-full h-full object-cover group-hover:scale-[1.06] transition-transform duration-700 ease-out",loading:"lazy"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/50 via-transparent to-transparent"}),e.jsx("div",{className:"absolute top-3 left-3 px-3 py-1 rounded-full text-[11px] font-bold tracking-wide uppercase text-white backdrop-blur-md",style:{backgroundColor:`${r}cc`},children:f.status||"Active"}),e.jsx("div",{className:"absolute bottom-3 left-3",children:e.jsxs("p",{className:"text-2xl font-bold text-white drop-shadow-lg",children:["$",(_=f.price)==null?void 0:_.toLocaleString()]})})]}),e.jsxs("div",{className:"p-4 flex-1 flex flex-col",children:[e.jsx("p",{className:"text-gray-900 font-semibold text-[15px] leading-snug mb-1 truncate",children:f.address}),e.jsxs("p",{className:"text-gray-500 text-sm mb-3 truncate",children:[f.city,", ",f.state," ",f.zip]}),e.jsxs("div",{className:"flex items-center gap-4 mt-auto pt-3 border-t border-gray-100",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(Im,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:f.bedrooms})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(Ju,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:f.bathrooms})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(oS,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"text-sm font-medium",children:[(j=f.sqft)==null?void 0:j.toLocaleString()," sqft"]})]})]})]})]})},f.mlsNumber)}),e.jsx(Hs.div,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},onClick:()=>n(`/search?q=${encodeURIComponent(s)}`),className:"min-w-[200px] flex-shrink-0 snap-start cursor-pointer flex items-center justify-center",children:e.jsxs("div",{className:"text-center group",children:[e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center mx-auto mb-3 transition-transform group-hover:scale-110",style:{backgroundColor:`${r}15`},children:e.jsx(Qa,{className:"h-6 w-6",style:{color:r}})}),e.jsx("p",{className:"text-sm font-semibold text-gray-700 group-hover:text-gray-900 transition-colors",children:"View All"})]})})]}),e.jsx("div",{className:"absolute right-0 top-0 bottom-0 w-12 bg-gradient-to-l from-white to-transparent pointer-events-none md:hidden"})]})]})}):null}function f5s({listings:t,cityName:s,accentColor:r}){const n=fr(),[a,o]=N.useState(null);return!t.some(i=>i.latitude&&i.longitude)&&t.length===0?null:e.jsx("section",{className:"py-16 md:py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs(Hs.div,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-10",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase font-semibold mb-3",style:{color:r},children:"Explore the Map"}),e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:["Properties in ",s]}),e.jsx("p",{className:"text-gray-500 mt-2",children:"Click any marker to view property details"})]}),e.jsx(Hs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:.1},className:"rounded-2xl overflow-hidden border border-gray-200 shadow-sm",style:{height:"500px"},children:e.jsx(kct,{listings:t,onListingClick:i=>n(`/listing/${i}`),hoveredMlsNumber:a})})]})})}function x5s({cityName:t,total:s,medianPrice:r,avgDom:n,pricePerSqft:a,accentColor:o}){if(s===0&&!r)return null;const l=[{icon:bn,label:"Active Listings",value:s>0?s.toLocaleString():"—",sublabel:"Currently on market"},{icon:nc,label:"Median Price",value:r?`$${(r/1e3).toFixed(0)}K`:"—",sublabel:"Active listings"},{icon:un,label:"Avg Days on Market",value:n?Math.round(n).toString():"—",sublabel:"Time to sell"},{icon:ul,label:"Price per Sq Ft",value:a?`$${Math.round(a)}`:"—",sublabel:"Average $/sqft"}];return e.jsx("section",{className:"py-16 md:py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsxs(Hs.div,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase font-semibold mb-3",style:{color:o},children:"Market Snapshot"}),e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:[t," Real Estate at a Glance"]})]}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-5",children:l.map((i,c)=>{const u=i.icon;return e.jsxs(Hs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:c*.08},className:"bg-white rounded-2xl p-6 border border-gray-100 shadow-sm text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mx-auto mb-4",style:{backgroundColor:`${o}15`},children:e.jsx(u,{className:"h-6 w-6",style:{color:o}})}),e.jsx("p",{className:"text-3xl font-bold text-gray-900 mb-1",children:i.value}),e.jsx("p",{className:"text-sm font-semibold text-gray-700 mb-0.5",children:i.label}),e.jsx("p",{className:"text-xs text-gray-400",children:i.sublabel})]},c)})})]})})}function g5s({cityName:t,agentName:s,accentColor:r}){const n=fr();return e.jsx("section",{className:"py-20 bg-gray-900 text-white",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 text-center",children:[e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold mb-4 tracking-tight",children:["Ready to Find Your Home in ",t,"?"]}),e.jsxs("p",{className:"text-gray-400 mb-10 text-lg leading-relaxed",children:[s," knows ",t," inside and out. Get personalized guidance on the best neighborhoods, pricing, and available properties."]}),e.jsxs("div",{className:"flex flex-wrap gap-4 justify-center",children:[e.jsxs("button",{onClick:()=>n("/contact"),className:"px-8 py-3.5 text-white font-semibold rounded-xl transition-colors text-lg",style:{backgroundColor:r},children:["Contact ",s]}),e.jsx("button",{onClick:()=>n(`/search?q=${encodeURIComponent(t)}`),className:"px-8 py-3.5 border border-white/20 text-white hover:bg-white/10 font-semibold rounded-xl transition-colors text-lg",children:"Browse All Listings"})]})]})})}function y5s({siteConfig:t,citySlugOverride:s}){var M;const r=yo(),n=s||r.citySlug;fr();const[a,o]=N.useState([]),[l,i]=N.useState(!0),[c,u]=N.useState(0),[p,f]=N.useState(null),g=N.useMemo(()=>(n||"").split("-").map(L=>L.charAt(0).toUpperCase()+L.slice(1)).join(" "),[n]),b=((M=t.agent)==null?void 0:M.full_name)||"Your Agent",_=t.accentColor||"#3b82f6",j=`https://${t.subdomainSlug}.thelocalmove.com`,w=`Homes for Sale in ${g} | ${b}`,k=`Browse ${g} homes for sale with ${b}. View listings, pricing, photos, and neighborhood info. Your trusted local real estate expert.`;N.useEffect(()=>{n&&(async()=>{const{data:I}=await H.from("lead_site_city_pages").select("description, highlights, hero_image_url").eq("site_id",t.id).eq("city_slug",n||"").eq("is_published",!0).maybeSingle();I&&f({description:I.description,highlights:Array.isArray(I.highlights)?I.highlights:[],hero_image_url:I.hero_image_url})})()},[t.id,n]),N.useEffect(()=>{g&&(async()=>{i(!0);try{const O=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-search",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({leadSiteId:t.id,filterCities:[g],limit:1e3,page:1}),signal:AbortSignal.timeout(15e3)});if(O.ok){const q=await O.json();o(q.listings||[]),u(q.total||0)}}catch{}finally{i(!1)}})()},[g,t.id]);const S=N.useMemo(()=>{if(!a.length)return{medianPrice:null,avgDom:null,pricePerSqft:null};const L=a.map(V=>V.price).filter(V=>!!V&&V>0).sort((V,Z)=>V-Z),I=L.length>0?L[Math.floor(L.length/2)]:null,O=a.map(V=>V.dom||V.daysOnMarket).filter(V=>typeof V=="number"&&V>=0),q=O.length>0?O.reduce((V,Z)=>V+Z,0)/O.length:null,U=a.filter(V=>V.price&&V.sqft&&V.sqft>0),B=U.length>0?U.reduce((V,Z)=>V+Z.price/Z.sqft,0)/U.length:null;return{medianPrice:I,avgDom:q,pricePerSqft:B}},[a]);return e.jsxs("div",{className:"min-h-screen bg-white",children:[e.jsx(fCe,{siteConfig:t,pagePath:`/homes-for-sale-in-${n}`}),e.jsx(xCe,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Search",path:"/search"},{name:`${g} Homes`,path:`/homes-for-sale-in-${n}`}]}),e.jsxs(Sc,{children:[e.jsx("title",{children:w}),e.jsx("meta",{name:"description",content:k}),e.jsx("link",{rel:"canonical",href:`${j}/homes-for-sale-in-${n}`}),e.jsx("meta",{property:"og:title",content:w}),e.jsx("meta",{property:"og:description",content:k}),e.jsx("meta",{property:"og:url",content:`${j}/homes-for-sale-in-${n}`}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:site_name",content:t.siteTitle||b}),((p==null?void 0:p.hero_image_url)||t.ogImageUrl)&&e.jsx("meta",{property:"og:image",content:(p==null?void 0:p.hero_image_url)||t.ogImageUrl||""}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:w}),e.jsx("meta",{name:"twitter:description",content:k}),((p==null?void 0:p.hero_image_url)||t.ogImageUrl)&&e.jsx("meta",{name:"twitter:image",content:(p==null?void 0:p.hero_image_url)||t.ogImageUrl||""})]}),e.jsx(h5s,{cityName:g,citySlug:n||"",agentName:b,total:c,medianPrice:S.medianPrice,avgDom:S.avgDom,accentColor:_,heroImageUrl:(p==null?void 0:p.hero_image_url)||void 0}),e.jsx(m5s,{cityName:g,description:(p==null?void 0:p.description)||null,highlights:(p==null?void 0:p.highlights)||[],agentName:b,accentColor:_}),e.jsx(x5s,{cityName:g,total:c,medianPrice:S.medianPrice,avgDom:S.avgDom,pricePerSqft:S.pricePerSqft,accentColor:_}),!l&&e.jsx(p5s,{listings:a.slice(0,12),cityName:g,accentColor:_}),!l&&a.length>0&&e.jsx(f5s,{listings:a,cityName:g,accentColor:_}),e.jsx(u5s,{city:g,agentName:b,accentColor:_}),e.jsx(g5s,{cityName:g,agentName:b,accentColor:_})]})}function v5s(){const{siteConfig:t,themeConfig:s,isLoading:r,error:n}=N3s();return r?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-blue-600 border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500",children:"Loading..."})]})}):n||!t?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 p-6",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Site Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This lead site is not available or has not been set up yet."})]})}):e.jsx(k3s,{siteConfig:t,children:e.jsx(L3s,{siteConfig:t,children:e.jsxs(O2e,{children:[e.jsx(ks,{path:"/",element:e.jsx(z3s,{siteConfig:t,themeConfig:s??void 0})}),e.jsx(ks,{path:"/search",element:e.jsx(Y3s,{siteConfig:t})}),e.jsx(ks,{path:"/listing/:mlsNumber",element:e.jsx(r5s,{siteConfig:t})}),e.jsx(ks,{path:"/about",element:e.jsx(n5s,{siteConfig:t})}),e.jsx(ks,{path:"/contact",element:e.jsx(a5s,{siteConfig:t})}),e.jsx(ks,{path:"/account",element:e.jsx(i5s,{siteConfig:t})}),e.jsx(ks,{path:"/blog",element:e.jsx(Qze,{siteConfig:t})}),e.jsx(ks,{path:"/blog/:slug",element:e.jsx(Qze,{siteConfig:t})}),e.jsx(ks,{path:"/sell",element:e.jsx(l5s,{siteConfig:t,themeConfig:s??void 0})}),e.jsx(ks,{path:"/community",element:e.jsx(o5s,{siteConfig:t})}),e.jsx(ks,{path:"/*",element:e.jsx(b5s,{siteConfig:t})})]})})})}function b5s({siteConfig:t}){const r=zd().pathname.match(/^\/homes-for-sale-in-(.+)$/);return r?e.jsx(y5s,{siteConfig:t,citySlugOverride:r[1]}):null}const _5s=({team:t,onSelect:s})=>{const{data:r}=mt({queryKey:["team-card-info",t.id],queryFn:async()=>{const{data:n}=await H.from("team_members").select("user_id, role").eq("team_id",t.id),a=(n==null?void 0:n.length)||0,o=n==null?void 0:n.find(i=>i.role==="team_leader");let l=null;if(o){const{data:i}=await H.from("profiles").select("name, avatar_url").eq("id",o.user_id).single();l=i}return{count:a,leaderProfile:l}}});return e.jsxs(Ee,{className:"cursor-pointer hover:shadow-md transition-shadow group",onClick:s,children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(gr,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(tt,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(pr,{className:"h-3 w-3 mr-1"}),(r==null?void 0:r.count)??"…"]})]})}),e.jsxs(De,{className:"space-y-3",children:[(r==null?void 0:r.leaderProfile)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx($a,{src:r.leaderProfile.avatar_url||""}),e.jsx(kn,{className:"text-xs",children:(r.leaderProfile.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Dm,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),r.leaderProfile.name||"Team Leader"]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(th,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"capitalize text-xs",children:t.contact_visibility.replace("_"," ")})]}),t.lead_pond_enabled&&e.jsx(tt,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),t.shared_assets_enabled&&e.jsx(tt,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),t.shared_videos_enabled&&e.jsx(tt,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},w5s=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=Ds(),l=o||(a.length>0?a[0].id:n),i=s?void 0:l||void 0,{teams:c,isLoading:u,createTeam:p,updateTeam:f,deleteTeam:g,addMember:b,removeMember:_,updateMemberRole:j}=bC(i),[w,k]=N.useState(!1),[S,M]=N.useState(null),{data:L}=mt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:q,error:U}=await H.from("brokerages").select("id, name").order("name");if(U)throw U;return q||[]},enabled:s}),{data:I}=mt({queryKey:["brokerage-agents-for-teams",l],queryFn:async()=>{const{data:q,error:U}=await H.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",l).order("name");if(U)throw U;return q||[]},enabled:!!l}),O=async q=>{const U=q.brokerage_id||l||null,B=await p.mutateAsync({name:q.name,brokerage_id:U,description:q.description});if(q.leaderId&&q.leaderId!=="none"&&await b.mutateAsync({team_id:B.id,user_id:q.leaderId,role:"team_leader"}),q.memberIds)for(const V of q.memberIds)await b.mutateAsync({team_id:B.id,user_id:V,role:"team_member"});k(!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(pr,{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:()=>k(!0),children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(ltt,{open:w,onOpenChange:k,onCreateTeam:O,isCreating:p.isPending,brokerageAgents:I||[],isAdmin:s,allBrokerages:L,activeBrokerageId:l}),u&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(q=>e.jsx(Ee,{children:e.jsxs(De,{className:"p-6",children:[e.jsx(ys,{className:"h-5 w-32 mb-3"}),e.jsx(ys,{className:"h-4 w-48 mb-4"}),e.jsx(ys,{className:"h-8 w-full"})]})},q))}),!u&&c.length===0&&!S&&e.jsx(Ee,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first team to organize agents and share resources."}),e.jsxs(K,{onClick:()=>k(!0),children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Create Your First Team"]})]})}),!u&&c.length>0&&!S&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:c.map(q=>e.jsx(_5s,{team:q,onSelect:()=>M(q)},q.id))}),S&&e.jsx(ott,{team:S,brokerageAgents:I||[],onBack:()=>M(null),onUpdate:q=>f.mutateAsync({id:S.id,...q}).then(U=>M(U)),onAddMember:(q,U)=>b.mutateAsync({team_id:S.id,user_id:q,role:U}),onRemoveMember:q=>_.mutateAsync({team_id:S.id,member_id:q}),onUpdateRole:(q,U)=>j.mutateAsync({team_id:S.id,member_id:q,role:U}),onDeleteTeam:()=>g.mutate(S.id),isUpdating:f.isPending,isAddingMember:b.isPending})]})})},j5s=()=>{const{data:t,isLoading:s}=Bx(),{useTeamMembers:r}=bC(),{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(ys,{className:"h-8 w-48"}),e.jsx(ys,{className:"h-40 w-full"})]})});if(!t)return e.jsx(Ms,{title:"My Team",description:"Your team",children:e.jsx(Ee,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pr,{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(tt,{variant:t.role==="team_leader"?"default":"secondary",className:"capitalize",children:t.role==="team_leader"?e.jsxs(e.Fragment,{children:[e.jsx(Dm,{className:"mr-1 h-3 w-3"})," Leader"]}):"Member"})]}),o.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:o.description})]}),e.jsxs(ba,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(pa,{className:"flex-wrap",children:[e.jsx(ns,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(ns,{value:"contacts",children:[e.jsx(J4,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(ns,{value:"lead-pond",children:[e.jsx(Yg,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(ns,{value:"shared-assets",children:[e.jsx(Om,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]})]}),e.jsx(bs,{value:"members",className:"space-y-2",children:a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(l=>e.jsx(ys,{className:"h-16 w-full"},l))}):n.map(l=>{var i,c,u,p;return e.jsx(Ee,{children:e.jsxs(De,{className:"flex items-center gap-3 p-4",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:((i=l.profile)==null?void 0:i.avatar_url)||""}),e.jsx(kn,{children:(((c=l.profile)==null?void 0:c.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium",children:((u=l.profile)==null?void 0:u.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(p=l.profile)==null?void 0:p.email})]}),l.role==="team_leader"?e.jsxs(tt,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[e.jsx(Dm,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(tt,{variant:"secondary",className:"ml-auto",children:"Member"})]})},l.id)})}),o.contact_visibility!=="private"&&e.jsx(bs,{value:"contacts",className:"space-y-4",children:e.jsx(Dke,{})}),o.lead_pond_enabled&&e.jsx(bs,{value:"lead-pond",className:"space-y-4",children:e.jsx(Oke,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx(bs,{value:"shared-assets",className:"space-y-4",children:e.jsx(itt,{teamId:t.teamId})})]})]})})};function N5s(){const{user:t}=Ds(),s=Qt(),r=mt({queryKey:["booking-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await H.from("agent_booking_settings").select("*").eq("user_id",t.id).maybeSingle();if(k)throw k;return w},enabled:!!t}),n=mt({queryKey:["booking-types",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await H.from("agent_booking_types").select("*").eq("user_id",t.id).order("sort_order");if(k)throw k;return w},enabled:!!t}),a=mt({queryKey:["availability-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await H.from("agent_availability_slots").select("*").eq("user_id",t.id).order("day_of_week").order("start_time");if(k)throw k;return w},enabled:!!t}),o=mt({queryKey:["blocked-dates",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await H.from("agent_blocked_dates").select("*").eq("user_id",t.id).order("blocked_date");if(k)throw k;return w},enabled:!!t}),l=mt({queryKey:["bookings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await H.from("bookings").select("*, booking_type:agent_booking_types(*)").eq("agent_user_id",t.id).order("booking_date",{ascending:!1});if(k)throw k;return w},enabled:!!t}),i=Dt({mutationFn:async()=>{const{data:w,error:k}=await H.from("agent_booking_settings").insert({user_id:t.id,slug:""}).select().single();if(k)throw k;const S=[{name:"Listing Consultation",description:"Get a comprehensive market analysis and listing strategy for your home",duration_minutes:60,color:"#10B981",icon:"Home",sort_order:0},{name:"Buyer Consultation",description:"Discuss your home search criteria, budget, and buying process",duration_minutes:45,color:"#3B82F6",icon:"Search",sort_order:1},{name:"Home Valuation",description:"Find out what your home is worth in today's market",duration_minutes:30,color:"#F59E0B",icon:"DollarSign",sort_order:2},{name:"General Meeting",description:"Coffee chat, check-in, or quick real estate question",duration_minutes:30,color:"#8B5CF6",icon:"Coffee",sort_order:3}],{error:M}=await H.from("agent_booking_types").insert(S.map(O=>({...O,user_id:t.id})));if(M)throw M;const L=[1,2,3,4,5].map(O=>({user_id:t.id,day_of_week:O,start_time:"09:00",end_time:"17:00"})),{error:I}=await H.from("agent_availability_slots").insert(L);if(I)throw I;return w},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),s.invalidateQueries({queryKey:["booking-types"]}),s.invalidateQueries({queryKey:["availability-slots"]}),me.success("Scheduler set up successfully!")},onError:w=>me.error(w.message)}),c=Dt({mutationFn:async w=>{const{error:k}=await H.from("agent_booking_settings").update(w).eq("user_id",t.id);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),me.success("Settings updated")},onError:w=>me.error(w.message)}),u=Dt({mutationFn:async w=>{const k={...w,user_id:t.id};if(w.id){const{error:S}=await H.from("agent_booking_types").update(k).eq("id",w.id);if(S)throw S}else{const{error:S}=await H.from("agent_booking_types").insert(k);if(S)throw S}},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),me.success("Booking type saved")},onError:w=>me.error(w.message)}),p=Dt({mutationFn:async w=>{const{error:k}=await H.from("agent_booking_types").delete().eq("id",w);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),me.success("Booking type deleted")},onError:w=>me.error(w.message)}),f=Dt({mutationFn:async w=>{const k={...w,user_id:t.id};if(w.id){const{error:S}=await H.from("agent_availability_slots").update(k).eq("id",w.id);if(S)throw S}else{const{error:S}=await H.from("agent_availability_slots").insert(k);if(S)throw S}},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>me.error(w.message)}),g=Dt({mutationFn:async w=>{const{error:k}=await H.from("agent_availability_slots").delete().eq("id",w);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>me.error(w.message)}),b=Dt({mutationFn:async w=>{const{error:k}=await H.from("agent_blocked_dates").insert({...w,user_id:t.id});if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]}),me.success("Date blocked")},onError:w=>me.error(w.message)}),_=Dt({mutationFn:async w=>{const{error:k}=await H.from("agent_blocked_dates").delete().eq("id",w);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]})},onError:w=>me.error(w.message)}),j=Dt({mutationFn:async({id:w,reason:k})=>{const{error:S}=await H.from("bookings").update({status:"cancelled",cancelled_at:new Date().toISOString(),cancel_reason:k}).eq("id",w);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["bookings"]}),me.success("Booking cancelled")},onError:w=>me.error(w.message)});return{settings:r.data,bookingTypes:n.data??[],availability:a.data??[],blockedDates:o.data??[],bookings:l.data??[],isLoading:r.isLoading,initializeSettings:i,updateSettings:c,upsertBookingType:u,deleteBookingType:p,upsertAvailability:f,deleteAvailability:g,addBlockedDate:b,removeBlockedDate:_,cancelBooking:j}}const Jze={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function k5s({types:t,onSave:s,onDelete:r}){const[n,a]=N.useState(null),[o,l]=N.useState(!1),i=()=>{a({name:"",description:"",duration_minutes:30,color:"#3B82F6",icon:"Calendar",is_active:!0,qualification_enabled:!1}),l(!0)},c=p=>{a({...p}),l(!0)},u=()=>{n!=null&&n.name&&(s(n),l(!1),a(null))};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Booking Types"}),e.jsx(gr,{children:"The meeting types prospects can book with you"})]}),e.jsxs(K,{onClick:i,size:"sm",children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Add Type"]})]}),e.jsx(De,{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:Jze[p.icon]||"📅"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:p.name}),!p.is_active&&e.jsx(tt,{variant:"secondary",className:"text-xs",children:"Inactive"}),p.qualification_enabled&&e.jsxs(tt,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(mL,{className:"h-3 w-3"})," Qualifying"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(un,{className:"h-3 w-3"}),p.duration_minutes," min",p.description&&e.jsxs("span",{children:["· ",p.description.slice(0,60),p.description.length>60?"...":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(p),children:e.jsx(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(Nr,{className:"h-4 w-4"})})]})]},p.id))})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsxs(vs,{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(ze,{value:n.name||"",onChange:p=>a({...n,name:p.target.value}),placeholder:"e.g. Listing Consultation"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Er,{value:n.description||"",onChange:p=>a({...n,description:p.target.value}),placeholder:"Brief description for prospects",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Duration (minutes)"}),e.jsx(ze,{type:"number",min:15,max:180,step:15,value:n.duration_minutes||30,onChange:p=>a({...n,duration_minutes:parseInt(p.target.value)||30})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(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(ze,{value:n.color||"#3B82F6",onChange:p=>a({...n,color:p.target.value}),className:"flex-1"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Icon"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(Jze).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(ze,{value:n.meeting_link_override||"",onChange:p=>a({...n,meeting_link_override:p.target.value||null}),placeholder:"Use a different link for this type"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Pre-Qualification Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask qualifying questions before booking"})]}),e.jsx(qr,{checked:n.qualification_enabled||!1,onCheckedChange:p=>a({...n,qualification_enabled:p})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Active"}),e.jsx(qr,{checked:n.is_active??!0,onCheckedChange:p=>a({...n,is_active:p})})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:u,children:"Save"})]})]})})]})}const e9e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function S5s({slots:t,onSave:s,onDelete:r}){const[n,a]=N.useState(null),[o,l]=N.useState("09:00"),[i,c]=N.useState("17:00"),u=e9e.map((f,g)=>t.filter(b=>b.day_of_week===g)),p=()=>{n!==null&&(s({day_of_week:n,start_time:o,end_time:i,is_active:!0}),a(null),l("09:00"),c("17:00"))};return e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-5 w-5"}),"Weekly Availability"]}),e.jsx(gr,{children:"Set your available hours for each day"})]}),e.jsx(De,{className:"space-y-2",children:e9e.map((f,g)=>{const b=u[g];return e.jsxs("div",{className:"flex items-start gap-3 py-2 border-b last:border-0",children:[e.jsx("div",{className:"w-24 pt-1",children:e.jsx("p",{className:"text-sm font-medium",children:f})}),e.jsxs("div",{className:"flex-1 space-y-1",children:[b.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"Unavailable"}):b.map(_=>{var j,w;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(j=_.start_time)==null?void 0:j.slice(0,5),onBlur:k=>s({id:_.id,start_time:k.target.value})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(ze,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(w=_.end_time)==null?void 0:w.slice(0,5),onBlur:k=>s({id:_.id,end_time:k.target.value})}),e.jsx(qr,{checked:_.is_active,onCheckedChange:k=>s({id:_.id,is_active:k})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>r(_.id),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},_.id)}),n===g?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"time",className:"w-28 h-8 text-sm",value:o,onChange:_=>l(_.target.value)}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(ze,{type:"time",className:"w-28 h-8 text-sm",value:i,onChange:_=>c(_.target.value)}),e.jsx(K,{size:"sm",className:"h-8",onClick:p,children:"Add"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8",onClick:()=>a(null),children:"Cancel"})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground",onClick:()=>a(g),children:[e.jsx($s,{className:"h-3 w-3 mr-1"})," Add hours"]})]})]},f)})})]})}const C5s={confirmed:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",cancelled:"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400",completed:"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",no_show:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"};function M5s({bookings:t,onCancel:s}){const r=t.filter(o=>o.status==="confirmed"&&new Date(o.booking_date)>=new Date(new Date().toDateString())),n=t.filter(o=>o.status!=="confirmed"||new Date(o.booking_date){var i,c;return e.jsxs("div",{className:"flex items-start justify-between p-4 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:o.guest_name}),e.jsx(tt,{className:`text-xs ${C5s[o.status]||""}`,children:o.status})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Dd,{className:"h-3.5 w-3.5"}),ms(new Date(o.booking_date+"T00:00:00"),"MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3.5 w-3.5"}),(i=o.start_time)==null?void 0:i.slice(0,5)," - ",(c=o.end_time)==null?void 0:c.slice(0,5)]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[o.guest_email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(cr,{className:"h-3 w-3"}),o.guest_email]}),o.guest_phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Un,{className:"h-3 w-3"}),o.guest_phone]})]}),o.booking_type&&e.jsx(tt,{variant:"outline",className:"text-xs mt-1",children:o.booking_type.name}),o.guest_message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 italic",children:['"',o.guest_message,'"']})]}),l&&o.status==="confirmed"&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s(o.id),className:"text-destructive hover:text-destructive",children:[e.jsx(vc,{className:"h-4 w-4 mr-1"})," Cancel"]})]},o.id)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Upcoming Bookings"}),e.jsxs(gr,{children:[r.length," upcoming appointment",r.length!==1?"s":""]})]}),e.jsx(De,{children:r.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No upcoming bookings"}):e.jsx("div",{className:"space-y-3",children:r.map(o=>a(o,!0))})})]}),n.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Past & Cancelled"})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-3",children:n.slice(0,20).map(o=>a(o))})})]})]})}function T5s({blockedDates:t,onAdd:s,onRemove:r}){const[n,a]=N.useState(!1),[o,l]=N.useState(""),[i,c]=N.useState(""),u=()=>{o&&(s({blocked_date:o,reason:i||void 0}),a(!1),l(""),c(""))};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(JI,{className:"h-5 w-5"}),"Blocked Dates"]}),e.jsx(gr,{children:"Block specific dates (vacations, holidays, etc.)"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>a(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Block Date"]})]}),e.jsxs(De,{children:[n&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx(ze,{type:"date",value:o,onChange:p=>l(p.target.value),className:"w-40"}),e.jsx(ze,{placeholder:"Reason (optional)",value:i,onChange:p=>c(p.target.value),className:"flex-1"}),e.jsx(K,{size:"sm",onClick:u,children:"Add"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>a(!1),children:"Cancel"})]}),t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No blocked dates"}):e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(p=>e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full border bg-muted/50 text-sm",children:[e.jsx("span",{children:ms(new Date(p.blocked_date+"T00:00:00"),"MMM d, yyyy")}),p.reason&&e.jsxs("span",{className:"text-muted-foreground",children:["(",p.reason,")"]}),e.jsx("button",{onClick:()=>r(p.id),className:"ml-1 text-muted-foreground hover:text-destructive",children:e.jsx(Rr,{className:"h-3.5 w-3.5"})})]},p.id))})]})]})}function A5s(){const{settings:t,bookingTypes:s,availability:r,blockedDates:n,bookings:a,isLoading:o,initializeSettings:l,updateSettings:i,upsertBookingType:c,deleteBookingType:u,upsertAvailability:p,deleteAvailability:f,addBlockedDate:g,removeBlockedDate:b,cancelBooking:_}=N5s(),[j,w]=N.useState(""),[k,S]=N.useState(15);j||t!=null&&t.meeting_link;const M=t!=null&&t.slug?`https://booking.relevelup.com/${t.slug}`:null;return o?e.jsx(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(Dd,{className:"h-6 w-6 text-primary"}),"LevelUp Scheduler"]}),e.jsx("p",{className:"text-muted-foreground",children:"Manage your booking types, availability, and appointments"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[M&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(M),me.success("Booking link copied!")},children:[e.jsx(gi,{className:"h-4 w-4 mr-1"})," Copy Link"]}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:M,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{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(qr,{id:"scheduler-active",checked:t.is_active,onCheckedChange:L=>i.mutate({is_active:L})})]})]})]}),e.jsxs(ba,{defaultValue:"types",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"types",children:"Booking Types"}),e.jsx(ns,{value:"availability",children:"Availability"}),e.jsx(ns,{value:"settings",children:"Settings"}),e.jsxs(ns,{value:"bookings",children:["Bookings",a.filter(L=>L.status==="confirmed").length>0&&e.jsx(tt,{variant:"secondary",className:"ml-1.5 text-xs",children:a.filter(L=>L.status==="confirmed").length})]})]}),e.jsx(bs,{value:"types",children:e.jsx(k5s,{types:s,onSave:L=>c.mutate(L),onDelete:L=>u.mutate(L)})}),e.jsx(bs,{value:"availability",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(S5s,{slots:r,onSave:L=>p.mutate(L),onDelete:L=>f.mutate(L)}),e.jsx(T5s,{blockedDates:n,onAdd:L=>g.mutate(L),onRemove:L=>b.mutate(L)})]})}),e.jsx(bs,{value:"settings",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(kL,{className:"h-5 w-5"}),"General Settings"]}),e.jsx(gr,{children:"Configure your booking page defaults"})]}),e.jsxs(De,{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(ze,{value:t.slug,readOnly:!0,className:"bg-muted"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>{M&&(navigator.clipboard.writeText(M),me.success("Copied!"))},children:e.jsx(gi,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:M})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"meeting-link",children:[e.jsx(dl,{className:"h-4 w-4 inline mr-1"}),"Default Meeting Link"]}),e.jsx(ze,{id:"meeting-link",placeholder:"https://zoom.us/j/your-personal-link",defaultValue:t.meeting_link||"",onBlur:L=>i.mutate({meeting_link:L.target.value||null})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Zoom personal link, Google Meet, or phone number"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Buffer Between Meetings"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"number",min:0,max:60,defaultValue:t.buffer_minutes,onBlur:L=>i.mutate({buffer_minutes:parseInt(L.target.value)||15})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"min"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Minimum Notice"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"number",min:0,max:72,defaultValue:t.min_notice_hours,onBlur:L=>i.mutate({min_notice_hours:parseInt(L.target.value)||2})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"hours"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Max Advance Booking"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"number",min:1,max:90,defaultValue:t.max_advance_days,onBlur:L=>i.mutate({max_advance_days:parseInt(L.target.value)||30})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"days"})]})]})]})]})]})}),e.jsx(bs,{value:"bookings",children:e.jsx(M5s,{bookings:a,onCancel:L=>_.mutate({id:L})})})]})]})}):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(Dd,{className:"h-8 w-8 text-primary"})}),e.jsx("h1",{className:"text-3xl font-bold",children:"LevelUp Scheduler"}),e.jsx("p",{className:"text-muted-foreground text-lg max-w-md mx-auto",children:"Your own booking page — built for real estate. Prospects book with you, get auto-added to your CRM, and you never miss a lead."})]}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-6 space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[{icon:"🏠",title:"Listing Consultation",desc:"60 min"},{icon:"🔍",title:"Buyer Consultation",desc:"45 min"},{icon:"💰",title:"Home Valuation",desc:"30 min"},{icon:"☕",title:"General Meeting",desc:"30 min"}].map(L=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx("span",{className:"text-2xl",children:L.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:L.desc})]})]},L.title))}),e.jsx(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(pn,{className:"h-4 w-4 mr-2"}),l.isPending?"Setting up...":"Activate Scheduler"]})]})})]})})}const t9e=[{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 E5s(){const{user:t}=Ds(),s=ci(),{toast:r}=Ua(),n=fr(),a=Qt(),[o,l]=N.useState(!1),[i,c]=N.useState(null),[u,p]=N.useState(null),[f,g]=N.useState({title:"",description:"",page_type:"lead_capture"}),{data:b=[],isLoading:_}=mt({queryKey:["landing-pages",s],queryFn:async()=>{const{data:S,error:M}=await H.from("landing_pages").select("*").eq("user_id",s).order("created_at",{ascending:!1});if(M)throw M;return S},enabled:!!s}),j=Dt({mutationFn:async()=>{const S=f.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")+"-"+Date.now().toString(36),{data:M}=await H.from("profiles").select("name, phone, avatar_url, email").eq("id",s).single(),L=f.page_type==="just_listed"||f.page_type==="just_sold",{data:I,error:O}=await H.from("landing_pages").insert({user_id:s,title:f.title,description:f.description||null,page_type:f.page_type,slug:S,hero_headline:L?f.page_type==="just_listed"?"🏡 Just Listed":"🎉 Just Sold":f.page_type==="lead_magnet"?"📥 Free Download":f.title,agent_name:(M==null?void 0:M.name)||null,agent_phone:(M==null?void 0:M.phone)||null,agent_email:(M==null?void 0:M.email)||t.email||null,agent_photo_url:(M==null?void 0:M.avatar_url)||null,property_status:L?f.page_type.replace("just_",""):null}).select().single();if(O)throw O;const q=P5s(f.page_type);if(q.length>0){const{error:U}=await H.from("landing_page_fields").insert(q.map((B,V)=>({...B,page_id:I.id,sort_order:V})));if(U)throw U}return I},onSuccess:S=>{a.invalidateQueries({queryKey:["landing-pages"]}),l(!1),g({title:"",description:"",page_type:"lead_capture"}),r({title:"Landing page created!"}),n(`/mission-control/landing-pages/${S.id}`)},onError:S=>r({title:"Error",description:S.message,variant:"destructive"})}),w=Dt({mutationFn:async S=>{const{error:M}=await H.from("landing_pages").delete().eq("id",S);if(M)throw M},onSuccess:()=>{a.invalidateQueries({queryKey:["landing-pages"]}),c(null),r({title:"Landing page deleted"})}}),k=S=>`https://pages.relevelup.com/${S}`;return e.jsxs(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($s,{className:"h-4 w-4 mr-2"})," New Page"]})]}),_?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):b.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(Sn,{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($s,{className:"h-4 w-4 mr-2"})," Create Landing Page"]})]})}):e.jsx("div",{className:"grid gap-4",children:b.map(S=>{var M;return e.jsx(Ee,{className:"hover:shadow-md transition-shadow",children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>n(`/mission-control/landing-pages/${S.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:S.title}),e.jsx(tt,{variant:S.is_published?"default":"secondary",className:"text-[10px]",children:S.is_published?"Published":"Draft"}),e.jsx(tt,{variant:"outline",className:"text-[10px]",children:((M=t9e.find(L=>L.id===S.page_type))==null?void 0:M.label)||S.page_type})]}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:S.description}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(On,{className:"h-3 w-3"})," ",S.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"})," ",S.submission_count," submissions"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[S.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>p(k(S.slug)),children:e.jsx(c1,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(k(S.slug)),r({title:"Link copied!"})},children:e.jsx(gi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:k(S.slug),target:"_blank",rel:"noopener noreferrer",children:e.jsx(tn,{className:"h-3.5 w-3.5"})})})]}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{size:"sm",variant:"ghost",children:e.jsx(mx,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[e.jsxs(Ma,{onClick:()=>n(`/mission-control/landing-pages/${S.id}`),children:[e.jsx(Ra,{className:"h-3.5 w-3.5 mr-2"})," Edit"]}),e.jsxs(Ma,{onClick:()=>c(S.id),className:"text-destructive",children:[e.jsx(Nr,{className:"h-3.5 w-3.5 mr-2"})," Delete"]})]})]})]})]})})},S.id)})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Create Landing Page"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Page Title"}),e.jsx(ze,{value:f.title,onChange:S=>g(M=>({...M,title:S.target.value})),placeholder:"e.g. Veterans Home & Land Expo"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description (optional)"}),e.jsx(Er,{value:f.description,onChange:S=>g(M=>({...M,description:S.target.value})),placeholder:"Brief internal description...",rows:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Page Template"}),e.jsxs(Zs,{value:f.page_type,onValueChange:S=>g(M=>({...M,page_type:S})),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:t9e.map(S=>e.jsx(Mt,{value:S.id,children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:S.label}),e.jsx("div",{className:"text-xs text-muted-foreground",children:S.description})]})},S.id))})]})]})]}),e.jsxs(qn,{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(kc,{open:!!i,onOpenChange:()=>c(null),children:e.jsxs(Xl,{children:[e.jsxs(Ql,{children:[e.jsx(ec,{children:"Delete Landing Page?"}),e.jsx(tc,{children:"This will permanently delete this page and all its submissions."})]}),e.jsxs(Jl,{children:[e.jsx(sc,{children:"Cancel"}),e.jsx(Ol,{onClick:()=>i&&w.mutate(i),children:"Delete"})]})]})}),e.jsx(fs,{open:!!u,onOpenChange:()=>p(null),children:e.jsxs(ps,{className:"max-w-sm",children:[e.jsx(_s,{children:e.jsx(vs,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[u&&e.jsx(kR,{value:u,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:u}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{u&&(navigator.clipboard.writeText(u),r({title:"URL copied!"}))},children:[e.jsx(gi,{className:"h-3.5 w-3.5 mr-1"})," Copy URL"]})]})]})})]})}function P5s(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 I5s=[{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 L5s(){const{pageId:t}=yo(),s=fr(),{user:r}=Ds(),n=ci(),{toast:a}=Ua(),o=Qt(),[l,i]=N.useState(null),[c,u]=N.useState(!1),{data:p,isLoading:f}=mt({queryKey:["landing-page",t],queryFn:async()=>{const{data:re,error:oe}=await H.from("landing_pages").select("*").eq("id",t).single();if(oe)throw oe;return re},enabled:!!t}),{data:g=[],isLoading:b}=mt({queryKey:["landing-page-fields",t],queryFn:async()=>{const{data:re,error:oe}=await H.from("landing_page_fields").select("*").eq("page_id",t).order("sort_order");if(oe)throw oe;return re},enabled:!!t}),{data:_=[]}=mt({queryKey:["landing-page-submissions",t],queryFn:async()=>{const{data:re,error:oe}=await H.from("landing_page_submissions").select("*").eq("page_id",t).order("created_at",{ascending:!1});if(oe)throw oe;return re},enabled:!!t}),{data:j=[]}=mt({queryKey:["my-listings-for-pages",n],queryFn:async()=>{const{data:re,error:oe}=await H.from("listings").select("id, property_address, city, state, price, bedrooms, bathrooms, square_footage, description, status").eq("agent_id",n).order("created_at",{ascending:!1});if(oe)throw oe;return re},enabled:!!r&&((p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold")}),[w,k]=N.useState({title:"",hero_headline:"",hero_subtext:"",hero_image_url:null,logo_url:null,primary_color:"#406E71",accent_color:"#2a4c64",agent_name:"",agent_phone:"",agent_email:"",agent_photo_url:null,success_message:"Thank you! We'll be in touch soon.",is_published:!1,description:"",lead_magnet_file_url:null,lead_magnet_file_name:null,lead_magnet_external_url:null,listing_id:null,property_address:"",property_price:"",property_beds:"",property_baths:"",property_sqft:"",property_description:"",property_photos:[],property_status:"just_listed"}),[S,M]=N.useState([]);N.useEffect(()=>{p&&k({title:p.title,hero_headline:p.hero_headline,hero_subtext:p.hero_subtext||"",hero_image_url:p.hero_image_url,logo_url:p.logo_url,primary_color:p.primary_color,accent_color:p.accent_color,agent_name:p.agent_name||"",agent_phone:p.agent_phone||"",agent_email:p.agent_email||"",agent_photo_url:p.agent_photo_url,success_message:p.success_message||"Thank you! We'll be in touch soon.",is_published:p.is_published,description:p.description||"",lead_magnet_file_url:p.lead_magnet_file_url||null,lead_magnet_file_name:p.lead_magnet_file_name||null,lead_magnet_external_url:p.lead_magnet_external_url||null,listing_id:p.listing_id||null,property_address:p.property_address||"",property_price:p.property_price||"",property_beds:p.property_beds||"",property_baths:p.property_baths||"",property_sqft:p.property_sqft||"",property_description:p.property_description||"",property_photos:Array.isArray(p.property_photos)?p.property_photos:[],property_status:p.property_status||"just_listed"})},[p]),N.useEffect(()=>{g.length>0&&M(g.map(re=>({id:re.id,field_type:re.field_type,label:re.label,placeholder:re.placeholder,is_required:re.is_required,options:typeof re.options=="string"?re.options:re.options?JSON.stringify(re.options):null,sort_order:re.sort_order})))},[g]);const L=Dt({mutationFn:async()=>{const{error:re}=await H.from("landing_pages").update({title:w.title,hero_headline:w.hero_headline,hero_subtext:w.hero_subtext||null,hero_image_url:w.hero_image_url,logo_url:w.logo_url,primary_color:w.primary_color,accent_color:w.accent_color,agent_name:w.agent_name||null,agent_phone:w.agent_phone||null,agent_email:w.agent_email||null,agent_photo_url:w.agent_photo_url,success_message:w.success_message,is_published:w.is_published,description:w.description||null,lead_magnet_file_url:w.lead_magnet_file_url,lead_magnet_file_name:w.lead_magnet_file_name,lead_magnet_external_url:w.lead_magnet_external_url,listing_id:w.listing_id,property_address:w.property_address||null,property_price:w.property_price||null,property_beds:w.property_beds||null,property_baths:w.property_baths||null,property_sqft:w.property_sqft||null,property_description:w.property_description||null,property_photos:w.property_photos,property_status:w.property_status,updated_at:new Date().toISOString()}).eq("id",t);if(re)throw re;if(await H.from("landing_page_fields").delete().eq("page_id",t),S.length>0){const{error:oe}=await H.from("landing_page_fields").insert(S.map((ce,xe)=>({page_id:t,field_type:ce.field_type,label:ce.label,placeholder:ce.placeholder||null,is_required:ce.is_required,options:ce.options?JSON.parse(ce.options):null,sort_order:xe})));if(oe)throw oe}},onSuccess:()=>{o.invalidateQueries({queryKey:["landing-page",t]}),o.invalidateQueries({queryKey:["landing-page-fields",t]}),a({title:"Page saved!"})},onError:re=>a({title:"Error",description:re.message,variant:"destructive"})}),I=async(re,oe)=>{const ce=re.name.split(".").pop(),xe=`landing-pages/${r.id}/${oe}-${Date.now()}.${ce}`,{error:ge}=await H.storage.from("recruit-landing").upload(xe,re);if(ge)throw ge;const{data:{publicUrl:ue}}=H.storage.from("recruit-landing").getPublicUrl(xe);return ue},O=async(re,oe)=>{var xe;const ce=(xe=re.target.files)==null?void 0:xe[0];if(ce){i(oe);try{const ge=await I(ce,oe);k(ue=>({...ue,[oe]:ge})),a({title:"Image uploaded!"})}catch(ge){a({title:"Upload failed",description:ge.message,variant:"destructive"})}finally{i(null)}}},q=async re=>{var ce;const oe=(ce=re.target.files)==null?void 0:ce[0];if(oe){i("lead_magnet");try{const xe=await I(oe,"lead-magnet");k(ge=>({...ge,lead_magnet_file_url:xe,lead_magnet_file_name:oe.name})),a({title:"File uploaded!"})}catch(xe){a({title:"Upload failed",description:xe.message,variant:"destructive"})}finally{i(null)}}},U=async re=>{const oe=re.target.files;if(!(!oe||oe.length===0)){i("property_photos");try{const ce=[];for(const xe of Array.from(oe)){const ge=await I(xe,"property-photo");ce.push(ge)}k(xe=>({...xe,property_photos:[...xe.property_photos,...ce]})),a({title:`${ce.length} photo(s) uploaded!`})}catch(ce){a({title:"Upload failed",description:ce.message,variant:"destructive"})}finally{i(null)}}},B=async re=>{const oe=j.find(xe=>xe.id===re);if(!oe)return;const{data:ce}=await H.from("listing_photos").select("photo_url").eq("listing_id",re).order("sort_order");k(xe=>({...xe,listing_id:re,property_address:oe.property_address||`${oe.city}, ${oe.state}`,property_price:oe.price?`$${oe.price.toLocaleString()}`:"",property_beds:oe.bedrooms?String(oe.bedrooms):"",property_baths:oe.bathrooms?String(oe.bathrooms):"",property_sqft:oe.square_footage?oe.square_footage.toLocaleString():"",property_description:oe.description||"",property_photos:(ce==null?void 0:ce.map(ge=>ge.photo_url))||xe.property_photos})),a({title:"Listing data imported!"})},V=()=>{M(re=>[...re,{field_type:"text",label:"",placeholder:"",is_required:!1,options:null,sort_order:re.length}])},Z=(re,oe)=>{M(ce=>ce.map((xe,ge)=>ge===re?{...xe,...oe}:xe))},X=re=>{M(oe=>oe.filter((ce,xe)=>xe!==re))},ee=p?`https://pages.relevelup.com/${p.slug}`:"",Q=(p==null?void 0:p.page_type)==="lead_magnet",ie=(p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold";return f||b?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(Ja,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:w.title||"Untitled Page"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(tt,{variant:w.is_published?"default":"secondary",className:"text-[10px]",children:w.is_published?"Published":"Draft"}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(On,{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(pr,{className:"h-3 w-3"})," ",_.length," submissions"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[w.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>u(!0),children:e.jsx(c1,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(ee),a({title:"Link copied!"})},children:[e.jsx(gi,{className:"h-3.5 w-3.5 mr-1"})," Copy Link"]}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:ee,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(K,{onClick:()=>L.mutate(),disabled:L.isPending,children:[e.jsx(qc,{className:"h-4 w-4 mr-2"}),L.isPending?"Saving...":"Save"]})]})]}),e.jsxs(ba,{defaultValue:"design",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"design",children:"Design"}),Q&&e.jsx(ns,{value:"lead_magnet",children:"Lead Magnet"}),ie&&e.jsx(ns,{value:"property",children:"Property Details"}),e.jsxs(ns,{value:"fields",children:["Form Fields (",S.length,")"]}),e.jsxs(ns,{value:"submissions",children:["Submissions (",_.length,")"]}),e.jsx(ns,{value:"settings",children:"Settings"})]}),e.jsxs(bs,{value:"design",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Page Details"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Page Title (internal)"}),e.jsx(ze,{value:w.title,onChange:re=>k(oe=>({...oe,title:re.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description (internal)"}),e.jsx(ze,{value:w.description,onChange:re=>k(oe=>({...oe,description:re.target.value}))})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Hero Section"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Headline"}),e.jsx(ze,{value:w.hero_headline,onChange:re=>k(oe=>({...oe,hero_headline:re.target.value})),placeholder:"Join us for..."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Subtext"}),e.jsx(Er,{value:w.hero_subtext,onChange:re=>k(oe=>({...oe,hero_subtext:re.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(li,{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:re=>O(re,"hero_image_url")})]}),w.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k(re=>({...re,hero_image_url:null})),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Branding"})}),e.jsxs(De,{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(li,{className:"h-3.5 w-3.5 mr-1"}),l==="logo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:re=>O(re,"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(li,{className:"h-3.5 w-3.5 mr-1"}),l==="agent_photo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:re=>O(re,"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:re=>k(oe=>({...oe,primary_color:re.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:w.primary_color,onChange:re=>k(oe=>({...oe,primary_color:re.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:re=>k(oe=>({...oe,accent_color:re.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:w.accent_color,onChange:re=>k(oe=>({...oe,accent_color:re.target.value})),className:"font-mono text-xs"})]})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Agent Info (shown on page)"})}),e.jsx(De,{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(ze,{value:w.agent_name,onChange:re=>k(oe=>({...oe,agent_name:re.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Phone"}),e.jsx(ze,{value:w.agent_phone,onChange:re=>k(oe=>({...oe,agent_phone:re.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Email"}),e.jsx(ze,{value:w.agent_email,onChange:re=>k(oe=>({...oe,agent_email:re.target.value}))})]})]})})]})]}),Q&&e.jsx(bs,{value:"lead_magnet",className:"space-y-4 mt-4",children:e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(yi,{className:"h-4 w-4"})," Giveaway File"]})}),e.jsxs(De,{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(tt,{variant:"outline",className:"gap-1",children:[e.jsx(yi,{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(li,{className:"h-3.5 w-3.5 mr-1"}),l==="lead_magnet"?"Uploading...":"Upload File"]})}),e.jsx("input",{type:"file",className:"hidden",onChange:q})]}),w.lead_magnet_file_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k(re=>({...re,lead_magnet_file_url:null,lead_magnet_file_name:null})),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"flex-1 border-t"}),e.jsx("span",{children:"OR"}),e.jsx("div",{className:"flex-1 border-t"})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1",children:[e.jsx(dl,{className:"h-3.5 w-3.5"})," External URL"]}),e.jsx(ze,{value:w.lead_magnet_external_url||"",onChange:re=>k(oe=>({...oe,lead_magnet_external_url:re.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"})]})]})]})}),ie&&e.jsxs(bs,{value:"property",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(bn,{className:"h-4 w-4"})," Import from Listing Exchange"]})}),e.jsxs(De,{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(Zs,{value:w.listing_id||"",onValueChange:re=>B(re),children:[e.jsx(Ws,{children:e.jsx(Xs,{placeholder:"Select a listing to import..."})}),e.jsx(Gs,{children:j.map(re=>{var oe;return e.jsxs(Mt,{value:re.id,children:[re.property_address||`${re.city}, ${re.state}`," — $",(oe=re.price)==null?void 0:oe.toLocaleString()]},re.id)})})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Property Information"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Property Address"}),e.jsx(ze,{value:w.property_address,onChange:re=>k(oe=>({...oe,property_address:re.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(ze,{value:w.property_price,onChange:re=>k(oe=>({...oe,property_price:re.target.value})),placeholder:"$450,000"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Beds"}),e.jsx(ze,{value:w.property_beds,onChange:re=>k(oe=>({...oe,property_beds:re.target.value})),placeholder:"4"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Baths"}),e.jsx(ze,{value:w.property_baths,onChange:re=>k(oe=>({...oe,property_baths:re.target.value})),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Sq Ft"}),e.jsx(ze,{value:w.property_sqft,onChange:re=>k(oe=>({...oe,property_sqft:re.target.value})),placeholder:"2,400"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Er,{value:w.property_description,onChange:re=>k(oe=>({...oe,property_description:re.target.value})),rows:3,placeholder:"Beautiful home in a great neighborhood..."})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Property Photos"})}),e.jsxs(De,{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((re,oe)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:re,alt:`Property ${oe+1}`,className:"h-24 w-full object-cover rounded"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>k(ce=>({...ce,property_photos:ce.property_photos.filter((xe,ge)=>ge!==oe)})),children:e.jsx(Nr,{className:"h-3 w-3"})})]},oe))}),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(li,{className:"h-3.5 w-3.5 mr-1"}),l==="property_photos"?"Uploading...":"Add Photos"]})}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:U})]})]})]})]}),e.jsxs(bs,{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($s,{className:"h-3.5 w-3.5 mr-1"})," Add Field"]})]}),S.length===0?e.jsx(Ee,{children:e.jsx(De,{className:"py-8 text-center text-muted-foreground",children:"No fields yet. Add fields to build your form."})}):e.jsx("div",{className:"space-y-3",children:S.map((re,oe)=>e.jsx(Ee,{children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Cu,{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(Zs,{value:re.field_type,onValueChange:ce=>Z(oe,{field_type:ce}),children:[e.jsx(Ws,{children:e.jsx(Xs,{})}),e.jsx(Gs,{children:I5s.map(ce=>e.jsx(Mt,{value:ce.value,children:ce.label},ce.value))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Label"}),e.jsx(ze,{value:re.label,onChange:ce=>Z(oe,{label:ce.target.value}),placeholder:"e.g. Full Name"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Placeholder"}),e.jsx(ze,{value:re.placeholder||"",onChange:ce=>Z(oe,{placeholder:ce.target.value}),placeholder:"Optional hint text"})]})]}),(re.field_type==="select"||re.field_type==="multiselect")&&e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Options (comma-separated)"}),e.jsx(ze,{value:re.options?(typeof re.options=="string"?JSON.parse(re.options):re.options).join(", "):"",onChange:ce=>Z(oe,{options:JSON.stringify(ce.target.value.split(",").map(xe=>xe.trim()).filter(Boolean))}),placeholder:"Option 1, Option 2, Option 3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:re.is_required,onCheckedChange:ce=>Z(oe,{is_required:ce})}),e.jsx(ve,{className:"text-xs",children:"Required"})]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>X(oe),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]})})},oe))})]}),e.jsx(bs,{value:"submissions",className:"mt-4",children:_.length===0?e.jsx(Ee,{children:e.jsx(De,{className:"py-12 text-center text-muted-foreground",children:"No submissions yet. Share your page to start collecting leads!"})}):e.jsx("div",{className:"space-y-3",children:_.map(re=>e.jsx(Ee,{children:e.jsx(De,{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:re.contact_name||"Anonymous"}),re.synced_to_crm&&e.jsx(tt,{variant:"outline",className:"text-[10px]",children:"Synced"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground mt-0.5",children:[re.contact_email&&e.jsx("span",{className:"mr-3",children:re.contact_email}),re.contact_phone&&e.jsx("span",{children:re.contact_phone})]}),re.answers&&typeof re.answers=="object"&&e.jsx("div",{className:"mt-2 text-sm space-y-1",children:Object.entries(re.answers).map(([oe,ce])=>e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-muted-foreground",children:[oe,":"]})," ",e.jsx("span",{children:String(ce)})]},oe))})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(re.created_at).toLocaleDateString()})]})})},re.id))})}),e.jsxs(bs,{value:"settings",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Publishing"})}),e.jsxs(De,{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(qr,{checked:w.is_published,onCheckedChange:re=>k(oe=>({...oe,is_published:re}))})]}),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:ee})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Thank You Message"})}),e.jsx(De,{children:e.jsx(Er,{value:w.success_message,onChange:re=>k(oe=>({...oe,success_message:re.target.value})),rows:2,placeholder:"Message shown after form submission"})})]})]})]})]}),e.jsx(fs,{open:c,onOpenChange:u,children:e.jsxs(ps,{className:"max-w-sm",children:[e.jsx(_s,{children:e.jsx(vs,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx(kR,{value:ee,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:ee})]})]})})]}):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 s9e({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(WI,{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(HI,{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 D5s={Phone:Un,MessageSquare:so,Mail:cr,Gift:ko,PenTool:q_,Video:An},r9e=["bg-primary","bg-emerald-500","bg-amber-500","bg-sky-500","bg-purple-500","bg-orange-500","bg-pink-500","bg-teal-500"];function O5s(){const t=fr(),{contactsWithScores:s,stats:r}=Nue(),{data:n}=$O(365),{data:a}=CNe(),{data:o}=BO(),l=NNe(),i=N.useMemo(()=>{if(!n)return{touchesThisMonth:0,touchesLastMonth:0,touchTrend:0};const M=new Date,L=Fc(M),I=lx(M),O=Fc(y4(M,1)),q=lx(y4(M,1)),U=n.filter(Z=>Rg(new Date(Z.completed_at),{start:L,end:I})).length,B=n.filter(Z=>Rg(new Date(Z.completed_at),{start:O,end:q})).length,V=B>0?Math.round((U-B)/B*100):U>0?100:0;return{touchesThisMonth:U,touchesLastMonth:B,touchTrend:V}},[n]),c=N.useMemo(()=>{if(!n)return 0;const M=new Date,L=Fc(M),I=lx(M);return new Set(n.filter(O=>Rg(new Date(O.completed_at),{start:L,end:I})).map(O=>O.contact_id)).size},[n]),u=N.useMemo(()=>{if(!a)return{closedThisMonth:0,totalGCI:0};const M=new Date,L=Fc(M),I=lx(M),O=a.filter(q=>q.close_date&&Rg(Dl(q.close_date),{start:L,end:I}));return{closedThisMonth:O.length,totalGCI:O.reduce((q,U)=>q+(Number(U.commission_amount)||0),0)}},[a]),p=N.useMemo(()=>{if(!s.length)return{newThisMonth:0,newLastMonth:0,trend:0};const M=new Date,L=Fc(M),I=Fc(y4(M,1)),O=lx(y4(M,1)),q=s.filter(V=>new Date(V.created_at)>=L).length,U=s.filter(V=>Rg(new Date(V.created_at),{start:I,end:O})).length,B=U>0?Math.round((q-U)/U*100):q>0?100:0;return{newThisMonth:q,newLastMonth:U,trend:B}},[s]),f=N.useMemo(()=>{if(!n||!o)return[];const M=new Date,L=Fc(M),I=lx(M),O=n.filter(B=>Rg(new Date(B.completed_at),{start:L,end:I})),q={};O.forEach(B=>{const V=B.action_type_id;q[V]=(q[V]||0)+1});const U=O.length||1;return o.filter(B=>q[B.id]).map(B=>({id:B.id,name:B.name,icon:B.icon,count:q[B.id]||0,percent:Math.round((q[B.id]||0)/U*100)})).sort((B,V)=>V.count-B.count)},[n,o]),g=N.useMemo(()=>[...s].filter(M=>M.relationshipScore.status==="at-risk"||M.relationshipScore.status==="cooling").sort((M,L)=>{const I=M.relationshipScore.daysSinceTouch??9999;return(L.relationshipScore.daysSinceTouch??9999)-I}).slice(0,5),[s]),b=N.useMemo(()=>{if(!n)return[];const M=new Date,L=Fc(M),I=lx(M),O=new Set(n.filter(q=>Rg(new Date(q.completed_at),{start:L,end:I})).map(q=>q.contact_id));return s.filter(q=>q.relationshipScore.status==="warm"&&O.has(q.id)&&q.relationshipScore.touchCountLast12Months>=2).sort((q,U)=>U.relationshipScore.score-q.relationshipScore.score).slice(0,5)},[s,n]),_=N.useMemo(()=>{if(!n)return{currentStreak:0,longestStreak:0};const M=new Set(n.map(V=>{const Z=new Date(V.completed_at);return`${Z.getFullYear()}-${Z.getMonth()}-${Z.getDate()}`})),L=new Date;L.setHours(0,0,0,0);let I=0,O=new Date(L);for(;M.has(`${O.getFullYear()}-${O.getMonth()}-${O.getDate()}`);)I++,O.setDate(O.getDate()-1);let q=0,U=0;if(Array.from(M).sort().length>0){const V=n.map(Z=>{const X=new Date(Z.completed_at);return X.setHours(0,0,0,0),X.getTime()}).filter((Z,X,ee)=>ee.indexOf(Z)===X).sort((Z,X)=>Z-X);U=1;for(let Z=1;Z[...s].sort((M,L)=>M.relationshipScore.score-L.relationshipScore.score),[s]),w=j.filter(M=>M.relationshipScore.status==="warm"),k=j.filter(M=>M.relationshipScore.status==="cooling"),S=j.filter(M=>M.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:[ms(new Date,"MMMM yyyy")," — Your monthly relationship health report"]})]}),_.currentStreak>0&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-full bg-orange-500/10 border border-orange-500/20",children:[e.jsx(eh,{className:"h-5 w-5 text-orange-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-orange-600 dark:text-orange-400",children:_.currentStreak}),e.jsx("span",{className:"text-sm text-muted-foreground ml-1",children:"day streak"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(ni,{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(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(kh,{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(s9e,{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(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(pr,{className:"h-4 w-4"}),"Reached"]}),e.jsx("div",{className:"text-3xl font-bold",children:c}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["of ",r.total," contacts"]})]})}),e.jsx(Ee,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(ul,{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(s9e,{value:p.trend})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"added this month"})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(zm,{className:"h-4 w-4 text-primary"}),"Weekly Goal"]})}),e.jsxs(De,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[l.actionsThisWeek," of ",l.weeklyGoal," touches"]}),e.jsxs("span",{className:"text-sm font-medium",children:[Math.round(l.progress),"%"]})]}),e.jsx(Bi,{value:l.progress,className:"h-3"}),l.progress>=100&&e.jsxs("p",{className:"text-xs text-emerald-600 dark:text-emerald-400 mt-2 flex items-center gap-1",children:[e.jsx(xo,{className:"h-3 w-3"}),"Goal reached! 🎉"]}),l.progress<100&&l.progress>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[l.weeklyGoal-l.actionsThisWeek," more to hit your goal"]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(eh,{className:"h-4 w-4 text-orange-500"}),"Momentum"]})}),e.jsxs(De,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Current Streak"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xl font-bold",children:_.currentStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"}),_.currentStreak>=7&&e.jsx("span",{className:"ml-1",children:"🔥"}),_.currentStreak>=30&&e.jsx("span",{children:"🏆"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Longest Streak"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xl font-bold",children:_.longestStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"})]})]}),_.currentStreak===0&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 italic",children:"Log a touch today to start your streak!"})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(kh,{className:"h-4 w-4"}),"How You're Reaching Out"]})}),e.jsx(De,{children:f.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No touches logged this month yet."}):e.jsx("div",{className:"space-y-2.5",children:f.slice(0,5).map((M,L)=>{const I=D5s[M.icon||""]||kh;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(I,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:M.name})]}),e.jsxs("span",{className:"text-muted-foreground",children:[M.count," (",M.percent,"%)"]})]}),e.jsx(Bi,{value:M.percent,className:It("h-1.5 bg-muted [&>div]:",r9e[L%r9e.length])})]},M.id)})})})]})]}),g.length>0&&e.jsxs(Ee,{className:"border-l-4 border-l-primary",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Un,{className:"h-5 w-5 text-primary"}),"Who to Reach Out to Today"]}),e.jsxs(tt,{variant:"secondary",children:[g.length," contacts"]})]}),e.jsx(gr,{children:"These relationships need attention the most"})]}),e.jsx(De,{children:e.jsx("div",{className:"space-y-2",children:g.map(M=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card hover:bg-accent/50 cursor-pointer transition-colors",onClick:()=>t(`/mission-control/contacts/${M.id}`),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(y8,{score:M.relationshipScore,showScore:!0,size:"sm",showTooltip:!1}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[M.first_name," ",M.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:M.relationshipScore.daysSinceTouch===null?"Never contacted":`Last touch ${M.relationshipScore.daysSinceTouch}d ago`})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[M.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:L=>{L.stopPropagation(),window.open(`tel:${M.phone}`)},children:e.jsx(Un,{className:"h-4 w-4"})}),M.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:L=>{L.stopPropagation(),window.open(`mailto:${M.email}`)},children:e.jsx(cr,{className:"h-4 w-4"})}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})]})]},M.id))})})]}),b.length>0&&e.jsxs(Ee,{className:"border-l-4 border-l-emerald-500",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Nc,{className:"h-5 w-5 text-emerald-500"}),"Biggest Wins This Month"]}),e.jsx(gr,{children:"Relationships you've successfully warmed up"})]}),e.jsx(De,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:b.map(M=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-full bg-emerald-500/10 border border-emerald-500/20 cursor-pointer hover:bg-emerald-500/20 transition-colors",onClick:()=>t(`/mission-control/contacts/${M.id}`),children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),e.jsxs("span",{className:"text-sm font-medium",children:[M.first_name," ",M.last_name]}),e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400 font-bold",children:M.relationshipScore.score})]},M.id))})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ee,{className:"border-l-4 border-l-emerald-500",children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Warm"}),e.jsx("p",{className:"text-3xl font-bold text-emerald-600 dark:text-emerald-400",children:r.warm})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🟢"})})]}),e.jsx(Bi,{value:r.total?r.warm/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-emerald-500"})]})}),e.jsx(Ee,{className:"border-l-4 border-l-amber-500",children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Cooling Off"}),e.jsx("p",{className:"text-3xl font-bold text-amber-600 dark:text-amber-400",children:r.cooling})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🟡"})})]}),e.jsx(Bi,{value:r.total?r.cooling/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-amber-500"})]})}),e.jsx(Ee,{className:"border-l-4 border-l-red-500",children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"At Risk"}),e.jsx("p",{className:"text-3xl font-bold text-red-600 dark:text-red-400",children:r.atRisk})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-red-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🔴"})})]}),e.jsx(Bi,{value:r.total?r.atRisk/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-red-500"})]})})]}),e.jsx(Ee,{children:e.jsx(De,{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(iL,{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(ba,{defaultValue:"at-risk",children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"at-risk",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),"At Risk (",r.atRisk,")"]}),e.jsxs(ns,{value:"cooling",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-500"}),"Cooling (",r.cooling,")"]}),e.jsxs(ns,{value:"warm",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),"Warm (",r.warm,")"]})]}),[{key:"at-risk",contacts:S},{key:"cooling",contacts:k},{key:"warm",contacts:w}].map(({key:M,contacts:L})=>e.jsx(bs,{value:M,children:e.jsx(Ee,{children:e.jsx(De,{className:"p-0",children:L.length===0?e.jsx("p",{className:"p-6 text-center text-muted-foreground",children:"No contacts in this category"}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Contact"}),e.jsx(St,{className:"hidden md:table-cell",children:"Last Touch"}),e.jsx(St,{className:"hidden md:table-cell",children:"Touches (12mo)"}),e.jsx(St,{children:"Score"}),e.jsx(St,{className:"w-10"})]})}),e.jsx(zn,{children:L.slice(0,20).map(I=>e.jsxs(Ss,{className:"cursor-pointer",onClick:()=>t(`/mission-control/contacts/${I.id}`),children:[e.jsxs(dt,{className:"font-medium",children:[I.first_name," ",I.last_name]}),e.jsx(dt,{className:"hidden md:table-cell text-muted-foreground",children:I.relationshipScore.daysSinceTouch===null?"Never":I.relationshipScore.daysSinceTouch===0?"Today":`${I.relationshipScore.daysSinceTouch}d ago`}),e.jsx(dt,{className:"hidden md:table-cell",children:I.relationshipScore.touchCountLast12Months}),e.jsx(dt,{children:e.jsx(y8,{score:I.relationshipScore,showScore:!0})}),e.jsx(dt,{children:e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})})]},I.id))})]})})})},M))]})]})})}function Sct(){const{user:t}=Ds(),s=Qt(),{data:r,isLoading:n}=mt({queryKey:["contact-intake-page",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:u,error:p}=await H.from("contact_intake_pages").select("*").eq("user_id",t.id).maybeSingle();if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),a=Dt({mutationFn:async u=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:p,error:f}=await H.from("contact_intake_pages").insert({user_id:t.id,slug:u.toLowerCase().replace(/[^a-z0-9-]/g,"-")}).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),me.success("Connect page created!")},onError:u=>{var p;(p=u.message)!=null&&p.includes("duplicate")?me.error("That slug is already taken. Try another."):me.error("Failed to create page")}}),o=Dt({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page");const{error:p}=await H.from("contact_intake_pages").update({...u,updated_at:new Date().toISOString()}).eq("id",r.id);if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),me.success("Page updated!")},onError:()=>me.error("Failed to update page")}),{data:l=[],isLoading:i}=mt({queryKey:["contact-intake-submissions",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:u,error:p}=await H.from("contact_intake_submissions").select("*").eq("agent_user_id",t.id).order("created_at",{ascending:!1}).limit(100);if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),c=Dt({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page. Create your Connect page first.");const{data:p,error:f}=await H.from("contact_intake_tokens").insert({contact_id:u,intake_page_id:r.id}).select("token").single();if(f)throw f;return`${window.location.origin}/connect/${r.slug}?t=${p.token}`}});return{intakePage:r,isLoading:n,createPage:a,updatePage:o,submissions:l,loadingSubmissions:i,generateUpdateLink:c}}function R5s(){const{user:t}=Ds();return mt({queryKey:["bulk-email-sends",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:s,error:r}=await H.from("bulk_email_sends").select("contact_id, sent_at, subject").eq("user_id",t.id).order("sent_at",{ascending:!1});if(r)throw r;return s}})}function F5s(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 PI=[{key:"email",label:"Missing Email",icon:cr,description:"No email — can't send drips or market updates",check:t=>!t.email,color:"text-red-500",fieldKey:"email",fieldType:"email",placeholder:"email@example.com"},{key:"phone",label:"Missing Phone",icon:Un,description:"No phone number — can't call or text",check:t=>!t.phone,color:"text-orange-500",fieldKey:"phone",fieldType:"tel",placeholder:"(555) 123-4567"},{key:"address",label:"Missing Address",icon:ma,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:Ch,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:bn,description:"No home anniversary — missing annual outreach opportunity",check:t=>!t.home_anniversary,color:"text-blue-500",fieldKey:"home_anniversary",fieldType:"date"},{key:"tags",label:"No Tags",icon:Fm,description:"Untagged — won't appear in filtered lists or plans",check:t=>!t.tags||t.tags.length===0,color:"text-slate-500"}];function W5(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 z5s({contact:t,onClose:s}){const r=_Ne(),[n,a]=N.useState({email:t.email||"",phone:t.phone||"",address:t.address||"",birthday:t.birthday||"",home_anniversary:t.home_anniversary||""}),o=async()=>{r.mutate({id:t.id,...n},{onSuccess:()=>s()})},l=PI.filter(i=>i.fieldKey&&i.check(t));return e.jsx(JA,{open:!0,onOpenChange:()=>s(),children:e.jsxs(yC,{className:"sm:max-w-md overflow-y-auto",children:[e.jsxs(eE,{children:[e.jsxs(tE,{children:["Quick Edit — ",t.first_name," ",t.last_name]}),e.jsxs($Ze,{children:["Fill in missing fields to improve this contact's completeness (",W5(t),"%)"]})]}),e.jsxs("div",{className:"space-y-5 mt-6",children:[l.length>0&&e.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400 mb-1",children:"Missing Fields"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:l.map(i=>{const c=i.icon;return e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(c,{className:"h-3 w-3"}),i.label.replace("Missing ","")]},i.key)})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," Email"]}),e.jsx(ze,{type:"email",placeholder:"email@example.com",value:n.email,onChange:i=>a(c=>({...c,email:i.target.value})),className:It(!t.email&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Phone"]}),e.jsx(ze,{type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:i=>a(c=>({...c,phone:i.target.value})),className:It(!t.phone&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(ma,{className:"h-3.5 w-3.5"})," Address"]}),e.jsx(ze,{placeholder:"123 Main St, City, ST 12345",value:n.address,onChange:i=>a(c=>({...c,address:i.target.value})),className:It(!t.address&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Ch,{className:"h-3.5 w-3.5"})," Birthday"]}),e.jsx(ze,{type:"date",value:n.birthday,onChange:i=>a(c=>({...c,birthday:i.target.value})),className:It(!t.birthday&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(bn,{className:"h-3.5 w-3.5"})," Home Anniversary"]}),e.jsx(ze,{type:"date",value:n.home_anniversary,onChange:i=>a(c=>({...c,home_anniversary:i.target.value})),className:It(!t.home_anniversary&&"border-amber-500/50")})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{className:"flex-1",onClick:o,disabled:r.isPending,children:[e.jsx(qc,{className:"h-4 w-4 mr-1.5"}),r.isPending?"Saving...":"Save Changes"]}),e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"})]})]})]})})}const Oye="Quick favor — can you update your info? 🙏",n9e=`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 B5s(){const t=fr(),{data:s,isLoading:r}=Gm(),{data:n}=Ux(),{intakePage:a}=Sct(),{isGmailConnected:o,gmailEmail:l}=Wx(),{data:i}=R5s(),[c,u]=N.useState("blocked"),[p,f]=N.useState("all"),[g,b]=N.useState(null),[_,j]=N.useState(!1),[w,k]=N.useState(!1),[S,M]=N.useState(null),[L,I]=N.useState([]),[O,q]=N.useState(""),[U,B]=N.useState(""),V=N.useMemo(()=>s?p==="all"?s:s.filter(Te=>{var ke;return(ke=Te.tags)==null?void 0:ke.some(Be=>Be.relationship_type_id===p)}):[],[s,p]),Z=N.useMemo(()=>V.filter(Te=>!Te.email&&!Te.phone),[V]),X=N.useMemo(()=>{if(!V.length)return{overallCompleteness:0,fullyComplete:0,contactsByGap:{}};const Te={};Te.blocked=Z,PI.forEach(Ae=>{Te[Ae.key]=V.filter(Ae.check)});const ke=V.map(W5),Be=V.length>0?Math.round(ke.reduce((Ae,ft)=>Ae+ft,0)/V.length):0,nt=ke.filter(Ae=>Ae===100).length;return{contactsByGap:Te,overallCompleteness:Be,fullyComplete:nt}},[V,Z]),ee=N.useMemo(()=>{if(!s||s.length===0)return null;const Te=Fc(y4(new Date,1)),ke=s.filter(ft=>new Date(ft.created_at)ft+fe,0)/ke.length),nt=X.overallCompleteness,Ae=nt-Be;return{oldCompleteness:Be,currentCompleteness:nt,diff:Ae,oldCount:ke.length}},[s,X.overallCompleteness]),Q=V.length,ie=N.useCallback(()=>{var at;const Te=X.contactsByGap[c];if(!(Te!=null&&Te.length))return;const ke=c==="blocked"?"Outreach Blocked":((at=PI.find(et=>et.key===c))==null?void 0:at.label)||c,Be=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Completeness %"],nt=Te.map(et=>[et.first_name,et.last_name||"",et.email||"",et.phone||"",et.address||"",et.birthday||"",et.home_anniversary||"",W5(et).toString()]),Ae=[Be.join(","),...nt.map(et=>et.map(Ce=>`"${Ce.replace(/"/g,'""')}"`).join(","))].join(` `),ft=new Blob([Ae],{type:"text/csv"}),fe=URL.createObjectURL(ft),Ve=document.createElement("a");Ve.href=fe,Ve.download=`sphere-gaps-${ke.toLowerCase().replace(/\s+/g,"-")}-${ms(new Date,"yyyy-MM-dd")}.csv`,Ve.click(),URL.revokeObjectURL(fe),wn({title:`Exported ${Te.length} contacts to CSV`})},[X.contactsByGap,c]),re=N.useCallback(async Te=>{if(!a)return null;try{const{data:ke,error:Be}=await H.from("contact_intake_tokens").insert({contact_id:Te,intake_page_id:a.id}).select("token").single();if(Be)throw Be;return ke.token}catch{return null}},[a]),oe=N.useCallback(Te=>a?`https://contacts.relevelup.com/${a.slug}?t=${Te}`:"",[a]),ce=N.useCallback(async Te=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const ke=await re(Te);ke?(await navigator.clipboard.writeText(oe(ke)),me.success("Update link copied!")):me.error("Failed to generate link")},[a,re,oe,t]),xe=N.useCallback(async Te=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}if(!Te.email){me.error("This contact has no email address");return}const ke=await re(Te.id);if(!ke){me.error("Failed to generate link");return}const Be=oe(ke),nt=n9e.replace("{{update_link}}",Be).replace(/\{\{first_name\}\}/g,Te.first_name).replace(/\{\{last_name\}\}/g,Te.last_name||""),Ae=Oye.replace(/\{\{first_name\}\}/g,Te.first_name).replace(/\{\{last_name\}\}/g,Te.last_name||"");if(o)M({id:Te.id,first_name:Te.first_name,last_name:Te.last_name,email:Te.email}),I([]),q(Ae),B(nt),k(!0);else{const ft=encodeURIComponent(Oye.replace("{{first_name}}",Te.first_name)),fe=encodeURIComponent(nt.replace(/\{\{first_name\}\}/g,Te.first_name));window.location.href=`mailto:${Te.email}?subject=${ft}&body=${fe}`}},[a,re,oe,o,t]),ge=N.useCallback(async Te=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const ke=Te.filter(Ae=>Ae.email);if(!ke.length){me.error("No contacts with email addresses in this group");return}const Be=new Set((i||[]).map(Ae=>Ae.contact_id)),nt=ke.filter(Ae=>!Be.has(Ae.id));if(nt.length===0){me.info(`All ${ke.length} contacts with email have already been sent this update request.`);return}if(nt.lengthrt.id),intake_page_id:a.id}});if(ft)throw ft;const fe=typeof Ae=="string"?JSON.parse(Ae):Ae,Ve=Array.isArray(fe)?fe:Array.isArray(fe==null?void 0:fe.tokens)?fe.tokens:[],at=new Map(Ve.filter(rt=>(rt==null?void 0:rt.contact_id)&&(rt==null?void 0:rt.token)).map(rt=>[rt.contact_id,rt.token]));if(at.size===0&&(await Promise.all(ke.map(async Ge=>({contactId:Ge.id,token:await re(Ge.id)})))).forEach(({contactId:Ge,token:ct})=>{ct&&at.set(Ge,ct)}),at.size===0){me.error("Failed to generate update links. Please try again.");return}const et=nt.filter(rt=>at.has(rt.id)).map(rt=>({id:rt.id,first_name:rt.first_name,last_name:rt.last_name,email:rt.email,updateLink:oe(at.get(rt.id))})),Ce=n9e;M(null),I(et),q(Oye),B(Ce),k(!0),me.success(`Ready to email ${et.length} contacts`)}catch{me.error("Failed to generate links")}finally{j(!1)}},[a,o,oe,re,t]),pe=[{key:"blocked",label:"Outreach Blocked",icon:Ov,color:"text-destructive",description:"Missing BOTH email AND phone — completely unreachable"},...PI].find(Te=>Te.key===c),be=X.contactsByGap[c]||[],Me=be.filter(Te=>Te.email).length,Ne=new Set((i||[]).map(Te=>Te.contact_id)),Pe=be.filter(Te=>Te.email&&Ne.has(Te.id)).length,Oe=Me-Pe;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(Xg,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(Zs,{value:p,onValueChange:f,children:[e.jsx(Ws,{className:"w-[180px]",children:e.jsx(Xs,{placeholder:"Filter by tag"})}),e.jsxs(Gs,{children:[e.jsx(Mt,{value:"all",children:"All Contacts"}),n==null?void 0:n.map(Te=>e.jsx(Mt,{value:Te.id,children:Te.name},Te.id))]})]})]})]}),e.jsx(Ee,{children:e.jsxs(De,{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:[X.overallCompleteness,"%"]}),ee&&ee.diff!==0&&p==="all"&&e.jsxs("div",{className:It("flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",ee.diff>0?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-red-500/10 text-red-600 dark:text-red-400"),children:[ee.diff>0?"↑":"↓"," ",Math.abs(ee.diff),"% vs older contacts"]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Fully Complete"}),e.jsxs("p",{className:"text-2xl font-bold text-emerald-600 dark:text-emerald-400",children:[X.fullyComplete," ",e.jsxs("span",{className:"text-base font-normal text-muted-foreground",children:["/ ",Q]})]})]})]}),e.jsx(Bi,{value:X.overallCompleteness,className:"h-3"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:X.overallCompleteness>=80?"🎉 Great job! Your database is well maintained.":X.overallCompleteness>=50?"⚡ Good start — fill in the gaps below to unlock more outreach channels.":"🔍 Your database needs attention. Start with emails and phone numbers."})]})}),Z.length>0&&e.jsx(Ee,{className:It("border-l-4 border-l-destructive cursor-pointer transition-all hover:shadow-md",c==="blocked"&&"ring-2 ring-primary"),onClick:()=>u("blocked"),children:e.jsx(De,{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(Ov,{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:Z.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:PI.map(Te=>{var ft;const ke=((ft=X.contactsByGap[Te.key])==null?void 0:ft.length)||0,Be=Q>0?Math.round(ke/Q*100):0,nt=Te.icon,Ae=c===Te.key;return e.jsx(Ee,{className:It("cursor-pointer transition-all hover:shadow-md",Ae&&"ring-2 ring-primary"),onClick:()=>u(Te.key),children:e.jsxs(De,{className:"pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(nt,{className:It("h-5 w-5",Te.color)}),e.jsx("span",{className:"text-sm font-medium",children:Te.label})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-2xl font-bold",children:ke}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Be,"% of contacts"]})]}),e.jsx(Bi,{value:100-Be,className:"mt-2 h-1.5"})]})},Te.key)})}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg",children:[(pe==null?void 0:pe.label)||"Contacts"," — Contacts to Fix"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(tt,{variant:"secondary",children:[be.length," contacts"]}),Pe>0&&e.jsxs(tt,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(sa,{className:"h-3 w-3"}),Pe," already emailed"]}),be.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,className:"gap-1.5",children:[e.jsx(yi,{className:"h-3.5 w-3.5"}),"Export"]}),Oe>0&&a&&e.jsxs(K,{size:"sm",onClick:()=>ge(be),disabled:_,className:"gap-1.5",children:[_?e.jsx(ws,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Bn,{className:"h-3.5 w-3.5"}),"Email ",Oe," Update Links"]})]})]})]}),e.jsx(gr,{children:pe==null?void 0:pe.description})]}),e.jsx(De,{className:"p-0",children:be.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(sa,{className:"h-10 w-10 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:c==="blocked"?"All contacts have at least an email or phone!":"All contacts have this field filled in!"})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Contact"}),e.jsx(St,{className:"hidden md:table-cell",children:"Email"}),e.jsx(St,{className:"hidden md:table-cell",children:"Phone"}),e.jsx(St,{children:"Completeness"}),e.jsx(St,{className:"w-28",children:"Actions"})]})}),e.jsx(zn,{children:be.map(Te=>{const ke=F5s(i,Te.id);return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"cursor-pointer hover:underline",onClick:()=>t(`/mission-control/contacts/${Te.id}`),children:[Te.first_name," ",Te.last_name]}),!Te.email&&!Te.phone&&c!=="blocked"&&e.jsx(tt,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"Blocked"}),ke&&e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsxs(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0 gap-1 text-muted-foreground border-muted",children:[e.jsx(cr,{className:"h-2.5 w-2.5"}),Uc(new Date(ke),{addSuffix:!0})]})}),e.jsxs(Yl,{children:["Last bulk emailed ",ms(new Date(ke),"MMM d, yyyy h:mm a")]})]})]})}),e.jsx(dt,{className:"hidden md:table-cell text-muted-foreground",children:Te.email||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(dt,{className:"hidden md:table-cell text-muted-foreground",children:Te.phone||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bi,{value:W5(Te),className:"h-2 w-16"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[W5(Te),"%"]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>b(Te),children:e.jsx(Fv,{className:"h-3.5 w-3.5"})})}),e.jsx(Yl,{children:"Quick edit"})]}),(Te.email||Te.phone)&&a&&e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ce(Te.id),children:e.jsx(gi,{className:"h-3.5 w-3.5"})})}),e.jsx(Yl,{children:"Copy update link"})]}),Te.email&&a&&e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>xe(Te),children:e.jsx(cr,{className:"h-3.5 w-3.5"})})}),e.jsx(Yl,{children:"Email update link"})]})]})})]},Te.id)})})]})})]})]}),g&&e.jsx(z5s,{contact:g,onClose:()=>b(null)}),e.jsx(qw,{open:w,onOpenChange:k,contact:S||void 0,bulkContacts:L.length>0?L:void 0,defaultSubject:O,defaultBody:U,gmailEmail:l})]})}function $5s(){const{user:t}=Ds(),{intakePage:s,isLoading:r,createPage:n,updatePage:a,submissions:o,loadingSubmissions:l}=Sct(),[i,c]=N.useState(""),[u,p]=N.useState(""),[f,g]=N.useState(!1);N.useEffect(()=>{s&&p(s.welcome_message||"")},[s]),N.useEffect(()=>{if(t!=null&&t.email&&!s){const M=t.email.split("@")[0];c(M.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+$/,""))}},[t,s]);const b=s?`https://contacts.relevelup.com/${s.slug}`:"",_=()=>{navigator.clipboard.writeText(b),me.success("Link copied!")};if(r)return e.jsx(Ee,{children:e.jsx(De,{className:"p-6 flex items-center justify-center",children:e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"})})});if(!s)return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(dl,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Connect Page"}),e.jsx(gr,{children:"Create a public link to capture contact info from new leads or update existing contacts"})]})]})}),e.jsx(De,{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(ze,{value:i,onChange:M=>c(M.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"jane-smith",className:"max-w-[200px]"})]})]}),e.jsxs(K,{onClick:()=>n.mutate(i),disabled:!i.trim()||n.isPending,children:[n.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Connect Page"]})]})})]});const j=o.filter(M=>!M.is_processed),w=o.filter(M=>M.is_processed),k=j.length,S=(M,L)=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:[M.first_name," ",M.last_name||""]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[M.email&&e.jsx("span",{children:M.email}),M.phone&&e.jsx("span",{children:M.phone})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[M.real_estate_interest&&M.real_estate_interest!=="not_now"&&e.jsx(tt,{variant:"outline",className:"text-xs",children:M.real_estate_interest==="buying"?"🏠 Buying":M.real_estate_interest==="selling"?"📋 Selling":M.real_estate_interest==="both"?"🔄 Both":M.real_estate_interest}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(M.created_at),"MMM d")]}),L&&e.jsx(sa,{className:"h-4 w-4 text-emerald-500"})]})]},M.id);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(dl,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Connect Page"}),e.jsx(gr,{children:"Share this link to capture contact info"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{htmlFor:"active-toggle",className:"text-sm text-muted-foreground",children:"Active"}),e.jsx(qr,{id:"active-toggle",checked:s.is_active,onCheckedChange:M=>a.mutate({is_active:M})})]})]})}),e.jsxs(De,{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:b}),e.jsxs(K,{size:"sm",variant:"outline",onClick:_,children:[e.jsx(gi,{className:"h-3.5 w-3.5 mr-1.5"})," Copy"]}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:b,target:"_blank",rel:"noopener noreferrer",children:e.jsx(tn,{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:M=>p(M.target.value),rows:3,className:"w-full px-3 py-2 text-sm border rounded-md bg-background"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",onClick:()=>{a.mutate({welcome_message:u}),g(!1)},children:"Save"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>g(!1),children:"Cancel"})]})]}):e.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground cursor-pointer hover:text-foreground transition-colors",onClick:()=>g(!0),children:s.welcome_message||"Click to set a welcome message..."})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pr,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-base",children:"New Submissions"}),k>0&&e.jsxs(gr,{children:[k," awaiting sync"]})]})]}),k>0&&e.jsxs(K,{size:"sm",onClick:async()=>{try{const{data:M,error:L}=await H.functions.invoke("process-intake-submissions",{body:{action:"process_all"}});if(L)throw L;me.success(`Synced ${M.processed} contacts to your CRM!`)}catch{me.error("Failed to sync")}},className:"gap-1.5",children:["Sync ",k," to CRM"]})]})}),e.jsx(De,{children:l?e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"}):j.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"All caught up! No new submissions to sync."}):e.jsx("div",{className:"space-y-3",children:j.map(M=>S(M,!1))})})]}),w.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(sa,{className:"h-5 w-5 text-emerald-500"}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-base",children:"Synced to CRM"}),e.jsxs(gr,{children:[w.length," contacts already in your database"]})]})]})}),e.jsx(De,{children:e.jsxs("div",{className:"space-y-3",children:[w.slice(0,10).map(M=>S(M,!0)),w.length>10&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-1",children:["+ ",w.length-10," more synced contacts"]})]})})]})]})}function q5s(){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($5s,{})]})})}const U5s={property_view:{label:"Viewed Listing",icon:On,badgeClass:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-200 dark:border-blue-700"},new_lead:{label:"New Lead",icon:Tl,badgeClass:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-200 dark:border-emerald-700"},saved_listing:{label:"Saved Listing",icon:ni,badgeClass:"bg-rose-500/10 text-rose-600 dark:text-rose-400 border-rose-200 dark:border-rose-700"}},V5s={home:"🏠",search:"🔍",listing:"🏡",city:"🌆",sell:"💰",blog:"📝",dashboard:"📊",other:"📄"};function H5s({locations:t}){const s=N.useRef(null),r=N.useRef(null),[n,a]=N.useState(null);return N.useEffect(()=>{H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle().then(({data:o})=>{o!=null&&o.value&&a(o.value)})},[]),N.useEffect(()=>{if(!(!s.current||!n||r.current))return Ao.accessToken=n,r.current=new Ao.Map({container:s.current,style:"mapbox://styles/mapbox/light-v11",zoom:3.5,center:[-98.5795,39.8283],interactive:!0}),r.current.addControl(new Ao.NavigationControl,"top-right"),()=>{var o;(o=r.current)==null||o.remove(),r.current=null}},[n]),N.useEffect(()=>{if(!r.current||!n||t.length===0)return;const o=()=>{if(t.forEach(l=>{if(!Number.isFinite(l.lat)||!Number.isFinite(l.lng))return;const i=Math.min(40,Math.max(16,12+l.visitor_count*3)),c=document.createElement("div");c.style.cssText=` width: ${i}px; height: ${i}px; border-radius: 50%; background: radial-gradient(circle, rgba(64,110,113,0.9), rgba(64,110,113,0.4)); border: 2px solid rgba(64,110,113,0.8); display: flex; align-items: center; justify-content: center; font-size: ${Math.max(9,i*.35)}px; font-weight: 700; color: white; cursor: pointer; transition: transform 0.2s; `,c.textContent=String(l.visitor_count),c.addEventListener("mouseenter",()=>{c.style.transform="scale(1.3)"}),c.addEventListener("mouseleave",()=>{c.style.transform="scale(1)"});const u=document.createElement("div");u.appendChild(c),new Ao.Marker({element:u,anchor:"center"}).setLngLat([l.lng,l.lat]).setPopup(new Ao.Popup({offset:15}).setHTML(`
${l.city}, ${l.region}
${l.visitor_count} visitor${l.visitor_count>1?"s":""}
`)).addTo(r.current)}),t.length>1){const l=new Ao.LngLatBounds;t.forEach(i=>{Number.isFinite(i.lat)&&Number.isFinite(i.lng)&&l.extend([i.lng,i.lat])}),l.isEmpty()||r.current.fitBounds(l,{padding:60,maxZoom:10})}else t.length===1&&r.current.flyTo({center:[t[0].lng,t[0].lat],zoom:8})};r.current.loaded()?o():r.current.on("load",o)},[t,n]),n?e.jsx("div",{ref:s,className:"w-full h-full rounded-xl overflow-hidden"}):e.jsxs("div",{className:"h-full flex items-center justify-center bg-muted/30 rounded-xl text-muted-foreground text-sm",children:[e.jsx(i1,{className:"h-5 w-5 mr-2"})," Map not configured"]})}function Cct(){var I,O,q,U;const{user:t}=Ds(),s=fr(),{isGmailConnected:r,gmailEmail:n}=Wx(),[a,o]=N.useState("all"),[l,i]=N.useState("30"),[c,u]=N.useState(""),[p,f]=N.useState(!1),[g,b]=N.useState(null),{data:_,isLoading:j}=mt({queryKey:["lead-site-activity-full",t==null?void 0:t.id,l],queryFn:async()=>{const{data:B,error:V}=await H.rpc("get_lead_site_activity_full",{_user_id:t.id,_days:parseInt(l)});if(V)throw V;const Z=B;return{...Z,visitor_locations:((Z==null?void 0:Z.visitor_locations)||[]).map(X=>({...X,lat:Number(X.lat),lng:Number(X.lng),visitor_count:Number(X.visitor_count??X.visit_count??0)}))}},enabled:!!t,refetchInterval:6e4}),w=N.useMemo(()=>{if(!(_!=null&&_.activities))return[];let B=_.activities;if(a!=="all"&&(B=B.filter(V=>V.activity_type===a)),c){const V=c.toLowerCase();B=B.filter(Z=>{var X,ee,Q,ie,re;return((X=Z.visitor_name)==null?void 0:X.toLowerCase().includes(V))||((ee=Z.visitor_email)==null?void 0:ee.toLowerCase().includes(V))||((Q=Z.mls_number)==null?void 0:Q.includes(V))||((ie=Z.property_address)==null?void 0:ie.toLowerCase().includes(V))||((re=Z.lead_type)==null?void 0:re.toLowerCase().includes(V))})}return B},[_==null?void 0:_.activities,a,c]),k=_==null?void 0:_.subdomain,S=B=>k?`https://${k}.thelocalmove.com/listing/${B}`:null,M=_==null?void 0:_.stats,L=B=>{if(B.visitor_email)if(r){const V=(B.visitor_name||"").split(" ");b({id:B.contact_id||"",first_name:V[0]||"",last_name:V.slice(1).join(" ")||null,email:B.visitor_email}),f(!0)}else window.location.href=`mailto:${B.visitor_email}`};return!(_!=null&&_.has_site)&&!j?e.jsx(Ms,{title:"Website Activity",description:"Monitor your website lead activity",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx(su,{className:"h-16 w-16 text-muted-foreground/30 mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Website Connected"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"Set up your Lead Site to start capturing and tracking visitor activity."})]})}):e.jsxs(Ms,{title:"Website Activity",description:"Monitor and act on your website leads",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/mission-control"),children:e.jsx(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(su,{className:"h-6 w-6 text-primary"}),"Website Activity"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track, respond, and convert your website visitors"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:["7","30","90"].map(B=>e.jsxs(K,{variant:l===B?"default":"outline",size:"sm",onClick:()=>i(B),children:[B,"d"]},B))})]}),M&&e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{label:"Page Views",value:M.total_page_views,sub:M.page_views_7d,icon:Sn,color:"text-violet-600 dark:text-violet-400",bg:"bg-violet-500/10"},{label:"Listing Views",value:M.total_views,sub:M.views_7d,icon:On,color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-500/10"},{label:"New Leads",value:M.total_leads,sub:M.leads_7d,icon:Tl,color:"text-emerald-600 dark:text-emerald-400",bg:"bg-emerald-500/10"},{label:"Saved Listings",value:M.total_saved,sub:M.saved_7d,icon:ni,color:"text-rose-600 dark:text-rose-400",bg:"bg-rose-500/10"}].map(B=>e.jsx(Ee,{children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:B.label}),e.jsx("p",{className:`text-2xl font-bold ${B.color}`,children:B.value})]}),e.jsx("div",{className:`p-2.5 rounded-xl ${B.bg}`,children:e.jsx(B.icon,{className:`h-5 w-5 ${B.color}`})})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-1",children:[e.jsx("span",{className:`font-semibold ${B.color}`,children:B.sub})," in last 7d"]})]})},B.label))}),e.jsxs(ba,{defaultValue:"overview",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"overview",className:"gap-1.5",children:[e.jsx(No,{className:"h-4 w-4"})," Overview"]}),e.jsxs(ns,{value:"leads",className:"gap-1.5",children:[e.jsx(Zh,{className:"h-4 w-4"})," Lead Inbox"]}),e.jsxs(ns,{value:"map",className:"gap-1.5",children:[e.jsx(i1,{className:"h-4 w-4"})," Visitor Map"]})]}),e.jsxs(bs,{value:"overview",className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(ul,{className:"h-4 w-4 text-primary"}),"Most Viewed Listings"]})}),e.jsx(De,{className:"pt-0",children:!(_!=null&&_.top_listings)||_.top_listings.length===0?e.jsxs("div",{className:"py-8 text-center text-sm text-muted-foreground",children:[e.jsx(bn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/30"}),"No listing views yet"]}):e.jsx("div",{className:"space-y-1.5",children:_.top_listings.map((B,V)=>{const Z=S(B.mls_number);return e.jsxs("a",{href:Z||"#",target:"_blank",rel:"noopener noreferrer",onClick:X=>{Z||X.preventDefault()},className:"group flex items-center gap-3 p-2.5 rounded-lg hover:bg-muted/60 transition-colors",children:[e.jsx("span",{className:"text-sm font-bold text-muted-foreground w-5 text-right",children:V+1}),B.photo_url?e.jsx("div",{className:"h-10 w-10 rounded-lg overflow-hidden bg-muted shrink-0",children:e.jsx("img",{src:B.photo_url,alt:"",className:"w-full h-full object-cover"})}):e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(bn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:B.property_address||`MLS# ${B.mls_number}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Uc(new Date(B.last_viewed),{addSuffix:!0})})]}),e.jsxs(tt,{variant:"secondary",className:"shrink-0 text-xs",children:[B.view_count," view",B.view_count!==1?"s":""]}),Z&&e.jsx(tn,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},B.mls_number)})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4 text-primary"}),"Most Visited Pages"]})}),e.jsx(De,{className:"pt-0",children:!(_!=null&&_.top_pages)||_.top_pages.length===0?e.jsxs("div",{className:"py-8 text-center text-sm text-muted-foreground",children:[e.jsx(Sn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/30"}),"No page views yet"]}):e.jsx("div",{className:"space-y-1.5",children:_.top_pages.map((B,V)=>e.jsxs("div",{className:"flex items-center gap-3 p-2.5 rounded-lg hover:bg-muted/60 transition-colors",children:[e.jsx("span",{className:"text-sm font-bold text-muted-foreground w-5 text-right",children:V+1}),e.jsx("span",{className:"text-lg w-8 text-center",children:V5s[B.page_type]||"📄"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:B.page_title||B.page_path}),e.jsx("p",{className:"text-xs text-muted-foreground",children:B.page_path})]}),e.jsx(tt,{variant:"secondary",className:"shrink-0 text-xs capitalize",children:B.page_type}),e.jsx(tt,{variant:"outline",className:"shrink-0 text-xs",children:B.view_count})]},`${B.page_type}-${B.page_path}`))})})]})]}),(_==null?void 0:_.visitor_locations)&&_.visitor_locations.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(ma,{className:"h-4 w-4 text-primary"}),"Where Visitors Are Browsing From"]})}),e.jsx(De,{className:"pt-0",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:_.visitor_locations.slice(0,9).map(B=>e.jsxs("div",{className:"flex items-center gap-2.5 p-2.5 rounded-lg bg-muted/40",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ma,{className:"h-3.5 w-3.5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[B.city,", ",B.region]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:B.country})]}),e.jsx("span",{className:"text-sm font-bold text-primary",children:B.visitor_count})]},`${B.city}-${B.region}`))})})]})]}),e.jsxs(bs,{value:"leads",className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, address...",value:c,onChange:B=>u(B.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex gap-2",children:[{key:"all",label:"All",count:((I=_==null?void 0:_.activities)==null?void 0:I.length)||0},{key:"new_lead",label:"Leads",count:((O=_==null?void 0:_.activities)==null?void 0:O.filter(B=>B.activity_type==="new_lead").length)||0},{key:"property_view",label:"Views",count:((q=_==null?void 0:_.activities)==null?void 0:q.filter(B=>B.activity_type==="property_view").length)||0},{key:"saved_listing",label:"Saved",count:((U=_==null?void 0:_.activities)==null?void 0:U.filter(B=>B.activity_type==="saved_listing").length)||0}].map(B=>e.jsxs(K,{variant:a===B.key?"default":"outline",size:"sm",onClick:()=>o(B.key),className:"gap-1.5",children:[B.label,e.jsx(tt,{variant:"secondary",className:"text-[10px] h-4 px-1 rounded-full",children:B.count})]},B.key))})]}),j?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(B=>e.jsx("div",{className:"h-20 rounded-xl bg-muted animate-pulse"},B))}):w.length===0?e.jsx(Ee,{children:e.jsxs(De,{className:"p-8 text-center",children:[e.jsx(kh,{className:"h-10 w-10 text-muted-foreground/30 mx-auto mb-3"}),e.jsx("p",{className:"font-medium",children:"No activity found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c?"Try adjusting your search.":"Website engagement will appear here."})]})}):e.jsx("div",{className:"space-y-2",children:w.map((B,V)=>{const Z=U5s[B.activity_type],X=Z.icon,ee=Uc(new Date(B.occurred_at),{addSuffix:!0}),Q=B.visitor_name&&B.visitor_name!=="Site Visitor";return e.jsx(Ee,{className:`transition-all hover:shadow-md ${B.activity_type==="new_lead"?"border-l-4 border-l-emerald-500":B.activity_type==="saved_listing"?"border-l-4 border-l-rose-500":"border-l-4 border-l-blue-500"}`,children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[B.photo_url?e.jsx("a",{href:B.mls_number&&S(B.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"shrink-0 rounded-lg overflow-hidden w-12 h-12 bg-muted",children:e.jsx("img",{src:B.photo_url,alt:B.property_address||"Property",className:"w-full h-full object-cover"})}):e.jsx("div",{className:`p-2 rounded-lg shrink-0 ${B.activity_type==="new_lead"?"bg-emerald-500/10":B.activity_type==="saved_listing"?"bg-rose-500/10":"bg-blue-500/10"}`,children:e.jsx(X,{className:`h-4 w-4 ${B.activity_type==="new_lead"?"text-emerald-500":B.activity_type==="saved_listing"?"text-rose-500":"text-blue-500"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[Q?e.jsx("button",{className:"font-semibold text-sm text-primary hover:underline text-left truncate",onClick:()=>{B.contact_id&&s(`/mission-control/contacts/${B.contact_id}`)},children:B.visitor_name}):e.jsx("span",{className:"font-medium text-sm text-muted-foreground",children:B.visitor_name||"Site Visitor"}),e.jsx(tt,{variant:"outline",className:`text-[10px] shrink-0 ${Z.badgeClass}`,children:Z.label}),B.lead_type&&e.jsx(tt,{variant:"secondary",className:"text-[10px] capitalize",children:B.lead_type.replace(/_/g," ")})]}),B.property_address&&B.mls_number&&e.jsxs("a",{href:S(B.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-0.5 text-xs font-medium text-foreground hover:text-primary transition-colors truncate",children:[e.jsx(ma,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:B.property_address}),e.jsx(tn,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),ee]}),B.mls_number&&!B.property_address&&e.jsxs("a",{href:S(B.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"hover:text-primary transition-colors",children:["MLS# ",B.mls_number]})]}),B.message&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5 line-clamp-2 italic",children:['"',B.message,'"']})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[B.visitor_email&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:r?"Compose via Gmail":"Send Email",onClick:()=>L(B),children:e.jsx(cr,{className:"h-4 w-4"})}),B.visitor_phone&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:"Call",onClick:()=>window.location.href=`tel:${B.visitor_phone}`,children:e.jsx(Un,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:"Text",onClick:()=>window.location.href=`sms:${B.visitor_phone}`,children:e.jsx(so,{className:"h-4 w-4"})})]}),B.contact_id&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",title:"View Contact",onClick:()=>s(`/mission-control/contacts/${B.contact_id}`),children:e.jsx(da,{className:"h-4 w-4"})})]})]})})},`${B.activity_type}-${B.occurred_at}-${V}`)})})]}),e.jsxs(bs,{value:"map",className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(i1,{className:"h-4 w-4 text-primary"}),"Visitor Locations",(_==null?void 0:_.visitor_locations)&&_.visitor_locations.length>0&&e.jsxs(tt,{variant:"secondary",className:"text-xs ml-2",children:[_.visitor_locations.reduce((B,V)=>B+V.visitor_count,0)," visitors from ",_.visitor_locations.length," cities"]})]})}),e.jsx(De,{className:"pt-0",children:e.jsx("div",{className:"h-[450px] rounded-xl overflow-hidden border",children:e.jsx(H5s,{locations:(_==null?void 0:_.visitor_locations)||[]})})})]}),(_==null?void 0:_.visitor_locations)&&_.visitor_locations.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsx(Rt,{className:"text-base",children:"Location Breakdown"})}),e.jsx(De,{className:"pt-0",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:_.visitor_locations.map(B=>e.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-muted/40",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ma,{className:"h-3.5 w-3.5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[B.city,", ",B.region]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:B.country})]}),e.jsx("span",{className:"text-sm font-bold text-primary",children:B.visitor_count})]},`${B.city}-${B.region}`))})})]})]})]})]}),r&&g&&e.jsx(qw,{open:p,onOpenChange:f,contact:g,gmailEmail:n})]})}const W5s=Object.freeze(Object.defineProperty({__proto__:null,default:Cct},Symbol.toStringTag,{value:"Module"})),G5s=N.lazy(()=>oc(()=>import("./PostcardManager-CHQqNc7Q.js"),__vite__mapDeps([0,1]))),K5s=N.lazy(()=>oc(()=>import("./HomeReelManager-Cxhppxyb.js"),[])),Z5s=N.lazy(()=>oc(()=>import("./AdminCredits-vjo0duFK.js"),[])),Y5s=N.lazy(()=>oc(()=>import("./DirectMail-OdpdHHPI.js").then(t=>t.D),__vite__mapDeps([2,1]))),X5s=N.lazy(()=>oc(()=>import("./InnerCirclePopbyMap-Bt8NykEN.js"),[])),Q5s=N.lazy(()=>oc(()=>import("./LiveVisitorFeed-CbavNeya.js"),[])),J5s=N.lazy(()=>oc(()=>import("./LeadSites-BO6HWdp4.js"),[])),a9e=N.lazy(()=>oc(()=>import("./LeadSiteEditor-BdbpoQbx.js"),[])),eMs=N.lazy(()=>oc(()=>import("./AdminMlsFeeds-B3XbH8eG.js"),[])),tMs=N.lazy(()=>oc(()=>import("./AdminLeadSiteAnalytics-8Dwtm9xJ.js"),[])),sMs=N.lazy(()=>oc(()=>import("./MLSListings-qa61D2_m.js"),[])),rMs=N.lazy(()=>oc(()=>import("./MLSListingDetail-DOFs_wuW.js"),[])),nMs=N.lazy(()=>oc(()=>import("./MarketReportPage-DFBDZonT.js"),[]));N.lazy(()=>oc(()=>Promise.resolve().then(()=>W5s),void 0));const aMs=N.lazy(()=>oc(()=>import("./EmailCampaigns-6czUUXN3.js"),[])),iMs=N.lazy(()=>oc(()=>import("./EmailCampaignComposer-yjR7sV-W.js"),__vite__mapDeps([3,4]))),oMs=N.lazy(()=>oc(()=>import("./EmailCampaignDetail-D2kp9Bmx.js"),[])),lMs=N.lazy(()=>oc(()=>import("./SharedCampaignTemplates-DiEVx-5l.js"),__vite__mapDeps([5,6,4]))),cMs=N.lazy(()=>oc(()=>import("./AgentTemplates-_zZV4xns.js"),__vite__mapDeps([7,6,4]))),i9e=N.lazy(()=>oc(()=>import("./TheLocalMoveHome-DmOIDzwy.js"),[])),dMs=new evt({defaultOptions:{queries:{refetchOnWindowFocus:!1,staleTime:5*60*1e3}}}),uMs=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},hMs=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},mMs=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},pMs=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},fMs=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},xMs=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},gMs=()=>{const t=window.location.hostname;return t==="booking.relevelup.com"||t.startsWith("booking.")},yMs=()=>{const t=window.location.hostname;return t==="contacts.relevelup.com"||t.startsWith("contacts.")},vMs=()=>{const t=window.location.hostname;return t==="pages.relevelup.com"||t.startsWith("pages.")},Mct=()=>{const t=window.location.hostname;return t==="thelocalmove.com"||t==="www.thelocalmove.com"},bMs=()=>window.location.hostname.endsWith(".thelocalmove.com")&&!Mct(),_Ms=()=>e.jsx(avt,{client:dMs,children:e.jsx(NUe,{children:e.jsxs(z1,{children:[e.jsx(bgt,{}),e.jsx(Qgt,{}),e.jsx(x1t,{children:e.jsx(vwt,{children:e.jsx(bwt,{children:e.jsxs(wwt,{children:[e.jsx(_wt,{}),e.jsx(eNt,{}),e.jsx(xNt,{}),xMs()?e.jsx(y3s,{}):hMs()?e.jsx(Dkt,{}):uMs()?e.jsx(rkt,{}):mMs()?e.jsx(Fkt,{}):pMs()?e.jsx(NEt,{}):fMs()?e.jsx($Et,{}):gMs()?e.jsx(v3s,{}):yMs()?e.jsx(b3s,{}):vMs()?e.jsx(_3s,{}):Mct()?e.jsx(N.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(i9e,{})}):bMs()?e.jsx(v5s,{}):e.jsxs(O2e,{children:[e.jsx(ks,{path:"/",element:e.jsx(YEt,{})}),e.jsx(ks,{path:"/the-local-move",element:e.jsx(N.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(i9e,{})})}),e.jsx(ks,{path:"/privacy-policy",element:e.jsx(XEt,{})}),e.jsx(ks,{path:"/terms-of-service",element:e.jsx(QEt,{})}),e.jsx(ks,{path:"/data-deletion",element:e.jsx(JEt,{})}),e.jsx(ks,{path:"/public/listings",element:e.jsx(tGe,{})}),e.jsx(ks,{path:"/public/listing/:slugOrId",element:e.jsx(zIt,{})}),e.jsx(ks,{path:"/card/:slug",element:e.jsx(BIt,{})}),e.jsx(ks,{path:"/join-brokerage/:slug",element:e.jsx(bCs,{})}),e.jsx(ks,{path:"/recruit-video/:shareToken",element:e.jsx(wCs,{})}),e.jsx(ks,{path:"/connect/:slug",element:e.jsx(BYe,{})}),e.jsx(ks,{path:"/auth",element:e.jsx(t6t,{})}),e.jsx(ks,{path:"/subscription-success",element:e.jsx(s6t,{})}),e.jsx(ks,{path:"/subscription",element:e.jsx(nr,{children:e.jsx(KPt,{})})}),e.jsxs(ks,{path:"/share/video",element:e.jsx(DIt,{}),children:[e.jsx(ks,{path:":shareToken",element:e.jsx(xIe,{})}),e.jsx(ks,{path:":shareToken/r/:recipientToken",element:e.jsx(xIe,{})})]}),e.jsx(ks,{path:"/p/:shareToken",element:e.jsx(BCs,{})}),e.jsx(ks,{path:"/portal/:slug",element:e.jsx(GCs,{})}),e.jsx(ks,{path:"/og/video/:token",element:e.jsx(OIt,{})}),e.jsx(ks,{path:"/setup-brokerage",element:e.jsx(nr,{children:e.jsx(ZPt,{})})}),e.jsx(ks,{path:"/claim-account",element:e.jsx(mIe,{})}),e.jsx(ks,{path:"/claim",element:e.jsx(mIe,{})}),e.jsx(ks,{path:"/join",element:e.jsx(YPt,{})}),e.jsx(ks,{path:"/trial",element:e.jsx(oIt,{})}),e.jsx(ks,{path:"/trial/success",element:e.jsx(lIt,{})}),e.jsx(ks,{path:"/dashboard",element:e.jsx(nr,{children:e.jsx(o8t,{})})}),e.jsx(ks,{path:"/profile",element:e.jsx(nr,{children:e.jsx(HBt,{})})}),e.jsx(ks,{path:"/apps",element:e.jsx(nr,{children:e.jsx(a$t,{})})}),e.jsx(ks,{path:"/admin",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(VUt,{})})}),e.jsx(ks,{path:"/admin/apps",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(GUt,{})})}),e.jsx(ks,{path:"/admin/members",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(tVt,{})})}),e.jsx(ks,{path:"/admin/invite-codes",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(sVt,{})})}),e.jsx(ks,{path:"/admin/events",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(lVt,{})})}),e.jsx(ks,{path:"/events",element:e.jsx(nr,{children:e.jsx(t$t,{})})}),e.jsx(ks,{path:"/events/:eventId",element:e.jsx(nr,{children:e.jsx(r$t,{})})}),e.jsx(ks,{path:"/templates",element:e.jsx(nr,{children:e.jsx(i$t,{})})}),e.jsx(ks,{path:"/templates/:templateId",element:e.jsx(nr,{children:e.jsx(d$t,{})})}),e.jsx(ks,{path:"/admin/templates",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(dVt,{})})}),e.jsx(ks,{path:"/academy",element:e.jsx(nr,{children:e.jsx(u$t,{})})}),e.jsx(ks,{path:"/academy/:videoId",element:e.jsx(nr,{children:e.jsx(m$t,{})})}),e.jsx(ks,{path:"/admin/academy",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(hVt,{})})}),e.jsx(ks,{path:"/toolbox",element:e.jsx(nr,{children:e.jsx(p$t,{})})}),e.jsx(ks,{path:"/toolbox/:kitId",element:e.jsx(nr,{children:e.jsx(f$t,{})})}),e.jsx(ks,{path:"/admin/toolbox",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(mVt,{})})}),e.jsx(ks,{path:"/social-swag",element:e.jsx(nr,{children:e.jsx(x$t,{})})}),e.jsx(ks,{path:"/social-swag-2",element:e.jsx(nr,{children:e.jsx(pUt,{})})}),e.jsx(ks,{path:"/social-swag/:swagId",element:e.jsx(nr,{children:e.jsx(fUt,{})})}),e.jsx(ks,{path:"/social-connections",element:e.jsx(nr,{children:e.jsx(jCs,{})})}),e.jsx(ks,{path:"/social-connections/callback",element:e.jsx(nr,{children:e.jsx(NCs,{})})}),e.jsx(ks,{path:"/social-connections/linkedin-callback",element:e.jsx(nr,{children:e.jsx(SCs,{})})}),e.jsx(ks,{path:"/social-connections/google-callback",element:e.jsx(nr,{children:e.jsx(kCs,{})})}),e.jsx(ks,{path:"/admin/social-swag",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(pVt,{})})}),e.jsx(ks,{path:"/admin/social-swag-2",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(XHt,{})})}),e.jsx(ks,{path:"/community",element:e.jsx(nr,{children:e.jsx(LUt,{})})}),e.jsx(ks,{path:"/support",element:e.jsx(nr,{children:e.jsx(DUt,{})})}),e.jsx(ks,{path:"/admin/community",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(QHt,{})})}),e.jsx(ks,{path:"/admin/support-tickets",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Bvs,{})})}),e.jsx(ks,{path:"/admin/email-templates",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(qvs,{})})}),e.jsx(ks,{path:"/admin/agent-email-templates",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Uvs,{})})}),e.jsx(ks,{path:"/admin/analytics",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Rvs,{})})}),e.jsx(ks,{path:"/admin/brokerage-resources",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Fvs,{})})}),e.jsx(ks,{path:"/admin/dashboard-management",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(zvs,{})})}),e.jsx(ks,{path:"/brokerage/dashboard",element:e.jsx(nr,{requireBrokerageManager:!0,children:e.jsx(t1s,{})})}),e.jsx(ks,{path:"/brokerage/teams",element:e.jsx(nr,{requireBrokerageManager:!0,children:e.jsx(w5s,{})})}),e.jsx(ks,{path:"/brokerage/recruiting",element:e.jsx(nr,{requireBrokerageManager:!0,children:e.jsx(H4s,{})})}),e.jsx(ks,{path:"/my-team",element:e.jsx(nr,{children:e.jsx(j5s,{})})}),e.jsx(ks,{path:"/my-brokerage",element:e.jsx(nr,{children:e.jsx(o1s,{})})}),e.jsx(ks,{path:"/brokerage-content",element:e.jsx(nr,{children:e.jsx(m1s,{})})}),e.jsx(ks,{path:"/brokerage-content/:contentId",element:e.jsx(nr,{children:e.jsx(y1s,{})})}),e.jsx(ks,{path:"/brokerage-resources",element:e.jsx(nr,{requireBrokerageManager:!0,children:e.jsx($Ut,{})})}),e.jsx(ks,{path:"/brokerage-resources/:resourceId",element:e.jsx(nr,{requireBrokerageManager:!0,children:e.jsx(qUt,{})})}),e.jsx(ks,{path:"/newsletters",element:e.jsx(nr,{children:e.jsx(v1s,{})})}),e.jsx(ks,{path:"/newsletters/:id",element:e.jsx(nr,{children:e.jsx(_1s,{})})}),e.jsx(ks,{path:"/wishlist",element:e.jsx(nr,{children:e.jsx(N1s,{})})}),e.jsx(ks,{path:"/wishlist/:itemId",element:e.jsx(nr,{children:e.jsx(k1s,{})})}),e.jsx(ks,{path:"/admin/wishlist",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(S1s,{})})}),e.jsx(ks,{path:"/admin/levelup-brief",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(C1s,{})})}),e.jsx(ks,{path:"/admin/newsletters",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(j1s,{})})}),e.jsx(ks,{path:"/admin/additional-services",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(M1s,{})})}),e.jsx(ks,{path:"/admin/discounts",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(T1s,{})})}),e.jsx(ks,{path:"/admin/subscriptions",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(A1s,{})})}),e.jsx(ks,{path:"/admin/referrals",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(E1s,{})})}),e.jsx(ks,{path:"/admin/prospector",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(C4s,{})})}),e.jsx(ks,{path:"/admin/recruiting",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(V4s,{})})}),e.jsx(ks,{path:"/admin/beta/social-post-generator",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(WSs,{})})}),e.jsx(ks,{path:"/admin/credits",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(Z5s,{})})})}),e.jsx(ks,{path:"/admin/beta/postcard-manager",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(G5s,{})})})}),e.jsx(ks,{path:"/admin/beta/homereel",element:e.jsx(nr,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(K5s,{})})})}),e.jsx(ks,{path:"/admin/lms",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(iCs,{})})}),e.jsx(ks,{path:"/admin/lms/stats",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(uCs,{})})}),e.jsx(ks,{path:"/admin/lms/:courseId",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(oCs,{})})}),e.jsx(ks,{path:"/levelup-u",element:e.jsx(nr,{children:e.jsx(hCs,{})})}),e.jsx(ks,{path:"/levelup-u/:courseId",element:e.jsx(nr,{children:e.jsx(pCs,{})})}),e.jsx(ks,{path:"/admin/brokerage-content-activity",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(W4s,{})})}),e.jsx(ks,{path:"/admin/onboarding-checklist",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(I1s,{})})}),e.jsx(ks,{path:"/admin/marketplace",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(n4s,{})})}),e.jsx(ks,{path:"/admin/agent-points",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Mks,{})})}),e.jsx(ks,{path:"/admin/reward-store",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(v4s,{})})}),e.jsx(ks,{path:"/admin/integrations",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(_4s,{})})}),e.jsx(ks,{path:"/admin/integrations/callback",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(S4s,{})})}),e.jsx(ks,{path:"/admin/email-campaigns",element:e.jsx(nr,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(aMs,{})})})}),e.jsx(ks,{path:"/admin/email-campaigns/templates",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(lMs,{})})})}),e.jsx(ks,{path:"/email-campaigns/templates",element:e.jsx(nr,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(cMs,{})})})}),e.jsx(ks,{path:"/admin/email-campaigns/new",element:e.jsx(nr,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(iMs,{})})})}),e.jsx(ks,{path:"/admin/email-campaigns/:id",element:e.jsx(nr,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(oMs,{})})})}),e.jsx(ks,{path:"/reward-store",element:e.jsx(nr,{children:e.jsx(LCs,{})})}),e.jsx(ks,{path:"/additional-services",element:e.jsx(nr,{children:e.jsx(V1s,{})})}),e.jsx(ks,{path:"/additional-services/:serviceId",element:e.jsx(nr,{children:e.jsx(H1s,{})})}),e.jsx(ks,{path:"/ai-toolkit",element:e.jsx(nr,{children:e.jsx(W1s,{})})}),e.jsx(ks,{path:"/mission-control",element:e.jsx(nr,{children:e.jsx(cbs,{})})}),e.jsx(ks,{path:"/mission-control/contacts",element:e.jsx(nr,{children:e.jsx(Gbs,{})})}),e.jsx(ks,{path:"/mission-control/contacts/:contactId",element:e.jsx(nr,{children:e.jsx(__s,{})})}),e.jsx(ks,{path:"/mission-control/plans",element:e.jsx(nr,{children:e.jsx(w_s,{})})}),e.jsx(ks,{path:"/mission-control/popbys",element:e.jsx(nr,{children:e.jsx(k_s,{})})}),e.jsx(ks,{path:"/mission-control/popbys/map",element:e.jsx(nr,{children:e.jsx(X5s,{})})}),e.jsx(ks,{path:"/admin/notification-settings",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(j4s,{})})}),e.jsx(ks,{path:"/admin/agent-os",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(D1s,{})})}),e.jsx(ks,{path:"/mission-control/listings",element:e.jsx(nr,{children:e.jsx(Z_s,{})})}),e.jsx(ks,{path:"/mission-control/listings/new",element:e.jsx(nr,{children:e.jsx(a7e,{})})}),e.jsx(ks,{path:"/mission-control/listings/:listingId",element:e.jsx(nr,{children:e.jsx(dws,{})})}),e.jsx(ks,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(nr,{children:e.jsx(a7e,{})})}),e.jsx(ks,{path:"/admin/listing-exchange",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(wks,{})})}),e.jsx(ks,{path:"/mission-control/pipeline",element:e.jsx(nr,{children:e.jsx(TNs,{})})}),e.jsx(ks,{path:"/mission-control/tasks",element:e.jsx(nr,{children:e.jsx(zNs,{})})}),e.jsx(ks,{path:"/mission-control/my-card",element:e.jsx(nr,{children:e.jsx(aks,{})})}),e.jsx(ks,{path:"/mission-control/integrations",element:e.jsx(nr,{children:e.jsx(fks,{})})}),e.jsx(ks,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(nr,{children:e.jsx(xks,{})})}),e.jsx(ks,{path:"/mission-control/integrations/canva/callback",element:e.jsx(gks,{})}),e.jsx(ks,{path:"/mission-control/integrations/meta/callback",element:e.jsx(nr,{children:e.jsx(yks,{})})}),e.jsx(ks,{path:"/mission-control/scorecard",element:e.jsx(nr,{children:e.jsx(z_s,{})})}),e.jsx(ks,{path:"/admin/scorecard",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(bks,{})})}),e.jsx(ks,{path:"/admin/scorecard/:userId",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(yze,{})})}),e.jsx(ks,{path:"/mission-control/scorecard/:userId",element:e.jsx(nr,{children:e.jsx(yze,{})})}),e.jsx(ks,{path:"/mission-control/relationship-scorecard",element:e.jsx(nr,{children:e.jsx(O5s,{})})}),e.jsx(ks,{path:"/mission-control/sphere-gaps",element:e.jsx(nr,{children:e.jsx(B5s,{})})}),e.jsx(ks,{path:"/mission-control/website-activity",element:e.jsx(nr,{children:e.jsx(Cct,{})})}),e.jsx(ks,{path:"/mission-control/connect-page",element:e.jsx(nr,{children:e.jsx(q5s,{})})}),e.jsx(ks,{path:"/admin/membership-reviews",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(jks,{})})}),e.jsx(ks,{path:"/admin/weekly-digest",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Sks,{})})}),e.jsx(ks,{path:"/mission-control/video/record",element:e.jsx(nr,{children:e.jsx(mjs,{})})}),e.jsx(ks,{path:"/mission-control/video-library",element:e.jsx(nr,{children:e.jsx(Mjs,{})})}),e.jsx(ks,{path:"/marketplace",element:e.jsx(nr,{children:e.jsx(CCs,{})})}),e.jsx(ks,{path:"/marketplace/:productId",element:e.jsx(nr,{children:e.jsx(MCs,{})})}),e.jsx(ks,{path:"/marketplace/cart",element:e.jsx(nr,{children:e.jsx(TCs,{})})}),e.jsx(ks,{path:"/marketplace/orders",element:e.jsx(nr,{children:e.jsx(ACs,{})})}),e.jsx(ks,{path:"/marketplace/orders/:orderId",element:e.jsx(nr,{children:e.jsx(PCs,{})})}),e.jsx(ks,{path:"/marketplace/success",element:e.jsx(nr,{children:e.jsx(ICs,{})})}),e.jsx(ks,{path:"/admin/agent-cards",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Tks,{})})}),e.jsx(ks,{path:"/admin/presentation-analytics",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(N4s,{})})}),e.jsx(ks,{path:"/admin/guest-book-analytics",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(k4s,{})})}),e.jsx(ks,{path:"/mission-control/smart-drips",element:e.jsx(nr,{children:e.jsx(x3s,{})})}),e.jsx(ks,{path:"/mission-control/direct-mail",element:e.jsx(nr,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(Y5s,{})})})}),e.jsx(ks,{path:"/mission-control/presentations",element:e.jsx(nr,{children:e.jsx(DCs,{})})}),e.jsx(ks,{path:"/mission-control/presentations/new",element:e.jsx(nr,{children:e.jsx(qze,{})})}),e.jsx(ks,{path:"/mission-control/presentations/:id",element:e.jsx(nr,{children:e.jsx(qze,{})})}),e.jsx(ks,{path:"/mission-control/guest-book",element:e.jsx(nr,{children:e.jsx(HCs,{})})}),e.jsx(ks,{path:"/mission-control/guest-book/live/:id",element:e.jsx(nr,{children:e.jsx(Q5s,{})})}),e.jsx(ks,{path:"/guestbook/:slug",element:e.jsx(DGe,{})}),e.jsx(ks,{path:"/mission-control/card-studio",element:e.jsx(nr,{children:e.jsx(JCs,{})})}),e.jsx(ks,{path:"/mission-control/scheduler",element:e.jsx(nr,{children:e.jsx(A5s,{})})}),e.jsx(ks,{path:"/c/:shareToken",element:e.jsx(gct,{})}),e.jsx(ks,{path:"/book/:slug",element:e.jsx(vct,{})}),e.jsx(ks,{path:"/page/:slug",element:e.jsx(bct,{})}),e.jsx(ks,{path:"/mission-control/landing-pages",element:e.jsx(nr,{children:e.jsx(E5s,{})})}),e.jsx(ks,{path:"/mission-control/landing-pages/:pageId",element:e.jsx(nr,{children:e.jsx(L5s,{})})}),e.jsx(ks,{path:"/my-website/:siteId/edit",element:e.jsx(nr,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(a9e,{})})})}),e.jsx(ks,{path:"/my-website/mls-listings",element:e.jsx(nr,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(sMs,{})})})}),e.jsx(ks,{path:"/my-website/mls-listings/:mlsId",element:e.jsx(nr,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(rMs,{})})})}),e.jsx(ks,{path:"/my-website/market-report",element:e.jsx(nr,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(nMs,{})})})}),e.jsx(ks,{path:"/admin/lead-sites",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(J5s,{})})})}),e.jsx(ks,{path:"/admin/lead-sites/:siteId/edit",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(a9e,{})})})}),e.jsx(ks,{path:"/admin/mls-feeds",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(eMs,{})})})}),e.jsx(ks,{path:"/admin/lead-site-analytics",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(tMs,{})})})}),e.jsx(ks,{path:"*",element:e.jsx(yct,{})})]}),")"]})})})})]})})}),o9e=window.location.hostname,wMs=o9e.includes("lovable.app")||o9e.includes("lovableproject.com");wMs&&"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))}));E$e(document.getElementById("root")).render(e.jsx(_Ms,{}));export{Nr as $,vs as A,K as B,Ee as C,nc as D,ve as E,Zs as F,Ws as G,Xs as H,ze as I,Gs as J,Mt as K,ws as L,qn as M,IMs as N,ms as O,Ml as P,ko as Q,Er as R,qr as S,ba as T,pr as U,gl as V,Qne as W,W4 as X,ka as Y,qc as Z,gi as _,Pt as a,GQ as a$,fr as a0,Ms as a1,Ja as a2,cr as a3,nS as a4,Bn as a5,qi as a6,li as a7,Ra as a8,pn as a9,Rse as aA,Wke as aB,qke as aC,Kke as aD,UMs as aE,uV as aF,Vke as aG,tR as aH,Zke as aI,QS as aJ,Cu as aK,bc as aL,_c as aM,e1 as aN,Yl as aO,Wte as aP,to as aQ,Un as aR,$o as aS,qo as aT,Ro as aU,Gi as aV,Cc as aW,eL as aX,sa as aY,kl as aZ,On as a_,z_ as aa,Ds as ab,JQ as ac,va as ad,It as ae,Rm as af,nl as ag,Sae as ah,Gg as ai,Bv as aj,Rr as ak,Bi as al,yi as am,LM as an,Go as ao,gu as ap,An as aq,h1 as ar,cS as as,p0 as at,qPt as au,Nn as av,$a as aw,kn as ax,$ke as ay,qle as az,Rt as b,pf as b$,$Q as b0,KI as b1,oh as b2,eV as b3,Sn as b4,cn as b5,PM as b6,OL as b7,Cx as b8,Gr as b9,RMs as bA,_d as bB,d1 as bC,wZe as bD,dl as bE,eh as bF,bn as bG,Hs as bH,ul as bI,W_ as bJ,un as bK,so as bL,JA as bM,yC as bN,eE as bO,tE as bP,_re as bQ,Sx as bR,su as bS,tn as bT,yL as bU,Tee as bV,hn as bW,BM as bX,PQ as bY,ku as bZ,Wh as b_,oc as ba,Vj as bb,z1 as bc,No as bd,PL as be,Ku as bf,ma as bg,vL as bh,Oo as bi,wn as bj,Rmt as bk,Po as bl,ht as bm,Eo as bn,ybs as bo,gbs as bp,bbs as bq,Ao as br,uX as bs,rJ as bt,xi as bu,yo as bv,LMs as bw,cGe as bx,DMs as by,OMs as bz,gr as c,Bo as c$,_ct as c0,Rv as c1,Dm as c2,ac as c3,Tl as c4,s1 as c5,Ah as c6,Jn as c7,WMs as c8,Sp as c9,hp as cA,bat as cB,aC as cC,iC as cD,I1 as cE,wh as cF,GI as cG,X4 as cH,x0 as cI,Fv as cJ,Gre as cK,Y4 as cL,nke as cM,ike as cN,d9t as cO,jat as cP,yke as cQ,xke as cR,gke as cS,Z4 as cT,tS as cU,AM as cV,EM as cW,Mh as cX,m0 as cY,H4 as cZ,G4 as c_,tL as ca,da as cb,cl as cc,zO as cd,Nx as ce,vd as cf,Im as cg,Ju as ch,oS as ci,Wx as cj,rSe as ck,kp as cl,c1 as cm,rl as cn,Su as co,Yne as cp,kR as cq,Xo as cr,Qa as cs,Om as ct,zd as cu,_f as cv,aT as cw,_at as cx,q0 as cy,iR as cz,De as d,fS as d0,hS as d1,ske as d2,Ua as d3,Sc as d4,Lm as d5,th as d6,J4 as d7,ni as d8,zm as d9,yj as da,R_ as db,rS as dc,ZI as dd,XW as de,Oee as df,Zh as dg,Hv as dh,pa as e,ns as f,Fm as g,bs as h,mt as i,e as j,Dt as k,me as l,$s as m,Rn as n,Fn as o,Ss as p,St as q,N as r,H as s,zn as t,Qt as u,dt as v,tt as w,fs as x,ps as y,_s as z};